<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Flash Monkey</title>
	<atom:link href="http://www.flashmonkey.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flashmonkey.co.uk</link>
	<description>Stephen Burgess - Interactive Developer</description>
	<pubDate>Sat, 04 Feb 2012 09:25:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>SWFAddress not updating on a Mac</title>
		<link>http://www.flashmonkey.co.uk/swfaddress-not-updating-on-a-mac/</link>
		<comments>http://www.flashmonkey.co.uk/swfaddress-not-updating-on-a-mac/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 09:25:03 +0000</pubDate>
		<dc:creator>FlashMonkey</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.flashmonkey.co.uk/?p=1280</guid>
		<description><![CDATA[At Specialmoves we maintain a very large multi-lingual Flash site for a luxury brand. As part of a recent update we noticed that there appeared to be some issues with the url and title of the browser not updating. It was only certain pages and happened in most languages. The problem became even stranger when [...]]]></description>
			<content:encoded><![CDATA[<p>At <a href="http://www.specialmoves.com">Specialmoves</a> we maintain a very large multi-lingual Flash site for a luxury brand. As part of a recent update we noticed that there appeared to be some issues with the url and title of the browser not updating. It was only certain pages and happened in most languages. The problem became even stranger when we realised that it was only happening on Macs.</p>
<p>After a little debugging I soon found the issue. SWFAddress actually does a check to detect the OS and calls JavaScript functions differently on a Mac. On Windows (and other Operating Systems) SWFAddress uses <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html#call()">ExternalInterface</a> to call JavaScript functions. However, on a Mac it sends a string of JavaScript to the browser by using <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/package.html#navigateToURL()">NavigateToURL</a>.</p>
<p>Why the difference? I’m not sure to be honest but I presume it may be something to do with making multiple calls in quick succession with ExternalInterface.call() not working in some browsers on a Mac? That’s just a guess though and I don’t have time to do tests and find out the definite reason. The difference is mentioned in <a href="http://www.asual.com/blog/swfaddress/swfaddress-23.html">this old blog post</a> on the Asual site but there is no explanation given why.</p>
<p>Anyway, back to why it was not updating on certain pages for our site update. The issue was that some of the translators had accidentally added a carriage return to the title on some pages. Probably caused from copying and pasting from an Excel or Word document. This carriage return was fine when using ExternalInterface but using NavigateToURL it meant the JavaScript was not valid and therefore never gets called.</p>
<p>The fix was simple, I changed this line in our code:</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:600px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace">SWFAddress.setTitle<span class="br0">&#40;</span>browserUpdateVO.title<span class="br0">&#41;</span>;</div></div>
<p>to this:</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:600px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace">SWFAddress.setTitle<span class="br0">&#40;</span><span class="kw7">encodeURI</span><span class="br0">&#40;</span><span class="kw7">decodeURI</span><span class="br0">&#40;</span>browserUpdateVO.title<span class="br0">&#41;</span><span class="br0">&#41;</span>.<span class="kw7">split</span><span class="br0">&#40;</span><span class="st0">&quot;%0D&quot;</span><span class="br0">&#41;</span>.<span class="kw7">join</span><span class="br0">&#40;</span><span class="st0">&quot;&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div></div>
<p>This removes any carriage returns and ensures the JavaScript will be called successfully. </p>
<p>I think this is perhaps a little flaw with SWFAddress. Sure we developers should ensure we’re sending a title or URL without a carriage return. However, there is no way that the JavaScript will work with NavigateToURL if it contains a carriage return, so I think it wouldn’t hurt for there to be a little check within SWFAddress. I have contacted Asual and suggested this for the next code release.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashmonkey.co.uk/swfaddress-not-updating-on-a-mac/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Some thoughts of the future of Flash</title>
		<link>http://www.flashmonkey.co.uk/some-thoughts-of-the-future-of-flash/</link>
		<comments>http://www.flashmonkey.co.uk/some-thoughts-of-the-future-of-flash/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 15:19:33 +0000</pubDate>
		<dc:creator>FlashMonkey</dc:creator>
		
		<category><![CDATA[ActionScript]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[HTML5]]></category>

		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.flashmonkey.co.uk/?p=1253</guid>
		<description><![CDATA[It&#8217;s that time of the year again when people write off Flash saying this year really is the end of flash with HTML5* taking over the world. I&#8217;m not so sure and here are my thoughts why.
Regular readers may have noticed over the past year or so an increase in HTML5, JavaScript and CSS experiments [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s that time of the year again when people write off Flash saying <i>this</i> year really <i>is</i> the end of flash with HTML5* taking over the world. I&#8217;m not so sure and here are my thoughts why.</p>
<p>Regular readers may have noticed over the past year or so an increase in HTML5, JavaScript and CSS experiments on this site and a lot less Flash. In fact I will soon be officially changing my day to day role to work almost exclusively with these technologies and much less (if at all) with Flash. More on that sometime soon.</p>
<p>However, my reason for jumping the Flash ship like Captain Schettino is not because I think it is going to sink and this year everything will be done in HTML5. I&#8217;ve been working almost exclusively with Flash and ActionScript for over 7 years now and I feel like it’s the right time for a change. It will be nice to add some new feathers to my programming hat and I will definitely sit more comfortably at work knowing I have more languages to call on to solve problems.</p>
<p>I don&#8217;t think it&#8217;s all doom and gloom for Flash though, in fact I believe Flash leads where HTML follows. Sure you can do a lot of stuff now in JS/CSS that you used to only really be able to do effectively in the browser with Flash; but Flash is still moving forward and you only have to look at audio stuff to see that. AS3&#8217;s SoundMixer Class enables you to do all sorts of cool stuff with audio (for example <a href="http://lf8.org/simple2.swf">this from trioptic</a>) whereas HTML5’s audio tag still has some short comings. <a href="http://nerdplusart.com/why-is-there-flash-in-the-html5-version-of-cut-the-rope">This article</a> about the recent HTML5 Cut the Rope games explains more. Let’s not forget the HTML5 specification is still a working draft and <a href="http://en.wikipedia.org/wiki/HTML5">2014 is the target date for recommendation by the WC3</a>.</p>
<p>HTML5 specs have to be agreed upon and implemented across many different browsers and platforms and even then there will always be some differences and quirks. Flash can move much faster as it’s only one platform, and in theory should work the same across all browsers.</p>
<p>Another big plus for Flash at the moment is the ability to compile for different devices such as iOS and Android using <a href="http://www.adobe.com/products/air.html">AIR</a>. I recently had to give some rough costings for a Mobile app to run on multiple operating systems (despite having never built such an application) and recommended AIR as a potential platform to develop in. I’m sure there are some issues with using this technique, possibly like <a href="http://usingimho.wordpress.com/2011/06/14/why-you-should-stay-away-from-appcelerators-titanium/">similar technologies such as appcelarator suffer from</a>, but it seems like it could be a good option.</p>
<p>I think consumers don&#8217;t really care what technology is used as long as it works. The only people who are getting excited (or scared as some Flash Devs I know) about HTML5 are us Developers. Imagine Joe average Internet user viewing my recent <a href="http://www.flashmonkey.co.uk/css-javascript-pacman/">Pacman demo</a> - they would think it&#8217;s pretty crap really, and maybe rightly so. They have seen amazing 3D Flash games so why would they care about a rubbish 2D prototype just because it runs in the browser on an iPad.</p>
<p>Also, do we really need browser games on iOS with the app store already offering so many great games? Although, maybe that’s not the point. I think in the immediate future HTML5 will be mostly used for UI stuff, replacing Flash for user interaction stuff like the simple example I created below.</p>
<p><iframe name="example" src="http://flashmonkey.co.uk/widget/rolloverimage/index.html?paths=main.png,../../images/nythumbs/image1.jpg,../../images/nythumbs/image2.jpg,../../images/nythumbs/image3.jpg,../../images/nythumbs/image4.jpg,../../images/nythumbs/image5.jpg" width="240" height="180"<br />
frameborder="0" scrolling="auto" name="myInlineFrame"><br />
<img src="main.png"></iframe></p>
<p>Anyway, I’m really having fun using JavaScript more and more. Sure it has it’s quirks, and can at times feel like a step back from AS3. But it’s interesting seeing what you can do in a browser without a plugin and overcoming new challenges JS throws up for me. Every JS project I work on I feel like I’m learning loads and it’s an exciting time.</p>
<p>It&#8217;s also nice not having to compile a SWF every time you want to make a little change, pressing cmd+R is so refreshing. I’ll leave it on that poor joke - all comments from Flash devs who are moving in the same direction as me, and also those not, are really welcomed as always.</p>
<p><font color="#666666" size="1">* To quote <a href="http://twitter.com/photonstorm">Richard Davey</a> from his recent <a href="http://www.photonstorm.com/archives/2759/the-reality-of-html5-game-development-and-making-money-from-it">blog post about HTML5 Games</a> (well worth a read) - &#8220;When I talk about “HTML5” I’m doing so from the popular media use of the word, rather than the technical one. On a technical level HTML5 is of course just a specification for a mark-up language. But the media has chosen to use the term as an umbrella, spanning lots of browser related technologies&#8230;&#8221;</font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashmonkey.co.uk/some-thoughts-of-the-future-of-flash/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CSS &#038; JavaScript Pacman</title>
		<link>http://www.flashmonkey.co.uk/css-javascript-pacman/</link>
		<comments>http://www.flashmonkey.co.uk/css-javascript-pacman/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 10:33:45 +0000</pubDate>
		<dc:creator>FlashMonkey</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Experiment]]></category>

		<category><![CDATA[HTML5]]></category>

		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.flashmonkey.co.uk/?p=1207</guid>
		<description><![CDATA[Anyone who has been on this site recently will know I’ve been playing around with a lot of little JavaScript and Canvas experiments. I’ve had fun porting some of my old Flash stuff over to Canvas and some of them have generated a fair bit of interest with my HTML5 ColorWall featured on Chrome Experiments [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone who has been on this site recently will know I’ve been playing around with a lot of little JavaScript and Canvas experiments. I’ve had fun porting some of my old Flash stuff over to Canvas and some of them have generated a fair bit of interest with my <a href="http://flashmonkey.co.uk/html5/colorwall/">HTML5 ColorWall</a> featured on <a href="http://www.chromeexperiments.com/detail/colorwall/">Chrome Experiments</a> (go and vote for it!) and my <a href="www.flashmonkey.co.uk/simple-javascript-physics/">Simple JavaScript Physics post</a> getting a lot of hits.</p>
<p>One thing I’ve found frustrating is how poorly these experiments run on iOS, especially before the recently released iOS5. Apple are against adding web plugins, such as Adobe Flash, to their devices claiming people should be using HTML5 tags such as Canvas. However, constantly clearing and re-drawing to a Canvas element on an iPhone running iOS4 gives you about 3 or 4 fps (it’s slightly better on iOS5 but still not good enough to write a game).</p>
<p>I then stumbled across <a href="http://sebleedelisle.com/2011/04/html5javascript-platform-game-optimised-for-ipad/">this article</a> on <a href="http://sebleedelisle.com/about/">Seb Lee-Delisles</a> site about a JavaScript hack day they held at <a href="http://www.pluginmedia.net/">Plugin Media</a> where they made <a href="http://www.pluginmedia.net/dev/infector/">the infector game</a> using CSS and JavaScript to see if they could get a fast browser game running on iOS. Inspired by this and wanting to learn a bit more CSS/JavaScript I decided to try putting my own game together using the same techniques. This post will explain how I went about it and stuff I learnt.</p>
<p>Before I continue I should mention that this isn’t a full version of Pacman, it’s merely a prototype to see if I could get a browser game working smoothly on an iPad and other touch devices. I never intended to finish it fully as I feel the world already has enough Pacman games floating about and we don’t really need another one. I am planning on creating a more original game with a Designer friend of mine early next year and will post about that when it’s ready.</p>
<p>First up <a href="http://www.flashmonkey.co.uk/lab/pacman/">click here to play the game</a>. Right click and have a glance over the source code then read on below and I’ll explain the main talking points of the game structure.</p>
<p><a href="http://www.flashmonkey.co.uk/lab/pacman/"><img src="http://www.flashmonkey.co.uk/images/pacman/game.png"></a></p>
<h2>Moving and animating the characters</h2>
<p>The movement of the characters is fairly simple. The <a href="http://www.flashmonkey.co.uk/lab/pacman/js/Player.js">Player</a> and <a href="http://www.flashmonkey.co.uk/lab/pacman/js/Ghost.js">Ghost</a> Classes (I’m going to call them Classes even though they aren’t strictly Classes, not in the way AS3 Developers would be used to anyway) both contain an instance of the Animation Class. This Class was adapted from the Plugin Media experiment and basically uses CSS transforms to position the game characters as seen in the code below. I updated the Class so it also incorporated rotation, which I needed for my Pacman game.</p>
<div class="codecolorer-container javascript " style="overflow:auto;white-space:nowrap;width:600px"><div class="javascript codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">var</span> xp <span class="sy0">=</span> Math.<span class="me1">round</span><span class="br0">&#40;</span><span class="kw1">this</span>.<span class="me1">x</span> <span class="sy0">+</span> <span class="kw1">this</span>.<span class="me1">offsetX</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw2">var</span> yp <span class="sy0">=</span> Math.<span class="me1">round</span><span class="br0">&#40;</span><span class="kw1">this</span>.<span class="me1">y</span> <span class="sy0">+</span> <span class="kw1">this</span>.<span class="me1">offsetY</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
styleStr <span class="sy0">=</span> <span class="st0">&quot;translate(&quot;</span> <span class="sy0">+</span> xp <span class="sy0">+</span> <span class="st0">&quot;px, &quot;</span> <span class="sy0">+</span> yp <span class="sy0">+</span> <span class="st0">&quot;px)&quot;</span><span class="sy0">;</span><br />
dom.<span class="me1">style</span>.<span class="me1">webkitTransform</span> <span class="sy0">=</span> styleStr<span class="sy0">;</span><br />
dom.<span class="me1">style</span>.<span class="me1">MozTransform</span> <span class="sy0">=</span> styleStr<span class="sy0">;</span><br />
dom.<span class="me1">style</span>.<span class="me1">OTransform</span> <span class="sy0">=</span> styleStr<span class="sy0">;</span><br />
dom.<span class="me1">style</span>.<span class="me1">transform</span> <span class="sy0">=</span> styleStr<span class="sy0">;</span><br />
<br />
styleStr <span class="sy0">=</span> <span class="st0">&quot;rotate(&quot;</span> <span class="sy0">+</span> <span class="kw1">this</span>.<span class="me1">rotation</span> <span class="sy0">+</span> <span class="st0">&quot;deg)&quot;</span><span class="sy0">;</span><br />
dom.<span class="me1">style</span>.<span class="me1">webkitTransform</span> <span class="sy0">+=</span> styleStr<span class="sy0">;</span><br />
dom.<span class="me1">style</span>.<span class="me1">MozTransform</span> <span class="sy0">+=</span> styleStr<span class="sy0">;</span><br />
dom.<span class="me1">style</span>.<span class="me1">OTransform</span> <span class="sy0">+=</span> styleStr<span class="sy0">;</span><br />
dom.<span class="me1">style</span>.<span class="me1">transform</span> <span class="sy0">+=</span> styleStr<span class="sy0">;</span></div></div>
<p>The character animations are done using simple Sprite sheets as seen below.</p>
<p><img src="http://www.flashmonkey.co.uk/images/pacman/sprite_sheets.png"></p>
<p>I liked the way Plugin Media wrote their Animation Class so the API worked in a similar way to ActionScript with play(), stop() and gotoAndStop() functions. View my adapted version of the Class <a href="http://www.flashmonkey.co.uk/lab/pacman/js/Animation.js">here</a>.</p>
<h2>Collision Detection / Level Generator</h2>
<p>The hit detection for when Pacman touches a wall is actually very simple. The level background is a transparent png as shown below.</p>
<p><img src="http://www.flashmonkey.co.uk/images/pacman/level.png"></p>
<p>I create a Canvas element and give it a green background. I then load the image on top of it, divide the image up into a grid and loop through to check if the pixel color is green using <i>&#8220;getImageData&#8221;</i> with the canvas tag. If it is I know it’s a space, otherwise it’s a wall. From this I can create an Array with info on the level and I use this throughout the game.</p>
<p>To see the full Level Class where this Array is generated click <a href="http://www.flashmonkey.co.uk/lab/pacman/js/Level.js">here</a>. You may remember me criticising the performance of the Canvas tag and be wondering why I am using it. It only performs badly when you are constantly clearing it and writing to it. Once graphics have been written to Canvas it’s performance is no better or worse than simply loading an image.</p>
<p>If you have downloaded the source and are running it locally you may find that it doesn’t work and you get a security error. That is due to the line of code below – <i>&#8220;getImageData&#8221;</i>. You won’t get this if you install and run a local webserver such as Apache – this <a href="http://stackoverflow.com/questions/358538/getimagedata-in-firefox-3-causing-ns-error-dom-security-err">post on stackoverflow</a> will explain further.</p>
<div class="codecolorer-container javascript " style="overflow:auto;white-space:nowrap;width:600px"><div class="javascript codecolorer" style="font-family:Monaco,Lucida Console,monospace">cellData<span class="br0">&#91;</span>w<span class="br0">&#93;</span><span class="br0">&#91;</span>h<span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#40;</span>context.<span class="me1">getImageData</span><span class="br0">&#40;</span>xp<span class="sy0">,</span> yp<span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">1</span><span class="br0">&#41;</span>.<span class="me1">data</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="nu0">255</span><span class="br0">&#41;</span> <span class="sy0">?</span> <span class="nu0">1</span> <span class="sy0">:</span> <span class="nu0">0</span><span class="sy0">;</span></div></div>
<p>The second bit of collision detection is between Pacman and the Ghost. This was much simpler and is done using a distance calculation.</p>
<div class="codecolorer-container javascript " style="overflow:auto;white-space:nowrap;width:600px"><div class="javascript codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">var</span> dx <span class="sy0">=</span> Math.<span class="me1">abs</span><span class="br0">&#40;</span>player.<span class="me1">xp</span> <span class="sy0">-</span> ghost.<span class="me1">xp</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw2">var</span> dy <span class="sy0">=</span> Math.<span class="me1">abs</span><span class="br0">&#40;</span>player.<span class="me1">yp</span> <span class="sy0">-</span> ghost.<span class="me1">yp</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw2">var</span> dist <span class="sy0">=</span> Math.<span class="me1">sqrt</span><span class="br0">&#40;</span>dx <span class="sy0">*</span> dx <span class="sy0">+</span> dy <span class="sy0">*</span> dy<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">if</span><span class="br0">&#40;</span>dist <span class="sy0">&lt;</span> CELL_SIZE<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; onGameOver<span class="br0">&#40;</span><span class="kw2">false</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<p>For the Ghost AI I have written a simple implementation of the good old <a href="http://en.wikipedia.org/wiki/A*_search_algorithm">A* algorithm</a>. <a href="http://www.bit-101.com/blog/">Keith Peters</a> wrote a great chapter on pathfinding in his <a href="http://www.amazon.com/AdvancED-ActionScript-Animation-Keith-Peters/dp/1430216085/ref=pd_bxgy_b_img_b">ActionScript 3.0 Advanced Animation book</a>, which is well worth a read if you’re completely new to pathfinding. A* is by far the most used pathfinding algorithm. You’ll find it being used from simple games like Pacman right up to complex PS3/Xbox games. You can see my implementation in the updateGhost function within the index.html source.</p>
<h2>Touch screen devices</h2>
<p>For the touch screen controls I used <a href="http://www.modernizr.com/">Modernizr</a> to detect if the device supports touch.</p>
<div class="codecolorer-container javascript " style="overflow:auto;white-space:nowrap;width:600px"><div class="javascript codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">if</span><span class="br0">&#40;</span>Modernizr.<span class="me1">touch</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; isTouch <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span><br />
&nbsp; makeControls<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<p>Then I create onscreen controls using divs and the HTML touch events. I combined the event listener for key presses and touches as shown below.</p>
<div class="codecolorer-container javascript " style="overflow:auto;white-space:nowrap;width:600px"><div class="javascript codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">function</span> onKeyPress<span class="br0">&#40;</span>e<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span>isPlaying <span class="sy0">&amp;&amp;</span> <span class="sy0">!</span>isKeyDown<span class="br0">&#41;</span> onClicked<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; isKeyDown <span class="sy0">=</span> <span class="br0">&#40;</span>isTouch<span class="br0">&#41;</span> <span class="sy0">?</span> <span class="br0">&#40;</span>e.<span class="me1">type</span> <span class="sy0">==</span> <span class="st0">&quot;touchstart&quot;</span><span class="br0">&#41;</span> <span class="sy0">:</span> <span class="br0">&#40;</span>e.<span class="me1">type</span> <span class="sy0">==</span> <span class="st0">&quot;keydown&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span> &nbsp; <br />
&nbsp; <br />
&nbsp; <span class="kw1">switch</span><span class="br0">&#40;</span><span class="br0">&#40;</span>isTouch<span class="br0">&#41;</span> <span class="sy0">?</span> e.<span class="me1">target</span> <span class="sy0">:</span> e.<span class="me1">keyCode</span><span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">case</span> KEY_LEFT <span class="sy0">:</span><br />
&nbsp; &nbsp; <span class="kw1">case</span> leftButton <span class="sy0">:</span><br />
&nbsp; &nbsp; &nbsp; leftDown <span class="sy0">=</span> isKeyDown<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">break</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">case</span> KEY_RIGHT <span class="sy0">:</span><br />
&nbsp; &nbsp; <span class="kw1">case</span> rightButton <span class="sy0">:</span><br />
&nbsp; &nbsp; &nbsp; rightDown <span class="sy0">=</span> isKeyDown<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">break</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">case</span> KEY_UP <span class="sy0">:</span><br />
&nbsp; &nbsp; <span class="kw1">case</span> upButton <span class="sy0">:</span><br />
&nbsp; &nbsp; &nbsp; upDown <span class="sy0">=</span> isKeyDown<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">break</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">case</span> KEY_DOWN <span class="sy0">:</span><br />
&nbsp; &nbsp; <span class="kw1">case</span> downButton <span class="sy0">:</span><br />
&nbsp; &nbsp; &nbsp; downDown <span class="sy0">=</span> isKeyDown<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">break</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<h2>Fixed timestep</h2>
<p>The final issue I experienced was a noticeable difference in frame rate between certain browsers and devices. This is an expected issue when running game physics on an interval and there is a simple solution: fix your timestep! I won’t go too much into this as you can read all you need to know in this <a href="http://gafferongames.com/game-physics/fix-your-timestep/">great article from Glenn Fiedler</a>. I have written an implementation of what is described in Glenn’s article in JavaScript and the game now runs at pretty much the same speed across all browsers and devices, it’s just smoother on some.</p>
<p>So with a fixed timestep and using CSS transformations on divs rather than constantly writing to Canvas I have succeeded in creating a simple browser based game that runs at an optimum speed on an iPhone/iPad and across other devices such as Android phones.</p>
<h2>Conclusion</h2>
<p>I really enjoyed creating this and learnt a lot about JavaScript and CSS. Reading books/online articles is a great way to learn but sometimes you just need to get stuck into code, and what better way than to make a simple game.</p>
<p>I want to say a little thanks to <a href="http://www.pluginmedia.net/">Seb and the guys at Plugin Media</a> whose code I used a bit of. Also, my current employers <a href="http://specialmoves.com/">Specialmoves</a>, who were happy for me to do a bit of work on the game during my downtime. Finally, thanks to <a href="http://richardhallows.com/">Richard Hallows</a> who gave me some advice on CSS and best practises (check out my alphabetically ordered CSS style sheet).</p>
<p><!--Check out the below video of the game running on my iPhone. Impressive speed huh! -->Go ahead and try it out on your phone and let me know if you have any issues. As always advice and comments are welcome so let me know what you think.</p>
<p><!--VIDEO--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashmonkey.co.uk/css-javascript-pacman/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Star Particles</title>
		<link>http://www.flashmonkey.co.uk/star-particles/</link>
		<comments>http://www.flashmonkey.co.uk/star-particles/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 14:20:55 +0000</pubDate>
		<dc:creator>FlashMonkey</dc:creator>
		
		<category><![CDATA[Experiment]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Physics]]></category>

		<guid isPermaLink="false">http://www.flashmonkey.co.uk/?p=1203</guid>
		<description><![CDATA[Two posts in two days! Just made a star version of the fun particle thing I made yesterday! Check it out here. The stars are drawn with code - check the source code to see how. I&#8217;ve got a few other ideas for these little particles so watch this space!  

]]></description>
			<content:encoded><![CDATA[<p>Two posts in two days! Just made a star version of the fun particle thing I made yesterday! <a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/lab/js-particles/stars/');" href="http://www.flashmonkey.co.uk/lab/js-particles/stars/" target="_blank">Check it out here.</a> The stars are drawn with code - check the source code to see how. I&#8217;ve got a few other ideas for these little particles so watch this space! <img src='http://www.flashmonkey.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/lab/js-particles/stars/');" href="http://www.flashmonkey.co.uk/lab/js-particles/stars/" target="_blank"><img src="http://www.flashmonkey.co.uk/lab/js-particles/stars/stars.png" alt="" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashmonkey.co.uk/star-particles/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fun with JavaScript and particles</title>
		<link>http://www.flashmonkey.co.uk/fun-with-javascript-and-particles/</link>
		<comments>http://www.flashmonkey.co.uk/fun-with-javascript-and-particles/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 16:18:40 +0000</pubDate>
		<dc:creator>FlashMonkey</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.flashmonkey.co.uk/?p=1173</guid>
		<description><![CDATA[So since my last post exactly 2 months ago it&#8217;s remained fairly quiet on the site. The reason being that I&#8217;m currently tech lead on a big project at Specialmoves that is due to go live really soon (more on that later). However, I&#8217;ve had a rare quiet weekend and somehow found the motivation to [...]]]></description>
			<content:encoded><![CDATA[<p>So since my last post exactly 2 months ago it&#8217;s remained fairly quiet on the site. The reason being that I&#8217;m currently tech lead on a big project at <a href="http://specialmoves.com/" onClick="pageTracker._trackEvent('External Link', 'Click', 'http://specialmoves.com/');" target="_blank">Specialmoves</a> that is due to go live really soon (more on that later). However, I&#8217;ve had a rare quiet weekend and somehow found the motivation to fire up the Macbook and write some code.</p>
<p>The project I&#8217;m currently working on features a fair amount of particles (it&#8217;s a Christmas site, need I say more). For the vast majority of them I&#8217;ve used <a href="http://www.richardlord.net/blog" onClick="pageTracker._trackEvent('External Link', 'Click', 'http://www.richardlord.net/blog');" target="_blank">Richard Lord&#8217;s</a> brilliant <a href="http://flintparticles.org/" onClick="pageTracker._trackEvent('External Link', 'Click', 'http://flintparticles.org/');" target="_blank">Flint library</a> but there was a couple of loaders on the site where I used my own simple particle system. I&#8217;ve always enjoyed playing around with particles as you can see from the posts featured on this blog, e.g. <a href="http://www.flashmonkey.co.uk/colorwall/" onClick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/colorwall/');" target="_blank">ColorWall</a>, <a href="http://www.flashmonkey.co.uk/wobblewall/" onClick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/wobblewall/');" target="_blank">WobbleWall</a> and <a href="http://www.flashmonkey.co.uk/simple-javascript-physics/" onClick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/simple-javascript-physics/');" target="_blank">Simple JavaScript Physics</a>.</p>
<p>So with yesterday being November 5th (bonfire night here in the UK) I started playing around with creating a sparkler effect using JavaScript and Canvas. It didn&#8217;t really look exactly how I hoped but in creating it I stumbled across some other cool effects, the best being the one below. <a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/lab/js-particles/bouncy-dir/');" href="http://www.flashmonkey.co.uk/lab/js-particles/bouncy-dir/" target="_blank">Click here to view the particles in action</a>, move your mouse around and click anywhere on the screen.</p>
<p><a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/lab/js-particles/bouncy-dir/');" href="http://www.flashmonkey.co.uk/lab/js-particles/bouncy-dir/" target="_blank"><img src="http://www.flashmonkey.co.uk/lab/js-particles/bouncy-dir/particles.png"></a></p>
<p>I&#8217;ve always enjoyed creating simple visual effects that are nice to interact with and fun to watch and I think this one is just that. It&#8217;s a simple effect but I found myself dragging the mouse around for ages playing with it.</p>
<p>I plan to write a simple particle tutorial soon (ambitious for me since I&#8217;m currently averaging 1 post every 4 or so months) where I&#8217;ll explain the basics of creating a simple particle effect. Many developers think particle effect are really hard to create but once you&#8217;ve got the basics down it&#8217;s easy peasy.</p>
<p>Below are some of the other particles experiments I made yesterday. The first is the sort of <a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/lab/js-particles/sparkle/');" href="http://www.flashmonkey.co.uk/lab/js-particles/sparkle/" target="_blank">sparkler effect</a>. The second <a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/lab/js-particles/floaty/');" href="http://www.flashmonkey.co.uk/lab/js-particles/floaty/" target="_blank">a slower more mellow version of the above</a> and finally the <a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/lab/js-particles/streams/');" href="http://www.flashmonkey.co.uk/lab/js-particles/streams/" target="_blank">sparkler effect without the canvas being cleared</a>.</p>
<p><a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/lab/js-particles/sparkle/');" href="http://www.flashmonkey.co.uk/lab/js-particles/sparkle/" target="_blank"><img src="http://www.flashmonkey.co.uk/lab/js-particles/sparkle/sparkle.png"></a><img src="http://www.flashmonkey.co.uk/lab/js-particles/seperator.png"><a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/lab/js-particles/floaty/');" href="http://www.flashmonkey.co.uk/lab/js-particles/floaty/" target="_blank"><img src="http://www.flashmonkey.co.uk/lab/js-particles/floaty/floaty.png"></a><img src="http://www.flashmonkey.co.uk/lab/js-particles/seperator.png"><a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/lab/js-particles/streams/');" href="http://www.flashmonkey.co.uk/lab/js-particles/streams/" target="_blank"><img src="http://www.flashmonkey.co.uk/lab/js-particles/streams/streams.png"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashmonkey.co.uk/fun-with-javascript-and-particles/feed/</wfw:commentRss>
		</item>
		<item>
		<title>It&#8217;s all gone quiet over there&#8230;</title>
		<link>http://www.flashmonkey.co.uk/its-all-gone-quiet-over-there/</link>
		<comments>http://www.flashmonkey.co.uk/its-all-gone-quiet-over-there/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 09:01:22 +0000</pubDate>
		<dc:creator>FlashMonkey</dc:creator>
		
		<category><![CDATA[Employment]]></category>

		<guid isPermaLink="false">http://www.flashmonkey.co.uk/?p=1157</guid>
		<description><![CDATA[Indeed it has all gone quiet over here on the site but not because I&#8217;ve buggered off travelling around the world again, oh no, I&#8217;ve been working hard actually. In fact a lot has changed since my last post way back in mid March.
I have a new job! Well, maybe not so new anymore as [...]]]></description>
			<content:encoded><![CDATA[<p>Indeed it has all gone quiet over here on the site but not because I&#8217;ve buggered off travelling around the world again, oh no, I&#8217;ve been working hard actually. In fact a lot has changed since my last post way back in mid March.</p>
<p>I have a new job! Well, maybe not so new anymore as I have been here for 3 months. After returning from travelling I soon realised that I needed a fresh start at a new company to really get me excited about programming again. After deciding it was time to move on one company instantly sprang to mind as the sort of place I&#8217;d love to work&#8230; <a href="http://specialmoves.com/">Specialmoves</a>. Having worked with them on a Lynx project whilst at <a href="http://tmw.co.uk/">TMW</a> I knew a few people at the company and thought I&#8217;d send my CV over and much to my delight - I got the job!</p>
<p>Specialmoves is very different to my previous jobs. The company is a studio rather than agency with little over 20 employees, and focuses primary on development. In my first week we had a Studio meeting and Darrell (one of the founders of the company) said that 10 years ago him and Pascal (you guessed it, the other founder) set the company up because they wanted to do <i>&#8220;cool sh*t&#8221;</i>, and it&#8217;s safe to say that is pretty much still the inspiration for all things Specialmoves. It&#8217;s an exciting place to work and the company are always trying to push the boundaries and be innovative. I hope to learn a lot working here.</p>
<p>Check out the video below for something I made in my first couple of weeks at Specialmoves. To read more about the project <a href="http://specialmoves.com/our-work/smirnoff.php">click here</a>.</p>
<p><iframe src="http://player.vimeo.com/video/26964891?title=0&amp;byline=0&amp;portrait=0&amp;color=772124" width="600" height="338" frameborder="0"></iframe></p>
<p>The other great thing about my new job is that it&#8217;s an Interactive Developer role, so not Flash/Actionscript specific. I like programming with Flash, it&#8217;s where I started out as a developer and I think AS3 is a fun language to write in. However, I&#8217;ve always believed as a developer it&#8217;s important not to get tied down to technologies and to remain open minded and keep learning/experimenting with new stuff. My role at Specialmoves will involve a lot of Flash, especially at the start, but I will also get an opportunity to work on other platforms like JavaScript and mobile development etc.</p>
<p>In other news my HTML5 version of ColorWall was recently added to the Chrome Experiments site. Check it out <a href="http://www.chromeexperiments.com/detail/colorwall/?f=">here</a> and give it a 5 star rating! <img src='http://www.flashmonkey.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I plan to re-ignite the website over the next few months so expect some more blog posts soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashmonkey.co.uk/its-all-gone-quiet-over-there/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HTML5 Snake</title>
		<link>http://www.flashmonkey.co.uk/html5-snake/</link>
		<comments>http://www.flashmonkey.co.uk/html5-snake/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 20:17:49 +0000</pubDate>
		<dc:creator>FlashMonkey</dc:creator>
		
		<category><![CDATA[HTML5]]></category>

		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.flashmonkey.co.uk/?p=1138</guid>
		<description><![CDATA[This is something I made this morning. I wanted to see if I could make a simple game in a couple of hours and I use to love playing snake on my old Nokia back when I was at school (yep mobile phones where invented before I left school - I&#8217;m not that old!!). Originally [...]]]></description>
			<content:encoded><![CDATA[<p>This is something I made this morning. I wanted to see if I could make a simple game in a couple of hours and I use to love playing snake on my old Nokia back when I was at school (yep mobile phones where invented before I left school - I&#8217;m not that old!!). Originally I was going to make it in Flash but a simple game like this is perfect for canvas and it&#8217;s an example of using the right technology for the job, rather than just sticking to something you know well.</p>
<p>Click <a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://flashmonkey.co.uk/html5/snake/');" href="http://flashmonkey.co.uk/html5/snake/" target="_blank">here</a> to play and see if you can beat my high score of <b>44</b>. I&#8217;ll probably update it with a scoreboard soon. Oh and don&#8217;t try and run it in IE as it won&#8217;t work (no canvas support).</p>
<p><a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://flashmonkey.co.uk/html5/snake/');" href="http://flashmonkey.co.uk/html5/snake/" target="_blank"><img src="http://flashmonkey.co.uk/html5/snake/nokia.jpg"></a></p>
<p>PS. It probably won&#8217;t work on your Nokia either but a mobile version could be an option in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashmonkey.co.uk/html5-snake/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Space Monkey</title>
		<link>http://www.flashmonkey.co.uk/space-monkey/</link>
		<comments>http://www.flashmonkey.co.uk/space-monkey/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 14:15:45 +0000</pubDate>
		<dc:creator>FlashMonkey</dc:creator>
		
		<category><![CDATA[ActionScript]]></category>

		<category><![CDATA[Physics]]></category>

		<guid isPermaLink="false">http://www.flashmonkey.co.uk/?p=1131</guid>
		<description><![CDATA[
You might play this game and think &#8220;this is just a copy of that iPhone game Doodle Jump&#8221;, and you&#8217;d be completely right. I was bored the other weekend and thought I&#8217;d make a game. I like Doodle Jump and there isn&#8217;t really any good online alternatives (google it, the top link is pretty poor, [...]]]></description>
			<content:encoded><![CDATA[<p><a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/flash/spacemonkey/');" href="http://www.flashmonkey.co.uk/flash/spacemonkey/" target="_blank"><img src="http://www.flashmonkey.co.uk/flash/spacemonkey/resources/banner.png"></a></p>
<p>You might play this game and think <i>&#8220;this is just a copy of that iPhone game Doodle Jump&#8221;</i>, and you&#8217;d be completely right. I was bored the other weekend and thought I&#8217;d make a game. I like Doodle Jump and there isn&#8217;t really any good online alternatives (google it, the top link is pretty poor, I&#8217;m not even going to link to it) so I thought I&#8217;d make one. I really enjoy programming physics and since it&#8217;s fairly simple for this game I did it all myself rather than using a library such as Box2D.</p>
<p>Normally I&#8217;d get the game to a certain level, like <a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/flash/spacemonkey/demo_v2_0/');" href="http://www.flashmonkey.co.uk/flash/spacemonkey/demo_v2_0/" target="_blank">this early demo of Space Monkey</a>, then move onto something else but I liked this one and thought I&#8217;d see it through to a properly finished game I&#8217;d be happy to post here. One thing I noticed was the game play is only a small part of a simple online game like this. It probably took roughly the same time to build the shell and score board etc.</p>
<p>Apart from the Monkey character (who I bought off iStock) I did all the graphics myself. I&#8217;m really pleased with the way this game turned out and I hope you have fun playing it.</p>
<p><a onclick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/flash/spacemonkey/');" href="http://www.flashmonkey.co.uk/flash/spacemonkey/" target="_blank"><img src="http://www.flashmonkey.co.uk/flash/spacemonkey/resources/spacemonkeyscreenshot.png"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashmonkey.co.uk/space-monkey/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ColorWall gets half a million hits</title>
		<link>http://www.flashmonkey.co.uk/colorwall-gets-half-a-million-hits/</link>
		<comments>http://www.flashmonkey.co.uk/colorwall-gets-half-a-million-hits/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 10:21:45 +0000</pubDate>
		<dc:creator>FlashMonkey</dc:creator>
		
		<category><![CDATA[ActionScript]]></category>

		<category><![CDATA[Experiment]]></category>

		<category><![CDATA[Physics]]></category>

		<guid isPermaLink="false">http://www.flashmonkey.co.uk/?p=1115</guid>
		<description><![CDATA[So last night, while I was tucked away in bed in London, somewhere in the world (possibly even in London) someone viewed ColorWall, and little did they know they where the 500,000th unique person to see it. Madness.
I made ColorWall purely as an example of how to re-create Yugo Nakamura&#8217;s great wonderwall effect. It was [...]]]></description>
			<content:encoded><![CDATA[<p>So last night, while I was tucked away in bed in London, somewhere in the world (possibly even in London) someone viewed <a href="http://www.flashmonkey.co.uk/flash/colorwall/" onClick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/flash/colorwall/');" target="_blank">ColorWall</a>, and little did they know they where the 500,000th unique person to see it. Madness.</p>
<p>I made ColorWall purely as an example of how to re-create <a href="http://yugop.com/" onClick="pageTracker._trackEvent('External Link', 'Click', 'http://yugop.com/');" target="_blank">Yugo Nakamura&#8217;s</a> great <a href="http://wonder-wall.com/" onClick="pageTracker._trackEvent('External Link', 'Click', 'http://wonder-wall.com/');" target="_blank">wonderwall</a> effect. It was really just to see if I could do it using particles rather than a 3D engine but I was so happy with the result I thought I&#8217;d post it here on FlashMonkey, along with <a href="http://www.flashmonkey.co.uk/colorwall/" onClick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/colorwall/');" target="_blank">an explanation of how I did it</a> and some <a href="http://www.flashmonkey.co.uk/flash/colorwall/example/colorwall_source.zip" onClick="pageTracker._trackEvent('Zip Link', 'Click', 'http://www.flashmonkey.co.uk/flash/colorwall/example/colorwall_source.zip');" target="_blank">source code</a>.</p>
<p>I got some nice comments here such as Sourav Bhargava&#8217;s - <i>&#8220;great analysis man . I appreciate your work. thanx the work helped me a lot&#8221;</i>, and I did some spin off work such as <a href="http://flashmonkey.co.uk/flash/wobblewall/" onClick="pageTracker._trackEvent('Internal Link', 'Click', 'http://flashmonkey.co.uk/flash/wobblewall/');" target="_blank">WobbleWall</a> and <a href="http://flashmonkey.co.uk/flash/colorsnake/" onClick="pageTracker._trackEvent('Internal Link', 'Click', 'http://flashmonkey.co.uk/flash/colorsnake/');" target="_blank">ColorSnake</a>, but eventually I moved onto the next thing and started to forget about ColorWall.</p>
<p>However, whilst away <a href="http://www.flashmonkey.co.uk/flash-monkey-is-back/" onClick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/flash-monkey-is-back/');" target="_self">travelling in Latin America last year</a> I decided to check my Google Analytics (as you do) and couldn&#8217;t believe my eyes! ColorWall was starting to get a lot of hits, one day alone it got over 20,000. A little further investigation in GA showed me that most of these hits came from <a href="http://www.stumbleupon.com/" onClick="pageTracker._trackEvent('External Link', 'Click', 'http://www.stumbleupon.com/');" target="_blank">StumbleUpon.com</a>, and a fair few from other social media sites such as Twitter, Facebook and Tumblr. It seems ColorWall (not ColourWall - I&#8217;ve taken a fair bit of stick from my compatriots for spelling it the American/programming way) has entertained people in a way I never intended/expected. Although 250 of the hits came from <a href="http://www.shroomery.org/" onClick="pageTracker._trackEvent('External Link', 'Click', 'http://www.shroomery.org/');" target="_blank">shroomery.org</a> so that might go some way to explaining things.</p>
<p>Anyway, I&#8217;ll leave you with some comments people have made on <a href="http://www.stumbleupon.com/url/flashmonkey.co.uk/flash/colorwall/" onClick="pageTracker._trackEvent('External Link', 'Click', 'http://www.stumbleupon.com/url/flashmonkey.co.uk/flash/colorwall/');" target="_blank">StumbleUpon</a>, I&#8217;ll start with the nice stuff, and end with some comments from people who &#8216;didn&#8217;t get it&#8217;! <img src='http://www.flashmonkey.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img src="http://www.flashmonkey.co.uk/flash/colorwall/stumbleuponcomments/positive1.png"></p>
<p><img src="http://www.flashmonkey.co.uk/flash/colorwall/stumbleuponcomments/positive2.png"></p>
<p><img src="http://www.flashmonkey.co.uk/flash/colorwall/stumbleuponcomments/positive3.png"></p>
<p><img src="http://www.flashmonkey.co.uk/flash/colorwall/stumbleuponcomments/positive4.png"></p>
<p>He should check out <a href="http://flashmonkey.co.uk/flash/wobblewall/" onClick="pageTracker._trackEvent('Internal Link', 'Click', 'http://flashmonkey.co.uk/flash/wobblewall/');" target="_blank">WobbleWall</a></p>
<p><img src="http://www.flashmonkey.co.uk/flash/colorwall/stumbleuponcomments/negative1.png"></p>
<p><img src="http://www.flashmonkey.co.uk/flash/colorwall/stumbleuponcomments/negative2.png"></p>
<p><img src="http://www.flashmonkey.co.uk/flash/colorwall/stumbleuponcomments/negative3.png"></p>
<p>No. It&#8217;s Flash. I have done a crappy HTML5 version though: <a href="http://www.flashmonkey.co.uk/html5/colorwall/" onClick="pageTracker._trackEvent('Internal Link', 'Click', 'http://www.flashmonkey.co.uk/html5/colorwall/');" target="_blank">HTML5 ColorWall</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashmonkey.co.uk/colorwall-gets-half-a-million-hits/feed/</wfw:commentRss>
		</item>
		<item>
		<title>addFrameScript and currentLabels</title>
		<link>http://www.flashmonkey.co.uk/addframescript-and-currentlabels/</link>
		<comments>http://www.flashmonkey.co.uk/addframescript-and-currentlabels/#comments</comments>
		<pubDate>Wed, 09 Feb 2011 12:17:08 +0000</pubDate>
		<dc:creator>FlashMonkey</dc:creator>
		
		<category><![CDATA[ActionScript]]></category>

		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://www.flashmonkey.co.uk/?p=1088</guid>
		<description><![CDATA[Today I&#8217;ve been setting up a very simple project - an intro animation and then some text/links fade in. The designers are making the animation and I&#8217;m just writing some basic code for the links etc (it&#8217;s CMS driven, many languages).
The client often like to change their minds (just a regular client then) and I [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve been setting up a very simple project - an intro animation and then some text/links fade in. The designers are making the animation and I&#8217;m just writing some basic code for the links etc (it&#8217;s CMS driven, many languages).</p>
<p>The client often like to change their minds (just a regular client then) and I know that the animation may change quite a bit. To fade the content in after the animation I am using <a onclick="pageTracker._trackEvent('External Link', 'Click', 'http://blog.newmovieclip.com/2007/04/30/add-a-frame-script-addframescript-dynamically-in-flash-cs3/');" href="http://blog.newmovieclip.com/2007/04/30/add-a-frame-script-addframescript-dynamically-in-flash-cs3/" target="_blank">addFrameScript</a>.</p>
<p>However, a problem, I know the frame that the fading should take place on could change several (hundred) times before the project goes live. I could just tell the designers where in the code to change the frame number, but I thought of a nicer solution than that.</p>
<p>The code was a simple combo of addFrameScript and <a onclick="pageTracker._trackEvent('External Link', 'Click', 'http://livedocs.adobe.com/livecycle/8.2/programLC/common/langref/flash/display/MovieClip.html#currentLabel');" href="http://livedocs.adobe.com/livecycle/8.2/programLC/common/langref/flash/display/MovieClip.html#currentLabel" target="_blank">currentLabels</a>. I got the designer to add a label on the frame they want the fading to take place and then used this simple code:</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:600px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">function</span> addLabelScript<span class="br0">&#40;</span>mc<span class="sy0">:</span><a href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:movieclip.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">MovieClip</span></a>, label<span class="sy0">:</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 class="kw5">String</span></a>, func<span class="sy0">:</span><a href="http://www.google.com/search?q=function%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:function.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">Function</span></a><span class="br0">&#41;</span><span class="sy0">:</span><span class="kw1">void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw2">var</span> <span class="kw7">labels</span><span class="sy0">:</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 class="kw5">Array</span></a> = mc.<span class="kw7">currentLabels</span>;<br />
&nbsp; <span class="kw2">var</span> i<span class="sy0">:</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 class="kw5">int</span></a> = <span class="kw7">labels</span>.<span class="kw7">length</span>;<br />
&nbsp; <br />
&nbsp; <span class="kw1">while</span><span class="br0">&#40;</span><span class="sy0">--</span>i <span class="sy0">&gt;</span> <span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.google.com/search?q=framelabel%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:framelabel.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">FrameLabel</span></a><span class="br0">&#40;</span><span class="kw7">labels</span><span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>.<span class="kw7">name</span> == label<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; mc.addFrameScript<span class="br0">&#40;</span><a href="http://www.google.com/search?q=framelabel%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:framelabel.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span class="kw5">FrameLabel</span></a><span class="br0">&#40;</span><span class="kw7">labels</span><span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>.<span class="kw7">frame</span>, func<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">return</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <br />
&nbsp; <span class="kw7">trace</span><span class="br0">&#40;</span><span class="st0">&quot;WARNING: The label '&quot;</span> <span class="sy0">+</span> label <span class="sy0">+</span> <span class="st0">&quot;' does not exist in the MovieClip '&quot;</span> <span class="sy0">+</span> mc.<span class="kw7">name</span> <span class="sy0">+</span> <span class="st0">&quot;'&quot;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div></div>
<p>OK it&#8217;s not going to make you fall off your chair with wonder but could be useful in the future. I&#8217;ve chucked it in a utils Class so it can be used like this:</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:600px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">function</span> <span class="kw7">init</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">:</span><span class="kw1">void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; Utils.addLabelScript<span class="br0">&#40;</span>animation, <span class="st0">&quot;animation-complete&quot;</span>, onComplete<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw3">function</span> onComplete<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">:</span><span class="kw1">void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw7">trace</span><span class="br0">&#40;</span><span class="st0">&quot;hello monkey I'm finished, do your fading thing&quot;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div></div>
<p>In the above example the frame label the designer adds is &#8220;animation-complete&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashmonkey.co.uk/addframescript-and-currentlabels/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

