<?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>Meet Andrew Nguyen &#187; cookbook</title>
	<atom:link href="http://meetandrew.com/tag/cookbook/feed/" rel="self" type="application/rss+xml" />
	<link>http://meetandrew.com</link>
	<description>Flex/Flash Developer, Photographer, User Experience Expert</description>
	<lastBuildDate>Mon, 17 May 2010 20:35:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>AS2 to AS3 Buttons</title>
		<link>http://meetandrew.com/2009/02/as2-to-as3-buttons/</link>
		<comments>http://meetandrew.com/2009/02/as2-to-as3-buttons/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 08:39:24 +0000</pubDate>
		<dc:creator>Andrew Nguyen</dc:creator>
				<category><![CDATA[AS2 to AS3 Migration]]></category>
		<category><![CDATA[actionscript2]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[cookbook]]></category>
		<category><![CDATA[migration]]></category>

		<guid isPermaLink="false">http://meetandrew.com/?p=34</guid>
		<description><![CDATA[In ActionScript 3, Adobe got rid of attatching code directly to the MovieClip or Button you were working with on the the timeline. So no more of this: [cc lang="actionscript"] on(press) { //do something } [/cc] For code on the timeline that affects a button (whose instance name we&#8217;ll call &#8220;button&#8221;), we used to do [...]]]></description>
			<content:encoded><![CDATA[<p>In ActionScript 3, Adobe got rid of attatching code directly to the MovieClip or Button you were working with on the the timeline.<span id="more-34"></span></p>
<p>So no more of this:<br />
[cc lang="actionscript"]<br />
on(press)<br />
{<br />
//do something<br />
}<br />
[/cc]</p>
<p>For code on the timeline that affects a button (whose instance name we&#8217;ll call &#8220;button&#8221;), we used to do this in AS2:<br />
[cc lang="actionscript"]<br />
button.onPress = function()<br />
{<br />
//do someting;<br />
}<br />
[/cc]</p>
<p>Now in AS3, we have something a little more &#8220;wordy&#8221;:<br />
[cc lang="actionscript3"]<br />
button.addEventListener(MouseEvent.MOUSE_DOWN,handleClick);<br />
function handleClick(e:MouseEvent):void<br />
{<br />
//do someting;<br />
}<br />
[/cc]</p>
<p>One thing to understand about ActionScript 3 is that it is an event driven language.  You listen for events, events get dispatched, and you handle them appropripately.  I&#8217;ll break down the code for you.<br />
[cc lang="actionscript3" first_line="1"]<br />
button.addEventListener(MouseEvent.MOUSE_DOWN,handleClick);<br />
[/cc]<br />
What we&#8217;re saying on line 1 is here, we have a button that will listen for MouseEvent.MOUSE_DOWN events, and if that happens run the handleClick function.</p>
<p>[cc lang="actionscript3" first_line="2"]<br />
function handleClick(e:MouseEvent):void<br />
[/cc]<br />
Here, we&#8217;re just defining the function &#8220;handleClick.&#8221;  It accepts an argument of type MouseEvent and :void means it doesn&#8217;t return anything.</p>
<p>As you can see, AS3 for buttons isn&#8217;t too difficult, just a little wordier.  Below, I&#8217;ve listed the old way of handling buttons with their new event listeners.  Just swap out the MouseEvents for what you need when you add the event listener.</p>
<table border="0">
<tbody>
<tr>
<td>AS2</td>
<td>AS3</td>
</tr>
<tr>
<td>button.onPress</td>
<td>MouseEvent.MOUSE_DOWN</td>
</tr>
<tr>
<td>button.onRelease</td>
<td>MouseEvent.MOUSE_UP</td>
</tr>
<tr>
<td>button.onRollOver</td>
<td>MouseEvent.MOUSE_OVER</td>
</tr>
<tr>
<td>button.onRollOut</td>
<td>MouseEvent.MOUSE_OUT</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://meetandrew.com/2009/02/as2-to-as3-buttons/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>ActionScript 2 to ActionScript 3 Migration Cookbook</title>
		<link>http://meetandrew.com/2009/02/actionscript-2-to-actionscript-3-migration-cookbook/</link>
		<comments>http://meetandrew.com/2009/02/actionscript-2-to-actionscript-3-migration-cookbook/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 06:58:11 +0000</pubDate>
		<dc:creator>Andrew Nguyen</dc:creator>
				<category><![CDATA[AS2 to AS3 Migration]]></category>
		<category><![CDATA[actionscript2]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[cookbook]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://meetandrew.com/?p=31</guid>
		<description><![CDATA[I&#8217;m starting a new series of mini how-to&#8217;s to ease ActionScript 2 migration to ActionScript 3.  AS3, as we like to call it, is a much cleaner and more standardized language; not to mention a whole lot faster.  Adobe has really been urging everyone who works with Flash to switch to AS3. So if you&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m starting a new series of mini how-to&#8217;s to ease ActionScript 2 migration to ActionScript 3.  AS3, as we like to call it, is a much cleaner and more standardized language; not to mention a whole lot faster.  Adobe has really been urging everyone who works with Flash to switch to AS3.</p>
<p>So if you&#8217;ve been putting migration off, now is the time to learn.  These recipe style how-tos will be targeted to mostly Flash Designers and novice to intermediate developers who haven&#8217;t made the switch quite yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://meetandrew.com/2009/02/actionscript-2-to-actionscript-3-migration-cookbook/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
