<?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>The efnx code blog. &#187; actionscript</title>
	<atom:link href="http://efnx.com/tag/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://efnx.com</link>
	<description>code. blog.</description>
	<lastBuildDate>Tue, 15 May 2012 17:46:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Flash Actionscript 3 Waveform Generation Class</title>
		<link>http://efnx.com/flash-actionscript-3-waveform-generation-class/</link>
		<comments>http://efnx.com/flash-actionscript-3-waveform-generation-class/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 22:45:35 +0000</pubDate>
		<dc:creator>Schell</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Sound]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[Wave]]></category>
		<category><![CDATA[waveform]]></category>

		<guid isPermaLink="false">http://blog.efnx.com/?p=90</guid>
		<description><![CDATA[In my last post, Plotting a Sound Wave in Flash AS3 I detailed a method to use when displaying audio data. The method itself works great, but due to Flash&#8217;s frame-based code execution and event processing the user looses input capabilities while the flash player chugs through millions of numbers adding, rounding and comparing. In [...]]]></description>
			<content:encoded><![CDATA[<p>In my last post, <a href="http://blog.efnx.com/?p=75">Plotting a Sound Wave in Flash AS3</a> I detailed a method to use when displaying audio data. The method itself works great, but due to Flash&#8217;s frame-based code execution and event processing the user looses input capabilities while the flash player chugs through millions of numbers adding, rounding and comparing. In order to make displaying an audio waveform easier on both the programmer and the user I wrote a class that analyzes a Sound object progressively, and dispatches a special event containing the analyzed data. The class will construct a left and right channel Vector, each containing one data point [a number between 0 and 1] for a given number of <a href="http://en.wikipedia.org/wiki/Window_function">windows</a>, between two positions in the sound. The left and right position are measured in samples and two types of analyzation are offered. Here is a demo of the class in action:<br />
<div class="wp-caption aligncenter" style="width: 578px"><a href="http://efnx.com/lab/WavePlotter/"><img alt="Screen Capture of Waveform Plot" src="http://efnx.com/lab/WavePlotter/waveform_screen.png" title="Waveform Plot" width="568" height="237" /></a><p class="wp-caption-text">Screen Capture of Waveform Plot</p></div><br />
The calculated data can be reached incrementally through the WaveformEvent object which is dispatched every frame, or at the end of all analyzation in the Waveform object&#8217;s leftChannel and rightChannel properties. The details are listed in the documentation below.</p>
<p>Thanks to the <a href="http://summitprojectsflashblog.wordpress.com/2008/07/31/wave-theory-in-actionscript-3/">Summit Projects Flash Blog</a> and <a href="http://www.bytearray.org/?p=329">Thibault Imbert at ByteArray</a> for their posts on the different techniques that went into my class.</p>
<p><a name="source"><strong>Source</strong></a><br />
Here is the source for my TextMate project: <a href="http://efnx.com/lab/WavePlotter/src/WavePlotter_Main_081024.src.tar.gz">Sources</a><br />
Documentation: <a href="http://efnx.com/docs/efnx/sound/Waveform.html">class</a> and <a href="http://efnx.com/docs/efnx/events/WaveformEvent.html">event</a></p>
<p>And here is a Flex version (made in windows): // Thanks dem!<br />
<a href='http://blog.efnx.com/wp-content/uploads/2009/11/WavePlotter_Main.zip'>Sources (Flex version)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://efnx.com/flash-actionscript-3-waveform-generation-class/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Multiple Bitmap Loader in AS3</title>
		<link>http://efnx.com/multiple-bitmap-loader-in-as3/</link>
		<comments>http://efnx.com/multiple-bitmap-loader-in-as3/#comments</comments>
		<pubDate>Mon, 26 Nov 2007 00:34:39 +0000</pubDate>
		<dc:creator>Schell</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[animated]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[GIF]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[resources]]></category>

		<guid isPermaLink="false">http://blog.efnx.com/?p=30</guid>
		<description><![CDATA[To aid in my projects I have written a simple bitmapData loading class entitled aquireResources. This class takes an array of image paths as strings and proceeds to load them one by one. A &#8220;complete&#8221; event is dispatched when loading is completed and the bitmapData of each loading instance are saved in an array in [...]]]></description>
			<content:encoded><![CDATA[<p>To aid in my projects I have written a simple bitmapData loading class entitled aquireResources. This class takes an array of image paths as strings and proceeds to load them one by one. A &#8220;complete&#8221; event is dispatched when loading is completed and the bitmapData of each loading instance are saved in an array in the order they were given. Calling the aquireResources.array() method returns the array of bitmapData. If you&#8217;ve already downloaded Thibault Imbert (bytearray.org)&#8217;s GIFPlayer and GIFDecoder classes you can uncomment the included properties and methods in my class and enable the aquireResources class to load multiple instances of animated GIFs into AS3 as arrays of bitmapData. In this case aquireResources.array() returns a two-dimensional array containing one array of bitmapData per animated GIF passed to it.</p>
<p><b>Usage</b></p>
<div class="codecolorer-container actionscript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">efnx</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">aquireResources</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> rsrc:aquireResources = <span style="color: #000000; font-weight: bold;">new</span> aquireResources<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;rsrc.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;complete&quot;</span>, onComplete, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">array</span>:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;imagePath1/image1.png&quot;</span>, <span style="color: #ff0000;">&quot;imagePath2/image2.gif&quot;</span>, <span style="color: #ff0000;">&quot;imagePath3/image3.jpeg&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> bitmapDataArray:<span style="color: #0066CC;">Array</span>;<br />
<span style="color: #000000; font-weight: bold;">function</span> onComplete<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;bitmapDataArray = rsrc.<span style="color: #0066CC;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
rsrc.<span style="color: #006600;">aquireImages</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">array</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p><b>For loading animated GIFs</b></p>
<div class="codecolorer-container actionscript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">efnx</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">aquireResources</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> rsrc:aquireResources = <span style="color: #000000; font-weight: bold;">new</span> aquireResources<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;rsrc.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;complete&quot;</span>, onComplete, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">array</span>:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;imagePath1/image1.gif&quot;</span>, <span style="color: #ff0000;">&quot;imagePath2/image2.gif&quot;</span>, <span style="color: #ff0000;">&quot;imagePath3/image3.gif&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> animatedArray:<span style="color: #0066CC;">Array</span>;<br />
<span style="color: #000000; font-weight: bold;">function</span> onComplete<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;animatedArray = rsrc.<span style="color: #0066CC;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
rsrc.<span style="color: #006600;">aquireGIFs</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">array</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p><b>Source</b><br />
<a href='http://blog.efnx.com/wp-content/uploads/2007/11/blogefnxcom-aquireresources.zip' title='aquireResources Source'>aquireResources Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://efnx.com/multiple-bitmap-loader-in-as3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AS3 Animation class to replace MovieClip</title>
		<link>http://efnx.com/as3-animation-class-to-replace-movieclip/</link>
		<comments>http://efnx.com/as3-animation-class-to-replace-movieclip/#comments</comments>
		<pubDate>Mon, 15 Oct 2007 20:14:42 +0000</pubDate>
		<dc:creator>Schell</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[FPS]]></category>
		<category><![CDATA[MovieClip]]></category>
		<category><![CDATA[resources]]></category>

		<guid isPermaLink="false">http://blog.efnx.com/?p=10</guid>
		<description><![CDATA[Okay, let me start by saying that I HATE importing resources into fla&#8217;s. When I first learned Flash [AS2] it wasn&#8217;t an issue. Now with AS3 and the necessity of classes my coding style has changed and I really, really like keeping things as separated into classes as possible. The Problem With MovieClips When attempting [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, let me start by saying that I HATE importing resources into fla&#8217;s. When I first learned Flash [AS2] it wasn&#8217;t an issue. Now with AS3 and the necessity of classes my coding style has changed and I really, really like keeping things as separated into classes as possible. </p>
<p><strong>The Problem With MovieClips</strong><br />
When attempting to program button classes I ran into this wall: Flash&#8217;s MovieClip is the only appropriate class object to use for animation. It&#8217;s great for placing images in your timeline to form moving pictures and placing Actionscript on certain frames makes directing the clip around really easy. But what about when you have to make MovieClips dynamically and add code to certain frames inside that clip, without using the GUI? MovieClip doesn&#8217;t support dynamically adding frames, or functions or Bitmaps to certain frames. This sucks. Why Adobe did this I do not know &#8211; so I wrote a class that DOES WHAT I WANT [and maybe you too].</p>
<p><strong>Usage</strong><br />
Animation takes three parameters, which are all optional: numFrames:int = 1 width:int = 0, and height:int = 0. These params just initiate the object.</p>
<div class="codecolorer-container actionscript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/*<br />
* &nbsp; &nbsp; blog.efnx.com:Animation Example<br />
*/</span><br />
<br />
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">efnx</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">Animation</span>; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//import the class</span><br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> character:Animation = <span style="color: #000000; font-weight: bold;">new</span> Animation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//object sets numFrames, width and height to 1, 0 and 0</span></div></div>
<p>After making the object you have to append the pictures to certain frames using the appendBitmapData function:</p>
<div class="codecolorer-container actionscript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">character.<span style="color: #006600;">appendBitmapData</span><span style="color: #66cc66;">&#40;</span>theFrame:<span style="color: #0066CC;">int</span>, bitmapData:BitmapData<span style="color: #66cc66;">&#41;</span>;</div></div>
<p>What this does is take the BitmapData and attach a function to the given frame that replaces the Animation&#8217;s default BitmapData with yours upon execution of that frame.<br />
Doing this achieves the same effect as dragging a bitmap onto the stage in a MovieClip keyframe.</p>
<p>I wrote the class keeping in mind that someone may want to use it not for animation but sequential code execution, so frames can be created and functions attached to each frame without any graphics associated. The function used to add [or append] other functions to a certain frame is</p>
<div class="codecolorer-container actionscript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp;appendFrameScript<span style="color: #66cc66;">&#40;</span>theFrame:<span style="color: #0066CC;">int</span>, theFunction:<span style="color: #000000; font-weight: bold;">Function</span>, <span style="color: #66cc66;">&#91;</span>testing:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p>theFrame is the frame you&#8217;d like to add a function to, theFunction is the function to be added and testing tells the class whether or not to print debug info.</p>
<p>After adding frames and bitmaps and all that Animation can be controlled using familiar MovieClip methods like gotoAndPlay(), gotoAndStop(), go(), stop() and properties like currentFrame and totalFrames, as well as some others &#8211; bmd [the current frames BitmapData], bmdArray [an array of all frames BitmapData] and cool functions like customFps(fps:int) which set a custom playback rate denoted in number of frames per second [fps:int] and accelerateFps(desiredFps:int, numberFrames:int) which accelerates the playback delay from the current FPS to the desired FPS in numberFrames frames. accelerateFps is still a little buggy, feel free to nice it up!</p>
<p><strong>Last Words</strong><br />
Animation doesn&#8217;t automatically loop your animation [since I usually don't need it to], so to really mimic a MovieClip you&#8217;d have to write a function incorporating gotoAndPlay(1) and then attach the function to the frame you&#8217;d like to loop your clip at:</p>
<div class="codecolorer-container actionscript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> character:Animation = <span style="color: #000000; font-weight: bold;">new</span> Animation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//initiate object</span><br />
&nbsp; &nbsp; &nbsp;character.<span style="color: #006600;">appendBitmapData</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, firstBitmapData<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//add BitmapData</span><br />
&nbsp; &nbsp; &nbsp;character.<span style="color: #006600;">appendBitmapData</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>, secondBitmapData<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;character.<span style="color: #006600;">appendFrameScript</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>, repeat<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//append repeat function</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> repeat<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">//repeat function</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;character.<span style="color: #0066CC;">gotoAndPlay</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Hope this class helps some of you out. Feel free to let me know what needs improving and comment if you like it!</p>
<p><strong>Source</strong><br />
<a href='http://blog.efnx.com/wp-content/uploads/2007/10/blogefnxcom-animation.zip' title='Animation Class Source Code'>Animation Class Source Code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://efnx.com/as3-animation-class-to-replace-movieclip/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

