<?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</title>
	<atom:link href="http://www.oyvindnordhagen.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oyvindnordhagen.com/blog</link>
	<description>Øyvind Nordhagen on ActionScript and other things</description>
	<lastBuildDate>Mon, 26 Mar 2012 22:49:37 +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>Objective-C for Flash Developers (pt. 2)</title>
		<link>http://www.oyvindnordhagen.com/blog/2012/03/26/objective-c-for-flash-dev-2/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2012/03/26/objective-c-for-flash-dev-2/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 09:42:50 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[obj-c]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[transition]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=754</guid>
		<description><![CDATA[A multipart guide in transitioning from ActionScript to Objective-C: Understanding Objective-C language, syntax and API in the Flash frame of reference.]]></description>
			<content:encoded><![CDATA[<div><img title="Objective-C for Flash Developers hasthead" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2012/03/as3toios.jpg" alt="" width="555" height="209" /></div>
<ul>
<li><a href="http://www.oyvindnordhagen.com/blog/2012/03/23/objective-c-for-flash-dev/">Part 1: Imports, strings and function calls</a></li>
<li><a href=" http://www.oyvindnordhagen.com/blog/2012/03/26/objective-c-for-flash-dev-2/">Part 2: Header files, variable and function definitions</a></li>
</ul>
<p>In this part 2 of Objective-C for Flash developers, we will look at header files and how variables are defined in comparison to ActionScript 3. Before we start, I need to clarify one thing: I will consistently use the term function throughout this tutorial, although technically there is a semantic difference between funcitons and methods. It&#8217;s just to make this all easier on the brain, that&#8217;s all.</p>
<h3>Header files (i.e. MyClass.h)</h3>
<p>Any and all Objective-C classes are split into a .h file and a .m file. The former being the header file, the latter the implementation.</p>
<p>This is a concept that has no counterpart in AS3 so a direct comparison won&#8217;t be possible. What a header file does is list the <em>definition</em> of your class. In one way you could say that it&#8217;s a bit like the part you put before the constructor in you AS3 classes, in another you could say it&#8217;s like and AS3 interface. Both are correct to some extent, however neither would be accurate.</p>
<p>If you cmd+click the name of a framework class in the Xcode source editor, you will get to the class header file. In a way this is <a href="http://en.wikipedia.org/wiki/Black_box" target="_blank">the Black Box Principle</a> in practice; you get to see what the class exposes as it&#8217;s interface, but not how it does it&#8217;s grunt work. That is reserved for the implementation file. The one exeption to this is that a header file also defines any private properties of a class, so these are also exposed.</p>
<p>An Obj-C header file defines what instance variables, properties og functions a class has, which class it inherits from and the interfaces it adheres to. It is declared with the @interface keyword:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #a61390;">@interface</span> MyClass <span style="color: #002200;">:</span> MySuperClass</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>@interface keyword, followed by class name, a colon and the super class name. For the most bare-bones objects, you extend NSObject.</p>
<p>You see, this might be the reason you would think a header file is like an AS3 interface, and it sort of is. But don&#8217;t put that one in the bank and move on just yet because you need to be aware that Objective-C has something called &#8220;protocols&#8221; which is semantically more similar to AS3 interfaces. We will deal with protocols in a later part, but for now here&#8217;s an illustration to help you map you understanding of these concepts to AS3:</p>
<p><img title="Class Header mapped to AS3" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2012/03/HeaderInterfaceProtocol.gif" alt="" width="555" height="300" /></p>
<p>In general you could say that the Objective-C header file is a combination of the AS3 class header and the AS3 interface, while the AS3 interface is a combination of the Objective-C header file and Objective-C protocols.</p>
<p>A complete abstract header file:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #6e371a;">#import &quot;SomeClass.h&quot;</span></li><li><span style="color: #a61390;">@class</span> SomeOtherClass;</li><li><span style="color: #a61390;">@interface</span> MyClass <span style="color: #002200;">:</span> MySuperClass <span style="color: #002200;">&#123;</span></li><li> DataType <span style="color: #002200;">*</span>myProtectedVariable;</li><li><span style="color: #002200;">&#125;</span></li><li>&nbsp;</li><li><span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>strong, nonatomic<span style="color: #002200;">&#41;</span> DataType <span style="color: #002200;">*</span>propertyName;</li><li><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>doSomething;</li><li><span style="color: #a61390;">@end</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Now what&#8217;s all this? First of all, if you read <a title="Objective-C for Flash Developers (pt. 1)" href="http://www.oyvindnordhagen.com/blog/2012/03/23/objective-c-for-flash-dev/">part 1</a>, you know that the #import keyword is just like imports in AS3. But here you see yet another kind of import:</p>
<h3>@class imports</h3>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #a61390;">@class</span> DetailViewController;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Quite simply, importing with @class does no more than tell the compiler that the class exists. This is called a forward declaration. The compiler will defer validation of the existance of the class to compile time. If your implementation uses properties or functions of this class, you will need to #import the class instead.</p>
<p>A way to remember which is which is to compare #import to ActionScript&#8217;s #include directive since that also uses the # sign and it inlines the code of the class. Another way is to notice that the @class keyword does not use a file extension (MyClass, not MyClass.h). This gives you an indication that @class is a general declaration, not an import.</p>
<h3>Instance variables (ivars)</h3>
<p>These are defined in what actually looks like a constructor, but this being a header file it&#8217;s not. (Actually, Obj-C doesn&#8217;t have explicit constructors, more on this in a later part).</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript"><div class="devcodeoverflow"><ol><li>protected <span style="color: #000000; font-weight: bold;">var</span> myProtectedVariable:DataType;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #a61390;">@interface</span> MyClass <span style="color: #002200;">:</span> MySuperClass <span style="color: #002200;">&#123;</span></li><li> DataType <span style="color: #002200;">*</span>myProtectedVariable;</li><li><span style="color: #002200;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Defining variables like this makes them local to the instance of the class. By default these variables are protected, making them accessible to the class and any subclasses, but not from the outside. Ivars can also be specified as private or public, though this is rare and highly discouraged.</p>
<h3>Properties</h3>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript"><div class="devcodeoverflow"><ol><li><span style="color: #808080; font-style: italic;">// In an interface</span></li><li><span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> propertyName<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:DataType</li><li><span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> propertyName<span style="color: #66cc66;">&#40;</span>value:DataType<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>strong, nonatomic, readwrite<span style="color: #002200;">&#41;</span> DataType <span style="color: #002200;">*</span>propertyName;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>From left to right: @property keyword, property modifiers in parethesis (see below), the data type, which by C convention is always listed before the property/variable name, and lastly the propertyName, with or without the asterisk (see below).</p>
<p>A property is an externally accessible variable. It is not a public property and in the context of the header file it is merely a declaration stating to other classes that this is a property you can access. You will have to provide getter/setter implementations in the .m file to support this declaration. Think of it as declaring getter and setter functions in an AS3 interface.</p>
<h3>Pointers</h3>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>strong, nonatomic, readwrite<span style="color: #002200;">&#41;</span> DataType <span style="color: #002200;">*</span>propertyName;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>You might have noticed that asterisk preceeding the property name. This declares that this variable is a pointer. A pointer is a reference to the memory space that an object occupies. By storing pointers to objects you don&#8217;t maintain copies of them throughout your application but rather references to the same instance.</p>
<p>Pointers do not have direct AS3 counterparts because AS3 is a higher level language that does not provide this level of memory management. In AS3 some datatypes are implicitly passed by reference/pointers (such as arrays) and others are passed by value, like strings. On a side note, in Objective-C strings are instances of NSString and as such they too are passed as pointers.</p>
<p>In Objective-C that asterisk is present whenever a pointer is declared, be it in a property, private variable or local variable. It is important to remember that function arguments are also declarations of local variables, hence you must include the asterisk there as well if the value you expect should be a pointer/reference.</p>
<h3>Property modifiers</h3>
<p>To assist in memory management, thread safety and access control, Objective-C has a number of possible modifiers you can specify in the property declaration. These are the words in parethesis following the @property keyword as seen in the example above:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>strong, nonatomic, readwrite<span style="color: #002200;">&#41;</span> DataType <span style="color: #002200;">*</span>propertyName;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Regarding the memory modifiers, you should be aware that iOS 5 introduced automatic reference counting (ARC) which simplifies memory management and thus changed the list of possible modifiers. iOS Memory management and thread safety is beyond the scope of this post series. <a href="http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/objectiveC/Chapters/ocProperties.html#//apple_ref/doc/uid/TP30001163-CH17-SW1" target="_blank">See Apple iOS Center documentation for these</a>.</p>
<p>The access modifiers do have AS3 equivalents: Specifying readwrite is the same as implementing a getter and a setter, while readonly is the same as only implementing a getter.</p>
<p>Property modifiers can appear in any order. The default property modifiers are weak, atomic, readwrite and need not be specified.</p>
<h3>Functions</h3>
<p>In the example above you saw a function signature at its simplest:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript"><div class="devcodeoverflow"><ol><li><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> doSomething<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>doSomething;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>These are more appropriately called methods because they are exposed and as such part of the class interface. The minus sign denotes an instance method, as opposed to a static method which is prefixed by a + sign:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript"><div class="devcodeoverflow"><ol><li><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> doSomething<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #002200;">+</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> doSomething;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>With arguments, functions look like this:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript"><div class="devcodeoverflow"><ol><li><span style="color: #0066CC;">public</span> function<span style="color: #66cc66;">&amp;</span>nbsp;doSomething<span style="color: #66cc66;">&#40;</span>soleArgument:DataType<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>doSomething<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span>DataType <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&amp;</span>nbsp;soleArgument;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>That&#8217;s all nice and well. The asterisk pointer indicater is placed inside the data type declaration parenthesis. If this was a primitive value, like an integer, the asterisk would be omitted. Look at what happens when you include multiple arguments. In this case I wrote the example a little less abstract to better convey why this is:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript"><div class="devcodeoverflow"><ol><li><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> doSomethingWith<span style="color: #66cc66;">&#40;</span>myArgument:DataType, numRepetitions:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> doSomethingWithMyObject<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span>DataType <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> theObject forThisManyTimes<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span> numRepetitions;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Whoah! That&#8217;s definitely not like ActionScript. Essentially you should read that signature like &#8220;do something with my object for this many times&#8221;. The function name and the first argument are together seen as the complete function name, whereas additional arguments add to it like a sentence. It sort of looks like you define the name of the second argument twice (and any additional arguments after that), but it&#8217;s actually not that weird. The name before the data type parethesis is the externally visible argument name (i.e. the name that pops up in the content assist), while the name after the parenthesis is the definition of the local variable exposed inside the function&#8217;s implementation.</p>
<p>What about return types? That&#8217;s easy:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript"><div class="devcodeoverflow"><ol><li><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getSomething<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:DataType</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>DataType<span style="color: #002200;">&#41;</span> getSomething;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>I&#8217;ll leave you with that for now <img src='http://www.oyvindnordhagen.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2012/03/26/objective-c-for-flash-dev-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Objective-C for Flash Developers (pt. 1)</title>
		<link>http://www.oyvindnordhagen.com/blog/2012/03/23/objective-c-for-flash-dev/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2012/03/23/objective-c-for-flash-dev/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 10:13:33 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[obj-c]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[transition]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=712</guid>
		<description><![CDATA[A multipart guide in transitioning from ActionScript to Objective-C: Understanding Objective-C language, syntax and API in the Flash frame of reference.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-717" title="Objective-C for Flash Developers hasthead" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2012/03/as3toios.jpg" alt="" width="555" height="209" /></p>
<ul>
<li><a href="http://www.oyvindnordhagen.com/blog/2012/03/23/objective-c-for-flash-dev/">Part 1: Imports, strings and function calls</a></li>
<li><a href=" http://www.oyvindnordhagen.com/blog/2012/03/26/objective-c-for-flash-dev-2/">Part 2: Header files, variable and function definitions</a></li>
</ul>
<p>This will be a multipart blog post covering how to understand Objective-C in the ActionScript frame of reference. In this first part we will deal with imports, function calls and strings. I give you the AS3 to Obj-C transition guide, part 1.</p>
<h3>Introduction</h3>
<p>Coming from an AS2/AS3 background, I found that many of my conceptions of design patterns, event models and general application structure didn&#8217;t apply very well when starting out with Cocoa Touch and Objective-C. In fact I expected that because my choice to learn Objective-C in particular was with the intent of doing something very different from what I&#8217;m used to. I wanted to rip myself completely out of my comfort zone in an attemp to lower my natural resistance to anything new. I got what I bargained for, in spades.</p>
<h3>Imports</h3>
<p>I&#8217;ll start litterally at the top: Imports in AS3 and Objective-C are quite similar:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript 3"><div class="devcodeoverflow"><ol><li><span style="color: #0033ff; font-weight: bold;">import</span> somepackage<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Class</span><span style="color: #000066; font-weight: bold;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--><br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #6e371a;">#import &lt;Foundation/Foundation.h&gt;</span></li><li><span style="color: #6e371a;">#import &quot;Class.h&quot;</li></ol></div></pre><!--END_DEVFMTCODE--><br />
Notice that the use of angle brackets is to denote a library of non-GUI classes and quotation marks to denote GUI classes. Notice also the lack of semicolons in import statements. The Obj-C Foundation classes are the basic framework for Objective-C, kind of like the playerglobal.swc in AS3, only in AS3 it&#8217;s a compiler argument and not an import in every single class file. It contains the basics like <a href="https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class">NSObject</a>, <a href="https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class">NSArray</a> and so on. In other words non-GUI classes, hence the angle brackets.</p>
<p>The <a href="https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIKit_Framework">UIKit</a> is another Obj-C framework which, as you probably guessed by the UI prefix, is comprised of GUI-classes. It&#8217;s closest equivalent in AS3 would be the flash.display.* package. Being GUI-classes you import them like so:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #6e371a;">#import &quot;UIKit/UIKit.h&quot;</li></ol></div></pre><!--END_DEVFMTCODE--><br />
Notice that the UIKit/Foundation/playerglobal analogy isn&#8217;t entirely accurate. playerglobal.swc includes both GUI and non-GUI classes, whereas in Objective-C they are separated.</p>
<h3>Function/Method calls</h3>
<p>This is the one thing that does the most in making Obj-C alien-looking to devs with an <a href="http://en.wikipedia.org/wiki/ECMAScript">ECMAScript</a> background. In Objective-C calling functions is not even called calling functions, but rather &#8220;passing messages&#8221;&#8230;that&#8217;s right: &#8220;passing messages&#8221;&#8230; I&#8217;ll let that sink in for a while because you&#8217;re gonna need it when you read forum threads and tutorials&#8230;&#8221;passing messages&#8221;.</p>
<p>So how do you pass a message?<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript 3"><div class="devcodeoverflow"><ol><li>myObject<span style="color: #000066; font-weight: bold;">.</span>myFunction<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--><br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #002200;">&#91;</span>myObject myFunction<span style="color: #002200;">&#93;</span>;</li></ol></div></pre><!--END_DEVFMTCODE--><br />
&#8230;or rather &#8220;[myObject myMessage];&#8221;. You can use plain C code in Objective-C as well, in which case calling a function has the exact same syntax as in ActionScript. But Objective-C being a superset of C needs different syntax to differentiate itself from it&#8217;s ancestor (as with all adolescents).</p>
<h3>Function calls with arguments</h3>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript 3"><div class="devcodeoverflow"><ol><li>myObject<span style="color: #000066; font-weight: bold;">.</span>myFunction<span style="color: #000000;">&#40;</span>soleArgument<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--><br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #002200;">&#91;</span>myObject myFunction<span style="color: #002200;">:</span>soleArgument<span style="color: #002200;">&#93;</span>;</li></ol></div></pre><!--END_DEVFMTCODE--><br />
That last one is not something you have to get, it&#8217;s just syntax to memorize (and arguments is still called arguments in Obj-C). It gets harder when you have to deal with multiple arguments:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript 3"><div class="devcodeoverflow"><ol><li>myObject<span style="color: #000066; font-weight: bold;">.</span>myFunction<span style="color: #000000;">&#40;</span>firstArgument<span style="color: #000066; font-weight: bold;">,</span> secondArgument<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--><br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #002200;">&#91;</span>myObject myFunction<span style="color: #002200;">:</span>firstArgument theSecondArgument<span style="color: #002200;">:</span>secondArgument<span style="color: #002200;">&#93;</span>;</li></ol></div></pre><!--END_DEVFMTCODE--><br />
Now hold on; that looks like two function calls in one! It&#8217;s not. In Objective-C you provide the argument label followed by the argument value for any arguments but the first one. Combined with the absence of a comma to separate the arguments, that it what makes it look like two function calls rather than one with two arguments. Actually if you did insert commas between the arguments, that would make them an array instead of an argument list.</p>
<p>This is one of the things Obj-C does to make itself more understandable, but it is also one of the things that make it seem like you need to be a fast typer in order to be productive in Objective-C. It gets clearer when you see it in the context of an actual example, here is how to initialize a standard iOS alert:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li><span style="color: #002200;">&#91;</span>myAlertInstance initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;My Alert&quot;</span> message<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;My message&quot;</span></li><li>	delegate<span style="color: #002200;">:</span>self cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;OK&quot;</span><span style="color: #002200;">&#93;</span>;</li></ol></div></pre><!--END_DEVFMTCODE--><br />
You noticed that &#8220;@&#8221; sign preceeding those string literals didn&#8217;t you, and you wonder why? We&#8217;ll get to that shortly.</p>
<p>There&#8217;s no denying that this does make it easier to understand what the arguments are, but you will notice a somewhat odd tingle in the back of your spine the first few times you type it. Just remember: First argument has no label (usually the label is the last word in the camelcased function name), the others are of the form label:value with spaces in between them. Don&#8217;t worry. XCode&#8217;s code completion feature is really, really good and you don&#8217;t have to remember the labels for each function you use.</p>
<p>A word of caution: You might think that since the arguments are labeled that their order is optional, but this is not the case. However you will rarely be tempted to pass arguments in a different order than the function signature.</p>
<p>Function signatures are a page of it&#8217;s own, so we&#8217;ll deal with that next time. For now here is the lowdown on that &#8220;@&#8221; sign as promised.</p>
<h3>Strings</h3>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript 3"><div class="devcodeoverflow"><ol><li>foo = <span style="color: #990000;">&quot;bar&quot;</span><span style="color: #000066; font-weight: bold;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--><br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li>foo <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;bar&quot;</span>;</li></ol></div></pre><!--END_DEVFMTCODE--><br />
Again, this comes from the fact that Objective-C is a superset of C and it needs to not be like it&#8217;s parents. A C string literal is provided just like in ActionScript, that is why we say that AS is another C-based language. But usually in Objective-C we would like to use an instance of Obj-C&#8217;s own string object, <a href="https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class">NSString</a>, because that gives us a whole bunch of helper methods to operate on it. Placing the &#8220;@&#8221; sign in front of the string literal does exactly that.</p>
<p>Next time we will deal with function signatures.</p>
<h3>Trivia</h3>
<ol>
<li>In C, a string is actually an array of characters, so you can probably imagine why <a href="https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class">NSString</a> is preferable in a higher level language.</li>
<li>An image in Objective-C is an instance of the <a href="https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImage_Class/">UIImage</a> class and the prefix &#8220;UI&#8221; naturally makes you think that it has to do with the user interface. You might even have assumed that it&#8217;s there because <a href="https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImage_Class/">UIImage</a> is part of <a href="https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIKit_Framework">UIKit</a> (and you&#8217;d be right!). That&#8217;s all nice an logical, but what about the &#8220;NS&#8221; prefix, like in <a href="https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class">NSString</a> and <a href="https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class">NSArray?</a> This is derived from the fact that the first versions of OSX was actually called <a href="http://en.wikipedia.org/wiki/NeXTSTEP">NeXTStep</a>, made by the company <a href="http://en.wikipedia.org/wiki/NeXT">NeXT</a>, founded by Steve Jobs in the years he was outed from Apple.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2012/03/23/objective-c-for-flash-dev/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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>3</slash:comments>
		</item>
		<item>
		<title>FIX: Garmin sync hangs at 50%</title>
		<link>http://www.oyvindnordhagen.com/blog/2011/12/01/fix-garmin-sync-hangs-at-50/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2011/12/01/fix-garmin-sync-hangs-at-50/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 22:10:55 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[communicator]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[crashes]]></category>
		<category><![CDATA[fail]]></category>
		<category><![CDATA[fails]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[forerunner]]></category>
		<category><![CDATA[garmin]]></category>
		<category><![CDATA[hangs]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[stall]]></category>
		<category><![CDATA[sync]]></category>
		<category><![CDATA[unable]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=634</guid>
		<description><![CDATA[Stable workaround for the Garmin Connect plug-in problem where sync stalls at 50%.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-635" title="sbbod" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2011/12/sbbod.jpg" alt="" width="630" height="269" /><br />
Completely unrelated post if you&#8217;re used to the usual ActionScript stuff I&#8217;m posting, but this has been bothering me for so long. I just want to put this out there now that I finally found a solution.</p>
<p>If you&#8217;re like me in that you exercise and you track your workouts with a Garmin device, there&#8217;s a chance that you&#8217;ve experienced the situation where the sync will hang about halfway through.</p>
<h3>Why?</h3>
<p>What seems to happen is that the Garmin Communicator plug-in is able to read the TCX-files off the device and onto disk (that&#8217;s the first 50% of the process), but crashes when it tries to upload the files to Gamin Connect, Dailymile, Runkeeper, Endomondo or any other site that uses the plug-in for sync with Garmin devices. There&#8217;s actually one progress bar for each of these steps on Garmin Connect, so the above image would not be completely accurate, the first bar would reach 100% and then it hangs.</p>
<h3>One solution..if you can call it that</h3>
<p>My previous solution would be to force quit the plug-in in Activity Monitor and try again until it finally worked (often as many as 6-8 attempts). I sync my runs to each of the four afformented websites (if only my friends could agree on the same site), so you can quickly see that this process becomes tedious.</p>
<h3>Better solution: Clear the cache</h3>
<p>What seems to be the problem is that the last TCX file that was synced is still in the browser cache and is somehow able to confuse to plug-in, because the solution to the problem is rather simple; clear your browser&#8217;s cache between each sync. This has proven to be a stable workaround for me for a while.</p>
<h3>A note on Garmin Support</h3>
<p>I&#8217;ve tried contacting Garmin Support several times about this, but no replies yet. The problem is even mentioned <a href="https://forums.garmin.com/search.php?searchid=5716658">several places on the Garmin Support forums</a>, but I doubt Garmin moderates or even monitors their own forum. An official response has yet to be made at least. I have a love-hate realationship with Garmin because I think they make hands down the best GPS HR monitors (<a href="http://www.oyvindnordhagen.com/blog/2010/10/02/garmin-forerunner-405cx-reviewwarning/">with some exceptions</a>), but at the same time their support is appalling and sadly I&#8217;m <a href="http://www.google.com/search?client=safari&amp;rls=en&amp;q=poor+garmin+support&amp;ie=UTF-8&amp;oe=UTF-8">far from the only one who thinks so</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2011/12/01/fix-garmin-sync-hangs-at-50/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:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript"><div class="devcodeoverflow"><ol><li><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyModel <span style="color: #0066CC;">extends</span> BindMax <span style="color: #66cc66;">&#123;</span></li><li>	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> state:<span style="color: #0066CC;">String</span> = State.<span style="color: #006600;">INPUT</span>;</li><li>	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> captureDelay:uint = <span style="color: #cc66cc;">0</span>;</li><li>	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> capturePhase:<span style="color: #0066CC;">String</span>;</li><li>	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> currentSwf:SwfVO;</li><li>	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">error</span>:ErrorVO;</li><li>	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> render:BitmapData;</li><li><span style="color: #66cc66;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--><br />
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:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="ActionScript"><div class="devcodeoverflow"><ol><li><span style="color: #808080; font-style: italic;">// Binding a property to a public property or setter on view</span></li><li>model.<span style="color: #006600;">bind</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;state&quot;</span>, view <span style="color: #66cc66;">&#41;</span>;</li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">// Property name needs to be passed as string, so using enums is recommended</span></li><li>model.<span style="color: #006600;">bind</span><span style="color: #66cc66;">&#40;</span> Bindable.<span style="color: #006600;">STATE</span>, view <span style="color: #66cc66;">&#41;</span>;</li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">// Changing a property and propagate the change if value is different</span></li><li>model.<span style="color: #006600;">update</span><span style="color: #66cc66;">&#40;</span> Bindable.<span style="color: #006600;">STATE</span>, <span style="color: #ff0000;">&quot;main&quot;</span> <span style="color: #66cc66;">&#41;</span>;</li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">// Changing a model property and force propagation</span></li><li>model.<span style="color: #006600;">update</span><span style="color: #66cc66;">&#40;</span> Bindable.<span style="color: #006600;">STATE</span>, <span style="color: #ff0000;">&quot;main&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>;</li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">// Resetting model properties to their values at define time</span></li><li>model.<span style="color: #006600;">reset</span><span style="color: #66cc66;">&#40;</span> Bindable.<span style="color: #006600;">STATE</span>, Bindable.<span style="color: #006600;">FILE</span> <span style="color: #66cc66;">&#41;</span>;</li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">// Removing a data binding. Omit the second argument to unbind target from all data bindings</span></li><li>model.<span style="color: #006600;">unbind</span><span style="color: #66cc66;">&#40;</span> view, Bindable.<span style="color: #006600;">STATE</span> <span style="color: #66cc66;">&#41;</span>;</li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">// Retrieve the before-change value of a bindable property</span></li><li>model.<span style="color: #006600;">retrieveLast</span><span style="color: #66cc66;">&#40;</span> Bindable.<span style="color: #006600;">STATE</span> <span style="color: #66cc66;">&#41;</span>;</li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">// Control what happens when last target unbinds from a property</span></li><li><span style="color: #808080; font-style: italic;">// true : Discard orphaned bindings</span></li><li><span style="color: #808080; font-style: italic;">// false : retain orphaned bindins (default)</span></li><li>model.<span style="color: #006600;">autoDisposeBindings</span> = <span style="color: #000000; font-weight: bold;">true</span>;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<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>Circular Tron pattern generator</title>
		<link>http://www.oyvindnordhagen.com/blog/2011/10/31/circular-tron-pattern-generator/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2011/10/31/circular-tron-pattern-generator/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 22:27:36 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Freebies]]></category>
		<category><![CDATA[circular]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[print size]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[tron]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=624</guid>
		<description><![CDATA[Just as part of a fun little side project, I made this class to generate random circular Tron-like patterns. I thought I&#8217;d post it here in case anyone else likes the look of what it does. I&#8217;ve included an option [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.oyvindnordhagen.com/tron/"><img class="alignnone size-full wp-image-625" title="tron_pattern" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2011/10/tron_pattern.jpg" alt="" width="576" height="300" /></a></p>
<p>Just as part of a fun little side project, I made this class to generate random circular Tron-like patterns. I thought I&#8217;d post it here in case anyone else likes the look of what it does. I&#8217;ve included an option to save the image in 2880&#215;2880 pixels.</p>
<p>Se the Tron pattern generator here: <a href="http://www.oyvindnordhagen.com/tron/">www.oyvindnordhagen.com/tron/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2011/10/31/circular-tron-pattern-generator/feed/</wfw:commentRss>
		<slash:comments>3</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>Perlin Lines &#8211; A Beautiful Art Effect in AS3 Flash</title>
		<link>http://www.oyvindnordhagen.com/blog/2011/08/29/perlin-lines-a-beautiful-art-effect-in-as3-flash/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2011/08/29/perlin-lines-a-beautiful-art-effect-in-as3-flash/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 07:00:00 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Shout!]]></category>
		<category><![CDATA[as3 flash art]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/2011/08/29/perlin-lines-a-beautiful-art-effect-in-as3-flash/</guid>
		<description><![CDATA[Really awesome generative art from flashandmath http://tpt.to/agn5D8]]></description>
			<content:encoded><![CDATA[<p><img style="display: block; margin-right: auto; margin-left: auto;" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2011/08/wpid-lines4.jpeg" alt="image" /></p>
<p>Really awesome generative art from flashandmath <a href="http://tpt.to/agn5D8">http://tpt.to/agn5D8</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2011/08/29/perlin-lines-a-beautiful-art-effect-in-as3-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announcing LazyFallback 2</title>
		<link>http://www.oyvindnordhagen.com/blog/2011/08/20/announcing-lazyfallback-2/</link>
		<comments>http://www.oyvindnordhagen.com/blog/2011/08/20/announcing-lazyfallback-2/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 00:24:21 +0000</pubDate>
		<dc:creator>Øyvind</dc:creator>
				<category><![CDATA[Freebies]]></category>
		<category><![CDATA[Problems & Solutions]]></category>
		<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[banner ads]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[fallback]]></category>
		<category><![CDATA[lazyfallback]]></category>

		<guid isPermaLink="false">http://www.oyvindnordhagen.com/blog/?p=601</guid>
		<description><![CDATA[Batch banner ad fallback generator for devs who work smarter, not harder! &#160; Around 8 months ago, I released LazyFallback, the batch jpg fallback generator for flash. That version was hacked together over just a few hours on the train [...]]]></description>
			<content:encoded><![CDATA[<h3><a href="http://www.oyvindnordhagen.com/lazyfallback"><img class="alignright size-medium wp-image-602" title="Screen Shot 2011-08-20 at 01.53.51" src="http://www.oyvindnordhagen.com/blog/wp-content/uploads/2011/08/Screen-Shot-2011-08-20-at-01.53.51-242x300.png" alt="" width="242" height="300" /></a><em>Batch banner ad fallback generator for devs who work smarter, not harder!</em></h3>
<p>&nbsp;</p>
<p>Around 8 months ago, I released LazyFallback, the batch jpg fallback generator for flash. That version was hacked together over just a few hours on the train to and from work and had a few obvious limitations. Especially when it came to movies with scripted animation.</p>
<p>This time, I&#8217;ve done it right (I think). Funnily enough, during the time I was working on improving LazyFallback, I talked to <a href="http://twitter.com/#!/paulholliday">@paulholliday</a> who by sheer coincidence was working on the exact same thing, and he kindly let me have the source for his own app, <a href="http://blog.mediafront.no/2011/03/07/fallback-creator/">FallbackCreator</a>. Inspired by his solution, I changed the solution for loading the swfs altogether from using a Loader to using AIR&#8217;s HTMLLoader to enable AVM1 movies to play as naturally as possible.</p>
<h3>Other improvements:</h3>
<ul>
<li>Much better memory handling</li>
<li>AutoUpdate</li>
<li>Graceful error handling</li>
<li>Slightly more polished UI</li>
<li>New icons</li>
</ul>
<p>Also, this has been a trial project for <a href="http://www.robotlegs.org/">Robotlegs</a> on my part, which I really like. But personally, I&#8217;m not too font of Flex data binding, so I combined it with<a href="http://www.oyvindnordhagen.com/blog/2011/02/28/introducing-bindlite/">BindLite</a> (or more specifically a new version called BindMax, which I might publish later).</p>
<h3>A word of caution</h3>
<p>Your swfs should not contain playing MovieClips or ActionScript on the first frame. This is a good practice in genereal when it comes to banners ads either way, but for LazyFallback to be able to reliably control the capture delay, nothing should <em>happen</em> before frame 2.</p>
<p>So why wait—<a href="http://www.oyvindnordhagen.com/lazyfallback">go get LazyFallback now</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oyvindnordhagen.com/blog/2011/08/20/announcing-lazyfallback-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

