<?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>Geek.blog &#187; actionscript</title>
	<atom:link href="http://blog.728media.com/tag/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.728media.com</link>
	<description>Advanced Flash and Actionscript 3 by Andrew Christensen</description>
	<lastBuildDate>Fri, 24 Dec 2010 00:14:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to Load External Images in Actionscript 3.0</title>
		<link>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/</link>
		<comments>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 03:37:12 +0000</pubDate>
		<dc:creator>Andrew Christensen</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[actionscript 3.0]]></category>
		<category><![CDATA[external images]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://blog.728media.com/?p=222</guid>
		<description><![CDATA[Using the flash.display.Loader class in AS3, you can load in external image files to display in flash. The loader class supports loading in JPG, SWF, PNG, or GIF file types. The Loader class sounds more like a loading manager that watches load progress, rather than a display object. Fact is, the Loader is treated as [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-225" title="loadingimage" src="http://blog.728media.com/wp-content/uploads/2009/03/loadingimage.jpg" alt="loadingimage" width="650" height="280" /></p>
<p>Using the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html">flash.display.Loader</a> class in AS3, you can load in external image files to display in flash. The loader class supports loading in JPG, SWF, PNG, or GIF file types. The Loader class sounds more like a loading manager that watches load progress, rather than a display object. Fact is, the Loader is treated as a <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html">DisplayObject</a>, so when it&#8217;s ready you just add it to the stage. Pretty simple, so let&#8217;s get started!</p>
<p><span id="more-222"></span></p>
<p>First, you will need to create an instance of the loader class and add a couple event listeners to it. One to watch load progress, and one to watch for when the loading is complete.</p>
<div class="codecolorer-container actionscript3 vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> myLoader<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=loader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:loader.html"><span style="color: #004993;">Loader</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=loader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:loader.html"><span style="color: #004993;">Loader</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
myLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=progressevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:progressevent.html"><span style="color: #004993;">ProgressEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PROGRESS</span><span style="color: #000066; font-weight: bold;">,</span> onLoaderProgress<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
myLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> onLoaderComplete<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>You&#8217;ll notice that I&#8217;m not adding the event listener to the loader instance (myLoader), but instead adding them to a property of myLoader called <strong><a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html#contentLoaderInfo">contentLoaderInfo</a>. </strong>The Loader class has a special property that controls all the loading events. This property is an instance of the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html">LoaderInfo</a> class, so we will listen to it for events, rather than our Loader instance.</p>
<p>Next, we will call the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html#load()">Loader.load()</a> method to initiate the loading sequence. You will need to create a new variable that will be an instance of the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLRequest.html">URLRequest</a> class. This new variable will be passed to the load() method.</p>
<div class="codecolorer-container actionscript3 vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> myLoader<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=loader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:loader.html"><span style="color: #004993;">Loader</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=loader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:loader.html"><span style="color: #004993;">Loader</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
myLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=progressevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:progressevent.html"><span style="color: #004993;">ProgressEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PROGRESS</span><span style="color: #000066; font-weight: bold;">,</span> onProgressStatus<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
myLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> onLoaderReady<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> fileRequest<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;myImage.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
myLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>fileRequest<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>Ok, so that&#8217;s pretty much it. All that is left is to create our callback methods for each of our eventListeners. Our final code should look like this:</p>
<div class="codecolorer-container actionscript3 vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> myLoader<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=loader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:loader.html"><span style="color: #004993;">Loader</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=loader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:loader.html"><span style="color: #004993;">Loader</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
myLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=progressevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:progressevent.html"><span style="color: #004993;">ProgressEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PROGRESS</span><span style="color: #000066; font-weight: bold;">,</span> onProgressStatus<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
myLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contentLoaderInfo</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> onLoaderReady<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> fileRequest<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;myImage.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
myLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>fileRequest<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> onProgressStatus<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=progressevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:progressevent.html"><span style="color: #004993;">ProgressEvent</span></a><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>   <br />
  &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// this is where progress will be monitored     </span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesLoaded</span><span style="color: #000066; font-weight: bold;">,</span> e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesTotal</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> onLoaderReady<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>     <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// the image is now loaded, so let's add it to the display tree!     </span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>myLoader<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.728media.com/2009/03/11/how-to-load-external-images-in-actionscript-30/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Connecting to a Flash Media Server using RTMP</title>
		<link>http://blog.728media.com/2008/08/03/connecting-to-a-flash-media-server-using-rtmp/</link>
		<comments>http://blog.728media.com/2008/08/03/connecting-to-a-flash-media-server-using-rtmp/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 04:06:49 +0000</pubDate>
		<dc:creator>Andrew Christensen</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flash media server]]></category>
		<category><![CDATA[flash video]]></category>
		<category><![CDATA[flash video streaming]]></category>
		<category><![CDATA[NetConnection]]></category>
		<category><![CDATA[NetStream]]></category>
		<category><![CDATA[rtmp]]></category>
		<category><![CDATA[stream]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://blog.728media.com/?p=70</guid>
		<description><![CDATA[RTMP is the protocol used by Adobe&#8217;s Flash Media Server to stream content into flash. Most of the help documentation doesn&#8217;t touch much on this method of connection and is limited to sources not easily available to users. This article should be used by those with an understanding of video playback using actionscript 3. If that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.728media.com/wp-content/uploads/2008/08/fms.bmp"><img class="alignnone size-full wp-image-76" title="fms" src="http://blog.728media.com/wp-content/uploads/2008/08/fms.bmp" alt="" /></a></p>
<p><a href="http://en.wikipedia.org/wiki/Real_Time_Messaging_Protocol">RTMP</a> is the protocol used by <a href="http://www.adobe.com/products/flashmediaserver/">Adobe&#8217;s Flash Media Server</a> to stream content into flash. Most of the help documentation doesn&#8217;t touch much on this method of connection and is limited to sources not easily available to users.<br />
<span id="more-70"></span></p>
<p><strong>This article should be used by those with an understanding of video playback using actionscript 3. If that isn&#8217;t you, please read </strong><a href="http://theflashblog.com/?p=233"><strong>this article</strong></a><strong> before continuing.</strong></p>
<p><strong>1.)</strong> In order to use the RTMP protocol, you will need to install and run a version of Adobe Flash Media Server. Adobe has released a free <a href="http://www.adobe.com/go/tryflashmediaserver">developer version</a> the limits you to 10 connections. That will be MORE than enough to do some basic development. Please make sure you are running or have access to a Flash Media Server before continuing to the next step.</p>
<p style="padding-left: 30px;"><strong>1.) (B)</strong> If you are having trouble installing or setting up an app, please read <a href="http://www.adobe.com/devnet/flashmediaserver/articles/beginner_live_fms3.html">this article.</a></p>
<p><strong>2.)</strong> Now that you have access to a Flash Media Server, we will start with some basic code that should look familiar if you have worked with actionscript and video before. For this step, you will need to know the URI for the server. If you installed Flash Media server on the machine you are running on, you can use &#8220;localhost&#8221; for the URI. We will be using the &#8220;vod&#8221; app that comes pre-installed on the server for this example.</p>
<pre lang="ACTIONSCRIPT">var nc:NetConnection = new NetConnection();
nc.connect("rtmp://YOUR_SERVER_URI/vod/");</pre>
<p>If we were loading an flv file without streaming, you would have passed null to the connect() method instead.</p>
<p><strong>3.)</strong> The only thing left is to load the stream, instead of loading an FLV video from a URL. This is actually much easier than you think. Instead of passing a URLRequest to the NetStream.play() method, you would instead pass the name of the stream you wish to play from within your app (this is the name of the FLV file on the server, but without the .FLV extension). To playback an HD streaming file, you will need to format your stream name slightly different: &#8220;mp4:NAME_OF_STREAM.mp4&#8243;</p>
<ul>
<li><strong>Please note that you can not setup your NetStream until after the NetConnection has successfully connected. You will know this from the NetStatus event: NetConnection.Connect.Success that is dispatched.</strong></li>
</ul>
<pre lang="ACTIONSCRIPT">var ns:NetStream = new NetStream(nc);
ns.play("NAME_OF_STREAM");
// ns.play("mp4:NAME_OF_STREAM.mp4");  // this will stream an HD movie instead.</pre>
<p><strong>4.)</strong> That&#8217;s it! I hope this article has helped. Please comment below with any questions and I would be glad to help answer them.</p>
<p>For a more informative tutorial, check out <a href="http://www.peachpit.com/articles/article.aspx?p=665127&amp;seqNum=7">this one</a> from <a href="http://www.peachpit.com">Peachpit</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.728media.com/2008/08/03/connecting-to-a-flash-media-server-using-rtmp/feed/</wfw:commentRss>
		<slash:comments>68</slash:comments>
		</item>
		<item>
		<title>What the hell is Modulus?!</title>
		<link>http://blog.728media.com/2008/05/24/what-the-hell-is-modulus/</link>
		<comments>http://blog.728media.com/2008/05/24/what-the-hell-is-modulus/#comments</comments>
		<pubDate>Sat, 24 May 2008 13:20:37 +0000</pubDate>
		<dc:creator>Andrew Christensen</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[core]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[grant skinner]]></category>

		<guid isPermaLink="false">http://blog.728media.com/?p=42</guid>
		<description><![CDATA[Grant Skinner has started a great series of posts related to core functionality. Each post will discuss methods that are less than 5 lines of code. These &#8220;Core AS3&#8243; snippets can be HUGE time savers when used properly. Grant does a great job at fully explaining what you need to do, and why you would [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.mississauga4sale.com/blog/uploaded_images/percent-761534.gif" alt="" width="250" height="237" /></p>
<p><a href="http://www.gskinner.com/blog/">Grant Skinner</a> has started a great series of posts related to core functionality. Each post will discuss methods that are less than 5 lines of code. These &#8220;Core AS3&#8243; snippets can be HUGE time savers when used properly. Grant does a great job at fully explaining what you need to do, and why you would want to do it.</p>
<p>This week: <a href="http://www.gskinner.com/blog/archives/2008/05/core_as3_modulu.html">Modulus (%)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.728media.com/2008/05/24/what-the-hell-is-modulus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

