<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>nulldesign // lars gerckens &#187; Actionscript</title>
	<atom:link href="http://www.nulldesign.de/category/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nulldesign.de</link>
	<description>A place to showcase my personal portfolio and flash related experiments</description>
	<lastBuildDate>Sun, 11 Apr 2010 20:55:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>F10 Astro Blackhole</title>
		<link>http://www.nulldesign.de/2008/09/30/f10-astro-blackhole/</link>
		<comments>http://www.nulldesign.de/2008/09/30/f10-astro-blackhole/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 08:31:36 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=182</guid>
		<description><![CDATA[The Flash 10 beta player is out for a while and I found a few minutes to try out the new native 3D effects. You can get quite nice and fast results out of the new API if you only want to display flat 2D planes in 3D-space:

(Space = fullscreen, Download source, Flash Player 10 [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://labs.adobe.com/technologies/flashplayer10/">Flash 10 beta player</a> is out for a while and I found a few minutes to try out the new native 3D effects. You can get quite nice and fast results out of the new API if you only want to display flat 2D planes in 3D-space:</p>
<p style="text-align: center;"><a href="http://www.nulldesign.de/exp/expviewer.php?file=f10_planets.swf&amp;width=600&amp;height=450"><img class="aligncenter" src="http://www.nulldesign.de/exp/f10_planets.jpg" alt="" width="480" height="305" /></a><br />
(Space = fullscreen, <a href="http://www.nulldesign.de/exp/f10_planets.zip">Download source</a>, Flash Player 10 needed)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2008/09/30/f10-astro-blackhole/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ND3D engine goes google.code</title>
		<link>http://www.nulldesign.de/2008/08/07/nd3d-engine-goes-googlecode/</link>
		<comments>http://www.nulldesign.de/2008/08/07/nd3d-engine-goes-googlecode/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 10:30:45 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=105</guid>
		<description><![CDATA[Good news everyone! I packed everything together, cleaned up a bit and created a google.code project for my 3D engine. Since it became popular under the name &#8216;nulldesign&#8217;s 3d engine&#8217; I call it ND3D from now on ;). I will post additional infos, more examples and future developments here in my blog and on the [...]]]></description>
			<content:encoded><![CDATA[<p>Good news everyone! I packed everything together, cleaned up a bit and created a <a href="http://code.google.com/p/nd3d/">google.code project</a> for my 3D engine. Since it became popular under the name &#8216;nulldesign&#8217;s 3d engine&#8217; I call it ND3D from now on ;). I will post additional infos, more examples and future developments <a href="http://www.nulldesign.de/nd3d-as3-3d-engine/">here</a> in my blog and on the project page. So long&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2008/08/07/nd3d-engine-goes-googlecode/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Flex: Adding a tooltip to truncated Datagrid columns</title>
		<link>http://www.nulldesign.de/2008/06/13/flex-adding-a-tooltip-to-truncated-datagrid-columns/</link>
		<comments>http://www.nulldesign.de/2008/06/13/flex-adding-a-tooltip-to-truncated-datagrid-columns/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 08:22:41 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=66</guid>
		<description><![CDATA[I just found a nice way to automatically truncate text in datagrid columns and show tooltips for truncated elements, that I wanted to share:

package
&#123;
	import mx.controls.dataGridClasses.DataGridItemRenderer;
&#160;
	public class TruncateToolTipRenderer extends DataGridItemRenderer
	&#123;
		private var textTruncated:Boolean = false;
		private var originalText:String;
&#160;
		public function TruncateDataGridItemRenderer&#40;&#41;
		&#123;
			super&#40;&#41;;
		&#125;
&#160;
		override public function set text&#40;value:String&#41;:void
		&#123;
			super.text = value;
			originalText = value;
			textTruncated = truncateToFit&#40;&#41;;
		&#125;
&#160;
		override public function validateProperties&#40;&#41;:void
		&#123;
			super.validateProperties&#40;&#41;;
			toolTip = textTruncated ? originalText : [...]]]></description>
			<content:encoded><![CDATA[<p>I just found a nice way to automatically truncate text in datagrid columns and show tooltips for truncated elements, that I wanted to share:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">dataGridClasses</span>.<span style="color: #006600;">DataGridItemRenderer</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TruncateToolTipRenderer <span style="color: #0066CC;">extends</span> DataGridItemRenderer
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> textTruncated:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> originalText:<span style="color: #0066CC;">String</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> TruncateDataGridItemRenderer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span>.<span style="color: #0066CC;">text</span> = value;
			originalText = value;
			textTruncated = truncateToFit<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> validateProperties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span>.<span style="color: #006600;">validateProperties</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			toolTip = textTruncated ? originalText : <span style="color: #000000; font-weight: bold;">null</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Just set the itemRenderer property of your column to the new TruncateToolTipRenderer. Neat!</p>
<p><strong>Update:</strong> &#8230; and it&#8217;s a lot easier if you just set the itemRenderer to mx.controls.Label, because a Label already has truncate and tooltip functionality. As so often in Flex, everything is built in. Lesson learned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2008/06/13/flex-adding-a-tooltip-to-truncated-datagrid-columns/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>3D Engine Sources + Examples</title>
		<link>http://www.nulldesign.de/2008/04/09/3d-engine-sources-examples/</link>
		<comments>http://www.nulldesign.de/2008/04/09/3d-engine-sources-examples/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 12:31:21 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/?p=61</guid>
		<description><![CDATA[About some time ago I started to code my own 3D engine in flash. Derived from a small AS2 project, I challenged myself to built my own flash 3D engine. So I took out my good old Actionscript Animation Book and opened the 3D chapter. Very soon I could move a cube around. A few [...]]]></description>
			<content:encoded><![CDATA[<p>About some time ago I started to code my own 3D engine in flash. Derived from a small AS2 project, I challenged myself to built my own flash 3D engine. So I took out my good old <a href="http://www.friendsofed.com/book.html?isbn=1590595181" target="_blank">Actionscript Animation Book</a> and opened the 3D chapter. Very soon I could move a <a href="http://www.nulldesign.de/2006/11/10/solid3dengine/" target="_blank">cube</a> around. A few pages later I learned how to implement simple <a href="http://www.nulldesign.de/exp/expviewer.php?file=lighting_test.swf&amp;width=800&amp;height=400">dynamic lighting</a>. The next challenge was to get texture mapping to work. Since flash still can&#8217;t distort images, you need a workaround. After I found these great examples: <a href="http://www.sebleedelisle.com/?page_id=7" target="_blank">Seb Lee-Delisle&#8217;s flash texture maps</a> and <a href="http://session.andre-michelle.com/w3d/" target="_blank">Andre Michelle&#8217;s texture examples</a> it was done. Somewhere inbetween I switched to AS3, which was quickly done. Meanwhile <a href="http://blog.papervision3d.org/" target="_blank">Papervision3D</a> became very popular and I thought it didn&#8217;t make sense to continue evolving my engine. But since I came so far, I needed to find out how to implement a few effects like <a href="http://www.nulldesign.de/exp/expviewer.php?file=3d_blur.swf&amp;width=800&amp;height=400">depth of field</a> or <a href="http://www.nulldesign.de/exp/expviewer.php?file=f9_3d_additive_cubes.swf&amp;width=800&amp;height=400">additive rendering</a> ;)</p>
<p style="text-align: center;"><img src="http://www.nulldesign.de/exp/3dengine_samples.jpg" alt="" width="472" height="473" /></p>
<p>My engine shouldn&#8217;t and doesn&#8217;t compete with <a href="http://blog.papervision3d.org/" target="_blank">Papervision3D</a> or <a href="http://www.flashsandy.org/blog/" target="_blank">Sandy3D</a>, nor it has a very user-friendly API, no stunning effects or animation support, but I learned a lot while building it, understanding 3D to 2D rendering, optimizing the code for a few ms of extra speed (AS3 rocks!) or challenge problems with 3D rotations like <a href="http://en.wikipedia.org/wiki/Gimbal_Lock" target="_blank">gimbal lock</a> and their solutions: <a href="http://en.wikipedia.org/wiki/Quaternion" target="_blank">quaternions</a>. It&#8217;s just another 3D flash engine, at least I can say: I made it! ;)</p>
<p>It&#8217;s undocumented, there&#8217;s still a lot of work to do and it doesn&#8217;t have a cool name , but if you want to play around with it or just take a look how I set up this and that, feel free to download the <a onclick="urchinTracker('3dengine_nulldesign.zip')" href="http://www.nulldesign.de/nd3d-as3-3d-engine/">sources</a> (yes, the <a href="http://www.nulldesign.de/exp/expviewer.php?file=3dribbon.swf&amp;width=700&amp;height=400">3D ribbon</a> example is included). And I&#8217;m always interested in what you think about it, so drop a comment or mail.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2008/04/09/3d-engine-sources-examples/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Collision Tests</title>
		<link>http://www.nulldesign.de/2007/12/19/collision-tests/</link>
		<comments>http://www.nulldesign.de/2007/12/19/collision-tests/#comments</comments>
		<pubDate>Wed, 19 Dec 2007 14:41:32 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash 9]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/2007/12/19/collision-tests/</guid>
		<description><![CDATA[As you noticed, I&#8217;m building a small arcarde shooter in AS3 besides my daily work. It started as a small test and got me ;). In my previous post I used getObectsUnderPoint for a hittest between the shot and the enemyclips, this works fine if you don&#8217;t need a collision reaction and the clips travel [...]]]></description>
			<content:encoded><![CDATA[<p>As you noticed, I&#8217;m building a small arcarde shooter in AS3 besides my daily work. It started as a small test and got me ;). In my previous post I used getObectsUnderPoint for a hittest between the shot and the enemyclips, this works fine if you don&#8217;t need a collision reaction and the clips travel at a moderade speed. Now I wanted to integrate a collision detection and reaction for the enemies and made use of some nice scripts I found out there:</p>
<p>A shape-based collision detection for bitmaps by <a target="_blank" href="http://www.gskinner.com/blog/archives/2005/10/source_code_sha.html">Grant Skinner</a>, since the third parameter in hitTestPoint(x:Number, y:Number, shapeFlag:Boolean) only works for vectorimages and I&#8217;m using bitmaps as graphics. A <a target="_blank" href="http://www.gskinner.com/blog/archives/2005/02/source_code_gri.html">Proximity Manager</a>. This small class comes really handy and the principle is so simple. The proximity manager splits the stage into grids and stores for every sprite in which grid they are. So you don&#8217;t need to test every sprite against all other sprites, instead you just say: &#8220;Give me all neighbours of that sprite&#8221;, which saves a lot of loops.</p>
<p>So I had the tools for a nice collision detection, for the collision reaction I converted a simple snooker algorithm to AS3: <a target="_blank" href="http://freespace.virgin.net/hugo.elias/models/m_snokr.htm">Snooker Balls</a>. Watch the result:<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_shooter_collision_1041601940"
			class="flashmovie"
			width="480"
			height="240">
	<param name="movie" value="http://www.nulldesign.de/exp/shooter_collision.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.nulldesign.de/exp/shooter_collision.swf"
			name="fm_shooter_collision_1041601940"
			width="480"
			height="240">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p align="center">Move your mouse over me!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2007/12/19/collision-tests/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>It all started as a performance test&#8230;</title>
		<link>http://www.nulldesign.de/2007/12/01/it-all-started-as-a-performance-test/</link>
		<comments>http://www.nulldesign.de/2007/12/01/it-all-started-as-a-performance-test/#comments</comments>
		<pubDate>Sat, 01 Dec 2007 12:25:57 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash 9]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/2007/12/01/it-all-started-as-a-performance-test/</guid>
		<description><![CDATA[Ok, AS3 can render thousands of particles per frame&#8230; but what if we want more than a few single moving pixels and hittests? So I started to write a small test, instancing bitmaps on random locations. And hey: These objects look like bombs, now I need something to destroy them &#8230; and there was the [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, AS3 can render <a href="http://www.nulldesign.de/2006/11/23/f9-particles/" target="_blank">thousands of particles</a> per frame&#8230; but what if we want more than a few single moving pixels and hittests? So I started to write a small test, instancing bitmaps on random locations. And hey: These objects look like bombs, now I need something to destroy them &#8230; and there was the battleship ;). For the hittest I used <a href="http://livedocs.adobe.com/flex/2/langref/flash/display/DisplayObjectContainer.html#getObjectsUnderPoint()" target="_blank">getObjectsUnderPoint</a>. It seems like this method is a bit slower than hitTest or hitTestObject, but you can actually save a lot of loops because you don&#8217;t need to test each bomb with each shot. Instead of:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// pseudo code</span>
<span style="color: #b1b100;">for</span> each<span style="color: #66cc66;">&#40;</span>bombs<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">for</span> each<span style="color: #66cc66;">&#40;</span>shots<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>bomb.<span style="color: #006600;">hitTestObject</span><span style="color: #66cc66;">&#40;</span>shot<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #808080; font-style: italic;">// shot hit bomb...</span>
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>you go:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// pseudo code</span>
<span style="color: #b1b100;">for</span> each<span style="color: #66cc66;">&#40;</span>bombs<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> objects:<span style="color: #0066CC;">Array</span> = shotClip.<span style="color: #006600;">getObjectsUnderPoint</span><span style="color: #66cc66;">&#40;</span>bomb.<span style="color: #006600;">x</span>, bomb.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>objects.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
          <span style="color: #808080; font-style: italic;">// shot hit bomb...</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>This only works, if you have a seperate clip for the shots. Enough of the talk: <a href="http://www.nulldesign.de/exp/expviewer.php?file=shooter_test.swf&amp;width=500&amp;height=350" target="_blank">Launch!</a></p>
<p style="text-align: center"> <img src="http://www.nulldesign.de/exp/shooter_test.jpg" height="203" width="450" /><br />
(Move using the mouse and rotate the gun with cursor keys)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2007/12/01/it-all-started-as-a-performance-test/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AS3 Preloading continued</title>
		<link>http://www.nulldesign.de/2007/11/30/as3-preloading-continued/</link>
		<comments>http://www.nulldesign.de/2007/11/30/as3-preloading-continued/#comments</comments>
		<pubDate>Fri, 30 Nov 2007 10:28:13 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/2007/11/30/as3-preloading-continued/</guid>
		<description><![CDATA[I wasn&#8217;t really satisfied with the solution I used for my AS3 preloader (see post: Preloader in AS3 projects). Now Sven found THE solution. It&#8217;s in german, so I try to explain how it works:
The class &#8220;Test&#8221; acts as the factory class that&#8217;s responsible for the preloading. The Class &#8220;Demo&#8221; is the main application class. [...]]]></description>
			<content:encoded><![CDATA[<p>I wasn&#8217;t really satisfied with the solution I used for my AS3 preloader (see post: <a href="http://www.nulldesign.de/2007/11/20/preloader-in-as3-projects-factoryclass/">Preloader in AS3 projects</a>). Now <a href="http://www.ghost23.de/blog/" target="_blank">Sven</a> found <a href="http://www.ghost23.de/blogarchive/2007/11/as3-application.html" target="_blank">THE solution</a>. It&#8217;s in german, so I try to explain how it works:</p>
<p>The class &#8220;Test&#8221; acts as the factory class that&#8217;s responsible for the preloading. The Class &#8220;Demo&#8221; is the main application class. Using the compiler option <strong>-frame frameLabel Demo</strong>,<strong> </strong>the class Demo is compiled into frame 2.</p>
<p>Just like in <a href="http://www.bit-101.com/blog/?p=946" target="_blank">Keith Peter&#8217;s Example</a> and my try using an exclude xml, you can preload a pure AS3 application now, but in this case no flex framework classes are compiled into the resulting SWF and there is no need for an exclude xml. Finally!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2007/11/30/as3-preloading-continued/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>AS3 Singletons, the other way</title>
		<link>http://www.nulldesign.de/2007/11/20/as3-singletons-the-other-way/</link>
		<comments>http://www.nulldesign.de/2007/11/20/as3-singletons-the-other-way/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 18:07:16 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/2007/11/20/as3-singletons-the-other-way/</guid>
		<description><![CDATA[Since you can&#8217;t declare a constructor private in AS3, there are a few methods out there to enforce a Singleton. A common way is to declare an internal SingletonEnforcer class outside the package: SingletonEnforcer, but the declaration of the Enforcer outside a package looks a bit &#8220;dirty&#8221; to me. Another way is to declare the [...]]]></description>
			<content:encoded><![CDATA[<p>Since you can&#8217;t declare a constructor private in AS3, there are a few methods out there to enforce a Singleton. A common way is to declare an internal SingletonEnforcer class outside the package: <a href="http://blog.pixelbreaker.com/flash/as30-better-singletons/" target="_blank">SingletonEnforcer</a>, but the declaration of the Enforcer outside a package looks a bit &#8220;<span>dirty</span>&#8221; to me. Another way is to declare the singleton as a <a href="http://www.onflex.org/code/" target="_blank">static variable</a>, but this way you can&#8217;t decide when your singleton is instantiated.</p>
<p>So, why don&#8217;t just try nearly same with a local variable:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Singleton <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> instance:Singleton;
        <span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const checker:<span style="color: #0066CC;">Object</span> = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Singleton<span style="color: #66cc66;">&#40;</span>initObj:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>initObj <span style="color: #66cc66;">!</span>= checker<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Private constructor!&quot;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> getInstance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:Singleton <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>instance == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                instance = <span style="color: #000000; font-weight: bold;">new</span> Singleton<span style="color: #66cc66;">&#40;</span>checker<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #b1b100;">return</span> instance;
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Update: I found another nice solution by GSkinner: <a href="http://www.gskinner.com/blog/archives/2006/07/as3_singletons.html" target="_blank">SingletonDemo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2007/11/20/as3-singletons-the-other-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preloader in AS3 projects (factoryClass)</title>
		<link>http://www.nulldesign.de/2007/11/20/preloader-in-as3-projects-factoryclass/</link>
		<comments>http://www.nulldesign.de/2007/11/20/preloader-in-as3-projects-factoryclass/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 10:52:01 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/2007/11/20/preloader-in-as3-projects-factoryclass/</guid>
		<description><![CDATA[The last days I was playing around with the Flex Metadata Tag &#8220;Frame&#8221; to implement a preloader in an AS3 project. You might have read Keith Peters post concerning this issue. This method is working fine, except of the fact that I can&#8217;t get rid of the flex framework classes in my compiled SWF, which [...]]]></description>
			<content:encoded><![CDATA[<p>The last days I was playing around with the Flex Metadata Tag &#8220;Frame&#8221; to implement a preloader in an AS3 project. You might have read <a href="http://www.bit-101.com/blog/?p=946" target="_blank">Keith Peters post</a> concerning this issue. This method is working fine, except of the fact that I can&#8217;t get rid of the flex framework classes in my compiled SWF, which blows up the size of an nearly empty SWF to 120kb.</p>
<p>If you check out the comments in his post, you&#8217;ll find a few solutions, but none of them worked for me. So I generated a XML exclude File, that excludes the whole flex framework. You might want to give it a try: <a href="http://www.nulldesign.de/stuff/flex_framework_exclude.xml" target="_blank">flex_framework_exclude.xml</a> (compile with the option -load-externs+=flex_framework_exclude.xml). It&#8217;s still not satisfying, but it&#8217;s working&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2007/11/20/preloader-in-as3-projects-factoryclass/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Custom right click menus in AIR</title>
		<link>http://www.nulldesign.de/2007/10/31/custom-right-click-menus-in-air/</link>
		<comments>http://www.nulldesign.de/2007/10/31/custom-right-click-menus-in-air/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 20:49:38 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/2007/10/31/custom-right-click-menus-with-air/</guid>
		<description><![CDATA[I was wondering, why DisplayObjects in AIR don&#8217;t support the MouseEvent.RIGHT_CLICK Event. The only way to implement a right-click-menu seemed to be a NativeMenu. But I needed only the event, not the ugly native-os-menu.
Here is the workaround: Just create a blank NativeMenu and listen for the display event.

var menu:NativeMenu = new NativeMenu&#40;&#41;;
menu.addEventListener&#40;Event.DISPLAYING, onRightClick, false, 0, [...]]]></description>
			<content:encoded><![CDATA[<p>I was wondering, why DisplayObjects in AIR don&#8217;t support the <em>MouseEvent.RIGHT_CLICK</em> Event. The only way to implement a right-click-menu seemed to be a <em>NativeMenu</em>. But I needed only the event, not the ugly native-os-menu.</p>
<p>Here is the workaround: Just create a blank <em>NativeMenu </em>and listen for the display event.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">menu</span>:NativeMenu = <span style="color: #000000; font-weight: bold;">new</span> NativeMenu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">DISPLAYING</span>, onRightClick, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
someSprite.<span style="color: #0066CC;">contextMenu</span> = <span style="color: #0066CC;">menu</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2007/10/31/custom-right-click-menus-in-air/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New site, new blog</title>
		<link>http://www.nulldesign.de/2007/10/21/new-site-new-blog/</link>
		<comments>http://www.nulldesign.de/2007/10/21/new-site-new-blog/#comments</comments>
		<pubDate>Sun, 21 Oct 2007 13:13:50 +0000</pubDate>
		<dc:creator>lars</dc:creator>
				<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://www.nulldesign.de/2007/10/21/new-site-new-blog/</guid>
		<description><![CDATA[Good news everyone!
I removed my three year old flash site and managed to set up this blog instead. I think this is a much better place to showcase my experiments. It&#8217;s not finished yet, but I&#8217;m working hard on it to get everything done.
I will post news, talk about my flash experiments, actionscript in general [...]]]></description>
			<content:encoded><![CDATA[<p>Good news everyone!<br />
I removed my three year old flash site and managed to set up this blog instead. I think this is a much better place to showcase my experiments. It&#8217;s not finished yet, but I&#8217;m working hard on it to get everything done.</p>
<p>I will post news, talk about my flash experiments, actionscript in general and whatever pops into my mind here.<br />
So, let&#8217;s get started!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nulldesign.de/2007/10/21/new-site-new-blog/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
