<?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>Web 2.1 &#187; AS3</title>
	<atom:link href="http://web.2point1.com/tag/as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://web.2point1.com</link>
	<description>Tim Whitlock&#039;s home in the Blogohedron</description>
	<lastBuildDate>Thu, 13 May 2010 21:26:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using ASDoc with JASPA</title>
		<link>http://web.2point1.com/2009/03/28/using-asdoc-with-jaspa/</link>
		<comments>http://web.2point1.com/2009/03/28/using-asdoc-with-jaspa/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 17:44:34 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[ASDoc]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[JASPA]]></category>

		<guid isPermaLink="false">http://web.2point1.com/2009/03/28/using-asdoc-with-jaspa/</guid>
		<description><![CDATA[I&#8217;ve spent this morning trying to get ASDoc to generate code documentation for the JASPA APIs, with mixed results.

I encountered problems straight away with the extended globals that JASPA uses. For example The DOM API defines a native Window class which extends the ECMAScript global. Of course in AS3 you cannot extend the global.
Eventually I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent this morning trying to get <a href="http://livedocs.adobe.com/flex/3/html/asdoc_9.html" target="_blank">ASDoc</a> to generate code documentation for the <a href="http://jaspa.org.uk/">JASPA</a> APIs, with mixed results.<br />
<span id="more-116"></span><br />
I encountered problems straight away with the extended globals that JASPA uses. For example The <a href="http://jaspa.org.uk/wiki/JASPA.DOM" target="_blank">DOM API</a> defines a native <a href="http://jaspa.org.uk/wiki/Jaspa.dom.Window" target="_blank">Window</a> class which extends the <a href="http://jaspa.org.uk/wiki/Global_class" target="_blank">ECMAScript global</a>. Of course in AS3 you cannot extend the global.</p>
<p>Eventually I managed to trick ASDoc into completing, but it has opened up further cans of worms. There are a whole bunch of practices in the JASPA code base that the AS3 compiler really doesn&#8217;t like. I&#8217;ve tried to be strict, but apparently not strict enough. In some cases I feel that AS3 is just being unreasonable, for example, you cannot have private constructors in AS3. A common practice for singleton classes is many OOP languages.</p>
<p>Here&#8217;s another example, where an extended event class provides access to an extended target -</p>
<pre class="code">public class EventTarget {
}

public class Event {
    public function get target():EventTarget;
}

public class SpecialEventTarget extends EventTarget {
}

public class SpecialEvent extends Event { 
    override public function get target():SpecialEventTarget;
}</pre>
<p>The overridden getter that returns a sub-type of the target is considered invalid. I don&#8217;t see how this is bad practice. Surely a more specific type of event should be allowed to return a more specific type of target, especially as the extended target still has all the traits of the original target.</p>
<p>Of course you can always cast with the <code>as</code> operator:</p>
<pre class="code">mySpecialEvent.target as SpecialEventTarget;</pre>
<p>The question is, do I really want JASPA to be tied so closely to AS3? At the end of the day it is a separate language, and is designed for compiling into JavaScript not for emulating ActionScript.</p>
<p>I am not caught between two options.<br />
1. Alter the JASPA codebase to be even more like AS3<br />
2. Write a JAS documentor, jasdoc</p>
<p>What do you think?</p>
]]></content:encoded>
			<wfw:commentRss>http://web.2point1.com/2009/03/28/using-asdoc-with-jaspa/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Eulogy</title>
		<link>http://web.2point1.com/2009/01/31/eulogy/</link>
		<comments>http://web.2point1.com/2009/01/31/eulogy/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 14:54:53 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Lingo]]></category>

		<guid isPermaLink="false">http://web.2point1.com/2009/01/31/eulogy/</guid>
		<description><![CDATA[Or, &#8220;why I haven&#8217;t done any Flash work for a year&#8221;
I effectively gave up Flash when I came to Public and it&#8217;s now a whole year since I did any significant Flash work. In this short time AS3 has really come of age, there are tonnes of serious libraries, from fractals to physics, and PaperVision [...]]]></description>
			<content:encoded><![CDATA[<h4>Or, &#8220;why I haven&#8217;t done any Flash work for a year&#8221;</h4>
<p>I effectively gave up Flash when I came to <a href="http://www.publicreative.com/" target="_blank">Public</a> and it&#8217;s now a whole year since I did any <em>significant </em>Flash work. In this short time AS3 has really come of age, there are tonnes of serious libraries, from fractals to physics, and PaperVision 3D seems almost omnipresent. The prospect of going back to the ActionScript freelance circuit after a year on the wagon would be quite daunting.<span id="more-87"></span></p>
<p>The reasons I&#8217;ve done little Flash since I&#8217;ve been at Public are perfectly sound: I work with two brilliant Flash developers who make up 50% of our development team, and rather than everyone doing a bit of everything, we all specialize quite specifically. I cover all the back end work, and do a lot of server admin; so ActionScript in my personal world is now just a fond legacy of my freelance career.</p>
<p>ActionScript is still of great interest to me &#8211; <a href="http://jaspa.org.uk/wiki/JAS_language">JASPA is closely modelled on AS3</a>, and at Public Flash makes up the majority of our projects, so I obviously stay up to date on its progress. But I&#8217;ve spent so many hours writing ActionScript that it seems a shame I won&#8217;t be so directly involved in its future. I started using Flash in version 3 and so I&#8217;ve seen ActionScript develop from nothing in real time. I remember when Flash 5 came out and we could finally write <em>real</em> code. I made a concious decision there and then to ditch <a href="http://en.wikipedia.org/wiki/Lingo_(programming_language)" target="_blank">Lingo</a>, because it was starting to become obvious that Flash had a brighter future on the web. This turned out to be a very good decision.</p>
<p>As usual with my blog posts I feel I need to write some kind of conclusion (<em>recalls GCSE English lessons</em>), but I don&#8217;t have one; except I miss Flash, it&#8217;s awesome. The end.</p>
]]></content:encoded>
			<wfw:commentRss>http://web.2point1.com/2009/01/31/eulogy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The law of leaky abstractions</title>
		<link>http://web.2point1.com/2009/01/17/the-law-of-leaky-abstractions/</link>
		<comments>http://web.2point1.com/2009/01/17/the-law-of-leaky-abstractions/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 13:12:36 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[abstraction]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PaperVision]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[recruitment]]></category>

		<guid isPermaLink="false">http://web.2point1.com/2009/01/17/the-law-of-leaky-abstractions/</guid>
		<description><![CDATA[I&#8217;m suspicious of people who don&#8217;t enable commenting on their blog &#8211; that just makes it a book. But this gripe aside, I like what Joel Spolsky has to say about abstraction in modern programming. Well, it pushes one of my buttons; perhaps &#8220;like&#8221; has nothing to do with it.
Sadly the people I feel need [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m suspicious of people who don&#8217;t enable commenting on their blog &#8211; that just makes it a book. But this gripe aside, I like what <a href="http://www.joelonsoftware.com/articles/LeakyAbstractions.html" target="_blank">Joel Spolsky has to say about abstraction</a> in modern programming. Well, it pushes one of my buttons; perhaps &#8220;<em>like</em>&#8221; has nothing to do with it.</p>
<p>Sadly the people I feel need to appreciate his point the most probably won&#8217;t get past the second paragraph. That point, or at least the one I took away from it, is best summarized by this quote:</p>
<blockquote><p><em>&#8220;[...] as we have higher and higher level programming tools with better and better abstractions, becoming a proficient programmer is getting harder and harder.&#8221;</em></p>
</blockquote>
<p><span id="more-84"></span>Bang on. Except, maybe not harder, but just less likely. In the [invariably rapid] world of creative web development this is known as &#8220;<em>getting shit done&#8221;</em>. Young developers in my business don&#8217;t learn JavaScript; they learn jQuery. They don&#8217;t learn PHP, they learn [ahem] WordPress. (as if PHP wasn&#8217;t already a high level abstraction). Now don&#8217;t get me wrong! I&#8217;m not pleased about this, but there is a happy medium to be found somewhere, and I don&#8217;t believe we&#8217;ve all settled on it yet.</p>
<p>Joel is pretty hard on the idea that abstraction saves us time, and seems to argue that on balance the time saved working is still spent learning. Maybe this is true of people who do the learning, but many do not. And sometimes it just isn&#8217;t practical. The ActionScript world seems to be dominated at the moment by PaperVision 3D. Obviously you should have buttoned up your AS3 before diving into a library like this, but as for a solid understanding of the 3D engine; what are you going to do? Pop out for a quick doctorate in 3D mathematics in your lunch break? There is not doubt that this huge abstraction empowers many developers with some real might, with some very real time saving.</p>
<p>I have always maintained that the more you understand about what lies beneath the abstraction layer in which you are working the better you will be at your job. Would you train someone on Dreamweaver, before they proved they could write HTML? However, there is a balance to be found that works for you and your business. Web development would be impossible without the many layers that exist between the code in an HTML page and the OS of the server dishing it up. As the web evolves more layers tend to get added, and nowadays popular code libraries are adding layers within layers.</p>
<p>At the bare minimum you have this: (please excuse rudimentary linear format, and refrain from posting flowcharts)<code><br />
HTML &lt; Browser &lt; HTTP &lt; Server </code></p>
<p>Then we add a wizzy AJAX front end and some back end architecture:<code><br />
JavaScript &lt; HTML &lt; Browser &lt; HTTP &lt; Server &lt; PHP &lt; MySQL </code></p>
<p>Then we use some cool 3rd party libraries to save us some work:<br />
<code>jQuery plugins &lt; jQuery &lt; JavaScript &lt; HTML &lt; Browser &lt; HTTP &lt; Server &lt; Drupal modules &lt; Drupal &lt; PHP &lt; MySQL</code></p>
<p>The more layers, the more points for possible failure. If you only have knowledge (i.e. control) of one or two of these points you are in a weaker position when things go wrong. If you have knowledge of all these layers you are in a much stronger position to harness the value of the extra layers, rather than suffer from them. This kind of philosophy is rarely evaluated when people make business decisions off the back of a Drupal press-release, but it&#8217;s one that I ensure I keep an eye on, especially when recruiting.</p>
<p>This area is of particular interest to me at the moment, so expect more posts on the topic.</p>
]]></content:encoded>
			<wfw:commentRss>http://web.2point1.com/2009/01/17/the-law-of-leaky-abstractions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaScript Method Closures</title>
		<link>http://web.2point1.com/2008/11/24/javascript-closures/</link>
		<comments>http://web.2point1.com/2008/11/24/javascript-closures/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 19:29:42 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[closures]]></category>
		<category><![CDATA[Delegate]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://web.2point1.com/2008/11/24/javascript-closures/</guid>
		<description><![CDATA[I was further convinced this week that the world needs JASPA when my Flash developer colleague asked me about closures in JavaScript. He&#8217;s been knee-deep in AS3 for almost a year, so JavaScript must seem rather weak now.
Unlike JavaScript and AS2, AS3 supports method closures implicitly; so I made sure they were built into the [...]]]></description>
			<content:encoded><![CDATA[<p>I was further convinced this week that the world needs <a href="http://web.2point1.com/tag/jaspa/">JASPA</a> when my Flash developer colleague asked me about closures in JavaScript. He&#8217;s been knee-deep in AS3 for almost a year, so JavaScript must seem rather weak now.</p>
<p>Unlike JavaScript and AS2, AS3 supports method closures implicitly; so I made sure they were built into the <a href="http://web.2point1.com/2008/10/29/jas-vs-actionscript/">JAS</a> language. Such a thing is not native to JavaScript so the JASPA compiler automatically generates a call to helper function <code>jaspa.closure</code> whenever an object&#8217;s method is referenced.</p>
<p>If you&#8217;ve ever used <code>Delegate.create</code> in AS2, then you&#8217;ve encountered this issue. If you don&#8217;t see the problem, consider this example in JavaScript:<br />
<span id="more-75"></span></p>
<ol class="javascript">
<li class="odd"><span class="J_KEYWORD">var</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">Cat</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_KEYWORD">function</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">{</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_WHITESPACE">       </span><span class="J_KEYWORD">this</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">voice</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_STRING_LITERAL">&#8216;Miaow&#8217;</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_PUNCTUATOR">}</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_IDENTIFIER">Cat</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">prototype</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">speak</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_KEYWORD">function</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">{</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_WHITESPACE">     alert</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_KEYWORD">this</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">voice</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_PUNCTUATOR">}</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_LINE_TERMINATOR">  </span></li>
<li class="even"><span class="J_KEYWORD">var</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">Sammy</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_KEYWORD">new</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">Cat</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_IDENTIFIER">Sammy</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">speak</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_WHITESPACE"> </span><span class="J_COMMENT">// alerts &#8220;Miaow&#8221;</span></li>
<li class="even"><span class="J_LINE_TERMINATOR">  </span></li>
<li class="odd"><span class="J_KEYWORD">var</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">Callback</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">Sammy</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">speak</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_IDENTIFIER">Callback</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_WHITESPACE"> </span><span class="J_COMMENT">// alerts undefined</span></li>
</ol>
<p>As soon as we&#8217;ve created a reference to the function member, we&#8217;ve severed it from its owner, so when we call it, it&#8217;s not being called on the object. In JavaScript and AS2 we need to use a method like <code>Delegate.create</code> to explicitly create a closure. Here&#8217;s an example:</p>
<ol class="javascript">
<li class="odd"><span class="J_KEYWORD">function</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">makeClosure</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">obj</span><span class="J_PUNCTUATOR">,</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">func</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">{</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_WHITESPACE">       </span><span class="J_KEYWORD">var</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">closure</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_KEYWORD">function</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">{</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_WHITESPACE">              </span><span class="J_KEYWORD">return</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">func</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">apply</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">obj</span><span class="J_PUNCTUATOR">,</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">arguments</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_WHITESPACE">       </span><span class="J_PUNCTUATOR">}</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_WHITESPACE">       </span><span class="J_IDENTIFIER">closure</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">apply</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_KEYWORD">function</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">obj</span><span class="J_PUNCTUATOR">,</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">args</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">{</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_WHITESPACE">              </span><span class="J_KEYWORD">return</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">func</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">apply</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">obj</span><span class="J_PUNCTUATOR">,</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">args</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_WHITESPACE">       </span><span class="J_PUNCTUATOR">}</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_WHITESPACE">       </span><span class="J_IDENTIFIER">closure</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">call</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_KEYWORD">function</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">obj</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">{</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_WHITESPACE">                 </span><span class="J_KEYWORD">var</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">args</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">[</span><span class="J_PUNCTUATOR">]</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_WHITESPACE">                  </span><span class="J_KEYWORD">for</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_KEYWORD">var</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">i</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_NUMERIC_LITERAL">1</span><span class="J_PUNCTUATOR">;</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">i</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">&lt;</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">arguments</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">length</span><span class="J_PUNCTUATOR">;</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">i</span><span class="J_PUNCTUATOR">++</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">{</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_WHITESPACE">                         </span><span class="J_IDENTIFIER">args</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">push</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">arguments</span><span class="J_PUNCTUATOR">[</span><span class="J_IDENTIFIER">i</span><span class="J_PUNCTUATOR">]</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_WHITESPACE">                  </span><span class="J_PUNCTUATOR">}</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_WHITESPACE">                 </span><span class="J_KEYWORD">return</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">func</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">apply</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">obj</span><span class="J_PUNCTUATOR">,</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">args</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_WHITESPACE">       </span><span class="J_PUNCTUATOR">}</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_WHITESPACE">       </span><span class="J_KEYWORD">return</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">closure</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_PUNCTUATOR">}</span></li>
</ol>
<p>It&#8217;s basically a wrapper function which seals in the original arguments. Additionally <code>apply</code> and <code>call</code> must be overridden or calling them directly will spoil the party. Try it with the Cat example and you&#8217;ll see the desired result.</p>
<ol class="javascript">
<li class="odd"><span class="J_KEYWORD">var</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">Callback</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">makeClosure</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">Sammy</span><span class="J_PUNCTUATOR">,</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">Sammy</span><span class="J_PUNCTUATOR">.</span><span class="J_IDENTIFIER">speak</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_IDENTIFIER">Callback</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_WHITESPACE"> </span><span class="J_COMMENT">// alerts &#8220;Miaow&#8221;</span></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://web.2point1.com/2008/11/24/javascript-closures/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AMF &#8211; Errata and other ramblings</title>
		<link>http://web.2point1.com/2008/09/13/amf-errata-and-other-ramblings/</link>
		<comments>http://web.2point1.com/2008/09/13/amf-errata-and-other-ramblings/#comments</comments>
		<pubDate>Sat, 13 Sep 2008 15:18:42 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Action Message Format]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://web.2point1.com/2008/09/13/amf-errata-and-other-ramblings/</guid>
		<description><![CDATA[I&#8217;ve been doing a lot of research into the AMF protocol recently. I&#8217;ve had the pleasure of reading the AMF0, and AMF3 standards cover-to-cover several times, with a view to understanding them well enough to write my own debugging tools. More about those projects another time.
Not only are the standards fairly brief, but they contain [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of research into the <a href="http://en.wikipedia.org/wiki/Action_Message_Format" target="_blank">AMF</a> protocol recently. I&#8217;ve had the pleasure of reading the <a href="http://download.macromedia.com/pub/labs/amf/amf0_spec_121207.pdf" target="_blank">AMF0</a>, and <a href="http://download.macromedia.com/pub/labs/amf/amf3_spec_121207.pdf" target="_blank">AMF3</a> standards cover-to-cover several times, with a view to understanding them well enough to write my own debugging tools. More about those projects another time.</p>
<p>Not only are the standards fairly brief, but they contain errors. I&#8217;ve not managed to find an official errata, so here&#8217;s my starter for 10.<span id="more-64"></span></p>
<h4>1.3.1 Variable Length Unsigned 29-bit Integer Encoding (U29)</h4>
<p>The standard states that the largest unsigned integer permitted is <code>pow(2,29)-1</code>, which would be <code>0x1FFFFFFF</code>, but then goes on to state that the range of a 4 byte value goes up to <code>0x3FFFFFFF</code>. This looks like a typo, unless I am missing something critical!</p>
<p>The AMF standard is supposed to be platform independent [ish], so it doesn&#8217;t talk about Flash [much]; but it&#8217;s worth noting that the Flash Player uses <em>U29</em> for serializing <strong><em>signed</em> </strong>integers, making its useful range <code>-0x10000000 -&gt; 0x0FFFFFFF. </code>Flash serializes all integers outside this range as a <em>double</em>s, even when the AS type is <code>uint</code>; because the AMF protocol does not support an unsigned data type.</p>
<p>I find this data type a bit pointless. It is designed cut down on redundancy, but surely this could be achieved with different integer markers, 8-bit, 16-bit, etc.. The range of the integer wouldn&#8217;t have to be restricted and it would probably deserialize faster too.</p>
<h4>1.3.2 Strings and UTF-8</h4>
<p>There appears to be a typo in the third paragraph which contradicts the grammar notation below. It states that a zero flag indicates a string literal, although it says below that a zero value indicates a reference. The latter seems correct and is the same convention used in other parts of the standard.</p>
<p>More to come &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://web.2point1.com/2008/09/13/amf-errata-and-other-ramblings/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ActionScript Emptiness</title>
		<link>http://web.2point1.com/2008/08/02/actionscript-emptiness/</link>
		<comments>http://web.2point1.com/2008/08/02/actionscript-emptiness/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 16:09:05 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://web.2point1.com/2008/08/02/actionscript-emptiness/</guid>
		<description><![CDATA[I&#8217;m a great believer that if you&#8217;re going to be good at something you should understand it a the lowest level possible. Every ActionScript developer I talk to at the moment is migrating to AS3 and mostly we talk about all the high level differences it has with AS2; the API, the event mechanism and [...]]]></description>
			<content:encoded><![CDATA[<p><strong>I&#8217;m a great believer that if you&#8217;re going to be good at something you should understand it a the lowest level possible. </strong>Every ActionScript developer I talk to at the moment is migrating to AS3 and mostly we talk about all the high level differences it has with AS2; the API, the event mechanism and so forth. But let&#8217;s not forget the little things. It&#8217;s often complacency toward the smallest components that cause the most trouble. It seems like an odd situation to know how to flip a cube around in 3D space, but not really know the difference between <code>null</code> and <code>undefined</code>. This is a real situation though, and it can mean bugs deep in complex layers of code just waiting to ruin everything.<span id="more-55"></span></p>
<p>So in this spirit of pedanticalness I&#8217;ve been playing around with the various changes to the <code>null</code>, and <code>undefined</code> types in AS3 and how they relate to the new concept of untyped objects. Having been writing JavaScript and ActionScript for years these notions are taking some getting used to. That&#8217;s fine, but I have noticed some nuances that I&#8217;m not happy with.</p>
<p>I&#8217;m fine with the notion that a typed object cannot contain the value <code>undefined</code>. It makes sense that it should adopt a native value of its own. I do find it strange though that a <code>Number</code> defaults to <code>NaN</code>, whereas <code>int</code>, and <code>uint</code> default to <code>0</code>, but I think I&#8217;ll just about sleep at night.</p>
<p>I also find it odd that some typed objects may be set to <code>null</code>, while some cannot. (<code>var s:String = null;</code>) holds <code>null</code> and is still a <code>String</code>, and yet: (<code>var n:Number = null;</code>) raises an error. Although I don&#8217;t really get this, being aware of it is the important thing when it comes to avoiding bugs.</p>
<p>Here are some more weird things I discovered today:<br />
Setting a <code>Number</code> to <code>null</code> via a function call prevents the error you get when setting it directly.</p>
<ol class="code javascript">
<li class="odd"><span class="J_KEYWORD">function</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">getNull</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">:</span><span class="J_PUNCTUATOR">*</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">{</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_WHITESPACE">    </span><span class="J_KEYWORD">return</span><span class="J_WHITESPACE"> </span><span class="J_LITERAL">null</span><span class="J_PUNCTUATOR">;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_PUNCTUATOR">}</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_IDENTIFIER">trace</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">getNull</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">===</span><span class="J_WHITESPACE"> null</span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_WHITESPACE"> </span><span class="J_COMMENT">// prints &#8221;true&#8221;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_KEYWORD">var</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">x</span><span class="J_PUNCTUATOR">:</span><span class="J_IDENTIFIER">Number</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_LITERAL">null</span><span class="J_PUNCTUATOR">;</span><span class="J_WHITESPACE"> </span><span class="J_COMMENT">// raises error</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_KEYWORD">var</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">y</span><span class="J_PUNCTUATOR">:</span><span class="J_IDENTIFIER">Number</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">getNull</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_WHITESPACE"> </span><span class="J_COMMENT">// no error   </span></li>
</ol>
<p>Setting a Number to undefined via a void function call raises an error</p>
<ol class="code javascript">
<li class="odd"><span class="J_KEYWORD">function</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">getUndefined</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">:</span><span class="J_KEYWORD">void</span><span class="J_PUNCTUATOR">{</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_WHITESPACE">    </span><span class="J_COMMENT">// no return value.</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_PUNCTUATOR">}</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_IDENTIFIER">trace</span><span class="J_PUNCTUATOR">(</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">getUndefined</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">===</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">undefined</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_WHITESPACE"> </span><span class="J_COMMENT">// prints &#8221;true&#8221;</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="odd"><span class="J_KEYWORD">var</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">x</span><span class="J_PUNCTUATOR">:</span><span class="J_IDENTIFIER">Number</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">undefined</span><span class="J_PUNCTUATOR">;</span><span class="J_WHITESPACE"> </span><span class="J_COMMENT">// sets to NaN as expected</span><span class="J_LINE_TERMINATOR"> </span></li>
<li class="even"><span class="J_KEYWORD">var</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">n</span><span class="J_PUNCTUATOR">:</span><span class="J_IDENTIFIER">Number</span><span class="J_WHITESPACE"> </span><span class="J_PUNCTUATOR">=</span><span class="J_WHITESPACE"> </span><span class="J_IDENTIFIER">getUndefined</span><span class="J_PUNCTUATOR">(</span><span class="J_PUNCTUATOR">)</span><span class="J_PUNCTUATOR">;</span><span class="J_WHITESPACE"> </span><span class="J_COMMENT">// raises error, halts execution</span></li>
</ol>
<p>Hmm..</p>
]]></content:encoded>
			<wfw:commentRss>http://web.2point1.com/2008/08/02/actionscript-emptiness/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scale &amp; rotate around an arbitrary centre</title>
		<link>http://web.2point1.com/2008/04/13/scale-rotate-around-an-arbitrary-centre/</link>
		<comments>http://web.2point1.com/2008/04/13/scale-rotate-around-an-arbitrary-centre/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 19:22:57 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[vector]]></category>

		<guid isPermaLink="false">http://web.2point1.com/2008/04/13/scale-rotate-around-an-arbitrary-centre/</guid>
		<description><![CDATA[The mini project I picked as my first dip into AS3 was a short example that I had been planning for this blog, so here it is in AS3, instead of AS2 as I had originally planned.
The South Park Chin balls Flash app required that the user drag and zoom a loaded photo. Anyone who&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>The mini project I picked as my first dip into AS3 was a short example that I had been planning for this blog, so here it is in AS3, instead of AS2 as I had originally planned.</p>
<p>The South Park <a href="http://web.2point1.com/2008/03/23/down-and-dirty/">Chin balls</a> Flash app required that the user drag and zoom a loaded photo. Anyone who&#8217;s ever done this will know that you can&#8217;t just scale the picture around it&#8217;s registration point when you zoom. <em>Why</em>? because the centre point changes as you pan the image around. So the requirement in a nutshell is &#8211; to be able to <strong>scale a <em>MovieClip</em> around an arbitrary centre</strong>.</p>
<p>Sure, you could take the <em>Russian doll</em> approach with multiple clips inside clips, but that just ain&#8217;t cool! I thought I&#8217;d share the way I did it as it&#8217;s pretty concise.<span id="more-25"></span></p>
<p>First of all here&#8217;s the principal in action. Scaling and rotation, both performed around an arbitrary centre point that you can alter by dragging that little marker around. Go on, have a go.</p>
<p>[ Update: due to a <a href="http://web.2point1.com/2009/03/21/lessons-learned-again/">nasty server crash</a> some of these files are missing.. sorry. <a href="/wp-content/uploads/2008/04/virtualcentresprite.html#scaleAround" title="scaleAround method" target="_blank">This source was rescued though</a> ]</p>
<p id="flashcontent" style="border: 1px solid #666666; padding: 0pt; display: block; width: 350px; height: 350px">Loading example SWF&#8230;</p>
<p><script type="text/javascript">  <!--     var so = new SWFObject("/wp-content/uploads/2008/04/virtualcentreexample.swf", "flashobj", "350", "350", "9", "#F0F0F0");  so.write("flashcontent");   so.addParam("wmode","opaque");  //-->   </script></p>
<p><a href="/wp-content/uploads/2008/04/virtualcentreexample.zip" title="VirtualCentreExample">Download the source files for this example</a></p>
<p>Most of the source files just serve to create the example interface. The only class we need to discuss is the one with the scale and rotating logic. The class <code><strong>VirtualCentreSprite</strong></code> is an extension of the <code>Sprite</code> class. In AS2 it would have to be an extension of the <code>MovieClip</code> class, but we don&#8217;t need a timeline. You could use this as a base class for sprites across your project to ensure they all have this capability.</p>
<p>It has two methods as follows:<br />
<code style="display: block; white-space: nowrap"><br />
void <strong>scaleAround</strong>( <strong>offsetX</strong>:Number, <strong>offsetY</strong>:Number, <strong>absScaleX</strong>:Number, <strong>absScaleY</strong>:Number )<br />
void <strong>rotateAround</strong>( <strong>offsetX</strong>:Number, <strong>offsetY</strong>:Number, <strong>toDegrees</strong>:Number )<br />
</code><br />
The scaling method is the simplest. It&#8217;s basically GCSE vector maths. We calculate the position that the clip should be at after scaling, do the scaling (which will move the clip according to the centre that Flash knows about) and then we simply reposition it to where it should be.<br />
<a href="/wp-content/uploads/2008/04/virtualcentresprite.html#scaleAround" title="scaleAround method" target="_blank">Click to see source of method <code>scaleAround</code></a></p>
<p>The rotating method is a bit more complex, because it uses a transformation matrix. But thanks to the <code>flash.geom</code> package this is short and sweet. Again the principal is that we let Flash rotate the sprite and then adjust the position.<br />
<a href="/wp-content/uploads/2008/04/virtualcentresprite.html#rotateAround" title="rotateAround method" target="_blank">Click to see source of method <code>rotateAround</code></a></p>
]]></content:encoded>
			<wfw:commentRss>http://web.2point1.com/2008/04/13/scale-rotate-around-an-arbitrary-centre/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>AS3 Migration &#8211; Day 1</title>
		<link>http://web.2point1.com/2008/04/13/as3-migration-day-1/</link>
		<comments>http://web.2point1.com/2008/04/13/as3-migration-day-1/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 17:26:57 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://web.2point1.com/2008/04/12/as3-migration-day-1/</guid>
		<description><![CDATA[Much later than planned I finally got around to checking out AS3.
I was quick to upgrade to AS2 when it came out in Flash MX 2004, and  never looked back, so why so late? Well, as usual, because I&#8217;m busy. Busy on a PHP project at that, so I haven&#8217;t really had the chance. [...]]]></description>
			<content:encoded><![CDATA[<p>Much later than planned I finally got around to checking out AS3.</p>
<p>I was quick to upgrade to AS2 when it came out in Flash MX 2004, and  never looked back, so why so late? Well, as usual, because I&#8217;m busy. Busy on a PHP project at that, so I haven&#8217;t really had the chance. Plus, if I do have to write some AS on the job it&#8217;s too big a risk to start learning something new. Pressures demand that I get on with it as I know how. That&#8217;s why <a href="http://web.2point1.com/2008/03/23/down-and-dirty/">this Facebook application</a> has it&#8217;s main Flash app (Chin Balls) written in AS2. Also, I view the upgrading of a programming language as a one-way process. I didn&#8217;t upgrade to PHP5 until I was confident I would never have to write PHP4 again. And with AS3 this is an even bigger deal.<span id="more-23"></span></p>
<p>I anticipated that AS3 was going to be stricter, less forgiving, and that I&#8217;d have to get used to a few things, but I have to confess to being quite surprised at how different it is. There&#8217;s so much material on AS3 available to you that there&#8217;s no point me banging on about things you can get better information on else where. However, as an AS2 developer here&#8217;s a quick list in no particular order of the things that either surprised or pleased me in my first couple of hours of AS3 writing:</p>
<ul>
<li>The MovieClip&#8217;s inheritance chain has 5 other classes between itself and the Object class. This abstracts out various types of functionality and means you don&#8217;t have to use a fully loaded MovieClip just to display a blob.</li>
<li>Small, but caught me out &#8211; Void must be lower case as a return type, e.g.  <code>function():void{ }</code> My bad.</li>
<li>Watch out; Ctrl-t <strong>only</strong> <strong>checks syntax</strong>.<br />
This is more profound than it sounds. I suspect the reason that AS2 compiles the script and checks all references and types is because that&#8217;s the best chance you&#8217;ve got of catching an error. AS3 actually has the ability to do this at run time, so don&#8217;t think &#8220;This script contains no errors&#8221; means you&#8217;re in the clear!</li>
<li>At last; percentage properties like <em>alpha</em> are now 0-1, instead of 0-100. Another design interface legacy bites the dust. &#8211; and say goodbye to underscores in property names too :)</li>
<li>A new <code>override</code> keyword must be used to redefine a parent class method of the same name</li>
<li>MovieClips do not have implicit onEnterFrame, onRelease,  or <em>any</em> such handlers invoked by default. You have to explicitly define all event handling via the thoroughly standardized Event mechanism.</li>
<li>Looking for onLoad? You won&#8217;t find it, see above;</li>
<li>Declaring child clips as member variables in classes was raising conflicts with members of the same name placed physically on the stage. It took me a while to find the publish setting &#8220;Automatically declare stage instances&#8221;. If you&#8217;re used to declaring all your physical members switch this off. If you&#8217;re normally lazy, switch it on!</li>
<li>No more prototype hacking. Not even if it&#8217;s 10pm and you really want to go home.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://web.2point1.com/2008/04/13/as3-migration-day-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 &#8211; The gap widens</title>
		<link>http://web.2point1.com/2008/04/12/as3-the-gap-widens/</link>
		<comments>http://web.2point1.com/2008/04/12/as3-the-gap-widens/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 16:41:31 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://web.2point1.com/2008/04/13/as3-the-gap-widens/</guid>
		<description><![CDATA[The designer/developer boundary has always been a little blurry when it comes to Flash. Flash has been celebrated for this since 1999, and  has established a pretty unique position. But with each release of Flash those who sit on the fence feel an increasing pressure to choose a camp and stay in it. Some do, [...]]]></description>
			<content:encoded><![CDATA[<p>The designer/developer boundary has always been a little blurry when it comes to Flash. Flash has been celebrated for this since <a href="http://en.wikipedia.org/wiki/Adobe_Flash#History" title="Flash 4 inroduced menu driven scripting" target="_blank">1999</a>, and  has established a pretty unique position. But with each release of Flash those who sit on the fence feel an increasing pressure to choose a camp and stay in it. Some do, some don&#8217;t and some just carry on doing things as they always did, but one thing&#8217;s for sure; that the drive toward Flash being a more robust, more powerful, more serious platform is not showing any signs of slowing down. AS3 is another leap forward. In fact a much bigger leap than AS2 was.<span id="more-22"></span></p>
<p>The casual and flexible nature of ActionScript has lent itself very well to the creative industries in particular over the years. In short, it gets the job done! And unfortunately that&#8217;s what this business is all about most of the time. But ActionScript has really grown up this time. Of course you can still publish Flash movies in AS2, and even AS1, but if you want to grow up too you&#8217;re going to have to get a bit more serious &#8211; again. This means more planning and less hacking. Generally you are going to spend longer doing pretty much everything.</p>
<p>I know plenty of creative developers who have been writing ActionScript for years and many of them eventually embraced AS2, even if a little reluctantly. AS2 was an important step in the maturing of the language, but a step that was in fact a bit of an illusion. The structure and strictness that it appears to impose is really rather superficial and the list of hacks and compiler workarounds is endless. Under the hood AS2 is pretty much the same deal as AS1. i.e. it&#8217;s JavaScript. JavaScript was purposefully designed for non-programmers. How often have you done this to create a button action:</p>
<pre class="code">myBtn.onRelease = function(){ /* do stuff */ }</pre>
<p>What you are doing is creating a function object and assigning it as a property of another object. You can do this because the prototype architecture of JavaScript allows you to &#8211; a concept foreign to pretty much all class-based languages.<br />
Well you can&#8217;t do it any more. &#8211; not in AS3.</p>
<p>This time around Adobe has based the language on the <em>draft</em> specification of <a href="http://en.wikipedia.org/wiki/ECMAScript#Fourth_edition" target="_blank">ECMAScript</a> Edition 4 (<a href="http://en.wikipedia.org/wiki/ECMAScript#Fourth_edition" target="_blank">ES4</a>). AS1 &amp; 2 (along with most implementations of JavaScript that you&#8217;ll encounter) are based on ES3 which is nearly ten years old now. So under the hood AS3 is genuinely a different beast and a more grown up one at that.</p>
<p>So with the ever-stricter, and more robust stature of ActionScript, how long can this designer/developer melting pot survive? And how narrow can the margin remain between the developer and the designer? I don&#8217;t mean to suggest that designers can&#8217;t code or that coders can&#8217;t design, but there are only so many hours in the day, and only so much you can fit into one person&#8217;s job description. Perhaps the distinction of merely two roles isn&#8217;t sufficient anymore. We don&#8217;t talk about Flash development in terms of <em>front </em>and <em>back</em> ends, but perhaps we should. As the gap widens perhaps we can identify multiple roles for specialists across multiple layers of development just as we do with HTML based web apps.</p>
]]></content:encoded>
			<wfw:commentRss>http://web.2point1.com/2008/04/12/as3-the-gap-widens/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
