<?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>The Nordhagen &#187; ActionScript</title>
	<atom:link href="http://www.oyvindnordhagen.com/blog/tag/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oyvindnordhagen.com/blog</link>
	<description>Øyvind Nordhagen on ActionScript and other things</description>
	<lastBuildDate>Fri, 20 Jan 2012 13:06:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The case for BindMax for data binding</title>
		<link>http://www.oyvindnordhagen.com/blog/2012/01/19/the-case-for-bindmax-for-data-binding/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2012/01/19/the-case-for-bindmax-for-data-binding/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 21:33:44 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[BindLite]]></category>
		<category><![CDATA[BindMax]]></category>
		<category><![CDATA[Freebies]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[binding]]></category>
		<category><![CDATA[bindlite]]></category>
		<category><![CDATA[bindmax]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[fast]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[speed]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=676</guid>
		<description><![CDATA[I made a couple of small updates to BindMax today (read about them at the bottom of the post). I&#8217;ve been using it myself for several projects and it has easily become one of my favorite self-made tools. It&#8217;s been [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.oyvindnordhagen.com/blog/bindmax"><img class="alignnone size-full wp-image-694" title="BindMax" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2012/01/BindMax.jpg" alt="" width="555" height="148" /></a><br />
I made a couple of small updates to BindMax today (read about them at the bottom of the post). I&#8217;ve been using it myself for several projects and it has easily become one of my favorite self-made tools. It&#8217;s been been rock solid and serving me very well and I feel like more people should be using it. But maybe you don&#8217;t know what it improves upon? Let me help you.</p>
<p>Data binding is essentially tha synchonization of values, typically between the model and the views (read more <a href="http://en.wikipedia.org/wiki/Data_binding">here</a>. For Flex applications data binding is typically accomplished with the [Bindable] compiler meta tag. For pure AS3 applications it&#8217;s been a roll-your-own world and some even use [Bindable] here as well. This is just wrong.</p>
<p>These are the reasons why BindMax is better than [Bindable]:</p>
<ul>
<li><strong>Mobile loving</strong><br />
Building mobile apps with AIR? Then you know it&#8217;s all about squeezing file size out and performace in. BindMax is an implementation of the observer pattern, which is a much simpler structure than the Flash Event bus. In fact it&#8217;s beautiful minimalism compared the Events. Smaller file size, better performance.</li>
<li><strong>Speed!</strong><br />
For primitive data types BindMax is generally 3x faster than [Bindable]. Performance with complex data types obviously depends on how fast your compare functions are, if you have any. Without them, complex data types propagate just as fast as the primitve ones. The speed tests are included with the source so check for yourself!</li>
<li><strong>Early type checking</strong><br />
A data binding is usually defined early in the application run cycle. When that happens, BindMax will evaluate each attempt to bind a property or setter against the data type of the binding and throw an error if the data types don&#8217;t match. With [Bindable], you get no errors until the target property/setter for that binding is used. For a property that is used only rarely, you may never even see that error until the client/user stumbles over that rare use case and tells you.</li>
<li><strong>Boot time property/getter/setter name validation on both sides of data binding</strong><br />
Just as with type checking, BindMax validates that that the names match between the property or setter you bind a property or getter to.</li>
<li><strong>Easy custom compare functions for complex and custom data types</strong><br />
Primitive data type values like numbers and strings are easy to compare. Complex data types like arrays, dictionaries and custom objects require special handling. For this scenario, BindMax provides setCompareFunction which lets you pass it a function reference to a custom function that takes two instances of the same class and returns true if they are equal.</li>
<li><strong>Optional automatic binding disposal</strong><br />
To play nice with the garbage collector, BindMax lets you turn on automatic disposal of bindings which are no longer in use. When the last target for a binding is removed, BindMax will dispose of it.</li>
<li><strong>Previous value retrieval</strong><br />
BindMax stores the last value of each binding so you can retrieve it with retrieveLast if for comparison with the new value. The typical use case for this functionality is an animated image gallery where animation direction is determined based on image index vs previous image index. I&#8217;m sure you can think of several others.</li>
<li><strong>Powerful reset function</strong><br />
With the reset function, you can reset any or all of the bound properties to their default values (value of the property when the binding was defined). A quick call to reset followed by propagateAll will effectively reset you application.</li>
<li><strong>Propagation forcing</strong><br />
There are times when checking if a value is in fact changed simply doesn&#8217;t make sense. Then you wanna be sure that a value spreads to you application each time it is set, even if hasn&#8217;t changed. BindMax lets you override change detection on a per-update or per-property basis.</li>
</ul>
<p>So go get it! At <a href="http://code.google.com/p/bindlite/downloads/list">Google Code</a></p>
<p>NOTE: From now on I will be talking mostly about BindMax instead of it&#8217;s little brother BindLite. I&#8217;m leaving BindLite in the source in case someone finds it useful, but BindMax is much more verastile by not being an all static access class.</p>
<p>I&#8217;ve also updated <a href="/blog/bindlite">the BindMax tutorial</a></p>
<p>The updates I made were the following:</p>
<ul>
<li>Added reset all functionality when calling reset without arguments</li>
<li>Added setForcedPropagation function</li>
<li>Added propagateAll function</li>
<li>Removed outdated example project</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2012/01/19/the-case-for-bindmax-for-data-binding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drawing a motherf**king dashed line in AS3</title>
		<link>http://www.oyvindnordhagen.com/blog/2011/12/14/drawing-a-motherfking-dashed-line-in-as3/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2011/12/14/drawing-a-motherfking-dashed-line-in-as3/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 21:57:34 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Freebies]]></category>
		<category><![CDATA[Problems & Solutions]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[dash]]></category>
		<category><![CDATA[dashed]]></category>
		<category><![CDATA[dotted]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[draw]]></category>
		<category><![CDATA[drawing api]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[line]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=644</guid>
		<description><![CDATA[Here's an easy, reasonably fast way to draw a dashed line in ActionScript.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.oyvindnordhagen.com/public/DashedLine.as"><img class="alignnone size-full wp-image-645" title="Dashed Line" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2011/12/Screen-Shot-2011-12-14-at-22.53.50.png" alt="" width="531" height="269" /></a></p>
<p>I needed to draw a dashed line in AS3. I thought it would be easy, but I thought &#8220;hey, that one&#8217;s already been covered&#8221;, expecting that if I could find some ready-made class or lib that would do the job, I might even get some extra benefits. I went on this great interweb page called Google and I searched for &#8220;Dashed Line AS3&#8243;.</p>
<p>I was disappointed at all the feeble attempts at doing something so simple, so after a couple of attempts i did it myself. I even threw in the added benefit of making it able to draw itself between two points you supply it. I was expecting something extra so I imagine you did too.</p>
<p>Here ya&#8217; go:</p>
<p><a href="http://www.oyvindnordhagen.com/public/DashedLine.as">DashedLine.as</a></p>
<p>PS: Damn, that drop shadow Mac OS X includes in window screenshots is really something.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2011/12/14/drawing-a-motherfking-dashed-line-in-as3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Passing properties by reference in ActionScript 3</title>
		<link>http://www.oyvindnordhagen.com/blog/2010/11/11/passing-properties-by-reference-in-actionscript-3/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2010/11/11/passing-properties-by-reference-in-actionscript-3/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 23:50:23 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Problems & Solutions]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[propery]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=480</guid>
		<description><![CDATA[@DavidArno asked on Twitter: That&#8217;s actually a good question. But it seems there&#8217;s no way to force a property to be passed by reference in AS3. The behaviour of most properties are to be passed by value, which means that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/#!/DavidArno" target="_blank">@DavidArno</a> asked on Twitter:</p>
<p><a href="http://twitter.com/#!/DavidArno"><img class="alignnone size-full wp-image-481" title="Skjermbilde 2010-11-11 kl. 00.09.27" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2010/11/Skjermbilde-2010-11-11-kl.-00.09.27.png" alt="" width="429" height="175" /></a></p>
<p>That&#8217;s actually a good question. But it seems there&#8217;s no way to force a property to be passed by reference in AS3. The behaviour of most properties are to be passed by value, which means that if you write this:</p>
<pre lang="actionscript">
var myValue:String = _myObject.value;
</pre>
<p>Then the value of _myObject.value is copied into the value of myValue and not further connection between the two is maintained. There are exceptions to this rule, Arrays being one of them. But in general this is how it works.</p>
<p>But sometimes you want myValue to continuously reflect the value of _myObject.value. Or maybe if you wanted another object to have access to the original object&#8217;s value, you would have to pass boh a reference to the object and the property name as a string. You would have to get a little dirty and use the AS3 equivalent of the old eval() function in AS2. In AS3, we do this with a string representation of the property name enclosed in square brackets, like so:</p>
<pre lang="actionscript">
var myValue:String = _myObject["value"];
</pre>
<p>As we know, eval is evil because it&#8217;s slower and more error prone than accessing the property directly. Hence we need an elegant workaround that at the very least looks like we&#8217;ve made an attempt to formalize the situation. So I created a small example class.</p>
<pre lang="actionscript">
package
{
	public class PropertyReference
	{
		private var _object:Object;
		private var _property:String;

		public function PropertyReference(object:Object, property:String):void
		{
			_object = object;
			_property = property;
		}

		public function get value():*
		{
			return _object[_property];
		}

		public function set value(val:*):void
		{
			_object[_property] = val;
		}
	}
}
</pre>
<p>As you see, all it does is store a reference to the object instance containing the property and the name of the property. It also contains getters and setters for hiding the grunt work of accessing and motifying the property. It does not help the speed issue, but it makes it less error prone. You would instantiate it like this:</p>
<pre lang="actionscript">
var propertyRef:PropertyReference = new PropertyReference(_myObject, "value");
</pre>
<p>That means you only specify the string equivalent of the property name once, which makes it less error prone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2010/11/11/passing-properties-by-reference-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Olog 1.2.2</title>
		<link>http://www.oyvindnordhagen.com/blog/2010/09/23/olog-1-2-2/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2010/09/23/olog-1-2-2/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 07:00:23 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Freebies]]></category>
		<category><![CDATA[Olog]]></category>
		<category><![CDATA[Problems & Solutions]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[logger]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[trace]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=435</guid>
		<description><![CDATA[I just committed version 1.2.2 of Olog to the Google Code repository. Updated docs are also in the trunk, but I have yet to update the online docs. New in version 1.2.2 If you didn&#8217;t catch the 1.2 update, you [...]]]></description>
			<content:encoded><![CDATA[<p>I just committed version 1.2.2 of <a href="http://code.google.com/p/olog/" target="_blank">Olog</a> to the Google Code repository. Updated docs are also in the trunk, but I have yet to update <a href="http://www.oyvindnordhagen.com/olog/docs" target="_blank">the online docs</a>.</p>
<h3>New in version 1.2.2</h3>
<p>If you didn&#8217;t catch the 1.2 update, you will not have discovered the new shorthand function which makes logging/tracing even simpler. Instead of trace, write otrace (works with the same arguments as the Olog.trace() method). Also check out the <a href="http://www.oyvindnordhagen.com/blog/2010/09/08/olog-1-2-is-released/">original blog post about version 1.2</a> for more about this goodie release.</p>
<h3>Olog.traceDisplayList()</h3>
<p>Version 1.2.2 introduces a safe and fast display list crawler, accessed via the function Olog.traceDisplayList(root, maxDepth, property). This is extremely handy if you need to debug UI issues. It will present a tree representation of the display list from the specified root object. Like so:</p>
<p><img class="alignnone size-full wp-image-436" title="Olog display list crawler" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2010/09/Skjermbilde-2010-09-23-kl.-08.47.02.png" alt="Olog display list crawler" width="565" height="323" /></p>
<p>You can simply call it without arguments. In which case it will use Olog&#8217;s own stage as the root object and a maximum traverse depth of 10 levels down. Supply the root argument with another DisplayObjectContainer, to start from there instead. Altering the maxDepth argument lets you control the tradeoff between level of instrospection and speed. Of course, on a huge display list, a maxDepth of 200 might result in a script timeout/crash, but I trust you to decide what&#8217;s safe.</p>
<p>In addition, you can specify the string name of a property to include for each child. If the child has this property, it will be appended with its value after the class name in the resulting tree. For instance, specify &#8220;alpha&#8221; and you will see the value of the alpha property on all children like so: MyView.alpha = 1.</p>
<h3>Automatic handling of uncaught exeptions</h3>
<p>Flash player 10.1 (SDK 4.1) introduced a way to handle uncaught exeptions globally in a movie. Olog compiles safely with SDK 3.5 (the SWC is compiled with 3.5), but takes advantage of this feature if it is accessible.</p>
<h3>Olog.addKeyBinding()</h3>
<p>This neat little trick lets you bind a sequence of characters to the call of a function. Watch:</p>
<pre lang="actionscript">Olog.addKeyBinding( "list" , _traceDisplayList );
private function _traceDisplayList ():void
{
	Olog.traceDisplayList( this );
}</pre>
<p>If you then, while the movie is running type the word &#8220;list&#8221;, Olog will call the function _traceDisplayList.</p>
<p>These two additions I&#8217;ve wanted to add for a long time and I finally got around to it. Having these tools at my disposal has made many a debug session considerably shorter.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2010/09/23/olog-1-2-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 dictionary back to back in 4 months</title>
		<link>http://www.oyvindnordhagen.com/blog/2009/11/09/as3-dictionary-back-to-back-in-4-months/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2009/11/09/as3-dictionary-back-to-back-in-4-months/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 03:03:48 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[General thoughts]]></category>
		<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/2009/11/09/as3-dictionary-back-to-back-in-4-months/</guid>
		<description><![CDATA[As some of you might know, I&#8217;m in layoff from my job as a flash developer at Allegro Interaktiv. I&#8217;ve been thinking hard and well about what I want to spend this period of four months doing. I will be [...]]]></description>
			<content:encoded><![CDATA[<p style="clear: both"><img class="alignnone size-full wp-image-223" title="AS3 Language Reference and Dictionary" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2009/11/asref.jpg" alt="AS3 Language Reference and Dictionary" width="570" height="300" /></p>
<p style="clear: both">As some of you might know, I&#8217;m in layoff from my job as a flash developer at <a href="http://www.allegro.no" target="_blank">Allegro Interaktiv</a>. I&#8217;ve been thinking hard and well about what I want to spend this period of four months doing. I will be freelancing a little if I can (in agreement with my employer of course), spend time with my family, and also catch up on a few forsaken hobbies.</p>
<p style="clear: both">But this sudden abundance of free time obviously creates a pefect climate for getting up to speed on new Flash libraries and dig deeper into the ones I already know. Like the AS3 core classes. That&#8217;s why I&#8217;ve given my self a perhaps rediculous challenge; to read the complete ActionScript Language Reference back to back over the next four months. This is clearly perversely nerd-like and all that, but here&#8217;s why.</p>
<p style="clear: both">
<h2>The case for reading it all</h2>
<p style="clear: both">Actually I&#8217;ve been thinking about it for a few years. You see every time I look up a class or a method in the dictionary, I usually read one or two paragraphs more than I need. Often I learn something new that&#8217;s been sitting just below the surface of what I already know. At times the AS3 language reference is not even that badly written and the examples are usually useful. So instead of googling for tutorials about particle engines, Papervision and what not, I decided that before trying to gain something completely new I&#8217;d be better off getting to know the old annoying aunt intimately. Well not in that sense&#8230; sorry, you know what I mean.</p>
<p style="clear: both">
<h2>You should too!</h2>
<p style="clear: both">I&#8217;m not saying you really should join me in this preposterous endeavour, but I am serious in that many tend to overlook what a great resource the AS3 Language Reference really is. So the essence is really that you can learn a lot from what you already have at a single keyboard command (shift-F1 in Flash that is). Look up some random class name that you&#8217;ve never used an find out what it&#8217;s for. You might be glad you did.</p>
<p style="clear: both">In the mean time, you can follow my progress here at the blog, and if you <a href="http://www.twitter.com/nordhagen" target="_blank">follow me on Twitter</a>.</p>
<p><br class="final-break" style="clear: both" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2009/11/09/as3-dictionary-back-to-back-in-4-months/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Free Flash ActionScript snow for christmas cards</title>
		<link>http://www.oyvindnordhagen.com/blog/2007/12/17/free-flash-actionscript-snow-for-christmas-cards/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2007/12/17/free-flash-actionscript-snow-for-christmas-cards/#comments</comments>
		<pubDate>Sun, 16 Dec 2007 23:42:19 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Problems & Solutions]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[flakes]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[snow]]></category>
		<category><![CDATA[snow flakes]]></category>
		<category><![CDATA[snowflakes]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/2007/12/17/free-flash-actionscript-snow-for-christmas-cards/</guid>
		<description><![CDATA[Although a bit late for this season, I thought I&#8217;d share a small christmasy ActionScript nugget with you. This stuff was developed some time ago, so it&#8217;ll happily compile to Flash Player 6 if needs be. The script simply replicates [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2007/12/snowflakes.jpg" alt="ActionScripSnowFlakes" /></p>
<p>Although a bit late for this season, I thought I&#8217;d share a small christmasy ActionScript nugget with you. This stuff was developed some time ago, so it&#8217;ll happily compile to Flash Player 6 if needs be. The script simply replicates a small, white particle that resembles a snow flake and animates it so that it falls from the sky. It also imitates 3D by altering the size and speed of the flakes and you can put any graphic you want inside the snowFlake movie clip to make it behave like a particle of snow.</p>
<p>I&#8217;ve actually had much use for it for various clients and projects. Go ahead and download it here:</p>
<p><a href="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2007/12/snowflake.zip" title="Snow Flake FLA">Snow Flake FLA</a></p>
<p>Merry Christmas!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2007/12/17/free-flash-actionscript-snow-for-christmas-cards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

