<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Dynamic Programming in AS3</title>
	<atom:link href="http://nodename.com/blog/2008/09/19/dynamic-programming-in-as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://nodename.com/blog/2008/09/19/dynamic-programming-in-as3/</link>
	<description></description>
	<lastBuildDate>Fri, 02 Jul 2010 12:12:19 -0600</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: alan</title>
		<link>http://nodename.com/blog/2008/09/19/dynamic-programming-in-as3/comment-page-1/#comment-168479</link>
		<dc:creator>alan</dc:creator>
		<pubDate>Fri, 21 Aug 2009 04:30:57 +0000</pubDate>
		<guid isPermaLink="false">http://nodename.com/blog/?p=62#comment-168479</guid>
		<description>@Krilnon: Thanks, that makes sense.  I&#039;ve moderated my excitement!</description>
		<content:encoded><![CDATA[<p>@Krilnon: Thanks, that makes sense.  I&#8217;ve moderated my excitement!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krilnon</title>
		<link>http://nodename.com/blog/2008/09/19/dynamic-programming-in-as3/comment-page-1/#comment-168478</link>
		<dc:creator>Krilnon</dc:creator>
		<pubDate>Fri, 21 Aug 2009 03:37:55 +0000</pubDate>
		<guid isPermaLink="false">http://nodename.com/blog/?p=62#comment-168478</guid>
		<description>&quot;By default you cannot overwrite Trait based class methods. Using “-es -as3=false” runs everything via prototype but with JIT.

We have always had access to .prototype but trait methods could not be overwritten. This reverses that in a compiler flag.&quot;

I don&#039;t really want to rain on your excitement, but I believe that the only reason that you are able to override (in effect) those particular methods is because the &#039;core&#039; classes (the top-level ones) were mandated by the ES4 draft spec to be defined on the prototype.  They&#039;re also defined the &#039;regular&#039; way so that they still end up in the traits object for each class.  

However, if you look carefully at the declarations of the methods of those classes in the AS3 docs, you&#039;ll notice that the methods are not public; they&#039;re defined in the &#039;AS3&#039; namespace.  That trickery allows them to be bound as regular methods unless you use the compiler flags that you were talking about.  Since the AS3 namespace isn&#039;t open by default anymore, your property access attempts will actually be able to reach the prototype versions.  

Sadly, the rest of the built-in classes use methods that are in the public namespace (and they don&#039;t even have prototype versions), so you won&#039;t be able to get around the bound versions using your compiler flags.  The most notable impact of this is that you can&#039;t redefine the methods of practically any of the other built-in classes, like Sprite.</description>
		<content:encoded><![CDATA[<p>&#8220;By default you cannot overwrite Trait based class methods. Using “-es -as3=false” runs everything via prototype but with JIT.</p>
<p>We have always had access to .prototype but trait methods could not be overwritten. This reverses that in a compiler flag.&#8221;</p>
<p>I don&#8217;t really want to rain on your excitement, but I believe that the only reason that you are able to override (in effect) those particular methods is because the &#8216;core&#8217; classes (the top-level ones) were mandated by the ES4 draft spec to be defined on the prototype.  They&#8217;re also defined the &#8216;regular&#8217; way so that they still end up in the traits object for each class.  </p>
<p>However, if you look carefully at the declarations of the methods of those classes in the AS3 docs, you&#8217;ll notice that the methods are not public; they&#8217;re defined in the &#8216;AS3&#8242; namespace.  That trickery allows them to be bound as regular methods unless you use the compiler flags that you were talking about.  Since the AS3 namespace isn&#8217;t open by default anymore, your property access attempts will actually be able to reach the prototype versions.  </p>
<p>Sadly, the rest of the built-in classes use methods that are in the public namespace (and they don&#8217;t even have prototype versions), so you won&#8217;t be able to get around the bound versions using your compiler flags.  The most notable impact of this is that you can&#8217;t redefine the methods of practically any of the other built-in classes, like Sprite.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alan</title>
		<link>http://nodename.com/blog/2008/09/19/dynamic-programming-in-as3/comment-page-1/#comment-168471</link>
		<dc:creator>alan</dc:creator>
		<pubDate>Mon, 17 Aug 2009 23:28:56 +0000</pubDate>
		<guid isPermaLink="false">http://nodename.com/blog/?p=62#comment-168471</guid>
		<description>Here&#039;s a series of tweets that appeared today from Ted Patrick, @adobeted, that supplement the information on dynamic programming in AS3:

Found the most awesome ASC compiler flag of all time. -es -as3=false. It allows fully editable prototyping using AS3.

-es -as3=false makes this street legal: Array.prototype.push = function():void{ trace(&#039;push&#039;) } override trait based methods.

By default you cannot overwrite Trait based class methods. Using &quot;-es -as3=false&quot; runs everything via prototype but with JIT.

We have always had access to .prototype but trait methods could not be overwritten. This reverses that in a compiler flag.

It is really great for those doing work in AS3 in Flash Pro and ASProject. It is super handy rewiring player methods http://proto.layer51.com/

And if you want to get really dynamic try &quot;-es -as3=false -strict=false&quot; suddenly your back in as1 land with JIT.

Take a look at this example, I reassign the Array.prototype.push method 2 times with execution:

01.package {
02.    import flash.display.Sprite;
03. 
04.    public class ESFla extends Sprite
05.    {
06.        public function ESFla()
07.        {
08.            Array.prototype.push = function( value:Object ):void{
09.                trace(&#039;1st definition of push:&#039; + value);
10.            }
11.            var a:Array = [];
12.            a.push(&#039;foo&#039;);
13.            Array.prototype.push = function( value:Object ):void{
14.                trace(&#039;2nd definition of push:&#039; + value);
15.            }
16.            a.push(&#039;foo&#039;);
17.        }
18.    }
19.}


Crazier still, create &#039;push&#039; on Object and delete Array.push at runtime:


01.package {
02.    import flash.display.Sprite;
03. 
04.    public class ESFla extends Sprite
05.    {
06.        public function ESFla()
07.        {
08.            Array.prototype.push = function( value:Object ):void{
09.                trace(&#039;1st definition of push:&#039; + value);
10.            }
11.            Object.prototype.push = function( value:Object ):void{
12.                trace(&#039;1st definition of push on Object:&#039; + value);
13.            }
14.            var a:Array = [];
15.            a.push(&#039;foo&#039;);
16.            Array.prototype.push = function( value:Object ):void{
17.                trace(&#039;2nd definition of push:&#039; + value);
18.            }
19.            a.push(&#039;foo&#039;);
20.            delete Array.prototype.push;
21.            a.push(&#039;foo&#039;);
22.        }
23.    }
24.}

You should be able to edit the __proto__ property to splice in new inheiritance on instances. Writing example.

It is so weird to have all this old knowledge come rushing back to relevance. prototype and __proto__ dear god. :)

__proto__ is gone in Tamarin engine. But there is reference to a &#039;toPrototype&#039; method for get/set on chain.

Well AS3 was intended to span strict and dynamic development. Some like strict while some like dynamic.</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a series of tweets that appeared today from Ted Patrick, @adobeted, that supplement the information on dynamic programming in AS3:</p>
<p>Found the most awesome ASC compiler flag of all time. -es -as3=false. It allows fully editable prototyping using AS3.</p>
<p>-es -as3=false makes this street legal: Array.prototype.push = function():void{ trace(&#8216;push&#8217;) } override trait based methods.</p>
<p>By default you cannot overwrite Trait based class methods. Using &#8220;-es -as3=false&#8221; runs everything via prototype but with JIT.</p>
<p>We have always had access to .prototype but trait methods could not be overwritten. This reverses that in a compiler flag.</p>
<p>It is really great for those doing work in AS3 in Flash Pro and ASProject. It is super handy rewiring player methods <a href="http://proto.layer51.com/" rel="nofollow">http://proto.layer51.com/</a></p>
<p>And if you want to get really dynamic try &#8220;-es -as3=false -strict=false&#8221; suddenly your back in as1 land with JIT.</p>
<p>Take a look at this example, I reassign the Array.prototype.push method 2 times with execution:</p>
<p>01.package {<br />
02.    import flash.display.Sprite;<br />
03.<br />
04.    public class ESFla extends Sprite<br />
05.    {<br />
06.        public function ESFla()<br />
07.        {<br />
08.            Array.prototype.push = function( value:Object ):void{<br />
09.                trace(&#8217;1st definition of push:&#8217; + value);<br />
10.            }<br />
11.            var a:Array = [];<br />
12.            a.push(&#8216;foo&#8217;);<br />
13.            Array.prototype.push = function( value:Object ):void{<br />
14.                trace(&#8217;2nd definition of push:&#8217; + value);<br />
15.            }<br />
16.            a.push(&#8216;foo&#8217;);<br />
17.        }<br />
18.    }<br />
19.}</p>
<p>Crazier still, create &#8216;push&#8217; on Object and delete Array.push at runtime:</p>
<p>01.package {<br />
02.    import flash.display.Sprite;<br />
03.<br />
04.    public class ESFla extends Sprite<br />
05.    {<br />
06.        public function ESFla()<br />
07.        {<br />
08.            Array.prototype.push = function( value:Object ):void{<br />
09.                trace(&#8217;1st definition of push:&#8217; + value);<br />
10.            }<br />
11.            Object.prototype.push = function( value:Object ):void{<br />
12.                trace(&#8217;1st definition of push on Object:&#8217; + value);<br />
13.            }<br />
14.            var a:Array = [];<br />
15.            a.push(&#8216;foo&#8217;);<br />
16.            Array.prototype.push = function( value:Object ):void{<br />
17.                trace(&#8217;2nd definition of push:&#8217; + value);<br />
18.            }<br />
19.            a.push(&#8216;foo&#8217;);<br />
20.            delete Array.prototype.push;<br />
21.            a.push(&#8216;foo&#8217;);<br />
22.        }<br />
23.    }<br />
24.}</p>
<p>You should be able to edit the __proto__ property to splice in new inheiritance on instances. Writing example.</p>
<p>It is so weird to have all this old knowledge come rushing back to relevance. prototype and __proto__ dear god. :)</p>
<p>__proto__ is gone in Tamarin engine. But there is reference to a &#8216;toPrototype&#8217; method for get/set on chain.</p>
<p>Well AS3 was intended to span strict and dynamic development. Some like strict while some like dynamic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danny Miller</title>
		<link>http://nodename.com/blog/2008/09/19/dynamic-programming-in-as3/comment-page-1/#comment-150330</link>
		<dc:creator>Danny Miller</dc:creator>
		<pubDate>Tue, 23 Sep 2008 07:13:18 +0000</pubDate>
		<guid isPermaLink="false">http://nodename.com/blog/?p=62#comment-150330</guid>
		<description>I completely disagree. I don&#039;t agree strategy pattern is appropriate... at least not in AS3... Why not just use event listeners? Add a listener and pass in a different function caller. This is also more powerful as let&#039;s say in your strategy pattern (with the game) you would like to call two private methods. You  can do that with events much cleaner...

After reading your post (great btw, very informative and well explained), I don&#039;t think that dynamic programming is worth the performance costs.

I don&#039;t know, maybe there&#039;s some other weird pattern or instance where it&#039;d work, maybe not... But def an interesting paradigm</description>
		<content:encoded><![CDATA[<p>I completely disagree. I don&#8217;t agree strategy pattern is appropriate&#8230; at least not in AS3&#8230; Why not just use event listeners? Add a listener and pass in a different function caller. This is also more powerful as let&#8217;s say in your strategy pattern (with the game) you would like to call two private methods. You  can do that with events much cleaner&#8230;</p>
<p>After reading your post (great btw, very informative and well explained), I don&#8217;t think that dynamic programming is worth the performance costs.</p>
<p>I don&#8217;t know, maybe there&#8217;s some other weird pattern or instance where it&#8217;d work, maybe not&#8230; But def an interesting paradigm</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alan</title>
		<link>http://nodename.com/blog/2008/09/19/dynamic-programming-in-as3/comment-page-1/#comment-150188</link>
		<dc:creator>alan</dc:creator>
		<pubDate>Mon, 22 Sep 2008 03:05:17 +0000</pubDate>
		<guid isPermaLink="false">http://nodename.com/blog/?p=62#comment-150188</guid>
		<description>Thanks, Steven!  I believe I&#039;m convinced.

No matter how you implement this, you need to be able to retrieve a discriminator (specifying what the Actor is to do) from a target instance.  I was thinking that it was properly not a property of the target instance but rather of its class, and therefore, since static class properties are not inherited in AS3, the prototype would be good.  But in fact making it an instance property of the target makes retrieval faster, and it&#039;s also more general, because you can then set different discriminators in targets based on any criterion, not just the target&#039;s class.</description>
		<content:encoded><![CDATA[<p>Thanks, Steven!  I believe I&#8217;m convinced.</p>
<p>No matter how you implement this, you need to be able to retrieve a discriminator (specifying what the Actor is to do) from a target instance.  I was thinking that it was properly not a property of the target instance but rather of its class, and therefore, since static class properties are not inherited in AS3, the prototype would be good.  But in fact making it an instance property of the target makes retrieval faster, and it&#8217;s also more general, because you can then set different discriminators in targets based on any criterion, not just the target&#8217;s class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Sacks</title>
		<link>http://nodename.com/blog/2008/09/19/dynamic-programming-in-as3/comment-page-1/#comment-149895</link>
		<dc:creator>Steven Sacks</dc:creator>
		<pubDate>Fri, 19 Sep 2008 18:38:51 +0000</pubDate>
		<guid isPermaLink="false">http://nodename.com/blog/?p=62#comment-149895</guid>
		<description>Your example can easily be achieved by using the the Strategy pattern.  This has the benefit of keeping your code clean, readable, strict-typed, fast and following good coding practices.</description>
		<content:encoded><![CDATA[<p>Your example can easily be achieved by using the the Strategy pattern.  This has the benefit of keeping your code clean, readable, strict-typed, fast and following good coding practices.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nodename &#187; Advanced Users May Choose</title>
		<link>http://nodename.com/blog/2008/09/19/dynamic-programming-in-as3/comment-page-1/#comment-149818</link>
		<dc:creator>nodename &#187; Advanced Users May Choose</dc:creator>
		<pubDate>Fri, 19 Sep 2008 04:38:13 +0000</pubDate>
		<guid isPermaLink="false">http://nodename.com/blog/?p=62#comment-149818</guid>
		<description>[...] I&#8217;ve looked into this and I have some answers to my own question: Dynamic Programming in AS3   &#124; [...]</description>
		<content:encoded><![CDATA[<p>[...] I&#8217;ve looked into this and I have some answers to my own question: Dynamic Programming in AS3   | [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
