<?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: AS3 Simple Button: breaking all rules</title>
	<atom:link href="http://xtyler.com/code/254/feed" rel="self" type="application/rss+xml" />
	<link>http://xtyler.com/code/254</link>
	<description>a developer&#039;s blog.</description>
	<lastBuildDate>Tue, 19 Apr 2011 14:30:37 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Jesse Freeman</title>
		<link>http://xtyler.com/code/254/comment-page-1#comment-12149</link>
		<dc:creator>Jesse Freeman</dc:creator>
		<pubDate>Tue, 22 Feb 2011 15:04:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.xtyler.com/?p=254#comment-12149</guid>
		<description>You will probably appreciate this then http://vimeo.com/20225162. I was doing a little testing with SimpleButton on AIR for Android and it takes down my FPS whenever you click on the stage, doesn&#039;t even have to be on the actual instance itself. Go Team Flash!</description>
		<content:encoded><![CDATA[<p>You will probably appreciate this then <a href="http://vimeo.com/20225162" rel="nofollow">http://vimeo.com/20225162</a>. I was doing a little testing with SimpleButton on AIR for Android and it takes down my FPS whenever you click on the stage, doesn&#8217;t even have to be on the actual instance itself. Go Team Flash!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aidan Fraser</title>
		<link>http://xtyler.com/code/254/comment-page-1#comment-11964</link>
		<dc:creator>Aidan Fraser</dc:creator>
		<pubDate>Tue, 23 Mar 2010 21:41:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.xtyler.com/?p=254#comment-11964</guid>
		<description>Tyler, that _is_ crazy. You just blew my mind.

So, in the upState, for example, the following code...

`this.parent as DisplayObjectContainer`

would evaulate to null? WTF, how is that possible?


Joe: interesting and informative as your comment is, it doesn&#039;t really address Tyler&#039;s point that a SimpleButton contains DisplayObjects, but also can&#039;t possibly, because of it not being a DisplayObjectContainer. MovieClip is a DisplayObjectContainer, but SimpleButton is _not_ a MovieClip. Not these days anyway.</description>
		<content:encoded><![CDATA[<p>Tyler, that _is_ crazy. You just blew my mind.</p>
<p>So, in the upState, for example, the following code&#8230;</p>
<p>`this.parent as DisplayObjectContainer`</p>
<p>would evaulate to null? WTF, how is that possible?</p>
<p>Joe: interesting and informative as your comment is, it doesn&#8217;t really address Tyler&#8217;s point that a SimpleButton contains DisplayObjects, but also can&#8217;t possibly, because of it not being a DisplayObjectContainer. MovieClip is a DisplayObjectContainer, but SimpleButton is _not_ a MovieClip. Not these days anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joeflash</title>
		<link>http://xtyler.com/code/254/comment-page-1#comment-11820</link>
		<dc:creator>Joeflash</dc:creator>
		<pubDate>Sat, 13 Jun 2009 20:15:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.xtyler.com/?p=254#comment-11820</guid>
		<description>The reason you&#039;re getting a little funkiness is that the SimpleButton is really an AS3 implementation of the Button class from AS1/AS2. Child objects in SimpleButton are created in Flash Authoring, and are not meant to be dynamically instantiated or manipulated, which is the most likely reason that SimpleButton does not extend DisplayObjectContainer. A SimpleButton is actually a four-frame &quot;MovieClip&quot; object with a fixed number of frames. It&#039;s one of the few quirky holdovers from the quirky legacy programming days of AS2.

In AS2, the Button class was really treated as a MovieClip by the Flash Player (AVM1), even though there was no MovieClip API support. You could simulate a custom Button with very little effort by creating a MovieClip and designating three frames by their &quot;magic frame labels&quot;: &quot;_up&quot;, &quot;_over&quot;, &quot;_down&quot; and the hit state by setting &quot;this._hitArea = this.hit_mc;&quot; on the first frame of the clip. Create a button event for the MovieClip, and it would magically act just like a Button.

This functionality was carried over into AS3, (see the &lt;a HREF=&quot;http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Sprite.html#buttonMode&quot; rel=&quot;nofollow&quot;&gt;MovieClip.ButtonMode  property&lt;/A&gt;), which makes me think that SimpleButton is treated like a specialized MovieClip by the Flash Player, without access to the MovieClip API.

Try this:
1. Create an MC with three frames, labelled &quot;_up&quot;, &quot;_over&quot;, &quot;_down&quot;.
2. Create another layer with a stop() action across all three frames.
3. Add this code to the main timeline:
btn_mc.buttonMode = true;
btn_mc.addEventListener(MouseEvent.MOUSE_DOWN, onBtnPress);
function onBtnPress(evt:MouseEvent):void { trace(&quot;Button Pressed!&quot;); }

And you have effectively demonstrated that a SimpleButton is in fact a MovieClip, but without access to the MovieClip API. Without access to that API, SimpleButton effectively extends InteractiveObject, which is why you get the funky results on child objects.</description>
		<content:encoded><![CDATA[<p>The reason you&#8217;re getting a little funkiness is that the SimpleButton is really an AS3 implementation of the Button class from AS1/AS2. Child objects in SimpleButton are created in Flash Authoring, and are not meant to be dynamically instantiated or manipulated, which is the most likely reason that SimpleButton does not extend DisplayObjectContainer. A SimpleButton is actually a four-frame &#8220;MovieClip&#8221; object with a fixed number of frames. It&#8217;s one of the few quirky holdovers from the quirky legacy programming days of AS2.</p>
<p>In AS2, the Button class was really treated as a MovieClip by the Flash Player (AVM1), even though there was no MovieClip API support. You could simulate a custom Button with very little effort by creating a MovieClip and designating three frames by their &#8220;magic frame labels&#8221;: &#8220;_up&#8221;, &#8220;_over&#8221;, &#8220;_down&#8221; and the hit state by setting &#8220;this._hitArea = this.hit_mc;&#8221; on the first frame of the clip. Create a button event for the MovieClip, and it would magically act just like a Button.</p>
<p>This functionality was carried over into AS3, (see the <a HREF="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Sprite.html#buttonMode" rel="nofollow">MovieClip.ButtonMode  property</a>), which makes me think that SimpleButton is treated like a specialized MovieClip by the Flash Player, without access to the MovieClip API.</p>
<p>Try this:<br />
1. Create an MC with three frames, labelled &#8220;_up&#8221;, &#8220;_over&#8221;, &#8220;_down&#8221;.<br />
2. Create another layer with a stop() action across all three frames.<br />
3. Add this code to the main timeline:<br />
btn_mc.buttonMode = true;<br />
btn_mc.addEventListener(MouseEvent.MOUSE_DOWN, onBtnPress);<br />
function onBtnPress(evt:MouseEvent):void { trace(&#8220;Button Pressed!&#8221;); }</p>
<p>And you have effectively demonstrated that a SimpleButton is in fact a MovieClip, but without access to the MovieClip API. Without access to that API, SimpleButton effectively extends InteractiveObject, which is why you get the funky results on child objects.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

