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

<channel>
	<title>Shawson&#039;s Code Blog &#187; javascript</title>
	<atom:link href="http://www.shawson.co.uk/codeblog/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shawson.co.uk/codeblog</link>
	<description>development notes for my failing memory</description>
	<lastBuildDate>Mon, 26 Jul 2010 19:08:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>8WeekGame &#8211; I Won!</title>
		<link>http://www.shawson.co.uk/codeblog/8weekgame-i-won/</link>
		<comments>http://www.shawson.co.uk/codeblog/8weekgame-i-won/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 15:47:16 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=728</guid>
		<description><![CDATA[Woo hoo!  I won the very first 8weekgame competition with my HTML5/ Javascript rendition of Manic Miner named &#8220;Manic Spaceman&#8221;.  
Hats off to both Martin &#038; Gareth- I think we all did brilliantly to get a game smashed out in 8 weeks with no previous game development experience.  The next competition kicks [...]


Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/speed-up-your-javascript-video/' rel='bookmark' title='Permanent Link: Speed up your JavaScript : Video'>Speed up your JavaScript : Video</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/8-week-game-competition/' rel='bookmark' title='Permanent Link: 8 Week Game Competition'>8 Week Game Competition</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/couple-of-interesting-news-items-today/' rel='bookmark' title='Permanent Link: Couple of interesting news items today'>Couple of interesting news items today</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>Woo hoo!  I won the very first <a href="http://8weekgame.shawson.co.uk/">8weekgame competition</a> with my HTML5/ Javascript rendition of Manic Miner named &#8220;Manic Spaceman&#8221;.  </p>
<p>Hats off to both Martin &#038; Gareth- I think we all did brilliantly to get a game smashed out in 8 weeks with no previous game development experience.  The next competition kicks off in October (the 4th) where I will be joining the other guys to tackle some XNA!  We will be free to produce any game we want this time round!</p>
<p>I&#8217;m on holiday for the next 3 weeks, returning mid-August when I shall complete the <a href="http://www.shawson.co.uk/codeblog/8-week-game-competition/">articles detailing the classes I wrote for Manic Spaceman</a>, just incase anyone else wants to try doing something similar and needs some ideas!</p>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/speed-up-your-javascript-video/' rel='bookmark' title='Permanent Link: Speed up your JavaScript : Video'>Speed up your JavaScript : Video</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/8-week-game-competition/' rel='bookmark' title='Permanent Link: 8 Week Game Competition'>8 Week Game Competition</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/couple-of-interesting-news-items-today/' rel='bookmark' title='Permanent Link: Couple of interesting news items today'>Couple of interesting news items today</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/8weekgame-i-won/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>8WeekGame Competition Over &#8211; Vote Now!</title>
		<link>http://www.shawson.co.uk/codeblog/8weekgame-competition-over-vote-now/</link>
		<comments>http://www.shawson.co.uk/codeblog/8weekgame-competition-over-vote-now/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 13:16:55 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=635</guid>
		<description><![CDATA[The 8 week are over, and each of us has our game up and live for you to try out- pop over here to try them out and vote!


Related posts:8WeekGame &#8211; I Won!
8 Week Game Competition
HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple [...]


Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/8weekgame-i-won/' rel='bookmark' title='Permanent Link: 8WeekGame &#8211; I Won!'>8WeekGame &#8211; I Won!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/8-week-game-competition/' rel='bookmark' title='Permanent Link: 8 Week Game Competition'>8 Week Game Competition</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/html5-audio-and-video-media-tags-how-do-you-know-when-the-datas-loaded-and-how-to-play-multiple-instances-of-the-same-sample-at-the-same-time/' rel='bookmark' title='Permanent Link: HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time'>HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>The 8 week are over, and each of us has our game up and live for you to try out- pop over <a href="http://8weekgame.shawson.co.uk/?p=147">here to try them out and vote</a>!</p>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/8weekgame-i-won/' rel='bookmark' title='Permanent Link: 8WeekGame &#8211; I Won!'>8WeekGame &#8211; I Won!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/8-week-game-competition/' rel='bookmark' title='Permanent Link: 8 Week Game Competition'>8 Week Game Competition</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/html5-audio-and-video-media-tags-how-do-you-know-when-the-datas-loaded-and-how-to-play-multiple-instances-of-the-same-sample-at-the-same-time/' rel='bookmark' title='Permanent Link: HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time'>HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/8weekgame-competition-over-vote-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speed up your JavaScript : Video</title>
		<link>http://www.shawson.co.uk/codeblog/speed-up-your-javascript-video/</link>
		<comments>http://www.shawson.co.uk/codeblog/speed-up-your-javascript-video/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 12:05:26 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=632</guid>
		<description><![CDATA[Found a great video today giving JavaScript performance tips while researching last minute omtimisations for my Manic Spaceman game, being launched tommorow at the end of the 8weekgame  competition!  Check the video out here of a talk given by Google employee, Nicholas Zakas.


Related posts:8WeekGame &#8211; I Won!
HTML5 Audio and Video (Media) Tags &#8211; [...]


Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/8weekgame-i-won/' rel='bookmark' title='Permanent Link: 8WeekGame &#8211; I Won!'>8WeekGame &#8211; I Won!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/html5-audio-and-video-media-tags-how-do-you-know-when-the-datas-loaded-and-how-to-play-multiple-instances-of-the-same-sample-at-the-same-time/' rel='bookmark' title='Permanent Link: HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time'>HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/8-week-game-competition/' rel='bookmark' title='Permanent Link: 8 Week Game Competition'>8 Week Game Competition</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>Found a great video today giving JavaScript performance tips while researching last minute omtimisations for my Manic Spaceman game, being launched tommorow at the end of the <a href="http://8weekgame.shawson.co.uk">8weekgame </a> competition!  <a href="http://www.youtube.com/watch?v=mHtdZgou0qU">Check the video out here</a> of a talk given by Google employee, Nicholas Zakas.</p>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/8weekgame-i-won/' rel='bookmark' title='Permanent Link: 8WeekGame &#8211; I Won!'>8WeekGame &#8211; I Won!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/html5-audio-and-video-media-tags-how-do-you-know-when-the-datas-loaded-and-how-to-play-multiple-instances-of-the-same-sample-at-the-same-time/' rel='bookmark' title='Permanent Link: HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time'>HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/8-week-game-competition/' rel='bookmark' title='Permanent Link: 8 Week Game Competition'>8 Week Game Competition</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/speed-up-your-javascript-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Great HTML5 Canvas/ Chrome Demo sites</title>
		<link>http://www.shawson.co.uk/codeblog/great-html5-canvas-chrome-demo-site/</link>
		<comments>http://www.shawson.co.uk/codeblog/great-html5-canvas-chrome-demo-site/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 15:16:35 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=629</guid>
		<description><![CDATA[Found this today; www.chromeexperiments.com loads of cool canvas experiments- geared towards google chrome but most run well in up to date firefox build.
Update: also worth a look in; www.canvasdemos.com


Related posts:HTML5 &#038; the Processing.js JavaScript library
Processingjs &#038; Box2d Physics!
Javascript Nintendo Emulator!!



Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/great-site-with-loads-of-javascript-and-css-resources/' rel='bookmark' title='Permanent Link: HTML5 &#038; the Processing.js JavaScript library'>HTML5 &#038; the Processing.js JavaScript library</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/processingjs-box2d-physics/' rel='bookmark' title='Permanent Link: Processingjs &#038; Box2d Physics!'>Processingjs &#038; Box2d Physics!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/javascript-nintendo-emulator/' rel='bookmark' title='Permanent Link: Javascript Nintendo Emulator!!'>Javascript Nintendo Emulator!!</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>Found this today; <a href="http://www.chromeexperiments.com">www.chromeexperiments.com</a> loads of cool canvas experiments- geared towards google chrome but most run well in up to date firefox build.</p>
<p>Update: also worth a look in; <a href="http://www.canvasdemos.com/">www.canvasdemos.com</a></p>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/great-site-with-loads-of-javascript-and-css-resources/' rel='bookmark' title='Permanent Link: HTML5 &#038; the Processing.js JavaScript library'>HTML5 &#038; the Processing.js JavaScript library</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/processingjs-box2d-physics/' rel='bookmark' title='Permanent Link: Processingjs &#038; Box2d Physics!'>Processingjs &#038; Box2d Physics!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/javascript-nintendo-emulator/' rel='bookmark' title='Permanent Link: Javascript Nintendo Emulator!!'>Javascript Nintendo Emulator!!</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/great-html5-canvas-chrome-demo-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.net update panel&#8217;s and jQuery</title>
		<link>http://www.shawson.co.uk/codeblog/asp-net-update-panels-and-jquery/</link>
		<comments>http://www.shawson.co.uk/codeblog/asp-net-update-panels-and-jquery/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 11:05:40 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=625</guid>
		<description><![CDATA[I had a problem today with buttons in an update panel and jQuery- there are some buttons which get hidden or displayed depending on the user&#8217;s OS &#8211; mac or pc users basically get shown different instructions- However because these buttons are added by a partial post back of the update panel, the jQuery document.ready [...]


Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/jquery-accordion-control-links-not-working/' rel='bookmark' title='Permanent Link: JQuery Accordion Control links not working'>JQuery Accordion Control links not working</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/google-code-highlighter/' rel='bookmark' title='Permanent Link: Google Code Highlighter'>Google Code Highlighter</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/using-findcontrol-to-find-a-repeater-nested-inside-a-repeater-with-headertemplate-or-footertemplate-defined/' rel='bookmark' title='Permanent Link: Using FindControl to find a repeater nested inside a repeater with HeaderTemplate or FooterTemplate defined'>Using FindControl to find a repeater nested inside a repeater with HeaderTemplate or FooterTemplate defined</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>I had a problem today with buttons in an update panel and jQuery- there are some buttons which get hidden or displayed depending on the user&#8217;s OS &#8211; mac or pc users basically get shown different instructions- However because these buttons are added by a partial post back of the update panel, the jQuery document.ready had already fired before these buttons existed.</p>
<p>So I experimented adding the code to the form.submit event but in the end found the solution on google; I simply added this;</p>
<pre class="brush: javascript">
&lt;script type=&#039;text/javascript&#039;&gt;
function pageLoad(sender, args)
{
    // your code here..
    showHideMacLinks();
}
&lt;/script&gt;
</pre>
<p>This handles the pageLoad event raised by my update panel which is fired on the initial load and on the partial post back.  You can filter this to only fire on partial post back by adding  &#8220;if(args.get_isPartialLoad())&#8221;</p>
<p>Found this over on the <a href="http://www.dotnetfunda.com/articles/article471-jquery-and-aspnet-ajax-updatepanel-.aspx">.net Funda blog</a></p>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/jquery-accordion-control-links-not-working/' rel='bookmark' title='Permanent Link: JQuery Accordion Control links not working'>JQuery Accordion Control links not working</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/google-code-highlighter/' rel='bookmark' title='Permanent Link: Google Code Highlighter'>Google Code Highlighter</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/using-findcontrol-to-find-a-repeater-nested-inside-a-repeater-with-headertemplate-or-footertemplate-defined/' rel='bookmark' title='Permanent Link: Using FindControl to find a repeater nested inside a repeater with HeaderTemplate or FooterTemplate defined'>Using FindControl to find a repeater nested inside a repeater with HeaderTemplate or FooterTemplate defined</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/asp-net-update-panels-and-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac Safari Web Developer Tools (inc javascript debugging!)</title>
		<link>http://www.shawson.co.uk/codeblog/mac-safari-web-developer-tools-inc-javascript-debugging/</link>
		<comments>http://www.shawson.co.uk/codeblog/mac-safari-web-developer-tools-inc-javascript-debugging/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 11:40:58 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mac os x]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=597</guid>
		<description><![CDATA[make sure you don&#8217;t have safari running, then go to the terminal window and type;
defaults write com.apple.Safari IncludeDebugMenu 1
You will have a new menu when you launch safari entitled &#8220;develop&#8221; in safari 5, and &#8220;debug&#8221; i believe in earlier versions.


Related posts:Showing Hidden files on the Mac OS
Javascript Nintendo Emulator!!
HTML5 &#038; the Processing.js JavaScript library



Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/showing-hidden-files-on-the-mac-os/' rel='bookmark' title='Permanent Link: Showing Hidden files on the Mac OS'>Showing Hidden files on the Mac OS</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/javascript-nintendo-emulator/' rel='bookmark' title='Permanent Link: Javascript Nintendo Emulator!!'>Javascript Nintendo Emulator!!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/great-site-with-loads-of-javascript-and-css-resources/' rel='bookmark' title='Permanent Link: HTML5 &#038; the Processing.js JavaScript library'>HTML5 &#038; the Processing.js JavaScript library</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>make sure you don&#8217;t have safari running, then go to the terminal window and type;</p>
<p><code>defaults write com.apple.Safari IncludeDebugMenu 1</code></p>
<p>You will have a new menu when you launch safari entitled &#8220;develop&#8221; in safari 5, and &#8220;debug&#8221; i believe in earlier versions.</p>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/showing-hidden-files-on-the-mac-os/' rel='bookmark' title='Permanent Link: Showing Hidden files on the Mac OS'>Showing Hidden files on the Mac OS</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/javascript-nintendo-emulator/' rel='bookmark' title='Permanent Link: Javascript Nintendo Emulator!!'>Javascript Nintendo Emulator!!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/great-site-with-loads-of-javascript-and-css-resources/' rel='bookmark' title='Permanent Link: HTML5 &#038; the Processing.js JavaScript library'>HTML5 &#038; the Processing.js JavaScript library</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/mac-safari-web-developer-tools-inc-javascript-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time</title>
		<link>http://www.shawson.co.uk/codeblog/html5-audio-and-video-media-tags-how-do-you-know-when-the-datas-loaded-and-how-to-play-multiple-instances-of-the-same-sample-at-the-same-time/</link>
		<comments>http://www.shawson.co.uk/codeblog/html5-audio-and-video-media-tags-how-do-you-know-when-the-datas-loaded-and-how-to-play-multiple-instances-of-the-same-sample-at-the-same-time/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 17:54:01 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=590</guid>
		<description><![CDATA[Quick post with a snippet of code I&#8217;ve used for the 8 week game competition I&#8217;m in- I&#8217;m going to be using html5 audio element for all my game&#8217;s sounds and needed a way to make sure the samples were totally loaded so the resource manager knows when to hand control to the game- So [...]


Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/great-site-with-loads-of-javascript-and-css-resources/' rel='bookmark' title='Permanent Link: HTML5 &#038; the Processing.js JavaScript library'>HTML5 &#038; the Processing.js JavaScript library</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/8-week-game-competition/' rel='bookmark' title='Permanent Link: 8 Week Game Competition'>8 Week Game Competition</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/processingjs-box2d-physics/' rel='bookmark' title='Permanent Link: Processingjs &#038; Box2d Physics!'>Processingjs &#038; Box2d Physics!</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>Quick post with a snippet of code I&#8217;ve used for the <a href="http://8weekgame.shawson.co.uk/">8 week game competition</a> I&#8217;m in- I&#8217;m going to be using html5 audio element for all my game&#8217;s sounds and needed a way to make sure the samples were totally loaded so the resource manager knows when to hand control to the game- So after flicking through <a href="http://www.whatwg.org/specs/web-apps/current-work/">the html5 spec</a> came up with this code (utilising jQuery to bind my event handler)</p>
<p>Note- This applies to any media object- so the video tag as well, but I&#8217;ve only tried this with audio.</p>
<pre class="brush: javascript">
// http://www.whatwg.org/specs/web-apps/current-work/#mediaevents
// http://api.jquery.com/bind/
var ao = new Audio();
$(ao).bind(&#039;canplaythrough&#039;, function() { // totally loaded
alert(&#039;ready to play&#039;);
});
ao.src = &#039;sounds/my_sound.wav&#039;;
ao.load();
</pre>
<p>The above example will wait until the media element has enough data to comfortably play through without stopping to buffer.  if you wanted you could also bind to a whole host of other events in exactly the same way, which you can <a href="http://www.whatwg.org/specs/web-apps/current-work/#mediaevents">read about here</a>.  You can check the status at any time to see how loaded the audio/video file is like this;</p>
<pre class="brush: javascript">
ao.readyState;
</pre>
<p>This will return you back a number between 0 (HAVE_NOTHING) to 4 (HAVE_ENOUGH_DATA) &#8211; <a href="http://www.whatwg.org/specs/web-apps/current-work/#dom-media-have_nothing">full info can be found here</a>.</p>
<p>Because I&#8217;m building a game I have slightly different requirements to the average web project- The way I use this is have a central &#8220;ResourceLoader&#8221; which I load up with all the url&#8217;s to the asset&#8217;s I&#8217;ll be using, this then reports when all the assets are totally loaded and hands control to the game.  So there is a single instance of every image and audio element I&#8217;m using- I then hand each loaded sound to the sound manager to play.  This raises a problem when i want to play the same sample more than once, overlapping because you are essentially just passing around reference to the same audio object- so i execute the play method, then execute it again and nothing happens because it is already playing!  The answer is to perform a deep copy of the audio element before playing- because this is a DOM object you can do this easily like so;</p>
<pre class="brush: javascript">
// https://developer.mozilla.org/en/CloneNode
var instance1 = ao.cloneNode(true);
var instance2 = ao.cloneNode(true);
instance1.play();
instance2.play();
</pre>
<p>This way you can hit the play() method of instance1, and the instance2 and they will both play at the same time, totally independant of each other, even though they both originate from the pre-loaded instance ao.</p>
<p>Anyway- you can see live demos of this here;</p>
<ul>
<li><a href="http://8weekgame.shawson.co.uk/shaw-demos/v3/sound-test-chrome.htm">MP3 Demo (For Chrome!)</a></li>
<li><a href="http://8weekgame.shawson.co.uk/shaw-demos/v3/sound-test.htm">WAV Demo</a></li>
</ul>
<p>Notice the need for 2 demos because chrome cant read wav and mozilla wont do MP3!  Ogg vorbis is a common format for the two, but i couldn&#8217;t quickly find any example files to use!  <a href="http://html5doctor.com/native-audio-in-the-browser/">Read here for browser file format support</a>.</p>
<p>These demo&#8217;s were made for us in the <a href="http://8weekgame.shawson.co.uk/">8weekgame </a>site &#8211; bare in mind the sound manager class I literally started about an hour ago so it&#8217;s got hardly any functionality but it does play sounds so take a look at the source code and hopefully it will all make sense!</p>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/great-site-with-loads-of-javascript-and-css-resources/' rel='bookmark' title='Permanent Link: HTML5 &#038; the Processing.js JavaScript library'>HTML5 &#038; the Processing.js JavaScript library</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/8-week-game-competition/' rel='bookmark' title='Permanent Link: 8 Week Game Competition'>8 Week Game Competition</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/processingjs-box2d-physics/' rel='bookmark' title='Permanent Link: Processingjs &#038; Box2d Physics!'>Processingjs &#038; Box2d Physics!</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/html5-audio-and-video-media-tags-how-do-you-know-when-the-datas-loaded-and-how-to-play-multiple-instances-of-the-same-sample-at-the-same-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>8 Week Game Competition</title>
		<link>http://www.shawson.co.uk/codeblog/8-week-game-competition/</link>
		<comments>http://www.shawson.co.uk/codeblog/8-week-game-competition/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 20:21:27 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=566</guid>
		<description><![CDATA[I&#8217;m currently participating in the 8weekgame competition.  This 8 week sprint is dedicated to (by picking out of a hat) a clone of the retro classic, &#8220;Manic Miner&#8220;- I&#8217;ve chosen to build mine using javascript and the canvas element in html5 (and probably the audio elements also).  The other 2 guys are using Microsoft XNA [...]


Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/8weekgame-i-won/' rel='bookmark' title='Permanent Link: 8WeekGame &#8211; I Won!'>8WeekGame &#8211; I Won!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/8weekgame-competition-over-vote-now/' rel='bookmark' title='Permanent Link: 8WeekGame Competition Over &#8211; Vote Now!'>8WeekGame Competition Over &#8211; Vote Now!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/html5-audio-and-video-media-tags-how-do-you-know-when-the-datas-loaded-and-how-to-play-multiple-instances-of-the-same-sample-at-the-same-time/' rel='bookmark' title='Permanent Link: HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time'>HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently participating in the 8weekgame competition.  This 8 week sprint is dedicated to (by picking out of a hat) a clone of the retro classic, &#8220;<a href="http://www.fraserking.co.uk/spectrum/screenshots/Manic_Miner1.png" target="_blank">Manic Miner</a>&#8220;- I&#8217;ve chosen to build mine using javascript and the canvas element in html5 (and probably the audio elements also).  The other 2 guys are using Microsoft XNA framework; with Martin targetting windows, and Gareth targetting XBox live arcade.  You can follow our progress here ; <a href="http://8weekgame.shawson.co.uk/" target="_blank">8weekgame.shawson.co.uk</a></p>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/8weekgame-i-won/' rel='bookmark' title='Permanent Link: 8WeekGame &#8211; I Won!'>8WeekGame &#8211; I Won!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/8weekgame-competition-over-vote-now/' rel='bookmark' title='Permanent Link: 8WeekGame Competition Over &#8211; Vote Now!'>8WeekGame Competition Over &#8211; Vote Now!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/html5-audio-and-video-media-tags-how-do-you-know-when-the-datas-loaded-and-how-to-play-multiple-instances-of-the-same-sample-at-the-same-time/' rel='bookmark' title='Permanent Link: HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time'>HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/8-week-game-competition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OO &amp; Inheritance with Javascript</title>
		<link>http://www.shawson.co.uk/codeblog/oo-inheritance-with-javascript/</link>
		<comments>http://www.shawson.co.uk/codeblog/oo-inheritance-with-javascript/#comments</comments>
		<pubDate>Sun, 23 May 2010 18:02:22 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[OO Design]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=551</guid>
		<description><![CDATA[I&#8217;m getting ready to start a game development project and getting my OO Javascript up to scratch- I&#8217;ve been googling around for a while as there seems to be a whole load of different ways to implement OO and in particular inheritance in javascript.  I&#8217;ve finally found a method that work&#8217;s reliably, and with multiple [...]


Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/creating-a-re-usable-shopping-basket-with-generics-in-c-sharp/' rel='bookmark' title='Permanent Link: Creating a re-usable shopping basket with Generics in C#'>Creating a re-usable shopping basket with Generics in C#</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/html5-audio-and-video-media-tags-how-do-you-know-when-the-datas-loaded-and-how-to-play-multiple-instances-of-the-same-sample-at-the-same-time/' rel='bookmark' title='Permanent Link: HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time'>HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/google-code-highlighter/' rel='bookmark' title='Permanent Link: Google Code Highlighter'>Google Code Highlighter</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m getting ready to start a game development project and getting my OO Javascript up to scratch- I&#8217;ve been googling around for a while as there seems to be a whole load of different ways to implement OO and in particular inheritance in javascript.  I&#8217;ve finally found a method that work&#8217;s reliably, and with multiple generation of inheritance- It&#8217;s from an <a href="http://www.sitepoint.com/blogs/2006/01/17/javascript-inheritance/">article on the site point website</a> &#8211; for quick reference I will cut to the meat and give a usage example- for details see the original article;</p>
<p>add this function to your project;</p>
<pre>
<pre class="brush: javascript">
function copyPrototype(descendant, parent) {
  var sConstructor = parent.toString();
  var aMatch = sConstructor.match( /\s*function (.*)\(/ );
  if ( aMatch != null ) { descendant.prototype[aMatch[1]] = parent; }
  for (var m in parent.prototype) {
    descendant.prototype[m] = parent.prototype[m];
  }
};
</pre>
</pre>
<p>Then define your classes (prototypes) like so;</p>
<pre>
<pre class="brush: javascript">
function AClass(param) {
   this.Text=param;
}
AClass.prototype.Speak = function() {
  alert(this.Text);
}

function BClass(param, name) {
  this.AClass(param);
  this.Name = name;
}
copyPrototype(BClass, AClass);
BClass.prototype.Speak = function() {
  alert(&#039;Hi &#039; + name);

  // Call overridden parent method...
  AClass.prototype.Speak.apply(this);
}
</pre>
</pre>
<p>So the above example will give you 2 classes- B is derived from A.  Calling AClass.Speak will give you a single alert with the contents of the &#8216;text&#8217; property, whereas BClass.Speak will give you two text boxes; the first greeting you by name, and the second being the alert box from AClass.  I&#8217;ve tested this myself with multiple generations of inheritance and it worked fine, where <a href="http://www.coolpage.com/developer/javascript/Correct%20OOP%20for%20Javascript.html">other</a> <a href="http://phrogz.net/JS/Classes/OOPinJS2.html">methods</a> have not.</p>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/creating-a-re-usable-shopping-basket-with-generics-in-c-sharp/' rel='bookmark' title='Permanent Link: Creating a re-usable shopping basket with Generics in C#'>Creating a re-usable shopping basket with Generics in C#</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/html5-audio-and-video-media-tags-how-do-you-know-when-the-datas-loaded-and-how-to-play-multiple-instances-of-the-same-sample-at-the-same-time/' rel='bookmark' title='Permanent Link: HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time'>HTML5 Audio and Video (Media) Tags &#8211; How do you know when the data&#8217;s loaded? And how to play multiple instances of the same sample at the same time</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/google-code-highlighter/' rel='bookmark' title='Permanent Link: Google Code Highlighter'>Google Code Highlighter</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/oo-inheritance-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Nintendo Emulator!!</title>
		<link>http://www.shawson.co.uk/codeblog/javascript-nintendo-emulator/</link>
		<comments>http://www.shawson.co.uk/codeblog/javascript-nintendo-emulator/#comments</comments>
		<pubDate>Mon, 17 May 2010 15:41:29 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=545</guid>
		<description><![CDATA[This is crazy; http://benfirshman.com/projects/jsnes/
A full blown nes emulator powered entirely by javascript/ html5 canvas.  I know- I&#8217;ve seen quake running, which is a full blown 3d game, and very cool- but this is a full blown games console!


Related posts:HTML5 &#038; the Processing.js JavaScript library
Processingjs &#038; Box2d Physics!
Great HTML5 Canvas/ Chrome Demo sites



Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/great-site-with-loads-of-javascript-and-css-resources/' rel='bookmark' title='Permanent Link: HTML5 &#038; the Processing.js JavaScript library'>HTML5 &#038; the Processing.js JavaScript library</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/processingjs-box2d-physics/' rel='bookmark' title='Permanent Link: Processingjs &#038; Box2d Physics!'>Processingjs &#038; Box2d Physics!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/great-html5-canvas-chrome-demo-site/' rel='bookmark' title='Permanent Link: Great HTML5 Canvas/ Chrome Demo sites'>Great HTML5 Canvas/ Chrome Demo sites</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>This is crazy; <a href="http://benfirshman.com/projects/jsnes/">http://benfirshman.com/projects/jsnes/</a></p>
<p>A full blown nes emulator powered entirely by javascript/ html5 canvas.  I know- I&#8217;ve seen <a href="http://code.google.com/p/quake2-gwt-port/">quake</a> running, which is a full blown 3d game, and very cool- but this is a full blown games console!</p>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/great-site-with-loads-of-javascript-and-css-resources/' rel='bookmark' title='Permanent Link: HTML5 &#038; the Processing.js JavaScript library'>HTML5 &#038; the Processing.js JavaScript library</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/processingjs-box2d-physics/' rel='bookmark' title='Permanent Link: Processingjs &#038; Box2d Physics!'>Processingjs &#038; Box2d Physics!</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/great-html5-canvas-chrome-demo-site/' rel='bookmark' title='Permanent Link: Great HTML5 Canvas/ Chrome Demo sites'>Great HTML5 Canvas/ Chrome Demo sites</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/javascript-nintendo-emulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
