<?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>homer gaines &#187; ActionScript 3.0</title>
	<atom:link href="http://www.homergaines.com/blog/category/flash/actionscript-30/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.homergaines.com/blog</link>
	<description>Freelance Web Designer &#38; Flash Developer</description>
	<lastBuildDate>Fri, 04 Jun 2010 16:39:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Passing Variables to A Function in ActionScript 3</title>
		<link>http://www.homergaines.com/blog/2008/11/passing-varibles-to-a-function-in-as3/</link>
		<comments>http://www.homergaines.com/blog/2008/11/passing-varibles-to-a-function-in-as3/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 21:36:53 +0000</pubDate>
		<dc:creator>homer</dc:creator>
				<category><![CDATA[ActionScript 2.0]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[addEventListener]]></category>
		<category><![CDATA[as2]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[homergaines]]></category>
		<category><![CDATA[variable]]></category>
		<category><![CDATA[xirclebox]]></category>

		<guid isPermaLink="false">http://www.homergaines.com/blog/?p=320</guid>
		<description><![CDATA[I have asked and have been asked, &#8220;How do I pass a variable to a function when using the addEventListener to call a function in ActionScript 3?&#8221; Passing a variable to a function in ActionScript 2 was a fairly simple task. However, it is not so easy using ActionScript 3. There are a few more [...]]]></description>
			<content:encoded><![CDATA[<p>I have asked and have been asked, &#8220;How do I pass a variable to a function when using the addEventListener to call a function in ActionScript 3?&#8221;</p>
<p>Passing a variable to a function in ActionScript 2 was a fairly simple task. However, it is not so easy using ActionScript 3. There are a few more things you must do first.</p>
<p>In ActionScript 2, passing a string variable looked like this.</p>
<blockquote><p><code>my_btn.onRelease = function(){<br />
doThis("whatever variable you want goes here");<br />
}</code></p>
<p><code>function doThis(a:String){<br />
trace(a);<br />
}</code></p></blockquote>
<p>In ActionScript 3, this is what I need to do to get the same results.  I initially wrote the example below thinking at some point, I will have several buttons that the user will interact with such as a navigation menu.</p>
<blockquote><p><code>var b:Array = [b1_btn, b2_btn, b3_btn];<br />
var a:Array = ["zero","one","two"];</code></p>
<p><code>for (var i:int = 0; i&lt;b.length; i++) {</code><br />
<code><br />
b[i].addEventListener(MouseEvent.CLICK, clickedOne);<br />
function clickedOne(e:MouseEvent):void {<br />
for (var j:int = 0; j&lt;a.length; j++) {<br />
if (e.currentTarget.name == b[j].name) {<br />
doThis(a[j])<br />
}<br />
}<br />
}<br />
}</code></p>
<p><code>function doThis(v:String):void {<br />
trace(v);<br />
}</code></p></blockquote>
<p><a href="http://www.homergaines.com/blog/wp-content/uploads/2008/11/hg_passingvars.zip">Get the source fla file here.</a></p>
<p>If you have any questions just drop me a line.</p>
<p>UPDATE!!!</p>
<p><strong>There&#8217;s more than one way to solve this problem.</strong></p>
<p>Thanks to <a href="mailto:kidneycreation@hotmail.com">kcreation</a> for this solution.</p>
<blockquote><p>var btns:Array = [b1_btn, b2_btn, b3_btn];<br />
var a:Array = ["zero","one","two"];</p>
<p>for (var b in btns) {<br />
btns[b].name = b;<br />
btns[b].addEventListener(MouseEvent.CLICK, clickedOne);<br />
}</p>
<p>function clickedOne(e:MouseEvent):void {<br />
var b:int = int(event.currentTarget.name);<br />
doThis(a[b]);<br />
}</p>
<p>function doThis(v:String):void {<br />
trace(v);<br />
}</p></blockquote>
<p>Thanks to <a href="http://www.as3errors.com/" target="_blank"><span>Mykola Bilokonsky</span></a> for this solution.</p>
<blockquote><p>var buttons:Array = [b1_btn, b2_btn, b3_btn];</p>
<p>var dict:Dictionary = new Dictionary();<br />
dict[b1_btn] = &#8220;String Argument&#8221;;<br />
dict[b2_btn] = new MySampleMovieClip();<br />
dict[b3_btn] = 7</p>
<p>for each (var b:MovieClip in buttons) {<br />
b.buttonMode = true;<br />
b.addEventListener(MouseEvent.CLICK, myHandler);<br />
}</p>
<p>function myHandler(e:MouseEvent):void {<br />
var myVariable = dict[e.currentTarget];<br />
}</p></blockquote>
<div id='retweet_button' style='float:left;margin-left: 10px;'><a class="addthis_button" addthis:url="http://www.homergaines.com/blog/2008/11/passing-varibles-to-a-function-in-as3/" href="http://www.addthis.com/bookmark.php?v=250&amp;pub=xa-4a9a4e0e5333be83"><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0;margin-bottom: 4px; margin-right: 8px;"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a9a4e0e5333be83"></script><script type="text/javascript">url='http://www.homergaines.com/blog/2008/11/passing-varibles-to-a-function-in-as3/';size='small';</script><script type="text/javascript" src="http://www.retweet.com/static/retweets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.homergaines.com/blog/2008/11/passing-varibles-to-a-function-in-as3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Tween Import : AS2 and AS3</title>
		<link>http://www.homergaines.com/blog/2008/09/tween-import/</link>
		<comments>http://www.homergaines.com/blog/2008/09/tween-import/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 20:15:41 +0000</pubDate>
		<dc:creator>homer</dc:creator>
				<category><![CDATA[ActionScript 2.0]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[homergaines]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[tween]]></category>
		<category><![CDATA[xirclebox]]></category>

		<guid isPermaLink="false">http://www.homergaines.com/blog/?p=223</guid>
		<description><![CDATA[I like to use code to handle basic animations like fades and sliding assets in. When you want to use the Tween class to add scripted motion to your projects, you&#8217;ll need to import these first. Actionscript 2 import mx.transitions.Tween; import mx.transitions.easing.*; Actionscript 3 import fl.transitions.Tween; import fl.transitions.easing.*; For tween methods click here. url='http://www.homergaines.com/blog/2008/09/tween-import/';size='small';]]></description>
			<content:encoded><![CDATA[<p>I like to use code to handle basic animations like fades and sliding assets in.  When you want to use the Tween class to add scripted motion to your projects, you&#8217;ll need to import these first.</p>
<h2><strong>Actionscript 2</strong></h2>
<blockquote><p><code>import mx.transitions.Tween;<br />
import mx.transitions.easing.*;</code></p></blockquote>
<h2><strong>Actionscript 3</strong></h2>
<blockquote><p><code>import fl.transitions.Tween;<br />
import fl.transitions.easing.*;</code></p></blockquote>
<p>For tween methods <a title="Tween Methods" href="http://www.homergaines.com/blog/2008/10/tweenonmotion-methods/">click here</a>.</p>
<div id='retweet_button' style='float:left;margin-left: 10px;'><a class="addthis_button" addthis:url="http://www.homergaines.com/blog/2008/09/tween-import/" href="http://www.addthis.com/bookmark.php?v=250&amp;pub=xa-4a9a4e0e5333be83"><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0;margin-bottom: 4px; margin-right: 8px;"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a9a4e0e5333be83"></script><script type="text/javascript">url='http://www.homergaines.com/blog/2008/09/tween-import/';size='small';</script><script type="text/javascript" src="http://www.retweet.com/static/retweets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.homergaines.com/blog/2008/09/tween-import/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparison: Importing an image using ActionScript 2 and 3</title>
		<link>http://www.homergaines.com/blog/2008/07/comparison-importing-an-image-using-actionscript-2-and-3/</link>
		<comments>http://www.homergaines.com/blog/2008/07/comparison-importing-an-image-using-actionscript-2-and-3/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 19:26:49 +0000</pubDate>
		<dc:creator>homer</dc:creator>
				<category><![CDATA[ActionScript 2.0]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Project Management]]></category>
		<category><![CDATA[actioscript]]></category>
		<category><![CDATA[as2]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[homergaines]]></category>
		<category><![CDATA[xirclebox]]></category>

		<guid isPermaLink="false">http://www.homergaines.com/blog/?p=134</guid>
		<description><![CDATA[If you are going to develop flash based content using AS3, you should know it takes a bit more work to do simple things.  For example, say for inistance you want to load an image into a movie clip called "imgHold_mc" using ActionScript 2,  you could use the following code:
]]></description>
			<content:encoded><![CDATA[<p>If you are going to develop flash based content using AS3, you should know it takes a bit more work to do simple things.  For example, say for inistance you want to load an image into a movie clip called &#8220;imgHold_mc&#8221; using ActionScript 2,  you could use the following code:</p>
<blockquote><p><code>function loadImage() {<br />
imgHold_mc.loadMovie(imgUrl);<br />
}<br />
loadImage();</code></p>
<p>-or-</p>
<p><code>var url:String = "imgUrl";<br />
function loadImage(link:String){<br />
imgHold.loadMovie(link);<br />
}<br />
loadImage(url);</code></p></blockquote>
<p>If you wanted to do the same thing but using ActionScript 3, you would need to use the code bellow:</p>
<blockquote><p><code>var imageLoader:Loader;<br />
function loadImage(url:String):void {<br />
imageLoader = new Loader();<br />
imageLoader.load(new URLRequest(url));<br />
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);<br />
}<br />
loadImage(imgUrl);<br />
function imageLoaded(e:Event):void {<br />
imgHold_mc.addChild(imageLoader);<br />
}</code></p>
<p>-or-</p>
<p><code>var imageLoader:Loader = new Loader();<br />
imageLoader.load(new URLRequest(url));<br />
imgHold_mc.addChild(imageLoader);</code></p>
<p>thanks Luis :)</p></blockquote>
<div id='retweet_button' style='float:left;margin-left: 10px;'><a class="addthis_button" addthis:url="http://www.homergaines.com/blog/2008/07/comparison-importing-an-image-using-actionscript-2-and-3/" href="http://www.addthis.com/bookmark.php?v=250&amp;pub=xa-4a9a4e0e5333be83"><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0;margin-bottom: 4px; margin-right: 8px;"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a9a4e0e5333be83"></script><script type="text/javascript">url='http://www.homergaines.com/blog/2008/07/comparison-importing-an-image-using-actionscript-2-and-3/';size='small';</script><script type="text/javascript" src="http://www.retweet.com/static/retweets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.homergaines.com/blog/2008/07/comparison-importing-an-image-using-actionscript-2-and-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript 3 Can Be A Pain</title>
		<link>http://www.homergaines.com/blog/2008/07/actionscript-3-can-be-a-pain/</link>
		<comments>http://www.homergaines.com/blog/2008/07/actionscript-3-can-be-a-pain/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 05:29:08 +0000</pubDate>
		<dc:creator>homer</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Articles of Intrest]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[homergaines]]></category>
		<category><![CDATA[xirclebox]]></category>

		<guid isPermaLink="false">http://www.homergaines.com/blog/?p=133</guid>
		<description><![CDATA[From the first time I picked up a book on ActionScript 3 I have had some level of anxiety.  It&#8217;s that usual song and dance when dealing with a new version of Flash. With a new release come the task of learning the new and improved way of writing ActionScript.  Now grantted, the evolution of [...]]]></description>
			<content:encoded><![CDATA[<p>From the first time I picked up a book on ActionScript 3 I have had some level of anxiety.  It&#8217;s that usual song and dance when dealing with a new version of Flash. With a new release come the task of learning the new and improved way of writing ActionScript.  Now grantted, the evolution of ActioScript has been a good thing thus far but AS3 is a bit on the rough side.  Code was easier to write in AS2. I could write simple functions using less code unlike in AS3.  However AS3 is not all bad. The improved handling of XML data is great. By far, much better than before and that&#8217;s one of the main reasons I use AS3.</p>
<p>Anyway the purpose of this post is to point out an article I came across today the Colin Mook had written about issues with AS3 and what Adobe should do to fix them.  It&#8217;s a good read and realy hits the nail on the head.</p>
<p><a title="The Charges Against ActionScript 3.0" href="http://www.insideria.com/2008/07/the-charges-against-actionscri.html" target="_self">The Charges Against ActionScript 3.0</a></p>
<div id='retweet_button' style='float:left;margin-left: 10px;'><a class="addthis_button" addthis:url="http://www.homergaines.com/blog/2008/07/actionscript-3-can-be-a-pain/" href="http://www.addthis.com/bookmark.php?v=250&amp;pub=xa-4a9a4e0e5333be83"><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0;margin-bottom: 4px; margin-right: 8px;"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a9a4e0e5333be83"></script><script type="text/javascript">url='http://www.homergaines.com/blog/2008/07/actionscript-3-can-be-a-pain/';size='small';</script><script type="text/javascript" src="http://www.retweet.com/static/retweets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.homergaines.com/blog/2008/07/actionscript-3-can-be-a-pain/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Antropod: Flash and AIR debugger</title>
		<link>http://www.homergaines.com/blog/2008/06/antropod-flash-and-air-debugger/</link>
		<comments>http://www.homergaines.com/blog/2008/06/antropod-flash-and-air-debugger/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 13:51:36 +0000</pubDate>
		<dc:creator>homer</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[appliction]]></category>
		<category><![CDATA[debugger]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://www.homergaines.com/blog/2008/06/antropod-flash-and-air-debugger/</guid>
		<description><![CDATA[Here a cool tool for those of you who would like to be able to color code your log messages while debugging your Flash and or Adobe AIR applications. Oh and it&#8217;s free! Get it here url='http://www.homergaines.com/blog/2008/06/antropod-flash-and-air-debugger/';size='small';]]></description>
			<content:encoded><![CDATA[<p>Here a cool tool for those of you who would like to be able to color code your log messages while debugging your Flash and or Adobe AIR applications.  Oh and it&#8217;s free!</p>
<p><a target="_blank" href="http://arthropod.stopp.se/">Get it here</a></p>
<div id='retweet_button' style='float:left;margin-left: 10px;'><a class="addthis_button" addthis:url="http://www.homergaines.com/blog/2008/06/antropod-flash-and-air-debugger/" href="http://www.addthis.com/bookmark.php?v=250&amp;pub=xa-4a9a4e0e5333be83"><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0;margin-bottom: 4px; margin-right: 8px;"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a9a4e0e5333be83"></script><script type="text/javascript">url='http://www.homergaines.com/blog/2008/06/antropod-flash-and-air-debugger/';size='small';</script><script type="text/javascript" src="http://www.retweet.com/static/retweets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.homergaines.com/blog/2008/06/antropod-flash-and-air-debugger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Project : Custom Music Player Using Adobe Air</title>
		<link>http://www.homergaines.com/blog/2008/05/new-project-custom-music-player-using-adobe-air-2/</link>
		<comments>http://www.homergaines.com/blog/2008/05/new-project-custom-music-player-using-adobe-air-2/#comments</comments>
		<pubDate>Thu, 15 May 2008 20:16:12 +0000</pubDate>
		<dc:creator>homer</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Lab]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[project]]></category>

		<guid isPermaLink="false">http://www.homergaines.com/blog/2008/05/new-project-custom-music-player-using-adobe-air-2/</guid>
		<description><![CDATA[Today I was asked to build a custom player for visitors to the brands website. Seeing as how the site is a dynamic site that requires the page refresh in order to see new content, I have suggested using Adobe Air as the method of delivery for the player. That way visitors can download it [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was asked to build a custom player for visitors to the brands website.  Seeing as how the site is a dynamic site that requires the page refresh in order to see new content, I have suggested using <a target="_blank" href="http://www.adobe.com/products/air/">Adobe Air</a> as the method of delivery for the player. That way visitors can download it and play the music independent of the site.  Basic planning and deciding what business rules should apply started today.</p>
<div id='retweet_button' style='float:left;margin-left: 10px;'><a class="addthis_button" addthis:url="http://www.homergaines.com/blog/2008/05/new-project-custom-music-player-using-adobe-air-2/" href="http://www.addthis.com/bookmark.php?v=250&amp;pub=xa-4a9a4e0e5333be83"><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0;margin-bottom: 4px; margin-right: 8px;"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a9a4e0e5333be83"></script><script type="text/javascript">url='http://www.homergaines.com/blog/2008/05/new-project-custom-music-player-using-adobe-air-2/';size='small';</script><script type="text/javascript" src="http://www.retweet.com/static/retweets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.homergaines.com/blog/2008/05/new-project-custom-music-player-using-adobe-air-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
