<?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>Is Good Stuff &#187; Tutorials</title>
	<atom:link href="http://www.isgoodstuff.com/tag/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.isgoodstuff.com</link>
	<description>All the good stuff here!</description>
	<lastBuildDate>Thu, 09 Feb 2012 13:46:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>HTML5 : FREE Cloud Carousel</title>
		<link>http://www.isgoodstuff.com/2012/02/09/html5-free-cloud-carousel/</link>
		<comments>http://www.isgoodstuff.com/2012/02/09/html5-free-cloud-carousel/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 12:57:37 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=2191</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/cloudCarouselCropped2-179245_300x185.png"/></p>New and free interactive HTML5 Canvas Carousel to try out today!]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/cloudCarouselCropped2-179245_300x185.png"/></p><p>Previously I&#8217;ve wrote before about an article about <a href="http://www.isgoodstuff.com/2008/05/28/free-flash-carousel-slideshow/">flash based carousel here</a>. Today I&#8217;m gonna share and write about carousel again, but not the flash version this is html5 canvas combo with jquery version. Check out the beautiful carousel picture below, click to <a href="http://www.isgoodstuff.com/wp-content/demo/CarouselHTML5/" target="_blank">run the demo</a>. It runs smoothly on all major browser and has a cool fallback support in case javascript is turned off. Such a beautiful expression of art written in latest cutting edge tech&#8230;all good!</p>
<p style="text-align: center;"><a href="http://www.isgoodstuff.com/wp-content/demo/CarouselHTML5/" target="_blank"><img class="aligncenter size-full wp-image-2192" title="cloudCarousel" src="http://www.isgoodstuff.com/wp-content/uploads/2012/02/cloudCarousel.png" alt="" width="495" height="342" /></a></p>
<p style="text-align: left;">The carousel above is called <a href="http://www.professorcloud.com/mainsite/carousel.htm" target="_blank">Cloud Carousel</a> written by Prof Cloud. Below are some example on how to implement this carousel.</p>
<p style="text-align: left;">
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;head&gt;
 &lt;title&gt;Cloud Carousel&lt;/title&gt;
 &lt;!-- 1. Download and insert the script from Cloud Carousel Website --&gt;
 &lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
 &lt;script type=&quot;text/javaScript&quot; src=&quot;cloud-carousel.1.0.5.min.js&quot;&gt;&lt;/script&gt;
 &lt;script type=&quot;text/javascript&quot;&gt;
  $(document).ready(function(){
		// This initialises carousels on the container elements specified, in this case, carousel1.
		$(&quot;#carousel1&quot;).CloudCarousel(		
			{			
				// Best is half of the width you set in DIV style of carouselID
				xPos: 285,
				// Determines the central height of the pivot point of the carousel itself.
				yPos: 100,
				buttonLeft: $(&quot;#butLeft&quot;),
				buttonRight: $(&quot;#butRight&quot;),
				reflHeight: 56,
				reflGap:2,
			}
		);
	});
&nbsp;
 &lt;/script&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
 &lt;!-- 2. Declare a div with a given carouselID Name, use style to manage the style and height. You can add background also --&gt;
 &lt;!-- 3. Declare class=&quot;cloudcarousel&quot; to all the images sandwitched in between the div tag, these will be the images for the carousel --&gt;
 &lt;div id=&quot;carousel1&quot; style=&quot;width:570px; height:220px; background:#000;overflow:scroll;&quot;&gt;
        &lt;a href=&quot;http://www.watchlearnknow.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/BlueAppIcon.png&quot; alt=&quot;AppIcon1&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
        &lt;a href=&quot;http://www.wikipedia.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/GoldAppIcon.png&quot; alt=&quot;AppIcon2&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
	&lt;a href=&quot;http://www.wordpress.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/GreenAppIcon.png&quot; alt=&quot;AppIcon3&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
	&lt;a href=&quot;http://www.yahoo.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/OrangeAppIcon.png&quot; alt=&quot;AppIcon4&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
	&lt;a href=&quot;http://www.apple.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/RedAppIcon.png&quot; alt=&quot;AppIcon5&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
	&lt;a href=&quot;http://www.android.com&quot;&gt;&lt;img class=&quot;cloudcarousel&quot; src=&quot;images/PinkAppIcon.png&quot; alt=&quot;AppIcon6&quot; width=&quot;58&quot; height =&quot;58&quot;/&gt;&lt;/a&gt;
&nbsp;
    &lt;div id=&quot;butLeft&quot; style=&quot;position:relative;top:20px;left:20px;padding:5px;background:#fff;&quot;&gt;&amp;lt;&lt;/div&gt;
    &lt;div id=&quot;butRight&quot; style=&quot;position:relative;top:20px;left:30px;padding:5px;background:#fff;&quot;&gt;&amp;gt;&lt;/div&gt; 
 &lt;/div&gt;
&lt;/body&gt;</pre></td></tr></table></div>

<p>Well that&#8217;s it for today. If you want to take a look on my demo in source file.<br />
<p><strong><a href="http://www.isgoodstuff.com/wp-content/plugins/download-monitor/download.php?id=33">Download Here</a></strong></p></br></p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2012/02/09/html5-free-cloud-carousel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5: Keyboard Controls &amp; Update Loop (enterFramer)</title>
		<link>http://www.isgoodstuff.com/2012/01/30/html5-keyboard-controls-update-loop-enterframer/</link>
		<comments>http://www.isgoodstuff.com/2012/01/30/html5-keyboard-controls-update-loop-enterframer/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 01:28:18 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=2184</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/html5Image.png"/></p>HTML5 - How to script a simple keyboard control and creating an update loop.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/html5Image.png"/></p><p style="text-align: justify;">Hiya folks, I&#8217;m back for more html5 goodies. Today i&#8217;m gonna focus more on how to script a simple keyboard control and how we make our update loop (for those coming from AS3 background, this is how we do our enterFrame). Let&#8217;s move on. </p>
<p style="text-align: justify;">Before we start, I would like to emphasize again scripting in html5 has always been with data and render done separately. Meaning, you write objects to contain it&#8217;s x and y value and compute it&#8217;s movement every updateCycle before rendering it into canvas. Check out the <strong><a href="http://www.isgoodstuff.com/wp-content/demo/Tutorial%202/" target="_blank">demo here</a></strong>.</p>
<p style="text-align: center;"><a href="http://www.isgoodstuff.com/wp-content/demo/Tutorial%202/" target="_blank"><img class="aligncenter size-full wp-image-2175" style="margin-top:5px;" title="CanvasUpdateCycle" src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/CanvasUpdateCycle.jpg" alt="" width="486" height="468" /></a></p>
<p style="text-align: justify;">Below is my enterFrame Util js (this is a update loop js). You can use it for all your project. In fact, it also comes with a cool fps counter for benchmarking; all you need to do is to pass in the div id parameter for it&#8217;s output. We use update loop cycle to check in runtime, changes that happen to the objects in canvas, for example, update of movement and etc.</p>
<h4><strong>Enterframe.js</strong></h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> enterFrame <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// To Use this enterFrame Utility just include into script src.</span>
	<span style="color: #006600; font-style: italic;">// Then, use enterFrame.init( callBackFunction );</span>
	<span style="color: #006600; font-style: italic;">// where callbackFunction is the function that will cycle update.</span>
	<span style="color: #006600; font-style: italic;">// e.g.</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// enterFrame.init(60, handleEnterFrame);</span>
	<span style="color: #006600; font-style: italic;">// function handleEnterFrame(){</span>
	<span style="color: #006600; font-style: italic;">//      // This function runs at default 60 FrameRate</span>
	<span style="color: #006600; font-style: italic;">//      // You can also use getFPS here since, it requires</span>
	<span style="color: #006600; font-style: italic;">//      // an constant update cycle.</span>
	<span style="color: #006600; font-style: italic;">// }</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
enterFrame <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> myFrameRate <span style="color: #339933;">=</span> <span style="color: #CC0000;">60</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> intervalTime <span style="color: #339933;">=</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">/</span>myFrameRate<span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> lastTime <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> frameCount <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> intervalTimer<span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> myCallbackFunc<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> ENTERFRAME<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> myCallbackFunc.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> calcFPS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> nowTime <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> diffTime <span style="color: #339933;">=</span> Math.<span style="color: #660066;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>nowTime.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> lastTime.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> fps <span style="color: #339933;">=</span> myFrameRate<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>diffTime <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			fps <span style="color: #339933;">=</span> frameCount<span style="color: #339933;">;</span>
			frameCount <span style="color: #339933;">=</span> <span style="color: #CC0000;">0.0</span><span style="color: #339933;">;</span>
			lastTime <span style="color: #339933;">=</span> nowTime<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">return</span> frameCount<span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
		init<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>arg1<span style="color: #339933;">,</span> arg2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">===</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">//Arguements checker:if pass in two, use arg1 as framerate override </span>
				<span style="color: #006600; font-style: italic;">// and arg2 as callback function</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setFrameRate</span><span style="color: #009900;">&#40;</span> arg1 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				myCallbackFunc <span style="color: #339933;">=</span> arg2<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">//Arguements checker:if pass in only one, use arg1 as callback function</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setFrameRate</span><span style="color: #009900;">&#40;</span> <span style="color: #CC0000;">60</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				myCallbackFunc <span style="color: #339933;">=</span> arg1<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			intervalTimer <span style="color: #339933;">=</span> setInterval<span style="color: #009900;">&#40;</span>ENTERFRAME<span style="color: #339933;">,</span> intervalTime <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
		clear<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			clearInterval<span style="color: #009900;">&#40;</span> intervalTimer <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
		setFrameRate<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			myFrameRate <span style="color: #339933;">=</span> value<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
		getFPS<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>divName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// Must be used within callback function of EnterFrame.</span>
			<span style="color: #000066; font-weight: bold;">return</span> divName.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;FPS Counter : &quot;</span> <span style="color: #339933;">+</span> calcFPS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-align: justify;">And let&#8217;s look at the main html and how we intend to use it today alongside with key controls. Always try to located the middle registration point of the object you are about to draw in canvas. It is useful for positioning and animation wise. You also will need to clear the canvas content every update cycle loop (in other words every enterFrame). See codes below.</p>
<h4><strong>index.html</strong></h4>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;Sample App HTML5 One - Using Canvas and Filters&lt;/title&gt;
	&lt;meta name=&quot;generator&quot; content=&quot;TextMate http://macromates.com/&quot;&gt;
	&lt;meta name=&quot;author&quot; content=&quot;Alex Tam Ming Yen&quot;&gt;
	&lt;LINK href=&quot;default.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;
	&lt;!-- Date: 2011-12-31 --&gt;
	&lt;script src=&quot;lib/enterFrame.js&quot; text=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	&lt;script&gt;
		function triggerReady(){
			var canvas = document.getElementById('canvas');  
			var contxt = canvas.getContext('2d');
			var myBox = new Object();  
&nbsp;
			function startDraw(){
				  var halfCanvasWidth = 480/2;
				  var halfCanvasHeight = 320/2;
				  var middlePointX = halfCanvasWidth - 10;
				  var middlePointY = halfCanvasHeight - 10;
&nbsp;
				  if (canvas.getContext){  
				    contxt.fillStyle = &quot;#fff&quot;;
				    contxt.fillRect(middlePointX,middlePointY,20,20);
				  	myBox.context = contxt;
					myBox.x = middlePointX;
					myBox.y = middlePointY;
					myBox.centerX = 10;
					myBox.centerY = 10;
				  }
			}
&nbsp;
			function clear(){
				contxt.clearRect(0, 0, 480, 320);
			}
&nbsp;
			startDraw();
			enterFrame.init( handleEnterFrame );
			function handleEnterFrame(){
				enterFrame.getFPS(label1);
				document.onkeypress = function(evt){
					var evt  = (evt) ? evt : ((event) ? event : null);
					var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
					// console.log( event.keyCode );
&nbsp;
					switch (event.keyCode) {
						case 32:
						     	clear();
								startDraw();
						break;
&nbsp;
						case 37:
								myBox.x -= 5;
					    break;
&nbsp;
						case 97:
								myBox.x -= 5;
						break;
&nbsp;
						case 38:
								myBox.y -=5;
						break;
&nbsp;
						case 119:
								myBox.y -=5;
						break;
&nbsp;
						case 39:
					    		myBox.x += 5;
					    break;
&nbsp;
						case 100:
								myBox.x += 5;
						break;
&nbsp;
						case 40:
								myBox.y += 5;					
					    break;
&nbsp;
						case 115:
								myBox.y += 5;
						break;
					}
				};
				renderUpdate();
			}
&nbsp;
			function renderUpdate(){
				clear();
				contxt.fillRect(myBox.x,myBox.y,20,20);				
			}
		}
	&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;triggerReady()&quot;&gt;
	&lt;div class=&quot;titleBar&quot;&gt;
		&lt;h1 class=&quot;label15Arial&quot;&gt;Canvas Update Cycle&lt;h1&gt;
	&lt;/div&gt;
&nbsp;
	&lt;div class=&quot;borderContainer&quot;&gt;&lt;canvas id=&quot;canvas&quot; width=&quot;480&quot; height=&quot;320&quot;&gt;&lt;/canvas&gt;&lt;/div&gt;
	&lt;div class=&quot;controlsContainer&quot;&gt;
		&lt;div id=&quot;label1&quot; class=&quot;label1&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>Here are the default.css for the html.</p>
<h4><strong>default.css</strong></h4>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/**************************** HTML 5 RESET **************************/</span>
html<span style="color: #00AA00;">,</span> body<span style="color: #00AA00;">,</span> div<span style="color: #00AA00;">,</span> span<span style="color: #00AA00;">,</span> applet<span style="color: #00AA00;">,</span> object<span style="color: #00AA00;">,</span> iframe<span style="color: #00AA00;">,</span>
h1<span style="color: #00AA00;">,</span> h2<span style="color: #00AA00;">,</span> h3<span style="color: #00AA00;">,</span> h4<span style="color: #00AA00;">,</span> h5<span style="color: #00AA00;">,</span> h6<span style="color: #00AA00;">,</span> p<span style="color: #00AA00;">,</span> blockquote<span style="color: #00AA00;">,</span> pre<span style="color: #00AA00;">,</span>
a<span style="color: #00AA00;">,</span> abbr<span style="color: #00AA00;">,</span> acronym<span style="color: #00AA00;">,</span> address<span style="color: #00AA00;">,</span> big<span style="color: #00AA00;">,</span> cite<span style="color: #00AA00;">,</span> code<span style="color: #00AA00;">,</span>
del<span style="color: #00AA00;">,</span> dfn<span style="color: #00AA00;">,</span> em<span style="color: #00AA00;">,</span> img<span style="color: #00AA00;">,</span> ins<span style="color: #00AA00;">,</span> kbd<span style="color: #00AA00;">,</span> q<span style="color: #00AA00;">,</span> s<span style="color: #00AA00;">,</span> samp<span style="color: #00AA00;">,</span>
small<span style="color: #00AA00;">,</span> strike<span style="color: #00AA00;">,</span> strong<span style="color: #00AA00;">,</span> sub<span style="color: #00AA00;">,</span> sup<span style="color: #00AA00;">,</span> tt<span style="color: #00AA00;">,</span> var<span style="color: #00AA00;">,</span>
b<span style="color: #00AA00;">,</span> u<span style="color: #00AA00;">,</span> i<span style="color: #00AA00;">,</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">,</span>
dl<span style="color: #00AA00;">,</span> dt<span style="color: #00AA00;">,</span> dd<span style="color: #00AA00;">,</span> ol<span style="color: #00AA00;">,</span> ul<span style="color: #00AA00;">,</span> li<span style="color: #00AA00;">,</span>
fieldset<span style="color: #00AA00;">,</span> form<span style="color: #00AA00;">,</span> label<span style="color: #00AA00;">,</span> legend<span style="color: #00AA00;">,</span>
table<span style="color: #00AA00;">,</span> caption<span style="color: #00AA00;">,</span> tbody<span style="color: #00AA00;">,</span> tfoot<span style="color: #00AA00;">,</span> thead<span style="color: #00AA00;">,</span> tr<span style="color: #00AA00;">,</span> th<span style="color: #00AA00;">,</span> td<span style="color: #00AA00;">,</span>
article<span style="color: #00AA00;">,</span> aside<span style="color: #00AA00;">,</span> canvas<span style="color: #00AA00;">,</span> details<span style="color: #00AA00;">,</span> <span style="color: #993333;">embed</span><span style="color: #00AA00;">,</span> 
figure<span style="color: #00AA00;">,</span> figcaption<span style="color: #00AA00;">,</span> footer<span style="color: #00AA00;">,</span> header<span style="color: #00AA00;">,</span> hgroup<span style="color: #00AA00;">,</span> 
menu<span style="color: #00AA00;">,</span> nav<span style="color: #00AA00;">,</span> output<span style="color: #00AA00;">,</span> ruby<span style="color: #00AA00;">,</span> section<span style="color: #00AA00;">,</span> summary<span style="color: #00AA00;">,</span>
time<span style="color: #00AA00;">,</span> mark<span style="color: #00AA00;">,</span> audio<span style="color: #00AA00;">,</span> video <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inherit</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">baseline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* HTML5 display-role reset for older browsers */</span>
article<span style="color: #00AA00;">,</span> aside<span style="color: #00AA00;">,</span> details<span style="color: #00AA00;">,</span> figcaption<span style="color: #00AA00;">,</span> figure<span style="color: #00AA00;">,</span> 
footer<span style="color: #00AA00;">,</span> header<span style="color: #00AA00;">,</span> hgroup<span style="color: #00AA00;">,</span> menu<span style="color: #00AA00;">,</span> nav<span style="color: #00AA00;">,</span> section <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
ol<span style="color: #00AA00;">,</span> ul <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
blockquote<span style="color: #00AA00;">,</span> q <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">quotes</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
blockquote<span style="color: #3333ff;">:before</span><span style="color: #00AA00;">,</span> blockquote<span style="color: #3333ff;">:after</span><span style="color: #00AA00;">,</span>
q<span style="color: #3333ff;">:before</span><span style="color: #00AA00;">,</span> q<span style="color: #3333ff;">:after </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">''</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
table <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border-collapse</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">collapse</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-spacing</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/**************************** HTML 5 RESET **************************/</span>
<span style="color: #6666ff;">.label15Arial</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">16pt</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bolder</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.titleBar</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -o-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -webkit-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -ms-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">45px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.borderContainer</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#c0c0c0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.controlsContainer</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#c0c0c0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.label1</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">255px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bolder</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.buttons</span> <span style="color: #00AA00;">&#123;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#canvas</span> <span style="color: #00AA00;">&#123;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#990000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Hope you enjoy this code samples. Don&#8217;t forget to try out the <strong><a href="http://www.isgoodstuff.com/wp-content/demo/Tutorial%202/" target="_blank">demo here</a></strong>.<br />
For today&#8217;s source code.<br />
<p><strong><a href="http://www.isgoodstuff.com/wp-content/plugins/download-monitor/download.php?id=32">Download Here</a></strong></p></br></p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2012/01/30/html5-keyboard-controls-update-loop-enterframer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 : Canvas Image Manipulation Tutorial</title>
		<link>http://www.isgoodstuff.com/2012/01/05/html5-image-in-canvas-tutorial/</link>
		<comments>http://www.isgoodstuff.com/2012/01/05/html5-image-in-canvas-tutorial/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 10:53:20 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=2127</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/html5.png"/></p>Short tutorial on Image manipulation using Canvas. Look Ma...no flash o_O!]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/html5.png"/></p><p style="text-align: justify;">Today, I&#8217;m sharing with you a little on Image manipulation using Canvas. Since it&#8217;s already 2012, I figured it&#8217;s time to write more on my HTML5 stuff. As you already know by now, one of the most powerful and interactive element in html5 is none other than the Canvas. Rather, than blogging about theory of what html5 is and what&#8217;s the new tag blah blah&#8230;I&#8217;m just gonna make a simple project out of it &#8211; a straight forward implementation. So today&#8217;s tutorial, I will be covering the followings :-</p>
<p style="text-align: center;"><a href="http://www.isgoodstuff.com/wp-content/demo/Tutorial%201/Tutorial%201%20-%20CanvasImage.html" target="_blank"><img class="aligncenter size-full wp-image-2129" title="SampleCanvas" src="http://www.isgoodstuff.com/wp-content/uploads/2012/01/SampleCanvas.png" alt="" width="480" height="467" style="margin-top:5px" valign="5" /></a></p>
<ul>
<li style="text-align: justify;">Loading an image into the canvas</li>
<li>Image blurring effect &#8211; using an External Library (StackBlur.js)</li>
<li>Image rotation &#8211; pure html5 canvas programming</li>
<li>Little on CSS3  - a little on the border radius stuff, gradient stuff.</li>
<li>Slider element of HTML5. &#8211; pure html5 usage of input type=&#8221;range&#8221; (yes, No more JQueryUI and loading lots of js files &#8211; just for one slider)</li>
</ul>
<p style="text-align: justify;">First of you might wanna have a look at the demo I&#8217;ve prepared in advance <a href="http://www.isgoodstuff.com/wp-content/demo/Tutorial%201/Tutorial 1 - CanvasImage.html" target="_blank">here</a>. You may also download the entire tutorial below.</p>
<p><strong><a href="http://www.isgoodstuff.com/wp-content/plugins/download-monitor/download.php?id=31">Download Here</a></strong></p></br>
<p style="text-align: justify;">Ok, first let&#8217;s look html code itself. Like all standard html5 page, the standard doctype must be declared prior to anything. Click on the button to load an image into the canvas which is the white box with rounded borders in the center of the html page. Try playing around with the sliders. Apply blur effect and the rotation.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;title&gt;Sample App HTML5 One - Using Canvas and Filters&lt;/title&gt;
	&lt;meta name=&quot;generator&quot; content=&quot;TextMate http://macromates.com/&quot;&gt;
	&lt;meta name=&quot;author&quot; content=&quot;Alex Tam Ming Yen&quot;&gt;
	&lt;LINK href=&quot;default.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;
	&lt;!-- Date: 2011-12-31 --&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;lib/StackBlur.js&quot;&gt;&lt;/script&gt;
	&lt;script&gt;
		function triggerReady(){
			var btnLoadImage 	= document.getElementById('btnLoadImage');
			var blur_range 		= document.getElementById('blurRange');
			var rotation_range 	= document.getElementById('rotationRange');
			var canvas 		 = document.getElementById('canvas');
			var imageRefence = document.getElementById('imgSrc');
                        // The Canvas context governs the rendering of the canvas content itself. 
			var contxt = canvas.getContext('2d');
                        // Declaring an image Object.
			var img = new Image();
			img.width = 480;
			img.height = 320;
&nbsp;
			btnLoadImage.onclick = function(){
				img.onload = function(){
				    clear();
				    contxt.drawImage(img, 0, 0, img.width, img.height);
				}
				img.src = 'images/ProfilePic.png';
				imageRefence.src = img.src;
			}
&nbsp;
			blur_range.onchange = function(){
				processImageBlur( blur_range.value );
			}
&nbsp;
			rotation_range.onchange = function(){
				processRotateImage( rotation_range.value );
			}
&nbsp;
			function processImageBlur( value ){
                                // I use stackBlur.js for this refer to this site to know more on how to use and apply this.
                                // http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html
				stackBlurImage( &quot;imgSrc&quot;, &quot;canvas&quot;, value, false );
				rotation_range.value = 0;
			}
&nbsp;
			function processRotateImage( value ){
				clear();
				contxt.save();
                                // Like all rotation, it needs a center pivot to refer to.
                                // For that we use translate and move the coordinate to the middle of the image
				contxt.translate(480/2, 320/2);
                                contxt.rotate(value * Math.PI / 180);
				// You need to reverse translate back the coordinate because, you still need to render the image from 0,0.
                                contxt.translate(-(480/2), -(320/2));
				contxt.drawImage(img, 0, 0, 480, 320);
				contxt.restore();
			}
&nbsp;
			function clear(){
                                // Erase content of the canvas and refresh.
				contxt.clearRect(0, 0, 480, 320);
			}
		}
&nbsp;
	&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;triggerReady()&quot;&gt;
	&lt;div class=&quot;titleBar&quot;&gt;
		&lt;h1 class=&quot;label15Arial&quot;&gt;Sample App With Canvas&lt;h1&gt;
	&lt;/div&gt;
&nbsp;
	&lt;div class=&quot;borderContainer&quot;&gt;&lt;canvas id=&quot;canvas&quot; width=&quot;480&quot; height=&quot;320&quot;&gt;&lt;/canvas&gt;&lt;/div&gt;
	&lt;div class=&quot;controlsContainer&quot;&gt;
		&lt;label class=&quot;range1label&quot;&gt;Blur Range&lt;/label&gt;
		&lt;input type=&quot;range&quot; min=&quot;0&quot; max=&quot;100&quot; value=&quot;0&quot; step=&quot;1&quot; class=&quot;range1&quot; id=&quot;blurRange&quot;/&gt;
&nbsp;
		&lt;label class=&quot;range2label&quot;&gt;Rotation&lt;/label&gt;
		&lt;input type=&quot;range&quot; min=&quot;0&quot; max=&quot;359&quot; value=&quot;0&quot; step=&quot;1&quot; class=&quot;range2&quot; id=&quot;rotationRange&quot;/&gt;
		&lt;center&gt;
		&lt;input type=&quot;submit&quot; value=&quot;Load Image...&quot; class=&quot;buttons&quot; id=&quot;btnLoadImage&quot; /&gt;
		&lt;/center&gt;
	&lt;/div&gt;
&nbsp;
	&lt;div id=&quot;referenceData&quot; hidden=&quot;true&quot;&gt;&lt;img id=&quot;imgSrc&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p style="text-align: justify;">Take a look how the canvas is implemented, just a simple and clean tag isn&#8217;t it sweet ? Notice, in canvas programming, you must always remember, to &#8220;represent&#8221; an object e.g. image in our case, everything must be done in data abstraction in the memory &#8211; then render to display. Like the case of rotation (see line 48).</p>
<ul>
<li>The canvas content is cleared, </li>
<li>New angle is calculated, </li>
<li>The coordinates is translated</li>
<li>Image object is rotated in memory</li>
<li>Image object is redrawn into the canvas</li>
</ul>
<p style="text-align: justify;">Every time a rotation slider value is changed. Well, the rest you can read up and experiment more by tweaking my codes in the source to find out more. We now take a look at the CSS file. By the way, I generate my gradient <a href="http://gradients.glrzad.com/">here</a> </p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/**************************** HTML 5 RESET **************************/</span>
html<span style="color: #00AA00;">,</span> body<span style="color: #00AA00;">,</span> div<span style="color: #00AA00;">,</span> span<span style="color: #00AA00;">,</span> applet<span style="color: #00AA00;">,</span> object<span style="color: #00AA00;">,</span> iframe<span style="color: #00AA00;">,</span>
h1<span style="color: #00AA00;">,</span> h2<span style="color: #00AA00;">,</span> h3<span style="color: #00AA00;">,</span> h4<span style="color: #00AA00;">,</span> h5<span style="color: #00AA00;">,</span> h6<span style="color: #00AA00;">,</span> p<span style="color: #00AA00;">,</span> blockquote<span style="color: #00AA00;">,</span> pre<span style="color: #00AA00;">,</span>
a<span style="color: #00AA00;">,</span> abbr<span style="color: #00AA00;">,</span> acronym<span style="color: #00AA00;">,</span> address<span style="color: #00AA00;">,</span> big<span style="color: #00AA00;">,</span> cite<span style="color: #00AA00;">,</span> code<span style="color: #00AA00;">,</span>
del<span style="color: #00AA00;">,</span> dfn<span style="color: #00AA00;">,</span> em<span style="color: #00AA00;">,</span> img<span style="color: #00AA00;">,</span> ins<span style="color: #00AA00;">,</span> kbd<span style="color: #00AA00;">,</span> q<span style="color: #00AA00;">,</span> s<span style="color: #00AA00;">,</span> samp<span style="color: #00AA00;">,</span>
small<span style="color: #00AA00;">,</span> strike<span style="color: #00AA00;">,</span> strong<span style="color: #00AA00;">,</span> sub<span style="color: #00AA00;">,</span> sup<span style="color: #00AA00;">,</span> tt<span style="color: #00AA00;">,</span> var<span style="color: #00AA00;">,</span>
b<span style="color: #00AA00;">,</span> u<span style="color: #00AA00;">,</span> i<span style="color: #00AA00;">,</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">,</span>
dl<span style="color: #00AA00;">,</span> dt<span style="color: #00AA00;">,</span> dd<span style="color: #00AA00;">,</span> ol<span style="color: #00AA00;">,</span> ul<span style="color: #00AA00;">,</span> li<span style="color: #00AA00;">,</span>
fieldset<span style="color: #00AA00;">,</span> form<span style="color: #00AA00;">,</span> label<span style="color: #00AA00;">,</span> legend<span style="color: #00AA00;">,</span>
table<span style="color: #00AA00;">,</span> caption<span style="color: #00AA00;">,</span> tbody<span style="color: #00AA00;">,</span> tfoot<span style="color: #00AA00;">,</span> thead<span style="color: #00AA00;">,</span> tr<span style="color: #00AA00;">,</span> th<span style="color: #00AA00;">,</span> td<span style="color: #00AA00;">,</span>
article<span style="color: #00AA00;">,</span> aside<span style="color: #00AA00;">,</span> canvas<span style="color: #00AA00;">,</span> details<span style="color: #00AA00;">,</span> <span style="color: #993333;">embed</span><span style="color: #00AA00;">,</span> 
figure<span style="color: #00AA00;">,</span> figcaption<span style="color: #00AA00;">,</span> footer<span style="color: #00AA00;">,</span> header<span style="color: #00AA00;">,</span> hgroup<span style="color: #00AA00;">,</span> 
menu<span style="color: #00AA00;">,</span> nav<span style="color: #00AA00;">,</span> output<span style="color: #00AA00;">,</span> ruby<span style="color: #00AA00;">,</span> section<span style="color: #00AA00;">,</span> summary<span style="color: #00AA00;">,</span>
time<span style="color: #00AA00;">,</span> mark<span style="color: #00AA00;">,</span> audio<span style="color: #00AA00;">,</span> video <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inherit</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">baseline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* HTML5 display-role reset for older browsers */</span>
article<span style="color: #00AA00;">,</span> aside<span style="color: #00AA00;">,</span> details<span style="color: #00AA00;">,</span> figcaption<span style="color: #00AA00;">,</span> figure<span style="color: #00AA00;">,</span> 
footer<span style="color: #00AA00;">,</span> header<span style="color: #00AA00;">,</span> hgroup<span style="color: #00AA00;">,</span> menu<span style="color: #00AA00;">,</span> nav<span style="color: #00AA00;">,</span> section <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
ol<span style="color: #00AA00;">,</span> ul <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
blockquote<span style="color: #00AA00;">,</span> q <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">quotes</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
blockquote<span style="color: #3333ff;">:before</span><span style="color: #00AA00;">,</span> blockquote<span style="color: #3333ff;">:after</span><span style="color: #00AA00;">,</span>
q<span style="color: #3333ff;">:before</span><span style="color: #00AA00;">,</span> q<span style="color: #3333ff;">:after </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">''</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
table <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border-collapse</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">collapse</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-spacing</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/**************************** HTML 5 RESET **************************/</span>
<span style="color: #6666ff;">.label15Arial</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">16pt</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bolder</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.titleBar</span> <span style="color: #00AA00;">&#123;</span>
        // Here is the cool gradient stuff - use generator http<span style="color: #00AA00;">:</span>//gradients<span style="color: #6666ff;">.glrzad</span>.com/
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -o-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -webkit-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -ms-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">58%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">184</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">39</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">46</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">94%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">45px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.borderContainer</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#c0c0c0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.controlsContainer</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#c0c0c0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">120px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.range1</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">280px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.range1label</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">105px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bolder</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.range2</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">280px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.range2label</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">105px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bolder</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.buttons</span> <span style="color: #00AA00;">&#123;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#canvas</span> <span style="color: #00AA00;">&#123;</span>
        // Just two lines for cool <span style="color: #000000; font-weight: bold;">border</span> radius<span style="color: #00AA00;">,</span> no more IE hack or using Image<span style="color: #00AA00;">,</span> then abusing of divs 
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<blockquote><p><strong>Note of warning</strong> :Things you should know about canvas. For some apparent reason,<strong> try not to style / css width and height of the canvas element</strong>. Instead using the attribute of width and height on to the tag itself. Reason being, some browsers will render the content scale weirdly. This information is accurate to date of the post. This issue might be fix in near future.</p></blockquote>
<p style="text-align: justify;">That&#8217;s it for today sharing. Oh yeah and Happy New Year 2012.</p>
<p style="text-align: justify;">&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2012/01/05/html5-image-in-canvas-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Titanium Appcelerator &#8211; Snippets Tutorial</title>
		<link>http://www.isgoodstuff.com/2011/12/21/titanium-appcelerator-tutorial-making-snippets-bundle/</link>
		<comments>http://www.isgoodstuff.com/2011/12/21/titanium-appcelerator-tutorial-making-snippets-bundle/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 00:02:55 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[Mobile Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Useful Scripts]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=2094</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/modified-83203_300x180.png"/></p>Short tutorial on how to write your own snippets using Titanium Appcelerator. ]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/et_temp/modified-83203_300x180.png"/></p><p>Today, I&#8217;m gonna write a short tutorial on how to write your own snippet using Titanium Appcelerator. What are snippets you say? Well a code snippet is a programming term for a small region of re-usable source <em>code</em>, machine<em>code</em> or text. Normally snippets when defined into an IDE or editor (thats supports em) will appear in autocompletion / auto assist when users are typing in a snippet like <strong>trigger word.</strong> For example, if you have a snippet that triggers from the word &#8220;info&#8221;, just by typing <strong>info</strong>, the auto assist popup will appear suggesting user to use the code snippet.</p>
<p style="text-align: center;"><a href="http://www.watchlearnknow.com/wp-content/uploads/2011/12/Screen-Shot-2011-12-21-at-6.58.07-AM.png"><img class="aligncenter" style="margin-top: 15px; margin-bottom: 15px;" title="Screen Shot 2011-12-21 at 6.58.07 AM" src="http://www.watchlearnknow.com/wp-content/uploads/2011/12/Screen-Shot-2011-12-21-at-6.58.07-AM.png" alt="" width="500" height="192" vspace="15" /></a></p>
<p>Snippets are very useful and should always be shared or placed in a common and centralized place like <a href="http://www.dropbox.com">dropbox</a>, somewhere in the net I find it easier to access as I travel from workplace to another. Not only this improves your coding speed but also improves your quality output by reducing error made in typos and such. I have a general rule of making a snippet, if the code is so useful and you find yourself repeatingly using it.. then, please code it into a snippet bundle.</p>
<p>Titanium Appcelerator is an IDE modified fork from the IDE called Aptana IDE. They both support ruby like bundle as their snippet programming language. For those using Aptana IDE, I think this tutorial works for that IDE as well. To write snippet bundle scripts, one needs to learn a little bit of ruby code. Don&#8217;t worry is not that hard only a few lines to get things done &#8211; in fact you can just copy paste code from here then modify the parameters if you like. Some important note to remember before starting&#8230;</p>
<ul>
<ul>
<li>First off, we need to know how Titanium Appcelerator accesses it Snippet Bundle Source File. It is always located at your Users <strong>/documents/Aptana Rubles/</strong> folder. This folder will be created once, you installed Titanium Appcelerator.</li>
<li>You also need to enable the bundle Viewer. This allows you to <strong>check to see if your snippet bundle is successfully &#8220;recognized&#8221; by the IDE</strong> and that there&#8217;s no error in the lines of code which prevents the snippet from triggering. Follow steps below to enable the Viewer.</li>
<ol>
<li>Go to <strong>Window &gt; Show View &gt; Other&#8230;</strong></li>
<li>Expand the Studio category</li>
<li>Select the <strong>Bundles</strong> item<br />
A view appears showing all currently loaded bundles</li>
<li>You should see the bundle with the name you gave above in the list</li>
<li>For detailed information on selected items in the Bundles View, go to <strong>Window &gt; Show View &gt; Other&#8230;</strong></li>
<li>Expand the General category</li>
<li>Select the <strong>Properties</strong> item<br />
A view appears showing detailed information on your Bundles View selection</li>
<li>If your bundle has an error, you should see output in the Console view.</li>
</ol>
<li>Next just Create a folder, in <strong>/documents/Aptana Rubles/ &lt;your snippet folder name &#8211; anyname of your choice&gt; , </strong> and a ruby file called <strong>bundle.rb</strong> inside this folder.</li>
</ul>
</ul>
<p>Start by adding this code to your bundle.rb file. Code below shows, the &#8220;definition of your snippet group&#8221;. Notice, that once you save your file, it will appear somewhere in the bundle viewer, (sorted in alphabetical order).</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">require <span style="color: #3366CC;">'ruble'</span>
&nbsp;
bundle <span style="color: #000066; font-weight: bold;">do</span> <span style="color: #339933;">|</span>bundle<span style="color: #339933;">|</span>
  bundle.<span style="color: #660066;">display_name</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'My Snippets'</span>
end</pre></div></div>

<ul>
<ul>
<li>Next, let&#8217;s add the code Titanium.API.info(something) into our snippet, since we also use that for displaying stuff in console.</li>
</ul>
</ul>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">snippet <span style="color: #3366CC;">&quot;API Info&quot;</span> <span style="color: #000066; font-weight: bold;">do</span> <span style="color: #339933;">|</span>snip<span style="color: #339933;">|</span>
  snip.<span style="color: #660066;">trigger</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;API.info&quot;</span>
  snip.<span style="color: #660066;">expansion</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Titanium.API.info(${1:variable});&quot;</span>
end</pre></div></div>

<ul>
<li><strong>snip.trigger</strong>, is what the IDE is constantly looking for to trigger this snippet. In my case, I wanted the snippet to appear once, I type <strong>API.info</strong>.</li>
<li><strong>snip.expansion</strong> is where all your actual snippet code will be.Notice I added ${} into the code, this means to place the cursor within after inserting, and <strong>1:variable</strong> the word &#8220;<strong>variable</strong>&#8221; can be anything you defined it to be, is <strong>just for your reference and it will appear in code assist</strong> and the <strong>number 1</strong> means is expecting 1st input, if there&#8217;s more than one, just add in another number, the IDE will jump from another variable input to another after user hits enter. However these are optional and most of the snippets doesn&#8217;t even need an input parameter assist.</li>
<li>To add new snippet simply, add copy paste the <strong>snippet &#8220;API Info&#8221; do&#8230;</strong> to <strong>end</strong> line to a new line and modify from there</li>
<li>Last thing you should know about snippet is that, sometimes, they failed to load and this may due to cache file corrupted. This cache is created automatically, by IDE. To clear the cache of the snippet file, just move the cache.yml to the trash and relaunch the IDE.</li>
</ul>
<p><a href="http://www.isgoodstuff.com/wp-content/uploads/2011/12/Screen-Shot-2011-12-21-at-7.38.02-AM.png"><img class="aligncenter size-full wp-image-2103" title="Screen Shot 2011-12-21 at 7.38.02 AM" src="http://www.isgoodstuff.com/wp-content/uploads/2011/12/Screen-Shot-2011-12-21-at-7.38.02-AM.png" alt="" width="444" height="167" /></a></p>
<p>I hope this tutorial helps you titanium developers out there, to speed up your development to at least 3 fold haha as it did to mine. CODE STRONG! Happy holidays and have a great year ahead!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2011/12/21/titanium-appcelerator-tutorial-making-snippets-bundle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 Implementing Keyboard Controls</title>
		<link>http://www.isgoodstuff.com/2011/12/05/as3-implementing-keyboard-controls/</link>
		<comments>http://www.isgoodstuff.com/2011/12/05/as3-implementing-keyboard-controls/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 07:35:13 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=2048</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/12/keyboardControls.png"/></p>Been busy lately, today we will cover on keyboardEvent and controls in as3. ]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/12/keyboardControls.png"/></p><p style="text-align: justify;">Today we will cover the topic on having a keyboard controls in AS3. This is an important element in game and interactive programming involving keyboard as input.</p>
<p style="text-align: justify;">Like usual, below is a sample demo of my flash embedded. Try using arrow keys and spacebar. Watch the blue box move according to your controls. If the screen is too small, try click on the flash below to start.</p>
<p style="text-align: center;"><object width="300" height="300" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.isgoodstuff.com/wp-content/uploads/2011/12/keyControls.swf" /><embed width="300" height="300" type="application/x-shockwave-flash" src="http://www.isgoodstuff.com/wp-content/uploads/2011/12/keyControls.swf" /></object></p>
<p>Below are the source code and sample on how keyboard listeners are used in AS3.</p>
<h6><strong>Main.as</strong></h6>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package 
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">KeyboardEvent</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">/********************************************************************
	* Description : This is the main document Class file.
	* @author Alex T.
	 ********************************************************************/</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span>  Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> mcCursor:<span style="color: #0066CC;">MovieClip</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> MCCURSOR_X:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">150</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> MCCURSOR_Y:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">150</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			resetCursorPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #808080; font-style: italic;">// Attaching stage keyListeners to listen to keyboard input </span>
			<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>KeyboardEvent.<span style="color: #006600;">KEY_DOWN</span>, handleKeyDown <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleKeyDown<span style="color: #66cc66;">&#40;</span> event:KeyboardEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// This is where we handle what to do when there's an input</span>
                        <span style="color: #808080; font-style: italic;">// event.keyCode returns a keyCode of the particular keyboard key.</span>
			<span style="color: #808080; font-style: italic;">// trace( &quot;KeyCode received : &quot; + event.keyCode ) ;</span>
			<span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">keyCode</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">32</span>:
					      <span style="color: #808080; font-style: italic;">// Spacebar is pressed. Enables recentering.</span>
					      resetCursorPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">break</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">37</span>:
					      <span style="color: #808080; font-style: italic;">// key left</span>
                                              mcCursor.<span style="color: #006600;">x</span> = mcCursor.<span style="color: #006600;">x</span> - <span style="color: #cc66cc;">2</span>;
				<span style="color: #b1b100;">break</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">38</span>:
					      <span style="color: #808080; font-style: italic;">// key up   	</span>
                                              mcCursor.<span style="color: #006600;">y</span> = mcCursor.<span style="color: #006600;">y</span> - <span style="color: #cc66cc;">2</span>;
				<span style="color: #b1b100;">break</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">39</span>:
                                              <span style="color: #808080; font-style: italic;">// key right						</span>
                                              mcCursor.<span style="color: #006600;">x</span> = mcCursor.<span style="color: #006600;">x</span> + <span style="color: #cc66cc;">2</span>;
				<span style="color: #b1b100;">break</span>;
&nbsp;
				<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">40</span>:
					      <span style="color: #808080; font-style: italic;">// key down						</span>
                                              mcCursor.<span style="color: #006600;">y</span> = mcCursor.<span style="color: #006600;">y</span> + <span style="color: #cc66cc;">2</span>;
				<span style="color: #b1b100;">break</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> resetCursorPosition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			mcCursor.<span style="color: #006600;">x</span> = MCCURSOR_X;
			mcCursor.<span style="color: #006600;">y</span> = MCCURSOR_Y;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Today&#8217;s source code tutorial downloadable below.<br />
<p><strong><a href="http://www.isgoodstuff.com/wp-content/plugins/download-monitor/download.php?id=29">Download Here</a></strong></p></br></p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2011/12/05/as3-implementing-keyboard-controls/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AS3 Using Custom Event &#8211; dispatchEvent</title>
		<link>http://www.isgoodstuff.com/2011/11/22/as3-using-custom-event-dispatchevent/</link>
		<comments>http://www.isgoodstuff.com/2011/11/22/as3-using-custom-event-dispatchevent/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 02:04:38 +0000</pubDate>
		<dc:creator>Alex T.</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.isgoodstuff.com/?p=2038</guid>
		<description><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/11/megaphone.png"/></p>Short tutorial on what, how and when to use dispatchEvent in as3. Read more...]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/11/megaphone.png"/></p><p style="text-align: justify;">Sometimes, we want a particular class to do something however, that task requires time to complete (e.g. loading XML or list of images remotely) and some process still awaits a form of &#8220;signal&#8221; to proceed. Pretty much like the real life shown in picture below. </p>
<p style="text-align: center;"><img src="http://www.isgoodstuff.com/wp-content/uploads/2011/11/ok.png"/></p>
<p style="text-align: justify;">See sample demo below. It&#8217;s a simple rss Reader that reads feed from CNN. Today&#8217;s sample is to show how a class can dispatch a custom event so that, the main class (which is listening to the customEvent) can trigger a specific function.</p>
<p style="text-align: center;"><object width="400" height="400" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.isgoodstuff.com/wp-content/uploads/2011/11/rssReader.swf" /><embed width="400" height="400" type="application/x-shockwave-flash" src="http://www.isgoodstuff.com/wp-content/uploads/2011/11/rssReader.swf" /></object></p>
<p style="text-align: justify;">
<p style="text-align: justify;">See source code below on how Main.as which listens to a customEvent called RSSReady and triggers a function when mcRSSContainer is done with loaded the data.</p>
<h6>Main.as</h6>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package  
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
	<span style="color: #808080; font-style: italic;">/********************************************************************
	 * Description : This is the main document root file.
	 * @author Alex T.
	 ********************************************************************/</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> mcPreloader : <span style="color: #0066CC;">MovieClip</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> mcRSSContainer:<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> 
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;init!&quot;</span><span style="color: #66cc66;">&#41;</span> ;
			mcPreloader.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			<span style="color: #808080; font-style: italic;">// Since, mcRSSContainer is the stage object of the class, </span>
			<span style="color: #808080; font-style: italic;">// we attach the listener here.This behaviour is similar to a doctor </span>
			<span style="color: #808080; font-style: italic;">// placing a stethoscope on your body to listen for heartbeat.</span>
			<span style="color: #808080; font-style: italic;">// listening for the RSSReady customEvent to be dispatch.</span>
			mcRSSContainer.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;RSSReady&quot;</span>, handleRSSReady<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleRSSReady<span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			mcPreloader.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h6>mcRSSContainer.as</h6>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">isgoodstuff</span> 
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">controls</span>.<span style="color: #0066CC;">List</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">FileReferenceList</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLLoader</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLRequest</span>;
	<span style="color: #808080; font-style: italic;">/********************************************************************
	* Description : This is mcRSSContainer Class. 
	* Contains a ListBox component. This class will load RSS using 
	* a URLLoader and then once loaded, sends a customEvent  or 
	* (dispatchEvent) which the Main is listening to, in order to hide 
	* mcPreloader.
	* @author Alex T.
	********************************************************************/</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> mcRSSContainer <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> listBox:<span style="color: #0066CC;">List</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> rssLoader:URLLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> rssXML:<span style="color: #0066CC;">XML</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> mcRSSContainer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> 
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;mcRSSContainer successfully initiatialize&quot;</span><span style="color: #66cc66;">&#41;</span>;
			startLoadingRSS<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> startLoadingRSS<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> rssURL:URLRequest =  <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://rss.cnn.com/rss/edition.rss&quot;</span><span style="color: #66cc66;">&#41;</span>;
			rssLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, rssLoaded<span style="color: #66cc66;">&#41;</span>;
			rssLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>rssURL<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> rssLoaded<span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			rssXML.<span style="color: #006600;">ignoreWhitespace</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			rssXML = <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span>rssLoader.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> item:<span style="color: #0066CC;">String</span> <span style="color: #b1b100;">in</span> rssXML.<span style="color: #006600;">channel</span>.<span style="color: #006600;">item</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				listBox.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span>label: rssXML.<span style="color: #006600;">channel</span>.<span style="color: #006600;">item</span><span style="color: #66cc66;">&#91;</span>item<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">title</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #808080; font-style: italic;">// This means the class has done all the RSS loading. Now we need to send a custom</span>
			<span style="color: #808080; font-style: italic;">// Event (dispatchEvent) like a shout to other classes listening that data is ready.</span>
			<span style="color: #808080; font-style: italic;">// The string RSSReady can be any other custom Event name you wanted. Just</span>
			<span style="color: #808080; font-style: italic;">// Make sure when attaching listener has to &quot;listen For&quot; the particular string event.</span>
			<span style="color: #808080; font-style: italic;">// Now see the mcRSSContainer.addEventListener(&quot;RSSReady&quot;, handleRSSReady); </span>
			<span style="color: #808080; font-style: italic;">// under Main.as</span>
			dispatchEvent<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;RSSReady&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>For today&#8217;s tutorial click the link below.<br />
<p><strong><a href="http://www.isgoodstuff.com/wp-content/plugins/download-monitor/download.php?id=28">Download Here</a></strong></p></br></p>
]]></content:encoded>
			<wfw:commentRss>http://www.isgoodstuff.com/2011/11/22/as3-using-custom-event-dispatchevent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

