<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss 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/" version="2.0">

<channel>
	<title>kelvinluck.com</title>
	
	<link>http://www.kelvinluck.com</link>
	<description>a stroke of luck</description>
	<pubDate>Thu, 01 Jan 2009 05:07:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/kelvinluck" type="application/rss+xml" /><item>
		<title>Happy Christmas and Happy New Year!</title>
		<link>http://www.kelvinluck.com/2008/12/happy-christmas-and-happy-new-year/</link>
		<comments>http://www.kelvinluck.com/2008/12/happy-christmas-and-happy-new-year/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 05:07:02 +0000</pubDate>
		<dc:creator>Kelvin Luck</dc:creator>
		
		<category><![CDATA[off-topic]]></category>

		<category><![CDATA[AS3]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[flintparticles]]></category>

		<category><![CDATA[papervision3d]]></category>

		<guid isPermaLink="false">http://www.kelvinluck.com/?p=508</guid>
		<description><![CDATA[This Christmas I am living in Canada whilst most of my friends and family are back in England or elsewhere. So I decided to make a virtual Christmas card that I could easily and quickly send anywhere. So here&#8217;s one for the reader(s?) of my blog:



You can click on the card to flip it over [...]]]></description>
			<content:encoded><![CDATA[<p>This Christmas I am living in Canada whilst most of my friends and family are back in England or elsewhere. So I decided to make a virtual Christmas card that I could easily and quickly send anywhere. So here&#8217;s one for the reader(s?) of my blog:</p>

<p><a rel="shadowbox;width=700;height=550;bgcolor=#fff;flashvars=cardId=814a672c6f0dbbee7bcc77ef4f969fff&amp;imagesPath=http://xmas08.kelvinluck.com/images/&amp;serverPath=http://xmas08.kelvinluck.com/" href="http://xmas08.kelvinluck.com/swf/Xmas08.swf"><img title="christmas-card" src="http://www.kelvinluck.com/wp-content/uploads/2008/12/christmas-card.jpg" alt="" width="518" height="431" /></a></p>

<p>You can click on the card to flip it over and read the message on the back but remember to flip back and see how the snow stacks up on the figures in the foreground&#8230; It&#8217;s not exactly realistic but I like it :)</p>

I managed to put the whole thing together in about a day (which didn&#8217;t stop me being about a day late sending it out!) thanks to a bunch of open source projects. So massive thanks to the authors of and contributors to:<br />
<ul>
	<li><a title="Papervision 3D" href="http://code.google.com/p/papervision3d/">Papervision</a> for the 3d (although thinking about it, I could have possibly tried to do something this simple using the new &#8220;postcards in space&#8221; 3d of the flash player 10).</li>
	<li><a title="Flint Particle System" href="http://flintparticles.org/">Flint particle system</a> for the snow (and I&#8217;m hoping to do more with this engine soon - it&#8217;s really nicely put together).</li>
	<li><a title="Pure MVC" href="http://puremvc.org/">Pure <span class="caps">MVC</span></a> for holding it together.</li>
	<li><a title="Code Igniter" href="http://codeigniter.com/">Code Igniter</a> for the backend (so I can send different cards to different people).</li>
	<li><a title="GTween" href="http://www.gskinner.com/libraries/gtween/">GTween</a> for the tweening.</li>
	<li>And also to <a title="Icon Drawer" href="http://www.icondrawer.com/free.php">Icon Drawer</a> for the icons who are standing in the foreground of this card.</li>
</ul>
And now it&#8217;s time to go out and celebrate the approach of another year! I&#8217;m looking forward to lots of cool stuff for next year, both work and play. So Happy Christmas and Happy New Year everyone!! And all the best for 2009 :D]]></content:encoded>
			<wfw:commentRss>http://www.kelvinluck.com/2008/12/happy-christmas-and-happy-new-year/feed/</wfw:commentRss>
		</item>
		<item>
		<title>First steps with flash 10 audio programming</title>
		<link>http://www.kelvinluck.com/2008/11/first-steps-with-flash-10-audio-programming/</link>
		<comments>http://www.kelvinluck.com/2008/11/first-steps-with-flash-10-audio-programming/#comments</comments>
		<pubDate>Sun, 23 Nov 2008 21:19:54 +0000</pubDate>
		<dc:creator>Kelvin Luck</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[flex]]></category>

		<category><![CDATA[audio]]></category>

		<category><![CDATA[flash10]]></category>

		<category><![CDATA[sourcecode]]></category>

		<guid isPermaLink="false">http://www.kelvinluck.com/?p=475</guid>
		<description><![CDATA[As I was reading my RSS feeds yesterday I came across a blog post by Andre Michelle where he released some sourcecode for using the new Sound APIs in Flash Player 10. I had a little spare time so I decided to finally set up FDT to allow me to author flash 10 swfs (which [...]]]></description>
			<content:encoded><![CDATA[<p>As I was reading my <span class="caps">RSS </span>feeds yesterday I came across a <a href="http://blog.andre-michelle.com/2008/adobe-max-audiosamples/">blog post by Andre Michelle</a> where he released some sourcecode for using the <a href="http://www.kaourantin.net/2008/05/adobe-is-making-some-noise-part-1.html">new</a> <a href="http://www.kaourantin.net/2008/05/adobe-is-making-some-noise-part-2.html">Sound</a> <a href="http://www.kaourantin.net/2008/05/adobe-is-making-some-noise-part-3.html"><span class="caps">API</span>s</a> in Flash Player 10. I had a little spare time so I decided to finally set up <a href="http://fdt.powerflasher.com/"><span class="caps">FDT</span></a> to allow me to <a href="http://fdt.powerflasher.com/blog/?p=219">author flash 10 swfs</a> (which was easier than I expected) so I could do some playing.</p>

<p>The idea was to re-create my <a href="/2008/03/wave-sequencer-experiment/">wave sequencer experiment</a> using the <span class="caps">API</span>s but to get started I did something simpler. I wrote a little class which allows you to load an <span class="caps">MP3 </span>file and play it back with the ability to change the playback speed dynamically. Here it is:</p>

<div><a rel="shadowbox;width=300;height=120" href="http://www.kelvinluck.com/wp-content/uploads/2008/11/mp3playerui.swf"><img title="Dynamic MP3 playback in Flash 10" src="http://www.kelvinluck.com/wp-content/uploads/2008/11/mp3player-screenshot.png" alt="" width="301" height="130" /></a></div>

<p>You can see the sourcecode for the relevant file below. The interesting stuff from an audio point of view is happening in the onSampleData callback. This is triggered by the Flash player whenever it needs a new buffer of audio samples to play. The code in that function is commented and hopefully pretty self explanatory. It is derived from code in my old wave sequencer experiment which was itself derived from some code in the <a href="http://code.google.com/p/popforge/">popforge</a> library.</p>

<div class="actionscript3 code actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.kelvinluck.audio <br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Event</span></a>;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.SampleDataEvent;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span>.<a href="http://www.google.com/search?q=sound%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sound.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Sound</span></a>;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">URLRequest</span></a>;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ByteArray</span></a>; <br />
<br />
&nbsp; &nbsp;<span style="color: #3f5fbf;">/**<br />
&nbsp; &nbsp; * @author Kelvin Luck<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MP3Player <br />
&nbsp; &nbsp;<span style="color: #000000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _playbackSpeed<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">1</span>; <br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> playbackSpeed<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_playbackSpeed = <span style="color: #004993;">value</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _mp3<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=sound%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sound.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Sound</span></a>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _loadedMP3Samples<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ByteArray</span></a>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _dynamicSound<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=sound%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sound.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Sound</span></a>;<br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _phase<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _numSamples<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a>;<br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MP3Player<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> loadAndPlay<span style="color: #000000;">&#40;</span>request<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">URLRequest</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_mp3 = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=sound%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sound.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Sound</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_mp3.<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&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Event</span></a>.<span style="color: #004993;">COMPLETE</span>, mp3Complete<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_mp3.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>request<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> playLoadedSound<span style="color: #000000;">&#40;</span>s<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=sound%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sound.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Sound</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> bytes<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ByteArray</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ByteArray</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s.extract<span style="color: #000000;">&#40;</span>bytes, <a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#40;</span>s.<span style="color: #004993;">length</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">44.1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span>bytes<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_dynamicSound<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dynamicSound.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>SampleDataEvent.SAMPLE_DATA, onSampleData<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dynamicSound = <span style="color: #0033ff; font-weight: bold;">null</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> mp3Complete<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;playLoadedSound<span style="color: #000000;">&#40;</span>_mp3<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span>bytes<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ByteArray</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_dynamicSound = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=sound%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sound.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Sound</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_dynamicSound.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>SampleDataEvent.SAMPLE_DATA, onSampleData<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_loadedMP3Samples = bytes;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_numSamples = bytes.<span style="color: #004993;">length</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">8</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_phase = <span style="color: #000000; font-weight:bold;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_dynamicSound.<span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onSampleData<span style="color: #000000;">&#40;</span> event<span style="color: #000000; font-weight: bold;">:</span>SampleDataEvent <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> l<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> r<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> outputLength<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">while</span> <span style="color: #000000;">&#40;</span>outputLength <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">2048</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">// until we have filled up enough output buffer</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">// move to the correct location in our loaded samples ByteArray</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _loadedMP3Samples.<span style="color: #004993;">position</span> = <a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#40;</span>_phase<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">8</span>; <span style="color: #009900;">// 4 bytes per float and two channels so the actual position in the ByteArray is a factor of 8 bigger than the phase</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">// read out the left and right channels at this position</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; l = _loadedMP3Samples.<span style="color: #004993;">readFloat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r = _loadedMP3Samples.<span style="color: #004993;">readFloat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">// write the samples to our output buffer</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event.<span style="color: #004993;">data</span>.<span style="color: #004993;">writeFloat</span><span style="color: #000000;">&#40;</span>l<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event.<span style="color: #004993;">data</span>.<span style="color: #004993;">writeFloat</span><span style="color: #000000;">&#40;</span>r<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputLength<span style="color: #000000; font-weight: bold;">++</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">// advance the phase by the speed...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _phase <span style="color: #000000; font-weight: bold;">+</span>= _playbackSpeed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">// and deal with looping (including looping back past the beginning when playing in reverse)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_phase <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_phase <span style="color: #000000; font-weight: bold;">+</span>= _numSamples;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_phase <span style="color: #000000; font-weight: bold;">&gt;</span>= _numSamples<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_phase <span style="color: #000000; font-weight: bold;">-</span>= _numSamples;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div>

<p>As you can see, there are three public methods in the above class. <code>loadAndPlay</code> will load an mp3 file into a sound object and start playing it at the desired <code>playbackSpeed</code>. <code>stop</code> will stop the currently playing mp3. And <code>playLoadedSound</code> will start playing an already loaded sound object at the desired <code>playbackSpeed</code>. This is useful if you have already preloaded your sound objects but it is also useful for another important reason as you can see in the demo.</p>

<p>Thanks to <a href="http://www.flexiblefactory.co.uk/flexible/?p=46">some great work</a> from an old friend of mine, it is possible to dynamically create a Sound object based on an <span class="caps">MP3 </span>loaded through the new <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/net/FileReference.html#load()">FileReference.load()</a> functionality in Flash 10. This is why in the demo you can browse for an mp3 file on your local machine which can then be dynamically controlled by Flash immediately without sending it to a server first.</p>

<p>You can download the complete <span class="caps">FDT </span>project of my demo <a href='/wp-content/uploads/2008/11/dynamic_mp3_player.zip'>here</a> if you want to look through all of the code. I&#8217;m excited by the possibilities that are opening up in flash now that Adobe <a href="http://www.make-some-noise.info/">made some noise</a> - I&#8217;ve got a long way to go before I can do anything nearly as incredible as the <a href="http://www.hobnox.com/audiotool">Hobnox audio tool</a> but I&#8217;ve got some ideas and I&#8217;m looking forward to playing around with them :)</p>]]></content:encoded>
			<wfw:commentRss>http://www.kelvinluck.com/2008/11/first-steps-with-flash-10-audio-programming/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Experiment with Papervision 3D particles and effects</title>
		<link>http://www.kelvinluck.com/2008/11/experiment-with-papervision-3d-particles-and-effects/</link>
		<comments>http://www.kelvinluck.com/2008/11/experiment-with-papervision-3d-particles-and-effects/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 00:59:54 +0000</pubDate>
		<dc:creator>Kelvin Luck</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[example]]></category>

		<category><![CDATA[papervision3d]]></category>

		<category><![CDATA[sourcecode]]></category>

		<guid isPermaLink="false">http://www.kelvinluck.com/?p=455</guid>
		<description><![CDATA[A while back I was prototyping something for a client which involved lots of red dots moving around in 3D space, realised using Papervision 3D. I didn&#8217;t end up persuing this route with the client in the end but the effect was pretty cool so I thought I might as well share it here.

The idea [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I was prototyping something for a client which involved lots of red dots moving around in 3D space, realised using <a title="Papervision 3D" href="http://code.google.com/p/papervision3d/">Papervision 3D</a>. I didn&#8217;t end up persuing this route with the client in the end but the effect was pretty cool so I thought I might as well share it here.</p>

<p>The idea is that there is a bunch of particles who are bouncing around randomly stuck within an invisible cube. The effect looked OK by itself but then I decided to try adding effects. I used a BlurFilter and a BitmapColorEffect to give the each of the particles trails. Then I changed the clipping point like in the original <a title="Borg cube papervision effects demo" href="http://blog.zupko.info/?p=76">borg cube effects demo</a> to give the impression of the particles falling. I like this version the best - if you move your mouse from side to side around the bottom of the demo swf then it starts to look like some kind of flocking is going on (like in my <a title="My experiment with perlin noise in as3" href="http://www.kelvinluck.com/2007/11/flash-on-the-beach-and-some-perlin-noise/">perlin noise experiment</a>).</p>

Click on the image below to see the demo. Click inside the demo swf to give it focus and then you can use the following keys:<br />
<ul>
	<li><strong>1</strong> - Sets the render mode to normal clean particles (the default).</li>
	<li><strong>2</strong> - Sets the render mode to particles with trails.</li>
	<li><strong>3</strong> - Sets the render mode to falling particles with trails.</li>
	<li><strong>c</strong> - Toggles display of a cube showing the area the particles are contained within.</li>
</ul>

<p><a href="http://www.kelvinluck.com/wp-content/uploads/2008/11/particlescube.swf" rel="shadowbox;width=450;height=450;"><img title="Particles and effects in Papervision 3D" src="http://www.kelvinluck.com/wp-content/uploads/2008/11/papervision_particles.png" alt="Particles and effects in Papervision 3D" width="450" height="450" /></a></p>

<p>The sourcecode for this example is pretty simple. You can see it below or you can download it from <a title="Sourcecode for particle cube experiment" href="http://www.kelvinluck.com/wp-content/uploads/2008/11/particlescube.as">here</a>.</p>

<div class="actionscript3 code actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> &nbsp;<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.core.effects.BitmapColorEffect;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.core.effects.BitmapLayerEffect;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.core.geom.Particles;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.WireframeMaterial;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.utils.MaterialsList;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.objects.DisplayObject3D;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.objects.primitives.Cube;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.view.AbstractView;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.view.BasicView;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.view.layer.BitmapEffectLayer;<br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<a href="http://www.google.com/search?q=stagequality%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:stagequality.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">StageQuality</span></a>;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Event</span></a>;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<a href="http://www.google.com/search?q=keyboardevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:keyboardevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">KeyboardEvent</span></a>;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.filters</span>.<a href="http://www.google.com/search?q=blurfilter%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:blurfilter.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">BlurFilter</span></a>;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a>; &nbsp; &nbsp; &nbsp;<br />
<br />
&nbsp; &nbsp;<span style="color: #3f5fbf;">/**<br />
&nbsp; &nbsp; * @author Kelvin Luck<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp;<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">'450'</span>, <span style="color: #004993;">height</span>=<span style="color: #990000;">'450'</span>, <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">'#000000'</span>, <span style="color: #004993;">frameRate</span>=<span style="color: #990000;">'41'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ParticlesCube extends BasicView <br />
&nbsp; &nbsp;<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #0033ff; font-weight: bold;">static</span> <span style="color: #6699cc; font-weight: bold;">const</span> NUM_PARTICLES<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">300</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #0033ff; font-weight: bold;">static</span> <span style="color: #6699cc; font-weight: bold;">const</span> CONTAINING_CUBE_SIZE<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">500</span>;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #0033ff; font-weight: bold;">static</span> <span style="color: #6699cc; font-weight: bold;">const</span> RENDER_MODE_CLEAN<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #0033ff; font-weight: bold;">static</span> <span style="color: #6699cc; font-weight: bold;">const</span> RENDER_MODE_TRAILS<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">1</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #0033ff; font-weight: bold;">static</span> <span style="color: #6699cc; font-weight: bold;">const</span> RENDER_MODE_FALLING<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">2</span>;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> particlesContainer<span style="color: #000000; font-weight: bold;">:</span>DisplayObject3D;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> particlesHolder<span style="color: #000000; font-weight: bold;">:</span>Particles;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> particles<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Array</span></a>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> boundsCube<span style="color: #000000; font-weight: bold;">:</span>Cube;<br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> bfx<span style="color: #000000; font-weight: bold;">:</span>BitmapEffectLayer;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _renderMode<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> renderMode<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span> == _renderMode<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clearBitmapEffects<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> clippingPoint<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> RENDER_MODE_CLEAN<span style="color: #000000; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">// nothing - effects already cleared above...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> RENDER_MODE_FALLING<span style="color: #000000; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clippingPoint.<span style="color: #004993;">y</span> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">// fall through...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> RENDER_MODE_TRAILS<span style="color: #000000; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bfx = <span style="color: #0033ff; font-weight: bold;">new</span> BitmapEffectLayer<span style="color: #000000;">&#40;</span>viewport, <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>, <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span>, <span style="color: #0033ff; font-weight: bold;">true</span>, 0xffffff<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bfx.addEffect<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> BitmapLayerEffect<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=blurfilter%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:blurfilter.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">BlurFilter</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span>, <span style="color: #000000; font-weight:bold;">2</span>, <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bfx.addEffect<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> BitmapColorEffect<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #000000; font-weight:bold;">1</span>, .9<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bfx.clippingPoint = clippingPoint;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bfx.addDisplayObject3D<span style="color: #000000;">&#40;</span>particlesHolder<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;viewport.containerSprite.addLayer<span style="color: #000000;">&#40;</span>bfx<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">default</span><span style="color: #000000; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">throw</span> <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=error%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:error.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Error</span></a><span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">' is an invalid render mode'</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_renderMode = <span style="color: #004993;">value</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _displayCube<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Boolean</span></a> = <span style="color: #0033ff; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> displayCube<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Boolean</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span> <span style="color: #000000; font-weight: bold;">!</span>= _displayCube<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _displayCube = <span style="color: #004993;">value</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; boundsCube.<span style="color: #004993;">visible</span> = <span style="color: #004993;">value</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ParticlesCube<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">550</span>, <span style="color: #000000; font-weight:bold;">550</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">stage</span>.<span style="color: #004993;">quality</span> = <a href="http://www.google.com/search?q=stagequality%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:stagequality.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">StageQuality</span></a>.<span style="color: #004993;">MEDIUM</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;particlesContainer = <span style="color: #0033ff; font-weight: bold;">new</span> DisplayObject3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scene.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>particlesContainer<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> cubeMaterial<span style="color: #000000; font-weight: bold;">:</span>WireframeMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> WireframeMaterial<span style="color: #000000;">&#40;</span>0x0000ff, <span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> materialsList<span style="color: #000000; font-weight: bold;">:</span>MaterialsList = <span style="color: #0033ff; font-weight: bold;">new</span> MaterialsList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;materialsList.addMaterial<span style="color: #000000;">&#40;</span>cubeMaterial, <span style="color: #990000;">'all'</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;boundsCube = <span style="color: #0033ff; font-weight: bold;">new</span> Cube<span style="color: #000000;">&#40;</span>materialsList, CONTAINING_CUBE_SIZE, CONTAINING_CUBE_SIZE, CONTAINING_CUBE_SIZE<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;particlesContainer.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>boundsCube<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;displayCube = <span style="color: #0033ff; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;particlesHolder = <span style="color: #0033ff; font-weight: bold;">new</span> Particles<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;particlesContainer.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>particlesHolder<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>NUM_PARTICLES, CONTAINING_CUBE_SIZE<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=keyboardevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:keyboardevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">KeyboardEvent</span></a>.<span style="color: #004993;">KEY_DOWN</span>, onKeyDown<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;startRendering<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>numParticles<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a>, containingCubeSize<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> movingParticle<span style="color: #000000; font-weight: bold;">:</span>MovingParticle;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>particles<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; particlesHolder.removeAllParticles<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;particles = <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = numParticles;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">while</span> <span style="color: #000000;">&#40;</span>i<span style="color: #000000; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; movingParticle = <span style="color: #0033ff; font-weight: bold;">new</span> MovingParticle<span style="color: #000000;">&#40;</span>containingCubeSize<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; particlesHolder.addParticle<span style="color: #000000;">&#40;</span>movingParticle<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; particles.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>movingParticle<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> onRenderTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Event</span></a> = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">// move each particle</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> movingParticle<span style="color: #000000; font-weight: bold;">:</span>MovingParticle;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span>movingParticle <span style="color: #0033ff; font-weight: bold;">in</span> particles<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; movingParticle.<span style="color: #004993;">position</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">// twist the container based on mouse position</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;particlesContainer.rotationY<span style="color: #000000; font-weight: bold;">+</span>=<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">mouseX</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">200</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;particlesContainer.rotationX<span style="color: #000000; font-weight: bold;">+</span>=<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">200</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">// render</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">super</span>.onRenderTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> clearBitmapEffects<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>bfx<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; viewport.containerSprite.removeLayer<span style="color: #000000;">&#40;</span>bfx<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bfx = <span style="color: #0033ff; font-weight: bold;">null</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onKeyDown<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=keyboardevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:keyboardevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">KeyboardEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a>.<span style="color: #004993;">fromCharCode</span><span style="color: #000000;">&#40;</span>event.<span style="color: #004993;">keyCode</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">'1'</span><span style="color: #000000; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;renderMode = RENDER_MODE_CLEAN;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">'2'</span><span style="color: #000000; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;renderMode = RENDER_MODE_TRAILS;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">'3'</span><span style="color: #000000; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;renderMode = RENDER_MODE_FALLING;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">'c'</span><span style="color: #000000; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">'C'</span><span style="color: #000000; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;displayCube = <span style="color: #000000; font-weight: bold;">!</span>_displayCube;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.core.geom.renderables.Particle;<br />
<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.special.ParticleMaterial;<br />
<br />
<span style="color: #0033ff; font-weight: bold;">internal</span> <span style="color: #9900cc; font-weight: bold;">class</span> MovingParticle extends Particle <br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #0033ff; font-weight: bold;">static</span> <span style="color: #6699cc; font-weight: bold;">const</span> PARTICLE_SIZE<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">10</span>;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #0033ff; font-weight: bold;">static</span> <span style="color: #6699cc; font-weight: bold;">const</span> MAX_SPEED<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">5</span>;<br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> dX<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a>;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> dY<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a>;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> dZ<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a>;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> halfSize<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Number</span></a>;<br />
<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MovingParticle<span style="color: #000000;">&#40;</span>containingCubeSize<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> mat<span style="color: #000000; font-weight: bold;">:</span>ParticleMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> ParticleMaterial<span style="color: #000000;">&#40;</span>0xff0000, <span style="color: #000000; font-weight:bold;">1</span>, ParticleMaterial.SHAPE_CIRCLE<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>mat, PARTICLE_SIZE<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">size</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = containingCubeSize;<br />
&nbsp; &nbsp; &nbsp; halfSize = <span style="color: #004993;">size</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span>;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span> = <span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Math</span></a>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #004993;">size</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">-</span> halfSize;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span> = <span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Math</span></a>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #004993;">size</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">-</span> halfSize;<br />
&nbsp; &nbsp; &nbsp; z = <span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Math</span></a>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #004993;">size</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">-</span> halfSize;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; dX = <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Math</span></a>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> MAX_SPEED;<br />
&nbsp; &nbsp; &nbsp; dY = <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Math</span></a>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> MAX_SPEED;<br />
&nbsp; &nbsp; &nbsp; dZ = <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Math</span></a>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> MAX_SPEED;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">position</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp;<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span>= dX;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">&gt;</span> halfSize <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">-</span>halfSize<span style="color: #000000;">&#41;</span> dX <span style="color: #000000; font-weight: bold;">*</span>= <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span>= dY;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">&gt;</span> halfSize <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">-</span>halfSize<span style="color: #000000;">&#41;</span> dY <span style="color: #000000; font-weight: bold;">*</span>= <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span>;<br />
&nbsp; &nbsp; &nbsp; z <span style="color: #000000; font-weight: bold;">+</span>= dZ;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>z <span style="color: #000000; font-weight: bold;">&gt;</span> halfSize <span style="color: #000000; font-weight: bold;">||</span> z <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">-</span>halfSize<span style="color: #000000;">&#41;</span> dZ <span style="color: #000000; font-weight: bold;">*</span>= <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span>;<br />
&nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #009900;">// This line is just to stop the code formatter on my blog getting confused! &gt;</span></div>]]></content:encoded>
			<wfw:commentRss>http://www.kelvinluck.com/2008/11/experiment-with-papervision-3d-particles-and-effects/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jScrollPane 1.2 released</title>
		<link>http://www.kelvinluck.com/2008/11/jscrollpane-12-released/</link>
		<comments>http://www.kelvinluck.com/2008/11/jscrollpane-12-released/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 22:02:29 +0000</pubDate>
		<dc:creator>Kelvin Luck</dc:creator>
		
		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[jscrollpane]]></category>

		<category><![CDATA[sourcecode]]></category>

		<guid isPermaLink="false">http://www.kelvinluck.com/?p=449</guid>
		<description><![CDATA[I&#8217;ve just released a new version of jScrollPane - my jQuery plugin for cross-browser customisable scrollbars. It&#8217;s been a long time since the plugin has been updated and this release contains a number of significant improvements:

	a jScrollPane now correctly scrolls when you tab to a focusable element within it [example]
	a jScrollPane can now automatically re-initialise [...]]]></description>
			<content:encoded><![CDATA[I&#8217;ve just released a new version of <a title="jScrollPane - cross browser customisable scrollbars" href="http://www.kelvinluck.com/projects/jscrollpane-custom-cross-browser-scrollbars/">jScrollPane</a> - my <a title="jQuery javascript library" href="http://www.jquery.com/">jQuery</a> plugin for cross-browser customisable scrollbars. It&#8217;s been a long time since the plugin has been updated and this release contains a number of significant improvements:<br />
<ul>
	<li>a jScrollPane now correctly scrolls when you tab to a focusable element within it [<a title="Example of jScrollPane updating when you tab inside it" href="http://www.kelvinluck.com/assets/jquery/jScrollPane/tabFormFieldExample.html">example</a>]</li>
	<li>a jScrollPane can now automatically re-initialise itself when images inside it load [<a title="a jScrollPane automatically re-initialising itself when the images inside it load" href="http://www.kelvinluck.com/assets/jquery/jScrollPane/imagesExample.html">example</a>]</li>
	<li>external (and internal) links to an anchor within a jScrollPane now correctly scroll the jScrollPane [<a title="An example of jScrollPane correctly scrolling when anchors within it are visited" href="http://www.kelvinluck.com/assets/jquery/jScrollPane/jumpToExternalAnchorExample.html#marker">example</a>]</li>
	<li>defaults settings are now user-settable [<a title="An example of setting the default options for all jScrollPanes on a page" href="http://www.kelvinluck.com/assets/jquery/jScrollPane/defaultOptions.html">example</a>]</li>
</ul>
In addition to these changes, jScrollPane now has a <a title="jScrollPane on googlecode" href="http://code.google.com/p/jscrollpane/">new home on googlecode</a>. This makes it easier for people to keep up to date with the latest version and more importantly it makes it easier for me to track <a title="Bug reports for jScrollPane" href="http://code.google.com/p/jscrollpane/issues/list">bug reports and issues</a> with jScrollPane (something that was basically impossible on the <a href="http://plugins.jquery.com/project/jScrollPane">jQuery plugins site</a>). As you can see, there is already a number of issues raised (one of which has high priority) so there may well be a bug fix release soon. In the meantime, it would be good to get people testing the new release and seeing if I broke anything else while implementing these changes&#8230;<br />
<div class="update">
<h2>Update:</h2>
jScrollPane 1.2.1 was released very shortly after 1.2 to fix <a href="http://code.google.com/p/jscrollpane/issues/detail?id=13">a fairly serious bug</a> which prevented links within the scroll pane from working correctly. As always, the googlecode site has the latest version.</div>]]></content:encoded>
			<wfw:commentRss>http://www.kelvinluck.com/2008/11/jscrollpane-12-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Now running on wordpress</title>
		<link>http://www.kelvinluck.com/2008/11/now-running-on-wordpress/</link>
		<comments>http://www.kelvinluck.com/2008/11/now-running-on-wordpress/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 21:49:59 +0000</pubDate>
		<dc:creator>Kelvin Luck</dc:creator>
		
		<category><![CDATA[off-topic]]></category>

		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.kelvinluck.com/?p=411</guid>
		<description><![CDATA[I&#8217;ve finally got around to updating my website and it is now running on the latest, greatest version of Wordpress. After many years of fighting against Textpattern and never updating the blog because it was such a hassle I&#8217;ve come kicking and screaming into the 21st century. And I have to say I&#8217;m pretty pleased [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finally got around to updating my website and it is now running on the latest, greatest version of <a href="http://www.wordpress.org/">Wordpress</a>. After many years of fighting against Textpattern and never updating the blog because it was such a hassle I&#8217;ve come kicking and screaming into the 21st century. And I have to say I&#8217;m pretty pleased so far with Wordpress&#8230; It was pretty easy to import my database from the the old Textpattern install and then it was just a case of going through and making sure all of my content wasn&#8217;t relying on any plugins I had installed in Textpattern.</p>

<p>For a theme, I started from <a href="http://code.google.com/p/daydreams/">Daydreams 2</a> by <a href="http://jway.com.cn/">J</a> but I found that there were lots of bits and pieces I wanted to change so I forked it into my own theme that I could add what I liked to it (including the random headers and <a href="http://www.mjijackson.com/shadowbox/">Shadowbox</a> support for displaying embedded flash) and fix a few bugs to make the generated <span class="caps">HTML </span>validate.</p>

I also installed a few plugins straight away:<br />
<ul>
	<li><a title="View the plugins page" href="http://wordpress.org/extend/plugins/textile-2">Textile2</a> helped by formatting all of my old posts imported from Textpattern (I first tried <a title="Visit plugin homepage" href="http://www.huddledmasses.org/category/development/wordpress/textile/">TextileWrapper</a> but had issues with it adding extra P tags).</li>
	<li><a title="Visit plugin homepage" href="http://www.huddledmasses.org/category/development/wordpress/textile/">GeshiWrapper</a> did likewise for sourcecode examples.</li>
	<li><a title="Visit plugin homepage" href="http://wordpress.org/extend/plugins/stats/">WordPress.com Stats</a> should let me know a little more about my visitors.</li>
	<li><a title="Visit plugin homepage" href="http://jeroensmeets.net/lastfmrecords/">Last.Fm Records</a> lets me put my most recent popular album covers in the sidebar.</li>
	<li><a title="Visit plugin homepage" href="http://ideasilo.wordpress.com/2007/04/30/contact-form-7/">Contact Form 7</a> does my contact page.</li>
	<li><a title="Visit plugin homepage" href="http://rick.jinlabs.com/code/delicious/">Delicious for wordpress</a> lets me put my latest links from delicious in the sidebar.</li>
	<li><a title="Visit plugin homepage" href="http://semperfiwebdesign.com/">All in One <span class="caps">SEO</span> Pack</a> might just help improve my search engine rankings.</li>
	<li><a title="Visit plugin homepage" href="http://akismet.com/">Akismet</a> should hopefully stop the comment spam and maybe I won&#8217;t need to moderate all my comments any more.</li>
	<li><a title="Visit plugin homepage" href="http://wordpress.org/extend/plugins/404-notifier/">404-notifier</a> should show me any <span class="caps">URL</span>s that I broke when I did the move.</li>
	<li><a title="Visit plugin homepage" href="http://wordpress.org/extend/plugins/live-comment-preview/">Live Comment Preview</a> is a little bit of javascript niceness for when people are leaving comments.</li>
</ul>
We&#8217;ll see as everthing settles into place if they all behave as expected and if I discover I want or need anything else&#8230;

<p>Because everything probably didn&#8217;t transfer correctly from the old site I have left it available at this <span class="caps">URL </span>(2005 was the year I started that blog):</p>

<p><a href="http://2005.kelvinluck.com/">http://2005.kelvinluck.com/</a></p>

<p>I&#8217;m still fiddling around with the theme (I&#8217;m not really happy with the headers at the moment) and the feeds to try and get everything working just so but hopefully the site is all functional and I will now be able to easily create new content so hopefully I&#8217;ll start doing it a bit more frequently&#8230;</p>

<p>And sorry to anyone who was subscribed to my <span class="caps">RSS&#8230;</span> I fear I may have spammed you all with my old content as part of this move.</p>]]></content:encoded>
			<wfw:commentRss>http://www.kelvinluck.com/2008/11/now-running-on-wordpress/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New multiplayer papervision game</title>
		<link>http://www.kelvinluck.com/2008/10/new-multiplayer-papervision-game/</link>
		<comments>http://www.kelvinluck.com/2008/10/new-multiplayer-papervision-game/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 21:57:00 +0000</pubDate>
		<dc:creator>Kelvin Luck</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[flex]]></category>

		<category><![CDATA[games]]></category>

		<category><![CDATA[competition]]></category>

		<category><![CDATA[multiplayer]]></category>

		<guid isPermaLink="false">http://nb.kelvinluck.com/?p=69</guid>
		<description><![CDATA[I&#8217;ve just released my entry into the Nonoba Multiplayer API Kick Off competition. It&#8217;s a multiplayer take on the old memory cards game where you have to turn over pairs of cards and try to remember what was under each one. The multiplayer aspect makes it much more frantic and fun as other players are [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released my entry into the <a href="http://nonoba.com/developers/contests/multiplayerapikickoff">Nonoba Multiplayer <span class="caps">API</span> Kick Off</a> competition. It&#8217;s a multiplayer take on the old memory cards game where you have to turn over pairs of cards and try to remember what was under each one. The multiplayer aspect makes it much more frantic and fun as other players are looking at the same cards at the same time as you and you don&#8217;t want them to steal your pairs!</p>

It will probably make more sense if you try it out yourself so go ahead and click the image below to play multiplayer memory mayhem!<br />
<div><a rel="shadowbox;width=842;height=556" href="http://www.kelvinluck.com/wp-content/uploads/2008/11/mmm.swf"><img title="Multiplayer Memory Mayhem" src="http://www.kelvinluck.com/wp-content/uploads/2008/11/ss2_export.jpg" alt="" width="450" height="390" /></a></div>
My good friend <a href="http://www.hoppermagic.com/">Leigh Kayley</a> did the designs (including illustrating all of the cool animals) and I built the game using <a href="http://www.papervision3d.org/">Papervision</a>, <a href="http://puremvc.org/">PureMVC</a>, <a href="http://www.gskinner.com/libraries/gtween/">GTween</a> and the <a href="http://nonoba.com/developers/multiplayerapi/overview">Nonoba multiplayer <span class="caps">API</span></a>.

<p>While I was building the game I did a little prototype for the score board transitions using papervision which you can see by clicking the image below. Click anywhere in the movie to give a random player some random points (and so maybe rearrange the scores) and press any keyboard key to toggle some mouse following behaviour.</p>

<p><a class="shadowbox" title="Papervision 3D score panels test" rel="shadowbox;width=400;height=400;" href="http://www.kelvinluck.com/assets/papervision3d/ScoreTest.swf"><img src="http://www.kelvinluck.com/wp-content/uploads/2008/11/noname.png" alt="Papervision 3D score panels test" width="400" height="400" /></a></p>

Unfortunately in the game you can&#8217;t really see the 3d transitions on the scores so I thought I&#8217;d upload this for people to look at. And I&#8217;ve also uploaded the <a href="/assets/papervision3d/ScoreTest.as">source code</a> for anyone who is interested. It&#8217;s probably not the best because it was a prototype stuck together quickly but it may be useful to someone&#8230;<br />
<div class="update">
<h2>Update:</h2>
I&#8217;m pleased to say that Multiplayer Memory Mayhem won third prize in the multiplayer kickoff competion on <a href="http://www.nonoba.com">Nonoba</a>&#8230; Yay!</div>]]></content:encoded>
			<wfw:commentRss>http://www.kelvinluck.com/2008/10/new-multiplayer-papervision-game/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Wave Sequencer experiment</title>
		<link>http://www.kelvinluck.com/2008/03/wave-sequencer-experiment/</link>
		<comments>http://www.kelvinluck.com/2008/03/wave-sequencer-experiment/#comments</comments>
		<pubDate>Sun, 16 Mar 2008 19:01:00 +0000</pubDate>
		<dc:creator>Kelvin Luck</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[audio]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[conference]]></category>

		<guid isPermaLink="false">http://nb.kelvinluck.com/?p=68</guid>
		<description><![CDATA[After getting inspired by Andre Michelle at FitC Amsterdam I made a little audio experiment which allows you to slice and dice a wav file...]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago I attended the <a href="http://www.fitc.ca/event_detail.cfm?festival_id=29">FitC Amsterdam</a> conference which was great fun. One of the most inspiring sessions I saw was <a href="http://blog.andre-michelle.com/">Andre Michelle</a>&#8217;s &#8220;Making <span class="caps">REAL</span> Music Within Flash&#8221; where he talked us through generating sound in flash using the <a href="http://blog.davr.org/2006/04/21/dynamic-sound-in-85">infamous flash sound hack</a> and then showed us how he is redefining what should be possible in flash by building the <a href="http://blog.andre-michelle.com/2008/hobnox-audiotool-guided-tour-video/">hobnox audio tool</a>.</p>

<p>I travelled to Amsterdam by <a href="http://www.seat61.com/Netherlands.htm#train+ferry">train and ferry</a> which meant that I had some spare time on the way back to play and luckily Andre and <a href="http://blog.je2050.de/">Joa Ebert</a> have released the complex code behind the flash sound hack as part of their <a href="http://www.popforge.de/">popforge</a> open source library.</p>

<p>So I built my Wave Sequencer. The idea is that it loads in a wav file and splits it into 16 equally sized chunks. You can then re-arrange these chunks to create new variations on the beat. Each 16 chunk section is a pattern and you can create up to 16 different patterns by choosing different patterns from the &#8220;pattern bank&#8221; at the bottom of the screen.</p>

<p>The loop I&#8217;m using is the famous <a href="http://en.wikipedia.org/wiki/Amen_break">Amen break</a> and I&#8217;ve sped it up a bit (and given you a slider so you can control the speed yourself). If you play around with it you&#8217;ll see you can slice and dice your own <a href="http://youtube.com/watch?v=SrvW4gEI-7E">old skool jungle riddims</a> :)</p>

<p><a href="http://www.kelvinluck.com/wp-content/uploads/2008/11/wavesequencer.swf" rel="shadowbox;width=600;height=200;flashbaseurl=http://www.kelvinluck.com/wp-content/uploads/2008/11/;" class="shadowbox" title="Wave Sequencer Experiment"><img src="http://www.kelvinluck.com/wp-content/uploads/2008/11/wav_sequencer.gif" alt="Screenshot of Wave Sequencer Experiment" width="450" height="139" /></a></p>

<p><strong>Note</strong>: If you are experiencing choppy audio then you are probably running the latest revision of the flash player (9.0.115.0) which  <a href="http://blog.andre-michelle.com/2007/198/">breaks onSoundComplete</a>. So join the petition and ask Adobe to <a href="http://www.adobemakesomenoise.com/">make some noise</a>. I&#8217;ve compiled a standalone version of the app against the older 9.0.28.0 player and you can download the <a href="http://www.kelvinluck.com/assets/wavesequencer/pc_standalone.zip">PC standalone version</a> which doesn&#8217;t have the audio issues.</p>

<p>Obviously this little experiment is very rough around the edges and there is a lot that can be done to improve it but I&#8217;ve been too busy with &#8220;real work&#8221; to look at it in the weeks since I got back from FitC and I thought it was better to publish it as is than to leave it to get lost on my hard drive&#8230;</p>

<p>My code here is really simple, all of the complex stuff is done by the <a href="http://www.popforge.de/">popforge</a> library. So big thanks to Andre for the inspiration and the sourcecode :) Hopefully I&#8217;ll find some time in the coming months to take this a lot further and to turn it into an <a href="http://www.adobe.com/products/air/"><span class="caps">AIR</span></a> app which is actually useful!</p>]]></content:encoded>
			<wfw:commentRss>http://www.kelvinluck.com/2008/03/wave-sequencer-experiment/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Wellcome Trust competition</title>
		<link>http://www.kelvinluck.com/2008/02/wellcome-trust-competition/</link>
		<comments>http://www.kelvinluck.com/2008/02/wellcome-trust-competition/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 22:12:13 +0000</pubDate>
		<dc:creator>Kelvin Luck</dc:creator>
		
		<category><![CDATA[flash]]></category>

		<category><![CDATA[flashr]]></category>

		<category><![CDATA[flickr]]></category>

		<category><![CDATA[as2]]></category>

		<category><![CDATA[competition]]></category>

		<category><![CDATA[games]]></category>

		<guid isPermaLink="false">http://nb.kelvinluck.com/?p=67</guid>
		<description><![CDATA[Details about my entry into a flash competition held by the Wellcome Trust, BD4D and Ico Design...]]></description>
			<content:encoded><![CDATA[<p>A few months back I heard about a competition being organised by <a href="http://www.icodesign.co.uk/">Ico Design</a>, <a href="http://www.bd4d.com"><span class="caps">BD4D</span></a> and the <a href="http://www.wellcome.ac.uk/">Wellcome Trust</a>. The idea behind this competition was to &#8220;produce an interactive Flash piece that is playful and engaging using at least 2 words from the Word Soup&#8221;. The &#8220;Word Soup&#8221; is a collection of words that form part of the branding for the <a href="http://www.wellcomecollection.org/">Wellcome Collection</a>.</p><p>I managed to scrape together a little bit of time so I put together an entry. It was a mashup between the provided words and <a href="http://www.flickr.com/">Flickr</a>. I built it using <a href="http://flashr.kelvinluck.com">Flashr</a> and skinned it with a nice clean design knocked up by my good friend <a href="http://www.hoppermagic.com/">Leigh Kayley</a> (based on the look and feel of the <a href="http://www.wellcomecollection.org/scramblegame/">scramble</a> game we found on the Wellcome collection&#8217;s site).</p><p><a rel="shadowbox" href="http://www.kelvinluck.com/wp-content/uploads/2008/11/word_soup.jpg"><img title="Word Soup - my flickr based game at the wellcome collection" src="http://www.kelvinluck.com/wp-content/uploads/2008/11/word_soup-450x189.jpg" alt="" width="450" height="189" /></a></p><p>The entry is described quite succinctly in an <a href="http://www.designweek.co.uk/Articles/137421/Word+pictures.html">article in Design Week</a> so I&#8217;ll borrow their words:</p><blockquote>Kelvin Luck asks us to look at images plucked from Flickr and choose from the wordsoup which one was used to tag the picture. It is harder than you think: what word could describe a masked woman in a spangly bikini who is wielding a chainsaw? Clue: it is not what you might think.</blockquote><p>If that doesn&#8217;t explain it then you can <a href="http://www.wellcomecollection.org/exhibitionsandevents/onlineexhibits/index.htm?deepLink=Kelvin_Luck_Word_Soup">play it yourself</a> and see if you can get on the high scores. It can be frustrating at times because some people tag their photos a bit randomly but that adds to the adictiveness :)</p><p>Last night I was invited to the launch event for the <a href="http://www.wellcomecollection.org/exhibitionsandevents/onlineexhibits/index.htm">new online exhibits</a> site (where all of the competition entries are showcased) and the announcement of the competition&#8217;s winners. I was very surprised and pleased to find out that my entry got the second prize! Yay :)</p><p>I&#8217;d recommend checking out the site to see the many cool entries and the very nice innovative interface for finding them (also courtesy of <a href="http://www.icodesign.co.uk">Ico Design</a>)</p>]]></content:encoded>
			<wfw:commentRss>http://www.kelvinluck.com/2008/02/wellcome-trust-competition/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flash on the Beach and some Perlin Noise</title>
		<link>http://www.kelvinluck.com/2007/11/flash-on-the-beach-and-some-perlin-noise/</link>
		<comments>http://www.kelvinluck.com/2007/11/flash-on-the-beach-and-some-perlin-noise/#comments</comments>
		<pubDate>Tue, 13 Nov 2007 23:24:00 +0000</pubDate>
		<dc:creator>Kelvin Luck</dc:creator>
		
		<category><![CDATA[AS3]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[experiment]]></category>

		<category><![CDATA[perlin noise]]></category>

		<category><![CDATA[sourcecode]]></category>

		<guid isPermaLink="false">http://nb.kelvinluck.com/?p=66</guid>
		<description><![CDATA[A very brief review of Flash on the Beach and then some examples of some code using perlin noise to produce flocking like behaviour that the conference inspired me to write...]]></description>
			<content:encoded><![CDATA[<p>Last week I went to the <a href="http://www.flashonthebeach.com/">Flash on the Beach</a> conference and as has been said by many people, it was amazing.</p>

<p>I decided to go for more of the inspirational rather than technical sessions and saw some absolutely amazing speakers including (in order of appearance): Hoss Gifford, Joshua Davis, Brendan Dawes, Craig Swann, Mario Klingemann, Robert Hodgin, Erik Natzke, Chris Allen, Dr Woohoo, Andre Michelle, Marcos Weskamp and Jared Tarbell. Wow!</p>

<p>And as well as all these amazing talks there was the opportunity to meet loads of friends - old and new - and to chat about geeky stuff. And then there was all of the booze and the parties&#8230; And <a href="http://www.flickr.com/photos/quasimondo/1919693775/">a girl in a box</a>!</p>

<p>Anyway, one particular example from <a href="http://www.flight404.com/">Robert</a> got me thinking and wanting to play&#8230; He mentioned the PerlinNoise function and talked about how it could be used to simulate flocking. And he showed a slide where a perlin noise image had been used to set the rotation of a set of arrows displayed on top of it. I wanted to play with this and had a little bit of time over the weekend so I managed to come up with this:</p>

<p><a href="http://www.kelvinluck.com/assets/perlin_noise_experiments/PerlinArrows_r13.swf" rel="shadowbox;width=400;height=400;" class="shadowbox" title="My perlin creatures"><img src="http://www.kelvinluck.com/wp-content/uploads/2008/11/perlin_creatures.jpg" alt="My perlin creatures" width="400" height="400" /></a></p>

<p>It&#8217;s really simple stuff - you can get the sourcecode and see the process that it evolved through <a href="http://www.kelvinluck.com/assets/perlin_noise_experiments">here</a>. The code isn&#8217;t beautiful or optimised as I was trying to concentrate on playing rather than doing it right (a concept which seemed to be a recurring theme of the conference).</p>

<p>And I wasn&#8217;t the only one who got interested by Robert&#8217;s mention of perlin noise. Seb Lee-Delisle posted on Sunday about <a href="http://www.sebleedelisle.com/?p=134">3D Perlin Noise in Flash</a> - it looks like a really interesting way to take this further. I can&#8217;t wait to see what he comes up with and hopefully to find some more time to play with it myself :)</p>]]></content:encoded>
			<wfw:commentRss>http://www.kelvinluck.com/2007/11/flash-on-the-beach-and-some-perlin-noise/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flash CS3 trial breaks Juniper Network Connect</title>
		<link>http://www.kelvinluck.com/2007/11/flash-cs3-trial-breaks-juniper-network-connect/</link>
		<comments>http://www.kelvinluck.com/2007/11/flash-cs3-trial-breaks-juniper-network-connect/#comments</comments>
		<pubDate>Fri, 09 Nov 2007 12:36:00 +0000</pubDate>
		<dc:creator>Kelvin Luck</dc:creator>
		
		<category><![CDATA[flash]]></category>

		<category><![CDATA[general]]></category>

		<category><![CDATA[error]]></category>

		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://nb.kelvinluck.com/?p=65</guid>
		<description><![CDATA[A quick tip for anyone having trouble connecting to a VPN powered by Juniper software's "Network Connect" after installing the trial version of Flash CS3...]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a long time since I&#8217;ve posted here because I have been crazily busy working on a massive <a href="http://www.flex.org/">flex</a> site with a great team over at <a href="http://www.tribalddb.co.uk/">Tribal <span class="caps">DDB</span> London</a>. Hopefully it will go live at the start of next year so I can talk more about it. In the meantime, here is a quick tip for anyone having trouble connecting to a <span class="caps">VPN </span>powered by Juniper software&#8217;s <a href="http://www.juniper.net/products_and_services/index.html?from=HomePage-Header-to-ProductsServices">Network Connect</a> after installing the trial version of Flash <span class="caps">CS3.</span></p>

<p>After installing a trial of Flash <span class="caps">CS3</span> I noticed that I became unable to connect to the <span class="caps">VPN.</span> Network Connect would connect briefly and then pop up an alert saying &#8220;The Network Connect session terminated. Do you want to reconnect? (nc.windows.app.23711).&#8221;</p>

<p>After a bit of googling I found out that there were complaints about the early betas of <span class="caps">CS3 </span>and the <a href="http://www.apple.com/macosx/technology/bonjour.html">Bonjour</a> service that they installed affecting networking. And this is what was causing my problem. If you press Ctrl-Alt-Del and look at your processes then you will find a &#8220;mDNSResponder.exe&#8221; service running after installing Flash <span class="caps">CS3.</span> Ending this process allows you to connect through Network Connect.</p>

<p>You will have to do this every time you have restarted your computer as the process is automatically started with the system. Alternatively you can stop the service which starts the mDNSResponder process.</p>

<p>Go to Start Menu &gt; Run and type in &#8220;services.msc&#8221; to open the services configuration panel. Look for a service with a name something like &#8220;##Id_String1.6844F930_1628_4223_B5CC_5BB94B879762##&#8221; (I think the bit after the dot will change on each computer). To confirm it&#8217;s the correct service double click on it and look at the &#8220;Path to executable&#8221; - it should be &#8220;C:\Program Files\Bonjour\mDNSResponder.exe&#8221;. If it is then change the &#8220;Startup type&#8221; to &#8220;disabled&#8221; and press the &#8220;Stop&#8221; button. You should now be able to connect to your <span class="caps">VPN.</span></p>

<p>As far as I can tell, neither of these solutions have had a detrimental effect on my trial install of Flash so I think that they are safe changes to make but no guarantees! Hopefully the information will save someone the time it took me to find the answer.</p>]]></content:encoded>
			<wfw:commentRss>http://www.kelvinluck.com/2007/11/flash-cs3-trial-breaks-juniper-network-connect/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
