<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Flash ActionScript(AS) Expert</title>
	<atom:link href="http://flashactionscriptexpert.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://flashactionscriptexpert.wordpress.com</link>
	<description>The Learning Flash Resource</description>
	<lastBuildDate>Tue, 02 Jun 2009 15:06:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='flashactionscriptexpert.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Flash ActionScript(AS) Expert</title>
		<link>http://flashactionscriptexpert.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://flashactionscriptexpert.wordpress.com/osd.xml" title="Flash ActionScript(AS) Expert" />
	<atom:link rel='hub' href='http://flashactionscriptexpert.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Loading an external SWF file</title>
		<link>http://flashactionscriptexpert.wordpress.com/2009/05/03/loading-an-external-swf-file/</link>
		<comments>http://flashactionscriptexpert.wordpress.com/2009/05/03/loading-an-external-swf-file/#comments</comments>
		<pubDate>Sun, 03 May 2009 15:49:31 +0000</pubDate>
		<dc:creator>sarapeter</dc:creator>
				<category><![CDATA[Flash ActionScript 3]]></category>
		<category><![CDATA[Flash MovieClip]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[External SWF]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[loading SWF]]></category>
		<category><![CDATA[SWF]]></category>

		<guid isPermaLink="false">http://flashactionscriptexpert.wordpress.com/?p=14</guid>
		<description><![CDATA[Loading an external SWF file In ActionScript 3.0, SWF files are loaded using the Loader class. To load an external SWF file, your ActionScript needs to do four things: Create a new URLRequest object with the url of the file. Create a new Loader object. Call the Loader object&#8217;s load() method, passing the URLRequest instance [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=14&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Loading an external SWF file</h3>
<p>In ActionScript 3.0, SWF files are loaded using the Loader class. To load an external SWF file, your ActionScript needs to do four things:</p>
<ol>
<li>Create a new URLRequest object with the url of the file.</li>
<li>Create a new Loader object.</li>
<li>Call the Loader object&#8217;s <code>l</code><code>oad()</code> method, passing the URLRequest instance as a parameter.</li>
<li>Call the <code>a</code><code>ddChild()</code> method on a display object container (such as the main timeline of a Flash document) to add the Loader instance to the display list.</li>
</ol>
<p>Ultimately, the code looks like this:</p>
<div class="listing">
<pre>var request:URLRequest = new URLRequest("http://www.[yourdomain].com/externalSwf.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);</pre>
</div>
<p>This same code can be used to load an external image file such as a JPEG, GIF, or PNG image, by specifying the image file&#8217;s url rather than a SWF file&#8217;s url. A SWF file, unlike an image file, may contain ActionScript. Thus, although the process of loading a SWF file may be identical to loading an image, when loading an external SWF file both the SWF file doing the loading and the SWF file being loaded must reside in the same security sandbox if you plan to use ActionScript to communicate in any way to the external SWF file. Additionally, if the external SWF file contains classes that share the same namespace as classes in the loading SWF file, you may need to create a new application domain for the loaded SWF file in order to avoid namespace conflicts. For more information on security and application domain considerations, see <a href="http://flashactionscriptexpert.wordpress.com/wp-admin/00000327.html#wp119371">Using the ApplicationDomain class</a> and <a href="http://flashactionscriptexpert.wordpress.com/wp-admin/00000353.html#wp141400">Loading SWF files and images</a>.</p>
<p>When the external SWF file is successfully loaded, it can be accessed through the <code>Loader.content</code> property. If the external SWF file is published for ActionScript 3.0, this will be either a movie clip or a sprite, depending on which class it extends.</p>
<h2><a name="wp154478"></a>Considerations for loading an older SWF file</h2>
<p>If the external SWF file has been published with an older version of ActionScript, there are important limitations to consider. Unlike an ActionScript 3.0 SWF file that runs in AVM2 (ActionScript Virtual Machine 2), a SWF file published for ActionScript 1.0 or 2.0 runs in AVM1 (ActionScript Virtual Machine 1).</p>
<p>When an AVM1 SWF file is successfully loaded, the loaded object (the <code>Loader.content </code>property) will be an AVM1Movie object. An AVM1Movie instance is not the same as a MovieClip instance. It is a display object, but unlike a movie clip, it does not include timeline-related methods or properties. The parent AVM2 SWF file will not have access to the properties, methods, or objects of the loaded AVM1Movie object.</p>
<p>There are additional restrictions on an AVM1 SWF file loaded by an AVM2 SWF file. For details, see the AVM1Movie class listing in the <em>A</em><em>ctionScript 3.0 Language and Components Reference</em>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flashactionscriptexpert.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flashactionscriptexpert.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flashactionscriptexpert.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flashactionscriptexpert.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/flashactionscriptexpert.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/flashactionscriptexpert.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/flashactionscriptexpert.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/flashactionscriptexpert.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flashactionscriptexpert.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flashactionscriptexpert.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flashactionscriptexpert.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flashactionscriptexpert.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flashactionscriptexpert.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flashactionscriptexpert.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=14&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://flashactionscriptexpert.wordpress.com/2009/05/03/loading-an-external-swf-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ada5375ba151ca886516ee0187b0cf8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sara Peter</media:title>
		</media:content>
	</item>
		<item>
		<title>Loading an External .swf in AS3</title>
		<link>http://flashactionscriptexpert.wordpress.com/2009/05/03/loading-an-external-swf-in-as3/</link>
		<comments>http://flashactionscriptexpert.wordpress.com/2009/05/03/loading-an-external-swf-in-as3/#comments</comments>
		<pubDate>Sun, 03 May 2009 15:45:05 +0000</pubDate>
		<dc:creator>sarapeter</dc:creator>
				<category><![CDATA[Flash ActionScript 3]]></category>
		<category><![CDATA[Flash MovieClip]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[External SWF]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[SWF]]></category>

		<guid isPermaLink="false">http://flashactionscriptexpert.wordpress.com/?p=12</guid>
		<description><![CDATA[Loading an External .swf in AS3 Here’s a simple example of loading a .swf in AS3. I had a typo before but now it’s fixed &#8211; sorry about that. Also, I updated it so you don’t have to strictly use it in an Class setting. Happy Coding… import flash.net.URLRequest; import flash.display.Loader; import flash.events.Event; import flash.events.ProgressEvent; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=12&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Loading an External .swf in AS3</h3>
<p>Here’s a simple example of loading a .swf in AS3. I had a typo before but now it’s fixed &#8211; sorry about that. Also, I updated it so you don’t have to strictly use it in an Class setting.</p>
<p>Happy Coding…</p>
<p><span class="kw3">import</span> flash.<span class="me1">net</span>.<span class="kw3">URLRequest</span>;<br />
<span class="kw3">import</span> flash.<span class="me1">display</span>.<span class="kw3">Loader</span>;<br />
<span class="kw3">import</span> flash.<span class="me1">events</span>.<span class="kw3">Event</span>;<br />
<span class="kw3">import</span> flash.<span class="me1">events</span>.<span class="kw3">ProgressEvent</span>;</p>
<p><span class="kw2">function</span> startLoad<span class="br0">(</span><span class="br0">)</span><br />
<span class="br0">{</span><br />
<span class="kw2">var</span> mLoader:<span class="kw3">Loader</span> = <span class="kw2">new</span> <span class="kw3">Loader</span><span class="br0">(</span><span class="br0">)</span>;<br />
<span class="kw2">var</span> mRequest:<span class="kw3">URLRequest</span> = <span class="kw2">new</span> <span class="kw3">URLRequest</span><span class="br0">(</span><span class="st0">“MouseActions.swf”</span><span class="br0">)</span>;<br />
mLoader.<span class="kw3">contentLoaderInfo</span>.<span class="kw3">addEventListener</span><span class="br0">(</span><span class="kw3">Event</span>.<span class="kw3">COMPLETE</span>, onCompleteHandler<span class="br0">)</span>;<br />
mLoader.<span class="kw3">contentLoaderInfo</span>.<span class="kw3">addEventListener</span><span class="br0">(</span><span class="kw3">ProgressEvent</span>.<span class="kw3">PROGRESS</span>, onProgressHandler<span class="br0">)</span>;<br />
mLoader.<span class="kw3">load</span><span class="br0">(</span>mRequest<span class="br0">)</span>;<br />
<span class="br0">}</span></p>
<p><span class="kw2">function</span> onCompleteHandler<span class="br0">(</span>loadEvent:<span class="kw3">Event</span><span class="br0">)</span><br />
<span class="br0">{</span><br />
        <span class="kw3">addChild</span><span class="br0">(</span>loadEvent.<span class="kw3">currentTarget</span>.<span class="kw3">content</span><span class="br0">)</span>;<br />
<span class="br0">}</span><br />
<span class="kw2">function</span> onProgressHandler<span class="br0">(</span>mProgress:<span class="kw3">ProgressEvent</span><span class="br0">)</span><br />
<span class="br0">{</span><br />
<span class="kw2">var</span> percent:<span class="kw3">Number</span> = mProgress.<span class="kw3">bytesLoaded</span>/mProgress.<span class="kw3">bytesTotal</span>;<br />
<span class="kw3">trace</span><span class="br0">(</span>percent<span class="br0">)</span>;<br />
<span class="br0">}</span><br />
startLoad<span class="br0">(</span><span class="br0">)</span>;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flashactionscriptexpert.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flashactionscriptexpert.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flashactionscriptexpert.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flashactionscriptexpert.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/flashactionscriptexpert.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/flashactionscriptexpert.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/flashactionscriptexpert.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/flashactionscriptexpert.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flashactionscriptexpert.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flashactionscriptexpert.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flashactionscriptexpert.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flashactionscriptexpert.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flashactionscriptexpert.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flashactionscriptexpert.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=12&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://flashactionscriptexpert.wordpress.com/2009/05/03/loading-an-external-swf-in-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ada5375ba151ca886516ee0187b0cf8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sara Peter</media:title>
		</media:content>
	</item>
		<item>
		<title>[AS 3] Loading External .mp3 File and Retrieving ID3 Information</title>
		<link>http://flashactionscriptexpert.wordpress.com/2009/05/01/as-3-loading-external-mp3-file-and-retrieving-id3-information/</link>
		<comments>http://flashactionscriptexpert.wordpress.com/2009/05/01/as-3-loading-external-mp3-file-and-retrieving-id3-information/#comments</comments>
		<pubDate>Fri, 01 May 2009 22:39:18 +0000</pubDate>
		<dc:creator>sarapeter</dc:creator>
				<category><![CDATA[Flash ActionScript 3]]></category>
		<category><![CDATA[Flash Sound]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[External]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Loading]]></category>
		<category><![CDATA[MP3]]></category>

		<guid isPermaLink="false">http://flashactionscriptexpert.wordpress.com/?p=10</guid>
		<description><![CDATA[[AS 3] Loading External .mp3 File and Retrieving ID3 Information I just discovered that Actionscript 3 has the ability to read the data that some .mp3 files have in them. To demonstrate I created a little movie below that will output all this data and dump it in a TextArea Component. In addition, I created [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=10&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>[AS 3] Loading External .mp3 File and Retrieving ID3 Information</h3>
<p>I just discovered that Actionscript 3 has the ability to read the data that some .mp3 files have in them. To demonstrate I created a little movie below that will output all this data and dump it in a TextArea Component. In addition, I created a little analyzer demo for the right and left channels.</p>
<p>First I needed a mask for the analyzer, so I used my Rectangle.as class.</p>
<div class="dp-highlighter">
<div class="bar">
<div class="tools"><a href="http://manewc.com/2008/02/07/as-3-loading-external-mp3-file-and-retrieving-id3-information/#">view plain</a><a href="http://manewc.com/2008/02/07/as-3-loading-external-mp3-file-and-retrieving-id3-information/#">copy to clipboard</a><a href="http://manewc.com/2008/02/07/as-3-loading-external-mp3-file-and-retrieving-id3-information/#">print</a><a href="http://manewc.com/2008/02/07/as-3-loading-external-mp3-file-and-retrieving-id3-information/#">?</a></div>
</div>
<ol class="dp-c">
<li class="alt"><span><span>package   </span></span></li>
<li><span>{   </span></li>
<li class="alt"><span>    import flash.display.Sprite;   </span></li>
<li><span>    </span><span class="keyword">public</span><span> </span><span class="keyword">class</span><span> Rectangle extends Sprite   </span></li>
<li class="alt"><span>    {   </span></li>
<li><span>        </span><span class="keyword">private</span><span> var xPos:Number;   </span></li>
<li class="alt"><span>        </span><span class="keyword">private</span><span> var yPos:Number;   </span></li>
<li><span>        </span><span class="keyword">private</span><span> var rWidth:Number;   </span></li>
<li class="alt"><span>        </span><span class="keyword">private</span><span> var rHeight:Number;   </span></li>
<li><span>        </span><span class="keyword">private</span><span> var color:</span><span class="keyword">uint</span><span>;   </span></li>
<li class="alt"><span>  </span></li>
<li><span>        </span><span class="keyword">public</span><span> function Rectangle(xPos:Number=0,yPos:Number=0,rWidth:Number=10,rHeight:Number=10,color:</span><span class="keyword">uint</span><span>=0&#215;336699)   </span></li>
<li class="alt"><span>        {   </span></li>
<li><span>            </span><span class="keyword">this</span><span>.graphics.beginFill(color);   </span></li>
<li class="alt"><span>            </span><span class="keyword">this</span><span>.graphics.drawRect(xPos,yPos,rWidth,rHeight);   </span></li>
<li><span>            </span><span class="keyword">this</span><span>.graphics.endFill();   </span></li>
<li class="alt"><span>        }   </span></li>
<li><span>    }   </span></li>
<li class="alt"><span>}  </span></li>
</ol>
</div>
<pre class="c-sharp" style="display:none;">package
{
	import flash.display.Sprite;
	public class Rectangle extends Sprite
	{
		private var xPos:Number;
		private var yPos:Number;
		private var rWidth:Number;
		private var rHeight:Number;
		private var color:uint;

		public function Rectangle(xPos:Number=0,yPos:Number=0,rWidth:Number=10,rHeight:Number=10,color:uint=0x336699)
		{
			this.graphics.beginFill(color);
			this.graphics.drawRect(xPos,yPos,rWidth,rHeight);
			this.graphics.endFill();
		}
	}
}</pre>
<p>Here is the document class</p>
<div class="dp-highlighter">
<div class="bar">
<div class="tools"><a href="http://manewc.com/2008/02/07/as-3-loading-external-mp3-file-and-retrieving-id3-information/#">view plain</a><a href="http://manewc.com/2008/02/07/as-3-loading-external-mp3-file-and-retrieving-id3-information/#">copy to clipboard</a><a href="http://manewc.com/2008/02/07/as-3-loading-external-mp3-file-and-retrieving-id3-information/#">print</a><a href="http://manewc.com/2008/02/07/as-3-loading-external-mp3-file-and-retrieving-id3-information/#">?</a></div>
</div>
<ol class="dp-c">
<li class="alt"><span><span>package   </span></span></li>
<li><span>{   </span></li>
<li class="alt"><span>    import flash.display.Sprite;   </span></li>
<li><span>    import flash.display.Loader;   </span></li>
<li class="alt"><span>    import flash.media.*   </span></li>
<li><span>    import flash.net.URLRequest;   </span></li>
<li class="alt"><span>    import flash.events.IOErrorEvent;   </span></li>
<li><span>    import flash.events.ProgressEvent;   </span></li>
<li class="alt"><span>    import flash.events.Event;   </span></li>
<li><span>    import flash.events.MouseEvent;   </span></li>
<li class="alt"><span>    import flash.text.*;   </span></li>
<li><span>  </span></li>
<li class="alt"><span>    </span><span class="keyword">public</span><span> </span><span class="keyword">class</span><span> LoadSound extends Sprite   </span></li>
<li><span>    {   </span></li>
<li class="alt"><span>        </span><span class="keyword">private</span><span> var snd:Sound;   </span></li>
<li><span>        </span><span class="keyword">private</span><span> var sndChannel:SoundChannel;   </span></li>
<li class="alt"><span>        </span><span class="keyword">private</span><span> var output:TextField;   </span></li>
<li><span>        </span><span class="keyword">private</span><span> var id3Array:Array;   </span></li>
<li class="alt"><span>        </span><span class="keyword">private</span><span> var ct:</span><span class="keyword">uint</span><span>;   </span></li>
<li><span>  </span></li>
<li class="alt"><span>        </span><span class="keyword">private</span><span> var image1:Loader = </span><span class="keyword">new</span><span> Loader();   </span></li>
<li><span>        </span><span class="keyword">private</span><span> var image2:Loader = </span><span class="keyword">new</span><span> Loader();   </span></li>
<li class="alt"><span>  </span></li>
<li><span>        </span><span class="keyword">private</span><span> var mask1:Rectangle;   </span></li>
<li class="alt"><span>        </span><span class="keyword">private</span><span> var mask2:Rectangle;   </span></li>
<li><span>  </span></li>
<li class="alt"><span>        </span><span class="keyword">public</span><span> function LoadSound()   </span></li>
<li><span>        {   </span></li>
<li class="alt"><span>            showInstructions();   </span></li>
<li><span>            showGraphics();   </span></li>
<li class="alt"><span>            init();   </span></li>
<li><span>        }   </span></li>
<li class="alt"><span>  </span></li>
<li><span>        </span><span class="keyword">private</span><span> function init():</span><span class="keyword">void</span><span>  </span></li>
<li class="alt"><span>        {   </span></li>
<li><span>            var snd:Sound = </span><span class="keyword">new</span><span> Sound();   </span></li>
<li class="alt"><span>            snd.load(</span><span class="keyword">new</span><span> URLRequest(</span><span class="string">&#8220;/path/to/mp3/file/&#8221;</span><span>));   </span></li>
<li><span>  </span></li>
<li class="alt"><span>            snd.addEventListener(IOErrorEvent.IO_ERROR, sndIOError);   </span></li>
<li><span>            snd.addEventListener(ProgressEvent.PROGRESS, sndProgress);   </span></li>
<li class="alt"><span>            snd.addEventListener(Event.COMPLETE, sndComplete);   </span></li>
<li><span>            snd.addEventListener(Event.ID3, ID3content);   </span></li>
<li class="alt"><span>  </span></li>
<li><span>        }   </span></li>
<li class="alt"><span>  </span></li>
<li><span>        </span><span class="keyword">private</span><span> function sndIOError(e:IOErrorEvent):</span><span class="keyword">void</span><span>  </span></li>
<li class="alt"><span>        {   </span></li>
<li><span>            output.text = </span><span class="string">&#8220;An error occured when laoding the sound&#8221;</span><span>;   </span></li>
<li class="alt"><span>        }   </span></li>
<li><span>  </span></li>
<li class="alt"><span>        </span><span class="keyword">private</span><span> function sndProgress(e:ProgressEvent):</span><span class="keyword">void</span><span>  </span></li>
<li><span>        {   </span></li>
<li class="alt"><span>            output.text = </span><span class="string">&#8220;Loading: &#8221;</span><span> + Math.round(100 * e.bytesLoaded / e.bytesTotal);   </span></li>
<li><span>        }   </span></li>
<li class="alt"><span>  </span></li>
<li><span>        </span><span class="keyword">private</span><span> function sndComplete(e:Event):</span><span class="keyword">void</span><span>  </span></li>
<li class="alt"><span>        {   </span></li>
<li><span>            output.text = </span><span class="string">&#8220;Sound loaded - click the stage to play and stop&#8221;</span><span>;   </span></li>
<li class="alt"><span>  </span></li>
<li><span>            stage.addEventListener(MouseEvent.MOUSE_DOWN, toggleMusic);   </span></li>
<li class="alt"><span>  </span></li>
<li><span>            var music:Sound = e.target </span><span class="keyword">as</span><span> Sound;   </span></li>
<li class="alt"><span>  </span></li>
<li><span>            function toggleMusic():</span><span class="keyword">void</span><span>  </span></li>
<li class="alt"><span>            {   </span></li>
<li><span>                ct++;   </span></li>
<li class="alt"><span>  </span></li>
<li><span>                </span><span class="keyword">if</span><span> (ct%2)   </span></li>
<li class="alt"><span>                {   </span></li>
<li><span>                    sndChannel = music.play();   </span></li>
<li class="alt"><span>                    addEventListener(Event.ENTER_FRAME, playSpectrum);   </span></li>
<li><span>                }   </span></li>
<li class="alt"><span>                </span><span class="keyword">else</span><span>  </span></li>
<li><span>                {   </span></li>
<li class="alt"><span>                    sndChannel.stop();   </span></li>
<li><span>                    removeEventListener(Event.ENTER_FRAME, playSpectrum);   </span></li>
<li class="alt"><span>                }   </span></li>
<li><span>            }   </span></li>
<li class="alt"><span>        }   </span></li>
<li><span>  </span></li>
<li class="alt"><span>        </span><span class="keyword">private</span><span> function ID3content(e:Event):</span><span class="keyword">void</span><span>  </span></li>
<li><span>        {   </span></li>
<li class="alt"><span>            var id3Prop:ID3Info = e.target.id3;   </span></li>
<li><span>  </span></li>
<li class="alt"><span>            var id3Array:Array = </span><span class="keyword">new</span><span> Array();   </span></li>
<li><span>  </span></li>
<li class="alt"><span>            </span><span class="keyword">for</span><span> (var idName:String </span><span class="keyword">in</span><span> id3Prop)   </span></li>
<li><span>            {   </span></li>
<li class="alt"><span>                </span><span class="comment">//trace (&#8220;ID3 Tag&#8221;,idName, &#8221;=&#8221;, id3Prop [idName]); </span><span>  </span></li>
<li><span>                id3Array.push(</span><span class="keyword">new</span><span> Array(idName, id3Prop [idName]));   </span></li>
<li class="alt"><span>            }   </span></li>
<li><span>  </span></li>
<li class="alt"><span>            id3Text.text = </span><span class="string">&#8220;&#8221;</span><span>;   </span></li>
<li><span>  </span></li>
<li class="alt"><span>            </span><span class="keyword">for</span><span> (var h:Number=0; h &lt; id3Array.length; h++)   </span></li>
<li><span>            {   </span></li>
<li class="alt"><span>                </span><span class="comment">// id3Text is the name of the TextArea component I placed on the stage in the .fla movie </span><span>  </span></li>
<li><span>                </span><span class="comment">// I also set the parameters for the componenet in the .fla movie </span><span>  </span></li>
<li class="alt"><span>                id3Text.text += id3Array[h][0] + </span><span class="string">&#8220; = &#8221;</span><span> + id3Array[h][1] + </span><span class="string">&#8220;\n&#8221;</span><span>;   </span></li>
<li><span>            }   </span></li>
<li class="alt"><span>        }   </span></li>
<li><span>  </span></li>
<li class="alt"><span>        </span><span class="keyword">private</span><span> function playSpectrum(e:Event):</span><span class="keyword">void</span><span>  </span></li>
<li><span>        {   </span></li>
<li class="alt"><span>            mask1.y = sndChannel.leftPeak * -100;   </span></li>
<li><span>            mask2.y = sndChannel.rightPeak * -100;   </span></li>
<li class="alt"><span>        }   </span></li>
<li><span>  </span></li>
<li class="alt"><span>        </span><span class="keyword">private</span><span> function showInstructions():</span><span class="keyword">void</span><span>  </span></li>
<li><span>        {   </span></li>
<li class="alt"><span>            </span><span class="comment">// Small Black Text Formatting </span><span>  </span></li>
<li><span>            var insText:TextFormat = </span><span class="keyword">new</span><span> TextFormat();   </span></li>
<li class="alt"><span>            insText.font = </span><span class="string">&#8220;Arial&#8221;</span><span>;   </span></li>
<li><span>            insText.color = 0xffffff;   </span></li>
<li class="alt"><span>            insText.size = 12;   </span></li>
<li><span>            insText.underline = </span><span class="keyword">false</span><span>;   </span></li>
<li class="alt"><span>  </span></li>
<li><span>            </span><span class="comment">// output TextField </span><span>  </span></li>
<li class="alt"><span>            output = </span><span class="keyword">new</span><span> TextField();   </span></li>
<li><span>            output.defaultTextFormat = insText;   </span></li>
<li class="alt"><span>            addChild(output);   </span></li>
<li><span>            output.x = 10;   </span></li>
<li class="alt"><span>            output.y = 35;   </span></li>
<li><span>            output.width = stage.stageWidth;   </span></li>
<li class="alt"><span>            output.height = 22;   </span></li>
<li><span>        }   </span></li>
<li class="alt"><span>  </span></li>
<li><span>        </span><span class="keyword">private</span><span> function showGraphics():</span><span class="keyword">void</span><span>  </span></li>
<li class="alt"><span>        {   </span></li>
<li><span>            image1.load(</span><span class="keyword">new</span><span> URLRequest(</span><span class="string">&#8220;http://manewc.com/projects/flash/LoadSoundID3/gradient.jpg&#8221;</span><span>));   </span></li>
<li class="alt"><span>            addChild(image1);   </span></li>
<li><span>            image1.x = 10;   </span></li>
<li class="alt"><span>            image1.y = 200;   </span></li>
<li><span>  </span></li>
<li class="alt"><span>            image2.load(</span><span class="keyword">new</span><span> URLRequest(</span><span class="string">&#8220;http://manewc.com/projects/flash/LoadSoundID3/gradient2.jpg&#8221;</span><span>));   </span></li>
<li><span>            addChild(image2);   </span></li>
<li class="alt"><span>            image2.x = stage.stageWidth - 244;   </span></li>
<li><span>            image2.y = 200;   </span></li>
<li class="alt"><span>  </span></li>
<li><span>            </span><span class="comment">// create an object to act as our mask </span><span>  </span></li>
<li class="alt"><span>            mask1 = </span><span class="keyword">new</span><span> Rectangle(image1.x, image1.y + 99, 100, 100);   </span></li>
<li><span>            addChild(mask1);   </span></li>
<li class="alt"><span>  </span></li>
<li><span>            mask2 = </span><span class="keyword">new</span><span> Rectangle(image2.x, image2.y + 99, 100, 100);   </span></li>
<li class="alt"><span>            addChild(mask2);   </span></li>
<li><span>  </span></li>
<li class="alt"><span>            </span><span class="comment">// set the masks: </span><span>  </span></li>
<li><span>            image1.mask = mask1;   </span></li>
<li class="alt"><span>            image2.mask = mask2;   </span></li>
<li><span>        }   </span></li>
<li class="alt"><span>    }   </span></li>
</ol>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flashactionscriptexpert.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flashactionscriptexpert.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flashactionscriptexpert.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flashactionscriptexpert.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/flashactionscriptexpert.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/flashactionscriptexpert.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/flashactionscriptexpert.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/flashactionscriptexpert.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flashactionscriptexpert.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flashactionscriptexpert.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flashactionscriptexpert.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flashactionscriptexpert.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flashactionscriptexpert.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flashactionscriptexpert.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=10&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://flashactionscriptexpert.wordpress.com/2009/05/01/as-3-loading-external-mp3-file-and-retrieving-id3-information/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ada5375ba151ca886516ee0187b0cf8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sara Peter</media:title>
		</media:content>
	</item>
		<item>
		<title>AS2&gt;&gt;AS3: Loading &amp; Playing External Sounds</title>
		<link>http://flashactionscriptexpert.wordpress.com/2009/05/01/as2as3-loading-playing-external-sounds/</link>
		<comments>http://flashactionscriptexpert.wordpress.com/2009/05/01/as2as3-loading-playing-external-sounds/#comments</comments>
		<pubDate>Fri, 01 May 2009 22:24:20 +0000</pubDate>
		<dc:creator>sarapeter</dc:creator>
				<category><![CDATA[Flash ActionScript 2]]></category>
		<category><![CDATA[Flash ActionScript 3]]></category>
		<category><![CDATA[Flash Sound]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Loading]]></category>
		<category><![CDATA[Exrernal Sounds]]></category>
		<category><![CDATA[Sounds]]></category>
		<category><![CDATA[ActionScript 2]]></category>

		<guid isPermaLink="false">http://flashactionscriptexpert.wordpress.com/?p=8</guid>
		<description><![CDATA[AS2 → AS3: Loading &#38; Playing External Sounds Download Example Files Loading and playing external sounds in AS3 is not far off from its AS2 counterpart. The code, as usual in AS3, is a little different because of the new event model, but really boils down to the same thing. Let&#8217;s take a look at [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=8&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>AS2 → AS3: Loading &amp; Playing External Sounds</h3>
<p><a href="http://evolve.reintroducing.com/_source/flas/conversion/LoadingPlayingExternalSounds.zip">Download Example Files</a></p>
<p>Loading and playing external sounds in AS3 is not far off from its AS2 counterpart. The code, as usual in AS3, is a little different because of the new event model, but really boils down to the same thing.</p>
<p>Let&#8217;s take a look at the AS2 version:</p>
<div class="igBar"><span><a href="http://flashactionscriptexpert.wordpress.com/wp-admin/#">PLAIN TEXT</a></span></div>
<div class="syntax_hilite" style="height:auto;"><span class="langName">Actionscript:</span></p>
<div id="actionscript-1">
<div class="actionscript">
<ol>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="font-weight:bold;color:#000000;">var</span> s:<span style="color:#0066cc;">Sound</span> = <span style="font-weight:bold;color:#000000;">new</span> <span style="color:#0066cc;">Sound</span><span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"> </div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">s.<span style="color:#0066cc;">onLoad</span> = <span style="font-weight:bold;color:#000000;">function</span><span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>:<span style="color:#0066cc;">Void</span></div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="color:#66cc66;">{</span></div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">    <span style="color:#0066cc;">trace</span><span style="color:#66cc66;">(</span><span style="color:#ff0000;">&#8220;Song loaded.&#8221;</span><span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="color:#66cc66;">}</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"> </div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">s.<span style="color:#0066cc;">onSoundComplete</span> = <span style="font-weight:bold;color:#000000;">function</span><span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>:<span style="color:#0066cc;">Void</span></div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="color:#66cc66;">{</span></div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">    <span style="color:#0066cc;">trace</span><span style="color:#66cc66;">(</span><span style="color:#ff0000;">&#8220;Song done.&#8221;</span><span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="color:#66cc66;">}</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"> </div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">s.<span style="color:#0066cc;">loadSound</span><span style="color:#66cc66;">(</span><span style="color:#ff0000;">&#8220;music.mp3&#8243;</span>, <span style="font-weight:bold;color:#000000;">true</span><span style="color:#66cc66;">)</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p> </p>
<p>And here is how to do that in AS3:</p>
<div class="igBar"><span><a href="http://flashactionscriptexpert.wordpress.com/wp-admin/#">PLAIN TEXT</a></span></div>
<div class="syntax_hilite" style="height:auto;"><span class="langName">Actionscript:</span></p>
<div id="actionscript-2">
<div class="actionscript">
<ol>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="font-weight:bold;color:#000000;">var</span> s:<span style="color:#0066cc;">Sound</span> = <span style="font-weight:bold;color:#000000;">new</span> <span style="color:#0066cc;">Sound</span><span style="color:#66cc66;">(</span><span style="font-weight:bold;color:#000000;">new</span> URLRequest<span style="color:#66cc66;">(</span><span style="color:#ff0000;">&#8220;music.mp3&#8243;</span><span style="color:#66cc66;">)</span><span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">s.<span style="color:#006600;">addEventListener</span><span style="color:#66cc66;">(</span>Event.<span style="color:#006600;">COMPLETE</span>, doLoadComplete<span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"> </div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="font-weight:bold;color:#000000;">var</span> channel:SoundChannel = <span style="font-weight:bold;color:#000000;">new</span> SoundChannel<span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">channel = s.<span style="color:#0066cc;">play</span><span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">channel.<span style="color:#006600;">addEventListener</span><span style="color:#66cc66;">(</span>Event.<span style="color:#006600;">SOUND_COMPLETE</span>, doSoundComplete<span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"> </div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="font-weight:bold;color:#000000;">function</span> doLoadComplete<span style="color:#66cc66;">(</span>$evt:Event<span style="color:#66cc66;">)</span>:<span style="color:#0066cc;">void</span></div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="color:#66cc66;">{</span></div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">    <span style="color:#0066cc;">trace</span><span style="color:#66cc66;">(</span><span style="color:#ff0000;">&#8220;Song loaded.&#8221;</span><span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="color:#66cc66;">}</span></div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"> </div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="font-weight:bold;color:#000000;">function</span> doSoundComplete<span style="color:#66cc66;">(</span>$evt:Event<span style="color:#66cc66;">)</span>:<span style="color:#0066cc;">void</span></div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="color:#66cc66;">{</span></div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">    <span style="color:#0066cc;">trace</span><span style="color:#66cc66;">(</span><span style="color:#ff0000;">&#8220;Song done.&#8221;</span><span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="color:#66cc66;">}</span></div>
</li>
</ol>
</div>
</div>
</div>
<p> </p>
<p>As you may have noticed, there is a strange work-around in AS3 for what used to be the onSoundComplete event. I did a bit of Googling before posting this and found <a href="http://blog.andre-michelle.com/2007/198/">an interesting post</a> by Andre Michelle on the topic. That didn&#8217;t really solve my problem though, as I wanted to demonstrate how to do it in AS3, so I looked at the Flex reference for the AS2 to AS3 conversion of the onSoundComplete event and saw that it was replaced by, according to this, the soundComplete event in flash.media.SoundChannel. I went ahead and tried it out and it seemed to fire off fine on my machine, so here you have it.</p>
<p>Initially I had thought that the following lines of code would do the trick, but they didn&#8217;t:</p>
<div class="igBar"><span><a href="http://flashactionscriptexpert.wordpress.com/wp-admin/#">PLAIN TEXT</a></span></div>
<div class="syntax_hilite" style="height:auto;"><span class="langName">Actionscript:</span></p>
<div id="actionscript-3">
<div class="actionscript">
<ol>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;"><span style="font-weight:bold;color:#000000;">var</span> s:<span style="color:#0066cc;">Sound</span> = <span style="font-weight:bold;color:#000000;">new</span> <span style="color:#0066cc;">Sound</span><span style="color:#66cc66;">(</span><span style="font-weight:bold;color:#000000;">new</span> URLRequest<span style="color:#66cc66;">(</span><span style="color:#ff0000;">&#8220;music.mp3&#8243;</span><span style="color:#66cc66;">)</span><span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">s.<span style="color:#006600;">addEventListener</span><span style="color:#66cc66;">(</span>Event.<span style="color:#006600;">COMPLETE</span>, doLoadComplete<span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">s.<span style="color:#006600;">addEventListener</span><span style="color:#66cc66;">(</span>Event.<span style="color:#006600;">SOUND_COMPLETE</span>, doSoundComplete<span style="color:#66cc66;">)</span>;</div>
</li>
<li>
<div style="font-weight:normal;font-family:'Courier New', Courier, monospace;">s.<span style="color:#0066cc;">play</span><span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p> </p>
<p>Hence why I Googled and tried what I did above, which, as I&#8217;ve already stated, seemed to fix the problem. I&#8217;m no expert on sound in Flash but if it works, why question it? <img class="wp-smiley" src="http://evolve.reintroducing.com/wp-includes/images/smilies/icon_razz.gif" alt=":P" /></p>
<p><strong>NOTE:</strong> I&#8217;ve obviously removed the &#8220;music.mp3&#8243; file from the download so just grab any .mp3 you have, put it in the same folder that the example files are in, and rename it to music.mp3.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flashactionscriptexpert.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flashactionscriptexpert.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flashactionscriptexpert.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flashactionscriptexpert.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/flashactionscriptexpert.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/flashactionscriptexpert.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/flashactionscriptexpert.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/flashactionscriptexpert.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flashactionscriptexpert.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flashactionscriptexpert.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flashactionscriptexpert.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flashactionscriptexpert.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flashactionscriptexpert.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flashactionscriptexpert.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=8&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://flashactionscriptexpert.wordpress.com/2009/05/01/as2as3-loading-playing-external-sounds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ada5375ba151ca886516ee0187b0cf8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sara Peter</media:title>
		</media:content>

		<media:content url="http://evolve.reintroducing.com/wp-includes/images/smilies/icon_razz.gif" medium="image">
			<media:title type="html">:P</media:title>
		</media:content>
	</item>
		<item>
		<title>Flash Action Script 3 MP3 Player</title>
		<link>http://flashactionscriptexpert.wordpress.com/2009/05/01/flash-action-script-3-mp3-player/</link>
		<comments>http://flashactionscriptexpert.wordpress.com/2009/05/01/flash-action-script-3-mp3-player/#comments</comments>
		<pubDate>Fri, 01 May 2009 22:16:50 +0000</pubDate>
		<dc:creator>sarapeter</dc:creator>
				<category><![CDATA[Flash ActionScript 3]]></category>
		<category><![CDATA[Flash Sound]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[MP3]]></category>
		<category><![CDATA[MP3 Player]]></category>
		<category><![CDATA[Player]]></category>

		<guid isPermaLink="false">http://flashactionscriptexpert.wordpress.com/?p=3</guid>
		<description><![CDATA[Flash Action Script 3 MP3 Player: Here goes Flash Action Script 3 MP3 Player &#8211; Part 1. Need Your comments and support on the articles. I am writing this first version of Flash Action Script 3 MP3 for beginners so that they can have an idea of Flash Action Script 3 Sound Classes. Also this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=3&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Flash Action Script 3 MP3 Player:</h3>
<p align="justify">Here goes <strong>Flash Action Script 3 MP3 Player</strong> &#8211; <strong>Part 1</strong>. Need Your comments and support on the articles.</p>
<p align="justify">I am writing this first version of <strong>Flash Action Script 3 MP3 </strong>for beginners so that they can have an idea of Flash Action Script 3 Sound Classes. Also this code uses memory optimization techniques to reduce memory leaks.</p>
<p align="justify">To Learn More About Memory Optimization read my previous post</p>
<p align="justify"><a title="Memory Optimization Flash Action Script 3" href="http://actionscript-blog.imaginationdev.com/Memory-Optimization-Flash-Action-Script-3" target="_blank">http://actionscript-blog.imaginationdev.com/Memory-Optimization-Flash-Action-Script-3</a></p>
<p align="justify"><strong>Flash Action Script 3 MP3</strong> <strong>Player</strong> can be developed in 2 ways. <strong>1-</strong> Songs are played once they are completely downloaded on the local machine, Part 1 of my <strong>Flash Action Script 3 MP3 Player </strong>uses this techniques. this approach is suitable when developing a desktop application. <strong>2-</strong> Songs are buffered and streamed from the server and played simultaneously. This type of approach is common for <strong>Online</strong> <strong>Flash Action Script 3 MP3 Player. </strong>Part 2 of this article series will cover the 2nd methodology.</p>
<p align="justify">Building a <strong>Flash Action Script 3 MP3 Player </strong>is really easy using Flash Action Script 3 classes. Once you have the concepts of Sound class, SoundChannel class and Timer class in Flash Action Script 3 you are ready to develop a Media Player in Flash Action Script 3. In case you need guidance and help in the above mentioned classes you are welcome to leave comments and i will respond as soon as possible.</p>
<p align="justify">This might not be the best <strong>Flash Action Script 3 MP3 Player. </strong>This sure will guide you how to develop a <strong>Flash Action Script 3 MP3 Player using </strong>flash action script. There are number of flash media players available on the internet but very few i saw focussed on the fact that action script sound class has some problems when optimizing memory space. So i thought to write one sample of my own.</p>
<p align="justify">This flash MP3 player is easily customizable and reusable. In coming future i plan to write a Flash MP3 Player Component using Action Script3. Hopefully that article will also cover the basis of creating a flash component.</p>
<p align="justify">You can use the <strong>flash action script 3 Mp3 player code</strong> to build your own customized <strong>Flash Action Script 3 MP3 Players. </strong>Basic idea will always remain the same.</p>
<p align="justify"><strong>Flash Action Script 3 MP3 </strong><strong>Player development starts with the code for loading XML and inserting data in the play list.</strong></p>
<p align="justify">///////////////////////////////////////////////////////////////// //Loading XML /////////////////////////////////////////////////////////////////</p>
<pre>var xmlData:XML; var xmlLoader:URLLoader = new URLLoader();xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

xmlLoader.load(new URLRequest("playlist.xml"));
function LoadXML(e:Event):void {</pre>
<blockquote>
<pre> trace(LoadXML); xmlData = new XML(e.target.data);function getValues(input:XML) {</pre>
<blockquote>
<pre> var xmlCategoryList:XMLList = input.children(); var item:XML;var intCount:int = 0;

for each (item in xmlCategoryList) {</pre>
<blockquote>
<pre> playList.addItem({label:item.title, data:item.url}); intCount = intCount + 1;</pre>
</blockquote>
<pre>}</pre>
</blockquote>
<pre>}//end of get Values Function
getValues(xmlData);</pre>
</blockquote>
<pre>}// end of Load XML</pre>
<p align="justify"><strong>After that we will wait until user clicks on any song in play list. For handling play list event we will write the following code.</strong></p>
<p align="justify">///////////////////////////////////////////////////////////////// //Play List Handler Function /////////////////////////////////////////////////////////////////</p>
<pre>playList.addEventListener(Event.CHANGE, playListChangeHandler);
function playListChangeHandler(event:Event) {</pre>
<blockquote>
<pre>if (flagSoundChannel==1) {</pre>
<blockquote>
<pre> soundChannel.stop();</pre>
</blockquote>
<pre>} else if (flagSoundChannel==0) {</pre>
<blockquote>
<pre> flagSoundChannel=1;</pre>
</blockquote>
<pre>} playSound(event.target.selectedItem.data);timeSlider.value=0;</pre>
</blockquote>
<pre>}// end of change Handler</pre>
<p align="justify"><strong>Above code calls another important function playSound. This method loads the new sound in the sound Object.</strong></p>
<p align="justify">///////////////////////////////////////////////////////////////// //Play Sound Function /////////////////////////////////////////////////////////////////</p>
<pre>function playSound(path) {</pre>
<blockquote>
<pre> songPath.url = path;if(playerObject.sound!=null)</pre>
<blockquote>
<pre> delete playerObject.sound;</pre>
</blockquote>
<pre>playerObject.sound = new Sound();
addSoundEvents();
playerObject.sound.load(songPath);</pre>
</blockquote>
<pre>}</pre>
<p align="justify"><strong>Above code requires sound events to be handled before a new sound object is created. </strong>If you focus on the <strong>delete playerObject.sound;</strong> statement, this deletes the previous allocation of memory for the sound object. If we don’t do this a lot of memory will leak and eventually application will crash.</p>
<p align="justify">///////////////////////////////////////////////////////////////// //Sound Loading Event Handler Function /////////////////////////////////////////////////////////////////</p>
<pre>function addSoundEvents():void
{
    playerObject.sound.addEventListener(Event.COMPLETE, funcSoundLoaded);
    playerObject.sound.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
    playerObject.sound.addEventListener(ProgressEvent.PROGRESS,funcOnLoadProgress);
}
function funcSoundLoaded(event:Event) {
    var soundObject:Sound = event.target as Sound;
    var totalSoundDuration:Number;
    soundChannel=soundObject.play();
    totalSoundDuration=(soundObject.length/1000)/(60);
    totalSoundDuration=Math.floor((totalSoundDuration*100));
    totalSoundDuration=totalSoundDuration/100;
    timeSlider.maximum=(soundObject.length/1000);
    sliderDivisionValue=totalSoundDuration;
    fileTimeInSec = Math.floor(playerObject.sound.length/1000);
    secTimer.start();
}//end of Function Loaded
function funcOnLoadProgress(event:ProgressEvent):void {
    var loadedPct:uint =Math.round(100 * (event.bytesLoaded / event.bytesTotal));
    trace("The playerObject.sound is " + loadedPct + "% loaded.");
}
function onIOError(e:IOErrorEvent) {
    trace("The playerObject.sound can not be Loaded"+ e.text);
}</pre>
<p><strong>Above code implementation of sound event handlers. </strong>Lastly we will add Timers and GUI element event handlers. ///////////////////////////////////////////////////////////////// //Control Handlers UIDesign /////////////////////////////////////////////////////////////////</p>
<pre>btnStop.addEventListener(MouseEvent.CLICK,funcStop);
btnPause.addEventListener(MouseEvent.CLICK,funcPause);
btnPlay.addEventListener(MouseEvent.CLICK,funcPlay);
btnForward.addEventListener(MouseEvent.CLICK,funcForward);
btnBack.addEventListener(MouseEvent.CLICK,funcReverse);
soundChannel.addEventListener(Event.SOUND_COMPLETE, funcComplete);
function funcComplete(event:Event) {
    soundChannel.stop();
    timeSlider.value=0;
    currPosition=0;
}
function funcStop(event:Event) {
    secTimer.reset();
    timeSlider.value=0;
    currPosition=0;
    soundChannel.stop();
    flagSoundChannel=0;
}
function funcPause(event:Event) {
    secTimer.stop();
    currPosition= soundChannel.position;
    soundChannel.stop();
    btnPlay.visible=true;
    btnPause.visible=false;
}
function funcPlay(event:Event) {
    soundChannel.stop();
    soundChannel=playerObject.sound.play(currPosition);
    btnPlay.visible=false;
    btnPause.visible=true;
    secTimer.start();
}
function funcForward(event:Event) {
    if (soundChannel.position+forwardDuration&lt;=playerObject.sound.bytesTotal) {
        timeSlider.value+=forwardDuration/1000;
        soundChannel.stop();
        soundChannel=playerObject.sound.play(soundChannel.position+forwardDuration);
    }
    else
    {
        timeSlider.value=0;
        currPosition=0;
        soundChannel.stop();
        flagSoundChannel=0;
    }
}
function funcReverse(event:Event) {
    if (soundChannel.position-forwardDuration&gt;0) {
        timeSlider.value-=forwardDuration/1000;
        soundChannel.stop();
        soundChannel=playerObject.sound.play(soundChannel.position-forwardDuration);
    }
    else
    {
        timeSlider.value=0;
        currPosition=0;
        soundChannel.stop();
        flagSoundChannel=0;
    }
}</pre>
<p>///////////////////////////////////////////////////////////////// //Control Handlers Sliders /////////////////////////////////////////////////////////////////</p>
<pre>timeSlider.addEventListener(SliderEvent.THUMB_PRESS,sliderPressed);
timeSlider.addEventListener(SliderEvent.THUMB_RELEASE,sliderReleased);
timeSlider.addEventListener(SliderEvent.CHANGE,sliderChangeHandler);
timeSlider.liveDragging =true;
function sliderChangeHandler(event:SliderEvent) {
    secTimer.stop();
    soundChannel.stop();
    soundChannel=playerObject.sound.play(event.target.value*1000);
    secTimer.start();
}
function sliderPressed(event:SliderEvent) {
}
function sliderReleased(event:SliderEvent) {
    secTimer.stop();
    soundChannel.stop();
    soundChannel=playerObject.sound.play(event.target.value*1000);
    secTimer.start();
}</pre>
<p>///////////////////////////////////////////////////////////////// //Control Handlers Timers /////////////////////////////////////////////////////////////////</p>
<pre>secTimer.addEventListener(TimerEvent.TIMER, onTick);
secTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
function onTick(event:TimerEvent):void {
    trace("Timer is running");
    timeSlider.value+=1;
}
function onTimerComplete(event:TimerEvent):void {
    trace("Time's Up!");
}</pre>
<p><strong>For Further details on voice control and sound buffering you may contact me. I will soon be writing part 2 of the flash MP3 Player series with voice control and Sound Buffering. </strong></p>
<p><strong>Kindly Let me know about your remarks if this article is being helpful in solving your problem.</strong></p>
<p><strong>Download Sample Project : </strong><a title="Flash MP3 Player Using Action Script 3" href="http://actionscript-blog.imaginationdev.com/wp-content/uploads/2008/05/mp3-player.zip">Flash MP3 Player Using Action Script 3</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flashactionscriptexpert.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flashactionscriptexpert.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flashactionscriptexpert.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flashactionscriptexpert.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/flashactionscriptexpert.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/flashactionscriptexpert.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/flashactionscriptexpert.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/flashactionscriptexpert.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flashactionscriptexpert.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flashactionscriptexpert.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flashactionscriptexpert.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flashactionscriptexpert.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flashactionscriptexpert.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flashactionscriptexpert.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=3&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://flashactionscriptexpert.wordpress.com/2009/05/01/flash-action-script-3-mp3-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ada5375ba151ca886516ee0187b0cf8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sara Peter</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello world!</title>
		<link>http://flashactionscriptexpert.wordpress.com/2009/05/01/hello-world/</link>
		<comments>http://flashactionscriptexpert.wordpress.com/2009/05/01/hello-world/#comments</comments>
		<pubDate>Fri, 01 May 2009 22:04:59 +0000</pubDate>
		<dc:creator>sarapeter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=1&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Welcome to <a href="http://wordpress.com/">WordPress.com</a>. This is your first post. Edit or delete it and start blogging!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flashactionscriptexpert.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flashactionscriptexpert.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flashactionscriptexpert.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flashactionscriptexpert.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/flashactionscriptexpert.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/flashactionscriptexpert.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/flashactionscriptexpert.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/flashactionscriptexpert.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flashactionscriptexpert.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flashactionscriptexpert.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flashactionscriptexpert.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flashactionscriptexpert.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flashactionscriptexpert.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flashactionscriptexpert.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=flashactionscriptexpert.wordpress.com&amp;blog=7583635&amp;post=1&amp;subd=flashactionscriptexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://flashactionscriptexpert.wordpress.com/2009/05/01/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ada5375ba151ca886516ee0187b0cf8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sara Peter</media:title>
		</media:content>
	</item>
	</channel>
</rss>
