<?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; as3</title>
	<atom:link href="http://www.oyvindnordhagen.com/blog/tag/as3/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>BindLite gets a big brother</title>
		<link>http://www.oyvindnordhagen.com/blog/2011/11/21/bindlite-gets-a-big-brother/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2011/11/21/bindlite-gets-a-big-brother/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 22:29:05 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[BindLite]]></category>
		<category><![CDATA[Freebies]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[binding]]></category>
		<category><![CDATA[bindlite]]></category>
		<category><![CDATA[bindmax]]></category>
		<category><![CDATA[data]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=629</guid>
		<description><![CDATA[Well not exactly bigger in terms of file size, but since BindLite was taken it had to be BindMax for its brother. BindLite was released earlier this year as a flex-less, event-less alternative to data binding in AS3. But whereas [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/bindlite/"><img class="alignnone size-full wp-image-571" title="BindLIte" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2011/02/BindLIte.jpg" alt="" width="487" height="228" /></a></p>
<p>Well not exactly bigger in terms of file size, but since BindLite was taken it had to be BindMax for its brother. BindLite was released earlier this year as a flex-less, event-less alternative to data binding in AS3. But whereas BindLite is a static class suitable for smaller projects, I quickly realized that to make it more usable, it could no longer be all static. Enter BindMax.</p>
<p>BindMax does exactly the same as BindLite does but with the added flexibility of being an instance. The recommended approach is to extend it for your Model class. Example:</p>
<pre lang="actionscript">public class MyModel extends BindMax {
	public var state:String = State.INPUT;
	public var captureDelay:uint = 0;
	public var capturePhase:String;
	public var currentSwf:SwfVO;
	public var error:ErrorVO;
	public var render:BitmapData;
}</pre>
<p>This is all you need for BindMax to do its magic. Your model class need no additional code, not even a constructor. As the superconstructor is implicitly called, BindMax will auto-enumerate all public variables and accessors as bindable with the correct data type for you. Explicitly calling the superconstructor lets you set the autoEnumerate argument to false if you wish to prevent this behaviour.</p>
<p>After this, all is the same as with BindLite with the exception that you need access to the MyModel instance. I recommend providing this acces through a dependency injection-driven framework such as <a href="http://www.robotlegs.org/">RobotLegs</a>.</p>
<p>Examples of use:</p>
<pre lang="actionscript">// Binding a property to a public property or setter on view
model.bind( "state", view );

// Property name needs to be passed as string, so using enums is recommended
model.bind( Bindable.STATE, view );

// Changing a property and propagate the change if value is different
model.update( Bindable.STATE, "main" );

// Changing a model property and force propagation
model.update( Bindable.STATE, "main", true );

// Resetting model properties to their values at define time
model.reset( Bindable.STATE, Bindable.FILE );

// Removing a data binding. Omit the second argument to unbind target from all data bindings
model.unbind( view, Bindable.STATE );

// Retrieve the before-change value of a bindable property
model.retrieveLast( Bindable.STATE );

// Control what happens when last target unbinds from a property
// true : Discard orphaned bindings
// false : retain orphaned bindins (default)
model.autoDisposeBindings = true;</pre>
<p>Download BindLIte and BindMax as a combined package here: <a href="http://code.google.com/p/bindlite/">http://code.google.com/p/bindlite/</a></p>
<p>Docs are here: <a href="http://www.oyvindnordhagen.com/bindlite/docs/">http://www.oyvindnordhagen.com/bindlite/docs/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2011/11/21/bindlite-gets-a-big-brother/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freebie: IPScanner</title>
		<link>http://www.oyvindnordhagen.com/blog/2011/09/21/freebie-ipscanner/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2011/09/21/freebie-ipscanner/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 12:28:39 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Freebies]]></category>
		<category><![CDATA[Problems & Solutions]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[IPScanner]]></category>
		<category><![CDATA[p2p]]></category>
		<category><![CDATA[peer-to-peer]]></category>
		<category><![CDATA[ping]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[scan]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=615</guid>
		<description><![CDATA[So these days I&#8217;m experimenting with AIR P2P apps through the recently introduced ServerSocket class (which I think is still in beta by the way). Since the AIR API does not provide any network client/server/peer discovery tools, I decided to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.oyvindnordhagen.com/freebies/IPScanner.zip"><img class="alignnone size-full wp-image-616" title="IPScanner doing its job through Olog" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2011/09/Screen-Shot-2011-09-21-at-14.15.08.png" alt="IPScanner doing its job through Olog" width="479" height="229" /></a></p>
<p>So these days I&#8217;m experimenting with AIR P2P apps through the recently introduced ServerSocket class (which I think is still in beta by the way). Since the AIR API does not provide any network client/server/peer discovery tools, I decided to hack down a simple IP scanner to do the trick.</p>
<p>This package consists of two classes; IPScanner and IPScannerEvent. IPScanner will accept a starting IP and it will scan the rest of the range from that IP. In other words, if you pass in 192.168.1.100, it will try to &#8220;ping&#8221; each possible address from 192.168.1.100 to 192.168.1.255. Pass in 192.168.0, and it will go on all the way from 192.168.0.0 to 192.168.255.255, but it is limited to those last two segments.</p>
<p>An optional handshake string can also provided. In which case IPScanner will attempt to send this handshake string to each IP it is able to connect to and wait for a reply. This enables you to make sure you&#8217;re connecting to the right peer.</p>
<p>I find this works really well for me, so I thougt maybe someone else might need it too. Feel free to leave comments!</p>
<p><a href="http://www.oyvindnordhagen.com/freebies/IPScanner.zip"><img class="size-full wp-image-54 alignnone" title="zip" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2008/01/zip.gif" alt="" width="32" height="32" /></a><a href="http://www.oyvindnordhagen.com/freebies/IPScanner.zip">IPScanner.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2011/09/21/freebie-ipscanner/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>AIR NativeDragDrop gotcha</title>
		<link>http://www.oyvindnordhagen.com/blog/2011/07/14/air-nativedragdrop-gotcha/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2011/07/14/air-nativedragdrop-gotcha/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 12:22:59 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Problems & Solutions]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[drag]]></category>
		<category><![CDATA[drop]]></category>
		<category><![CDATA[gotcha]]></category>
		<category><![CDATA[nativedragdrop]]></category>
		<category><![CDATA[nativedragdropevent]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=593</guid>
		<description><![CDATA[While performing some refactorings to LazyFallback, I came across a small gotcha with the sequence of the drag and drop implementation in Adobe AIR. It seems that dropping files will trigger a NativeDragEvent.NATIVE_DRAG_EXIT just before the NativeDragEvent.NATIVE_DRAG_DROP fires. This might not be [...]]]></description>
			<content:encoded><![CDATA[<p>While performing some refactorings to LazyFallback, I came across a small gotcha with the sequence of the drag and drop implementation in Adobe AIR. It seems that dropping files will trigger a NativeDragEvent.NATIVE_DRAG_EXIT just before the NativeDragEvent.NATIVE_DRAG_DROP fires. This might not be a problem if all you use the NATIVE_DRAG_EXIT event for is to update some visuals. I my case however, I was also clearing the file list to be processed, which lead me to spot the problem.</p>
<p>Here&#8217;s an example class:</p>
<pre lang="actionscript">public class DropTest {
   private var fileQue:Array;
   private var dropWell:Sprite;

   public function DropTest () {
      dropWell.addEventListener( NativeDragEvent.NATIVE_DRAG_ENTER, dragEnterhandler );
      dropWell.addEventListener( NativeDragEvent.NATIVE_DRAG_DROP, dropHandler );
      dropWell.addEventListener( NativeDragEvent.NATIVE_DRAG_EXIT, dragExitHandler );
   }

   private function dragEnterhandler ( event:NativeDragEvent ):void {
      var files:Array = event.clipboard.getData( ClipboardFormats.FILE_LIST_FORMAT ) as Array;
      if (files &#038;&#038; files.length) queFiles( files );
      else queFiles( null );
   }

   private function queFiles ( files:Array ):void {
      fileQue = files;
      if (files) {
         NativeDragManager.acceptDragDrop(dropWell);
         // Update visuals
      }
      else {
         // Update visuals
      }
   }
   private function dragExitHandler ( event:NativeDragEvent ):void {
      // This event handler will be called before dropHandler when dropping files
      queFiles( null );
   }

   private function dropHandler ( event:NativeDragEvent ):void {
      for each (var file:File in fileQue) {
         processFile( file ); // Fails because dragExitHandler has nulled fileQue
      }
   }
}
</pre>
<p>My suggestion for a solution to this is that you assign responsibilities for the event handlers as follows:</p>
<ul>
<li><strong>NativeDragEvent.NATIVE_DRAG_ENTER:</strong> Validate files and update visuals</li>
<li><strong>NativeDragEvent.NATIVE_DRAG_DROP</strong>: Que files and start processsing</li>
<li><strong>NativeDragEvent.NATIVE_DRAG_EXIT:</strong> Update visuals</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2011/07/14/air-nativedragdrop-gotcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BindLite 0.9.2 adds previous value retrieval</title>
		<link>http://www.oyvindnordhagen.com/blog/2011/03/21/bindlite-0-9-2-adds-previous-value-retrieval/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2011/03/21/bindlite-0-9-2-adds-previous-value-retrieval/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 10:55:16 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[BindLite]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[bindlite]]></category>
		<category><![CDATA[data binding]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=582</guid>
		<description><![CDATA[Just updated BindLite to version 0.9.2 (build 24). It adds the following: Added BindLite.retrieveLast which lets you read the previous value of any bound property. Added public property autoDisposeBindings. Setting this to true will make BindLite dispose a binding if [...]]]></description>
			<content:encoded><![CDATA[<p>Just updated <a href="http://www.oyvindnordhagen.com/blog/bindlite/">BindLite</a> to version 0.9.2 (build 24). It adds the following:</p>
<ul>
<li>Added BindLite.retrieveLast which lets you read the previous value of any bound property.</li>
<li>Added public property autoDisposeBindings. Setting this to true will make BindLite dispose a binding if it no longer has any listeners after calling BindLite.unbind.</li>
<li>Added public function BindLite.disposeBinding() to hard dispose a given binding.</li>
</ul>
<p>This means you can now read the binding&#8217;s previous value when it gets set to a new value. This is useful for—say for instance—comparing an image gallery image index against its previous value to determine if the user clicked the next or the previous button.</p>
<p>This version also plays better with garbage collection because you can now have BindLite detect orphan bindings and remove them. Note that you need to specifically set autoDisposeBindings to true and actively remove a binding using unbind to make it run. You can also manually dispose a binding via disposeBinding(). Doing so will free all source and target refrences immediately.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2011/03/21/bindlite-0-9-2-adds-previous-value-retrieval/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing BindLite</title>
		<link>http://www.oyvindnordhagen.com/blog/2011/02/28/introducing-bindlite/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2011/02/28/introducing-bindlite/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 23:52:27 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[BindLite]]></category>
		<category><![CDATA[Freebies]]></category>
		<category><![CDATA[Problems & Solutions]]></category>
		<category><![CDATA[alternative]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[bindable]]></category>
		<category><![CDATA[binding]]></category>
		<category><![CDATA[bindlite]]></category>
		<category><![CDATA[data]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=576</guid>
		<description><![CDATA[BindLite is a lightweight, flex-less data binding alternative for AS3 applications. The reason I created it is to avoid including the flex.swc in my applications and to get a cleaner, more efficient syntax for data binding with better performance than the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.oyvindnordhagen.com/blog/bindlite/"><img class="alignnone size-full wp-image-571" title="BindLIte" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2011/02/BindLIte.jpg" alt="" width="487" height="228" /></a></p>
<p>BindLite is a lightweight, flex-less data binding alternative for AS3 applications. The reason I created it is to avoid including the flex.swc in my applications and to get a cleaner, more efficient syntax for data binding with better performance than the [Bindable] meta tag.</p>
<p>It is currently at version 0.9 for obvious reasons; I would like to hear from you about what you think, whether it works for you and if there are features it lacks. I have already tested it on two small projects and it has worked very well for me.</p>
<ul>
<li>Visit the <a href="http://www.oyvindnordhagen.com/blog/bindlite/">project page</a> for more info</li>
<li>Visit the <a href="http://code.google.com/p/bindlite/">Google Code page</a></li>
<li>Download <a href="http://code.google.com/p/bindlite/downloads/detail?name=BindLite_0.9.0.5.zip">the zip</a></li>
<li>Read <a href="http://www.oyvindnordhagen.com/bindlite/docs/">the docs</a></li>
<li>Give me <a href="http://twitter.com/nordhagen">feedback</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2011/02/28/introducing-bindlite/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Compile SWC fast and easy with compc</title>
		<link>http://www.oyvindnordhagen.com/blog/2011/01/18/compile-swc-fast-and-easy-with-compc/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2011/01/18/compile-swc-fast-and-easy-with-compc/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 21:57:19 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Problems & Solutions]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[compc]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[libs]]></category>
		<category><![CDATA[swc]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=533</guid>
		<description><![CDATA[I&#8217;m not a command line pro. I make my way around it when I have to, but it usually takes some trial and error. Today I got fed up over having to set up projects in FDT/Flash Builder only to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not a command line pro. I make my way around it when I have to, but it usually takes some trial and error. Today I got fed up over having to set up projects in FDT/Flash Builder only to compile a SWC from some external library. So I decided it was time to learn how to do it with compc, the command line library compiler, and then write it down as a template I could use over and over. Here&#8217;s the recipe it five easy steps.</p>
<ol>
<li>Open Terminal or whatever command line pertains to your system.</li>
<li>Use the &#8220;cd&#8221; command to navigate to the &#8220;bin&#8221; folder in the SDK folder you wish to use. In my case the complete command is &#8220;cd /Users/nord/as3/sdks/4.0.0/bin&#8221;</li>
<li>Paste the stuff below into a text editor that supports Regular Expressions (e.g. <a href="http://macromates.com/">TextMate</a>).</li>
<li>Replace all the paths based on the comments and run search/replace with this pattern: \[.+\]|\r|\n|\t (replace with nothing). This removes the comments and line breaks and creates a complete, but harder to read command that can be pasted into the command line.</li>
<li>Select all, copy, paste in the command line, press enter and you are done!.</li>
</ol>
<p></p>
<pre lang="shell">bash compc
[Define SDK root folder + /frameworks here]
 -framework=
	/Users/nord/as3/sdks/4.0.0/frameworks
[Define target player]
 -target-player=
	10.0
[Debug false when creating libraries]
 -compiler.debug=
	false
[All referenced source folders]
 -source-path=
	/Users/nord/as3/libs/nordhagen/src/,
	/Users/nord/as3/libs/SWFAddress/2.4
[All referenced source SWCs]
 -library-path=
	/Users/nord/as3/sdks/4.0.0/frameworks/libs/player/10.0/playerglobal.swc,
	/Users/nord/as3/sdks/4.0.0/frameworks/libs/flex.swc,
	/Users/nord/as3/libs/Olog2/swc/Olog.swc,
	/Users/nord/as3/libs/TweenLite/greensock.swc,
[Only these sources are actually compiled]
 -include-sources=
	/Users/nord/as3/libs/nordhagen/src
[Path and file name to resulting SWC file]
 -output=
	/Users/nord/as3/libs/nordhagen/bin/nordhagen.swc</pre>
<h3>Notes</h3>
<ul>
<li><strong>-source-path</strong> and <strong>-library-path</strong> are source folders and swc files respectively. There is no special treatment for external/linked libraries. This actually confused me a little at first because the project&#8217;s main source folder and it&#8217;s external dependencies are treated so differently in most IDEs, but here they are equal. This is where you tell the compiler what folders/SWCs it needs to be aware of so to speak. At this point, these paths are solely used for compiler validation, they are not included in the SWC unless you also list them under&#8230;</li>
<li><strong>-include-sources </strong>is the list of source folders among those listed under -source-path/-library-path that should be <em>included</em> in the compiled SWC.</li>
<li>Note that it you decide to format the command without the supplied RegEx, you need to make sure that the paths are separated only by the comma. No spaces!</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2011/01/18/compile-swc-fast-and-easy-with-compc/feed/</wfw:commentRss>
		<slash:comments>0</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>Freebie: ClickTag AS3</title>
		<link>http://www.oyvindnordhagen.com/blog/2010/10/20/clicktag-as3/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2010/10/20/clicktag-as3/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 23:31:40 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Problems & Solutions]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[ads]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[banner]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[click]]></category>
		<category><![CDATA[clicktag]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[freebie]]></category>
		<category><![CDATA[tag]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=473</guid>
		<description><![CDATA[Just thought i&#8217;d share this class I made for doing ClickTag banner ads with AS3. It will get the clickTag url form root.loaderInfo. It will also use window.open for compability reasons with IE7 ans Firefox and it will also do [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2010/10/clicktagas3.jpg" rel="lightbox[473]"><img class="alignnone size-full wp-image-474" title="ClickTag as3" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2010/10/clicktagas3.jpg" alt="" width="565" height="176" /></a></p>
<p>Just thought i&#8217;d share this class I made for doing ClickTag banner ads with AS3. It will get the clickTag url form root.loaderInfo. It will also use window.open for compability reasons with IE7 ans Firefox and it will also do logging so the website that will host it can tell if the clickTag is being read in correctly or not.</p>
<p>Here it is:</p>
<p><a href="http://www.oyvindnordhagen.com/public/ClickTag.as"><img class="alignnone size-full wp-image-475" title="Download" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2010/10/asicon.jpg" alt="" width="32" height="33" /></a> <a href="http://www.oyvindnordhagen.com/public/ClickTag.as">ClickTag.as</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2010/10/20/clicktag-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

