<?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>Renaun Erickson</title> <atom:link href="http://renaun.com/blog/feed/" rel="self" type="application/rss+xml" /><link>http://renaun.com/blog</link> <description>My ideas on the web and mobile application/game technologies</description> <lastBuildDate>Tue, 21 May 2013 00:19:16 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=</generator> <item><title>Code Three.js in ActionScript with Randori Compiler</title><link>http://renaun.com/blog/2013/05/code-three-js-in-actionscript-with-randori-compiler/</link> <comments>http://renaun.com/blog/2013/05/code-three-js-in-actionscript-with-randori-compiler/#comments</comments> <pubDate>Fri, 17 May 2013 17:47:09 +0000</pubDate> <dc:creator>Renaun Erickson</dc:creator> <category><![CDATA[Blog]]></category> <category><![CDATA[actionscript]]></category> <category><![CDATA[randori]]></category> <category><![CDATA[three.js]]></category> <category><![CDATA[webgl]]></category><guid isPermaLink="false">http://renaun.com/blog/?p=2140</guid> <description><![CDATA[<p>Live Demo Live Demo of three.js html/js generated by ActionScript 3 using the Randori compiler &#8211; http://renaun.com/html5/as3threejs/ What is Randori? Randori is a project with various parts and can be found at http://randoriframework.com/. For my example I am using a subset of the Randori project&#8217;s capabilities, which is fine as the Randori project is put [...]</p><p>The post <a href="http://renaun.com/blog/2013/05/code-three-js-in-actionscript-with-randori-compiler/">Code Three.js in ActionScript with Randori Compiler</a> appeared first on <a href="http://renaun.com/blog">Renaun Erickson</a>.</p>]]></description> <content:encoded><![CDATA[<h2>Live Demo</h2><p>Live Demo of three.js html/js generated by ActionScript 3 using the Randori compiler &#8211; <a href="http://renaun.com/html5/as3threejs/">http://renaun.com/html5/as3threejs/</a></p><h2>What is Randori?</h2><p><img src="http://randoriframework.com/wp-content/uploads/2013/01/headliners-started.png" alt="Randori Project" style="float:left;width: 200px; padding: 10px;" />Randori is a project with various parts and can be found at <a href="http://randoriframework.com/what_is_randori/">http://randoriframework.com/</a>. For my example I am using a subset of the Randori project&#8217;s capabilities, which is fine as the Randori project is put together in such a way that it allows for this. You can find the various Randori repos here: <a href="https://github.com/RandoriAS">https://github.com/RandoriAS</a></p><p>Repos:</p><ul><li><strong>randori-sdk:</strong> This repo contains all the Randori framework bits you need for both the ActionScript 3 and JavaScript side.</li><li><strong>randori-compiler:</strong> This repo contains the ActionScript 3 to JavaScript compiler source files. Precompiled version is located <a href="https://github.com/RandoriAS/randori-compiler/raw/develop/deployed/randori-compiler-latest.zip">here</a></li><li><strong>randori-framework &#038; randori-guice-framework:</strong> These repos contains the source files for the Randori framework.</li><li><strong>randori-libraries:</strong> This repo contains source files for ActionScript 3 classes that stubbed out JavaScript libraries. For example to get three.js code hinting in ActionScript there are stubbed out ActionScript 3 classes that map to three.js classes.</li><li><strong>randori-plugin-intellij:</strong> This repo contains an IntelliJ plugin for creating Randori framework based apps and an integrated compiler.</li><li><strong>randori-demos-bundle:</strong> This repo contains demo Randori applications.</li><li><strong>randori-tools:</strong> This repo contains the Randori Toolset for ActionScript. These tools help to generate the JavaScript interop libraries.</li></ul><p>The ActionScript three.js example in this post makes use of the <strong>randori-compiler</strong>, <strong>randori-libraries</strong>, and <strong>randori-sdk</strong> repos.</p><h2>Setup Randori for Compiling ActionScript</h2><p>Here are the steps I used to set up my development space:</p><ul><li>Create a folder called <strong>RandoriRepos</strong> somewhere on your hard drive, and keep track of this folder path for later use.</li><li>Download <a href="https://github.com/RandoriAS/randori-compiler/raw/develop/deployed/randori-compiler-latest.zip">https://github.com/RandoriAS/randori-compiler/raw/develop/deployed/randori-compiler-latest.zip</a> to the RandoriRepos folder. Unzip the folder, you should see the <strong>RandoriRepos/randori-compiler-latest/</strong> folder now.</li><li>Use a git client to clone the <strong>randori-libraries</strong> repo into the RandoriRepos folder. Or on the command line navigate to the RandoriRepos folder and execute:<pre>git clone git://github.com/RandoriAS/randori-libraries.git</pre></li><li>Use a git client to clone the <strong>randori-sdk</strong> repo into the RandoriRepos folder. Or on the command line navigate to the RandoriRepos folder and execute:<pre>git clone git://github.com/RandoriAS/randori-sdk.git</pre></li></ul><p>The compiler is located at <strong>RandoriRepos/randori-compiler-latest/randori.jar</strong>. Next we&#8217;ll compile a simple ActionScript 3 class into JavaScript with the compiler.</p><h2>Compiling ActionScript to JavaScript with the Randori Compiler</h2><p>The sample files that I used to create the three.js example in ActionScript 3 are located at <a href="https://github.com/renaun/RandoriExamples">https://github.com/renaun/RandoriExamples</a>.</p><li>Use a git client to clone the <strong>RandoriExamples</strong> repo into the parent folder of the RandoriRepos folder. Or on the command line navigate to the RandoriRepos&#8217; parent folder and execute:<pre>git clone https://github.com/renaun/RandoriExamples.git</pre><p> We want RandoriRepos and RandoriExamples folders to have the same parent folder.</li><li>Open a command line and navigate to the <strong>RandoriExamples/SimpleClass</strong> folder.</li><li>Compile the <strong>HelloWorld.as</strong> file using the provided <strong>randori.sh</strong> script or with the following command modified with your path values:<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">java -jar /path/to/RandoriRepos/randori-compiler-latest/randori.jar &nbsp; &nbsp; randori.compiler.clients.Randori \<br /> &nbsp; &nbsp; -library-path /path/to/RandoriRepos/randori-sdk/randori-framework/bin/swc/builtin.swc \<br /> &nbsp; &nbsp; -source-path ./ \<br /> &nbsp; &nbsp; -js-classes-as-files=true \<br /> &nbsp; &nbsp; -output ./randori-output</div></div></li><p>You should see a <strong>HelloWorld.js</strong> file in the <strong>RandoriExamples/SimpleClass/randori-output/</strong> folder. The contents should look like this:</p><div class="codecolorer-container javascript railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;height:300px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/** Compiled by the Randori compiler v0.2.4.2 on Thu May 16 15:47:28 PDT 2013 */</span><br /> <br /> <br /> HelloWorld <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><br /> &nbsp; &nbsp; <br /> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br /> <br /> HelloWorld.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">toString</span> <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><br /> &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;Hello Randori!&quot;</span><span style="color: #339933;">;</span><br /> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br /> <br /> HelloWorld.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;HelloWorld&quot;</span><span style="color: #339933;">;</span><br /> <br /> HelloWorld.<span style="color: #660066;">getClassDependencies</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br /> &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> p<span style="color: #339933;">;</span><br /> &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br /> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br /> <br /> HelloWorld.<span style="color: #660066;">injectionPoints</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br /> &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br /> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></div><p>To see the <strong>HelloWorld.js</strong> class in action take a look at <strong>RandoriExamples/SimpleClass/index.html</strong>.</p><p>Well compiling a simple class is not that impressive. Lets get to the real example and show how to use ActionScript 3 and the Randori compiler to create a three.js demo</p><p><em>NOTE: The Randori compiler will not magically convert any of the Flash Player APIs in ActionScript. Whatever you are coding in ActionScript 3 has to be available on the JavaScript side. Meaning we are writing ActionScript 3 code that will map to three.js APIs.</em></p><h2>Creating the three.js demo in ActionScript 3</h2><p>The first thing we need is the ability to reference some basic HTML DOM APIs and the three.js library in ActionScript 3. This is done with stub classes in the <strong>randori-libraries</strong> repo. But to use them with the Randori compiler we need to create a SWC version of the libraries we want to use. The SWC also allows for code hinting in your IDE, for example in Adobe Flash Builder.</p><p>Here are the steps to setup the ActionScript Library Project in Adobe Flash Builder for the <strong>randori-libraries</strong>:</p><ul><li>In Adobe Flash Builder click on File -> New -> ActionScript Library Project</li><li>Give it a project name of: randori-libraries</li><li>Set the Folder location to: /path/to/RandoriRepos/randori-libraries</li><li>Click Finish</li><li>Open the randori-libraries project properties by right clicking on the project -> Properties</li><li>Open ActionScript Library Build Path -> Library Path and remove the AIR SDK path library</li><li>In Library Path click on &#8220;Add SWC&#8230;&#8221;, enter the following path for builtin.swc and click Ok:<pre>${PARENT-1-PROJECT_LOC}/randori-sdk/randori-framework/bin/swc/builtin.swc</pre></li><li>Open up ActionScript Library Build Path -> Source Path and click on Add Folder, type in the following path and click OK:<pre>HTMLCoreLib/src</pre></li><li>Repeat the above step for: <pre>ThreeJs/src <pre></li></ul><p><em>NOTE: The <strong>randori-sdk</strong> repo does contain compiled SWC versions for some of the randori-libraries. If you look at https://github.com/RandoriAS/randori-sdk/tree/master/randori-framework/bin/swc you can see it contains: HTMLCoreLib.swc, JQuery.swc, builtin.swc, randori-framework.swc, randori-guice-framework.swc.</em></p><p>Now that we have the libraries for our stub classes we'll use this in the Randori compiler's -library-path arguments.</p><p>You might be able to import the ActionScriptThreeJS Adobe Flash Builder project as is; the project is located in the RandoriExamples folder. The steps below can be skipped if the import works; these steps show how to create a new ActionScript project in Adobe Flash Builder and use the Randori stub libraries.</p><ul><li>In Adobe Flash Builder click File -> New -> ActionScript Project</li><li>Give it a project name of: ActionScriptThreeJS</li><li>Set the Folder location to: /path/to/RandoriExamples/ActionScriptThreeJS</li><li>Click Finish</li><li>Open the ActionScriptThreeJS project properties by right clicking on the project -> Properties</li><li>Open ActionScript Build Path -> Library Path and remove the AIR SDK path library</li><li>In Library Path click on "Add Project...", select the "randori-libraries" project and click OK</li><li>Open ActionScript Compiler and uncheck the "Generate HTML wrapper file" checkbox</li><li>Open the src/ActionScriptThreeJS.as and you should see code hinting for Three class as well as others.</li></ul><p>Here is the code for ActionScriptThreeJS.as:</p><div class="codecolorer-container actionscript3 railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;height:300px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #3f5fbf;">/***<br /> &nbsp;*&nbsp; Author: Renaun Erickson (renaun.com - @renaun - github.com/renaun)<br /> &nbsp;* &nbsp;<br /> &nbsp;* &nbsp;Attribution: Leonard Souza - https://github.com/leonardsouza/RandoriAS-ThreeJS<br /> &nbsp;*/</span><br /> <span style="color: #9900cc; font-weight: bold;">package</span><br /> <span style="color: #000000;">&#123;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>stats<span style="color: #000066; font-weight: bold;">.</span>Stats<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span>Three<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span>cameras<span style="color: #000066; font-weight: bold;">.</span>PerspectiveCamera<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span>extras<span style="color: #000066; font-weight: bold;">.</span>geometries<span style="color: #000066; font-weight: bold;">.</span>CubeGeometry<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span>extras<span style="color: #000066; font-weight: bold;">.</span>geometries<span style="color: #000066; font-weight: bold;">.</span>PlaneGeometry<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span>loaders<span style="color: #000066; font-weight: bold;">.</span>ImageUtils<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span>materials<span style="color: #000066; font-weight: bold;">.</span>MeshBasicMaterial<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span>math<span style="color: #000066; font-weight: bold;">.</span>Matrix4<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span>math<span style="color: #000066; font-weight: bold;">.</span>Plane<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span>objects<span style="color: #000066; font-weight: bold;">.</span>Mesh<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span>renderers<span style="color: #000066; font-weight: bold;">.</span>WebGLRenderer<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">scenes</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=scene%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:scene.html"><span style="color: #004993;">Scene</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>mrdoob<span style="color: #000066; font-weight: bold;">.</span>three<span style="color: #000066; font-weight: bold;">.</span>textures<span style="color: #000066; font-weight: bold;">.</span>Texture<span style="color: #000066; font-weight: bold;">;</span><br /> <br /> <span style="color: #0033ff; font-weight: bold;">import</span> randori<span style="color: #000066; font-weight: bold;">.</span>webkit<span style="color: #000066; font-weight: bold;">.</span>dom<span style="color: #000066; font-weight: bold;">.</span>DomEvent<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> randori<span style="color: #000066; font-weight: bold;">.</span>webkit<span style="color: #000066; font-weight: bold;">.</span>dom<span style="color: #000066; font-weight: bold;">.</span>Element<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> randori<span style="color: #000066; font-weight: bold;">.</span>webkit<span style="color: #000066; font-weight: bold;">.</span>dom<span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> randori<span style="color: #000066; font-weight: bold;">.</span>webkit<span style="color: #000066; font-weight: bold;">.</span>dom<span style="color: #000066; font-weight: bold;">.</span>TouchEvent<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> randori<span style="color: #000066; font-weight: bold;">.</span>webkit<span style="color: #000066; font-weight: bold;">.</span>html<span style="color: #000066; font-weight: bold;">.</span>HTMLDivElement<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> randori<span style="color: #000066; font-weight: bold;">.</span>webkit<span style="color: #000066; font-weight: bold;">.</span>html<span style="color: #000066; font-weight: bold;">.</span>HTMLElement<span style="color: #000066; font-weight: bold;">;</span><br /> <span style="color: #0033ff; font-weight: bold;">import</span> randori<span style="color: #000066; font-weight: bold;">.</span>webkit<span style="color: #000066; font-weight: bold;">.</span>page<span style="color: #000066; font-weight: bold;">.</span>Window<span style="color: #000066; font-weight: bold;">;</span><br /> <br /> <span style="color: #0033ff; font-weight: bold;">import</span> utils<span style="color: #000066; font-weight: bold;">.</span>RequestAnimationFrame<span style="color: #000066; font-weight: bold;">;</span><br /> <br /> <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ActionScriptThreeJS<br /> <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> container<span style="color: #000066; font-weight: bold;">:</span>Element<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> stats<span style="color: #000066; font-weight: bold;">:</span>Stats<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> camera<span style="color: #000066; font-weight: bold;">:</span>PerspectiveCamera<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> scene<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=scene%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:scene.html"><span style="color: #004993;">Scene</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> renderer<span style="color: #000066; font-weight: bold;">:</span>WebGLRenderer<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> cube<span style="color: #000066; font-weight: bold;">:</span>Mesh<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> plane<span style="color: #000066; font-weight: bold;">:</span>Plane<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> targetRotation<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> targetRotationOnMouseDown<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">mouseX</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> mouseXOnMouseDown<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> windowHalfX<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = window<span style="color: #000066; font-weight: bold;">.</span>innerWidth <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> windowHalfY<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = window<span style="color: #000066; font-weight: bold;">.</span>innerHeight <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> animation<span style="color: #000066; font-weight: bold;">:</span>RequestAnimationFrame<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span> &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; container = <span style="color: #0033ff; font-weight: bold;">new</span> HTMLDivElement<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">appendChild</span><span style="color: #000000;">&#40;</span>container<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">:</span>HTMLElement = <span style="color: #0033ff; font-weight: bold;">new</span> HTMLDivElement<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>style<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">position</span> =<span style="color: #990000;">&quot;absolute;&quot;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>style<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">top</span> =<span style="color: #990000;">&quot;10px&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>style<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> =<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>style<span style="color: #000066; font-weight: bold;">.</span>textAlign =<span style="color: #990000;">&quot;center&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>innerHTML =<span style="color: #990000;">&quot;Drag to spin the cube&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; container<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">appendChild</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">info</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; camera = <span style="color: #0033ff; font-weight: bold;">new</span> PerspectiveCamera<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">45</span><span style="color: #000066; font-weight: bold;">,</span> window<span style="color: #000066; font-weight: bold;">.</span>innerWidth <span style="color: #000066; font-weight: bold;">/</span> window<span style="color: #000066; font-weight: bold;">.</span>innerHeight<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">2000</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; camera<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">150</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; camera<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">.</span>z = <span style="color: #000000; font-weight:bold;">600</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; scene = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=scene%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:scene.html"><span style="color: #004993;">Scene</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// FLOOR</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> floorTexture<span style="color: #000066; font-weight: bold;">:</span>Texture = ImageUtils<span style="color: #000066; font-weight: bold;">.</span>loadTexture<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;images/checkerboard.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; floorTexture<span style="color: #000066; font-weight: bold;">.</span>wrapS = floorTexture<span style="color: #000066; font-weight: bold;">.</span>wrapT = Three<span style="color: #000066; font-weight: bold;">.</span>RepeatWrapping<span style="color: #000066; font-weight: bold;">;</span> <br /> &nbsp; &nbsp; &nbsp; &nbsp; floorTexture<span style="color: #000066; font-weight: bold;">.</span>repeat<span style="color: #000066; font-weight: bold;">.</span><span style="color: #0033ff; font-weight: bold;">set</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> floorMaterial<span style="color: #000066; font-weight: bold;">:</span>MeshBasicMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> MeshBasicMaterial<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span> <span style="color: #004993;">map</span><span style="color: #000066; font-weight: bold;">:</span> floorTexture<span style="color: #000066; font-weight: bold;">,</span> side<span style="color: #000066; font-weight: bold;">:</span> Three<span style="color: #000066; font-weight: bold;">.</span>DoubleSide <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> floorGeometry<span style="color: #000066; font-weight: bold;">:</span>PlaneGeometry = <span style="color: #0033ff; font-weight: bold;">new</span> PlaneGeometry<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1200</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1200</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">floor</span><span style="color: #000066; font-weight: bold;">:</span>Mesh = <span style="color: #0033ff; font-weight: bold;">new</span> Mesh<span style="color: #000000;">&#40;</span>floorGeometry<span style="color: #000066; font-weight: bold;">,</span> floorMaterial<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">floor</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">floor</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rotation</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PI</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">floor</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">.</span>z = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; scene<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Cube</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> geometry<span style="color: #000066; font-weight: bold;">:</span>CubeGeometry = <span style="color: #0033ff; font-weight: bold;">new</span> CubeGeometry<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> geometry<span style="color: #000066; font-weight: bold;">.</span>faces<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; geometry<span style="color: #000066; font-weight: bold;">.</span>faces<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">color</span><span style="color: #000066; font-weight: bold;">.</span>setHex<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> 0xffffff<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> material<span style="color: #000066; font-weight: bold;">:</span>MeshBasicMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> MeshBasicMaterial<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span> vertexColors<span style="color: #000066; font-weight: bold;">:</span> Three<span style="color: #000066; font-weight: bold;">.</span>FaceColors <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; cube = <span style="color: #0033ff; font-weight: bold;">new</span> Mesh<span style="color: #000000;">&#40;</span>geometry<span style="color: #000066; font-weight: bold;">,</span> material<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; cube<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">150</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; scene<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>cube<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Plane</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> geometry2<span style="color: #000066; font-weight: bold;">:</span>PlaneGeometry = <span style="color: #0033ff; font-weight: bold;">new</span> PlaneGeometry<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; geometry2<span style="color: #000066; font-weight: bold;">.</span>applyMatrix<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Matrix4<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>makeRotationX<span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span> <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PI</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; material = <span style="color: #0033ff; font-weight: bold;">new</span> MeshBasicMaterial<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span> <span style="color: #004993;">color</span><span style="color: #000066; font-weight: bold;">:</span> 0xe0e0e0 <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; plane = <span style="color: #0033ff; font-weight: bold;">new</span> Mesh<span style="color: #000000;">&#40;</span>geometry2<span style="color: #000066; font-weight: bold;">,</span> material<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> Plane<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; scene<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>plane<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; renderer = <span style="color: #0033ff; font-weight: bold;">new</span> WebGLRenderer<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#123;</span>antialias<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; renderer<span style="color: #000066; font-weight: bold;">.</span>setSize<span style="color: #000000;">&#40;</span>window<span style="color: #000066; font-weight: bold;">.</span>innerWidth<span style="color: #000066; font-weight: bold;">,</span> window<span style="color: #000066; font-weight: bold;">.</span>innerHeight<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; container<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">appendChild</span><span style="color: #000000;">&#40;</span>renderer<span style="color: #000066; font-weight: bold;">.</span>domElement<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; stats = <span style="color: #0033ff; font-weight: bold;">new</span> Stats<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; stats<span style="color: #000066; font-weight: bold;">.</span>domElement<span style="color: #000066; font-weight: bold;">.</span>style<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">position</span> =<span style="color: #990000;">&quot;absolute&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; stats<span style="color: #000066; font-weight: bold;">.</span>domElement<span style="color: #000066; font-weight: bold;">.</span>style<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">top</span> =<span style="color: #990000;">&quot;0px&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; container<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">appendChild</span><span style="color: #000000;">&#40;</span>stats<span style="color: #000066; font-weight: bold;">.</span>domElement<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;mousedown&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentMouseDown<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;touchstart&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentTouchStart<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;touchmove&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentTouchMove<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;resize&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onWindowResize<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; startRender<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onDocumentMouseDown<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">preventDefault</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>console<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;down&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;mousemove&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentMouseMove<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;mouseup&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentMouseUp<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;mouseout&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentMouseOut<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; mouseXOnMouseDown = event<span style="color: #000066; font-weight: bold;">.</span>clientX <span style="color: #000066; font-weight: bold;">-</span> windowHalfX<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; targetRotationOnMouseDown = targetRotation<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onDocumentTouchStart<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span>TouchEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span>touches<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span> === <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">preventDefault</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mouseXOnMouseDown = event<span style="color: #000066; font-weight: bold;">.</span>touches<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>pageX <span style="color: #000066; font-weight: bold;">-</span> windowHalfX<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; targetRotationOnMouseDown = targetRotation<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onDocumentTouchMove<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span>TouchEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span>touches<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span> === <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">preventDefault</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">mouseX</span> = event<span style="color: #000066; font-weight: bold;">.</span>touches<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>pageX <span style="color: #000066; font-weight: bold;">-</span> windowHalfX<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; targetRotation = targetRotationOnMouseDown <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span> <span style="color: #000066; font-weight: bold;">-</span> mouseXOnMouseDown<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.05</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>console<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;touchMove&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onDocumentMouseMove<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">mouseX</span> = event<span style="color: #000066; font-weight: bold;">.</span>clientX <span style="color: #000066; font-weight: bold;">-</span> windowHalfX<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; targetRotation = targetRotationOnMouseDown <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span> <span style="color: #000066; font-weight: bold;">-</span> mouseXOnMouseDown <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.02</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onDocumentMouseUp<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>console<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;up&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;mousemove&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentMouseMove<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;mouseup&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentMouseUp<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;mouseout&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentMouseOut<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onDocumentMouseOut<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>console<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;out&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;mousemove&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentMouseMove<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;mouseup&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentMouseUp<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; window<span style="color: #000066; font-weight: bold;">.</span>document<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;mouseout&quot;</span><span style="color: #000066; font-weight: bold;">,</span> onDocumentMouseOut<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onWindowResize<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span>DomEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; windowHalfX = window<span style="color: #000066; font-weight: bold;">.</span>innerWidth <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; windowHalfY = window<span style="color: #000066; font-weight: bold;">.</span>innerHeight <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; camera<span style="color: #000066; font-weight: bold;">.</span>aspect = window<span style="color: #000066; font-weight: bold;">.</span>innerWidth <span style="color: #000066; font-weight: bold;">/</span> window<span style="color: #000066; font-weight: bold;">.</span>innerHeight<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; camera<span style="color: #000066; font-weight: bold;">.</span>updateProjectionMatrix<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; renderer<span style="color: #000066; font-weight: bold;">.</span>setSize<span style="color: #000000;">&#40;</span>window<span style="color: #000066; font-weight: bold;">.</span>innerWidth<span style="color: #000066; font-weight: bold;">,</span> window<span style="color: #000066; font-weight: bold;">.</span>innerHeight<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> startRender<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; animation<span style="color: #000066; font-weight: bold;">.</span>request<span style="color: #000000;">&#40;</span>startRender<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; stats<span style="color: #000066; font-weight: bold;">.</span>update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; plane<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rotation</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = cube<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rotation</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span>targetRotation <span style="color: #000066; font-weight: bold;">-</span> cube<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rotation</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.05</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; renderer<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span>scene<span style="color: #000066; font-weight: bold;">,</span> camera<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> <span style="color: #000000;">&#125;</span><br /> <span style="color: #000000;">&#125;</span></div></div><p>The class contains a <strong>main()</strong> method that is called by the GuiceInjectorBootstrap class once the class has been instantiated. We'll talk about the bootstrap class in a bit. In the <strong>main()</strong> method you can see three.js like classes. For example the "//Floor" code was copied straight out of a JavaScript example with minor changes to make it reference class names directly without the JavaScript THREE. prefix (ie: ImageUtils instead of THREE.ImageUtils) and strong typing declarations.</p><p>The ActionScript class in the <strong>randori-libraries/ThreeJS</strong> folder are not guaranteed to be complete and are based on r57 of three.js. But it is enough to show you how to mock up a 3rd party JS library and use it in ActionScript 3 with randori-compiler. It was easy to add missing stuff too, I added the ImageUtils class in a jiffy and had it working with r58 of three.js easily.</p><p>Well enough talk we need to compile the ActionScript into JavaScript and see it run. Lets take a look at the compile arguments for this project. There is a shell script that shows the compiler arguments, if you are on a Mac you can easily run it in terminal. Here is the full command; this needs to be run in the command line from the <strong>RandoriExamples/ActionScriptThreeJS/src/</strong> folder:</p><div class="codecolorer-container bash railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">java <span style="color: #660033;">-jar</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>RandoriRepos<span style="color: #000000; font-weight: bold;">/</span>randori-compiler-latest<span style="color: #000000; font-weight: bold;">/</span>randori.jar randori.compiler.clients.Randori \<br /> &nbsp; &nbsp; <span style="color: #660033;">-sdk-path</span>=<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>RandoriRepos<span style="color: #000000; font-weight: bold;">/</span>randori-sdk<span style="color: #000000; font-weight: bold;">/</span> \<br /> &nbsp; &nbsp; <span style="color: #660033;">-library-path</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>RandoriRepos<span style="color: #000000; font-weight: bold;">/</span>randori-libraries<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>randori-libraries.swc \<br /> &nbsp; &nbsp; <span style="color: #660033;">-source-path</span> .<span style="color: #000000; font-weight: bold;">/</span> \<br /> &nbsp; &nbsp; <span style="color: #660033;">-js-classes-as-files</span>=<span style="color: #c20cb9; font-weight: bold;">true</span> \<br /> &nbsp; &nbsp; <span style="color: #660033;">-output</span> ..<span style="color: #000000; font-weight: bold;">/</span>js-randori</div></div><p>The <strong>-sdk-path</strong> will tell the compiler where the <strong>randori-sdk</strong> is and will copy over the required randori js files. The <strong>-sdk-path</strong> also will link in the swc files from the <strong>randori-sdk</strong> location, which means we don't have to use the <strong>-library-path</strong> argument to add builtin.swc, HTMLCoreLib.swc, or the <strong>randori-guice-framework.swc</strong> (Used by the GuiceInjectorBootstrap.as class). The <strong>-library-path</strong> references the needed SWC's to compile the ActionScript files. The rest should be straightforward, but here is a <a href="https://github.com/RandoriAS/randori-compiler/wiki/Randori-Commandline-Compiler-Documentation">link to the documentation for the randori compiler arguments</a>.</p><p>The code generated by the Randori compiler is found in <strong>RandoriExamples/ActionScriptThreeJS/js-randori</strong>. It includes the following files:</p><ul><li>GuiceInjectorBootstrap.js</li><li>ActionScriptThreeJS.js</li><li>randori-framework-min.js</li><li>randori-framework.js</li><li>randori-guice-framework-min.js</li><li>randori-guice-framework.js</li><li>utils/RequestAnimationFrame.js</li></ul><p>The current Randori compiler doesn't create a wrapper HTML file but I have put in a request for it to create a basic one. Either way we still have to hook up the three.js library and other application assets. These files are located in the <strong>RandoriExamples/ActionScriptThreeJS</strong> folder as the following:</p><ul><li>index.html - The three.js example index html file.</li><li>images/checkerboard.jpg - Asset file used in the three.js demo.</li><li>js/ - contains the three.js and stats.js libraries that are included in the index.html</li></ul><p>Here is what the index.html file looks like:</p><div class="codecolorer-container html4strict railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML&gt;</span><br /> <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span><br /> <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br /> &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>ActionScript to ThreeJS Example<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span><br /> &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js/three.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br /> &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js/stats.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br /> &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js-randori/randori-guice-framework.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br /> &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js-randori/GuiceInjectorBootstrap.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br /> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br /> <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br /> &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; onload = function() {<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var bootstrap = new GuiceInjectorBootstrap( &quot;ActionScriptThreeJS&quot;, &quot;js-randori/&quot; );<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bootstrap.launch();<br /> &nbsp; &nbsp; &nbsp; &nbsp; }<br /> &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br /> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br /> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></div></div><p>So here is where some of the Randori magic happens. The Randori compiler outputs code that the <strong>randori-guice-framework.js</strong> can do stuff with. What kind of stuff? Well, like dependency injection and lazy loading compiled JavaScript classes when they are needed. The GuiceInjectorBootstrap.as file contains Randori guice classes to handle the loading and injection. All we have to do is pass in the main class file and output folder where the generated JavaScript is located. In this example this is done by the <strong>var bootstrap = new GuiceInjectorBootstrap( "ActionScriptThreeJS", "js-randori/" );</strong> code. It loads the <strong>js-randori/ActionScriptThreeJS.js</strong> file. When it finds that ActionScriptThreeJS is looking for <strong>utils/RequestAnimationFrame.js</strong> from the [Inject] metadata used in the ActionScriptThreeJS.as file it will go load that class file too. To demonstrate this, run the index.html in the browser and check the network calls in Chrome Developer Tools. It should look something like this:<br /> <a href="http://renaun.com/blog/wp-content/uploads/2013/05/threejsdemonetworkcalls.png"><img src="http://renaun.com/blog/wp-content/uploads/2013/05/threejsdemonetworkcalls-300x152.png" alt="threejsdemonetworkcalls" width="300" height="152" class="aligncenter size-medium wp-image-2200" /></a></p><p>You can see as it loads three.js, stats.js, randori-guice-framework.js and GuiceInjectorBootstrap.js they are parallel calls. Then it loads the class files, first the ActionScriptThreeJS.js file (which is not included in the index.html script tags). The Randori guice framework then notices that ActionScriptThreeJS injects the utils.RequestAnimationFrame classes and goes and fetches that JavaScript class file. So no worrying about what classes are required to run your code just give it the main class and let Randori guice does the rest.</p><p>This is actually where the full Randori framework is pretty cool. The full Randori stack is geared for large applications making use of MVC patterns and dependency injection for some great features. A great place to learn more about the Randori framework for large application development is the <a href="http://randoriframework.com/getting-started/">getting started section here</a>.</p><p>Randori is a fairly new project but it was really fun to play with and something I'll be exploring more.</p><h3>Links Used in the Post</h3><p>RandoriAS Project Github - <a href="https://github.com/RandoriAS" title="RandoriAS">https://github.com/RandoriAS</a><br /> My ActionScript 3 Three.js Example Code - <a href="https://github.com/renaun/RandoriExamples" title="ActionScript 3 to three.js example using Randori">https://github.com/renaun/RandoriExamples</a><br /> My ActionScript 3 Three.js Live Demo - <a href="http://renaun.com/html5/as3threejs/">http://renaun.com/html5/as3threejs/</a></p><p>A thank you goes out to <a href="https://twitter.com/_leonardsouza_">Leonard Souza</a> for providing the ThreeJS+Randori example - <a href="https://github.com/leonardsouza/RandoriAS-ThreeJS">https://github.com/leonardsouza/RandoriAS-ThreeJS</a></p><p><center>&copy; %FIRST Erickson - visit the <a href="http://www.renaun.com">&lt;renaun.com:flexblog text="{ ModelLocator.myThoughts }"/&gt;</a></center></p><p>The post <a href="http://renaun.com/blog/2013/05/code-three-js-in-actionscript-with-randori-compiler/">Code Three.js in ActionScript with Randori Compiler</a> appeared first on <a href="http://renaun.com/blog">Renaun Erickson</a>.</p>]]></content:encoded> <wfw:commentRss>http://renaun.com/blog/2013/05/code-three-js-in-actionscript-with-randori-compiler/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>How Far is the Reach of WebGL on the Desktop</title><link>http://renaun.com/blog/2013/04/how-far-is-the-reach-of-webgl-on-the-desktop/</link> <comments>http://renaun.com/blog/2013/04/how-far-is-the-reach-of-webgl-on-the-desktop/#comments</comments> <pubDate>Mon, 15 Apr 2013 16:05:55 +0000</pubDate> <dc:creator>Renaun Erickson</dc:creator> <category><![CDATA[Blog]]></category><guid isPermaLink="false">http://renaun.com/blog/?p=2120</guid> <description><![CDATA[<p>WebGL WebGL is definitely making some great in-roads into desktop browsers. There are a lot of other HTML5 features that round out WebGL for games, for example check out some AAA web demos here. In talking to people there seems to be some confusion about what is the real reach vs all the hype. Of [...]</p><p>The post <a href="http://renaun.com/blog/2013/04/how-far-is-the-reach-of-webgl-on-the-desktop/">How Far is the Reach of WebGL on the Desktop</a> appeared first on <a href="http://renaun.com/blog">Renaun Erickson</a>.</p>]]></description> <content:encoded><![CDATA[<h3>WebGL</h3><p>WebGL is definitely making some great in-roads into desktop browsers. There are a lot of other HTML5 features that round out WebGL for games, for example check out some <a href="http://renaun.com/blog/2013/04/aaa-3d-web-game-demos-flash-unity-webgl-nacl/">AAA web demos here</a>. In talking to people there seems to be some confusion about what is the real reach vs all the hype. Of course WebGL keeps changing fast, one of the reasons for all the hype, but I wanted to talk about the current technical landscape of WebGL.</p><h3>Background</h3><p>WebGL is not a W3C specification, it is driven by the <a href="http://www.khronos.org/webgl/">Khronos Group</a>. Here is a blurb from their site:</p><blockquote><p>WebGL is a cross-platform, royalty-free web standard for a low-level 3D graphics API based on OpenGL ES 2.0, exposed through the HTML5 Canvas element as Document Object Model interfaces. Developers familiar with OpenGL ES 2.0 will recognize WebGL as a Shader-based API using GLSL, with constructs that are semantically similar to those of the underlying OpenGL ES 2.0 API. It stays very close to the OpenGL ES 2.0 specification, with some concessions made for what developers expect out of memory-managed languages such as JavaScript.</p><p>WebGL brings plugin-free 3D to the web, implemented right into the browser. Major browser vendors Apple (Safari), Google (Chrome), Mozilla (Firefox), and Opera (Opera) are members of the WebGL Working Group.</p></blockquote><p>If you have noticed there is one major browser vendor missing from the list, Microsoft (Internet Explorer). That <a href="http://www.theverge.com/2013/3/30/4165204/microsoft-bringing-webgl-support-internet-explorer-11-windows-blue">might change (rumors) in the future with IE11</a>. But this doesn&#8217;t address IE browsers before version 11.</p><p>Ok, so in the real world what browsers have WebGL? The latest Chrome and Firefox enable it by default. Safari and Opera require steps to enable WebGL. IE does not support WebGL in its current form.</p><h3>Don&#8217;t forget GPUs</h3><p>Even if all the browser vendors supported WebGL fully out of the box there are other factors that affect reach. The biggest one being graphic drivers. A good comprehensive list of driver support can be found on the <a href="http://www.khronos.org/webgl/wiki/BlacklistsAndWhitelists">khronos WebGL wiki page</a>. For various stability and security reasons WebGL implementations use blacklists and whitelists to determine what GPU drivers are allowed to be used. For example Chrome uses a certain set of drivers on Windows that are newer than 2009, but Firefox currently only does drivers newer than 2010. WebGL driver support will change over time; the <a href="http://helpx.adobe.com/x-productkb/multi/stage3d-unsupported-chipsets-drivers-flash.html">Stage3D API implements driver support back to 2006 (Intel GMA 2005 drivers with constrained mode)</a>. There are other considerations as well. The older chipsets have the potential for the GPU hardware itself to not support the entire WebGL specification. This is especially true for the newer WebGL specs, like the WebGL OpenGL ES 3.0 specification that will drive WebGL in the future.</p><p>What does this mean in the real world? It&#8217;s hard to give definitive numbers since WebGL is changing in the browser and graphic drivers areas. I can give highly subjective numbers based on companies that have implemented Stage3D APIs with live web content that can give you a rough idea. With Stage3D the browser reach factor is not there, as it was implemented across all browsers on Mac, Windows, and Linux support. That means just taking into consideration the GPU driver reach factor the dev is left with the following tidbits. For Stage3D content that was limited to drivers released after 2009 saw about 60%-70% of the users able to play the content. Going back to later than 2008 the reach jumped up to 70%-85%. Going back to later than 2006 and support certain Intel GMA chipset with a constrained mode allowed content developers to reach 90%+ (usually 94%-96% is best possible regardless of technology) of their users.</p><p><a href="http://forum.starling-framework.org/topic/real-world-gpu-acceleration-availability-statistics">Or here is a thread for a specific test inside a legacy app to see Stage3D&#8217;s reach.</a></p><p>There is a site that is a rough indication of where WebGL is right now called <a href="http://webglstats.com/">http://webglstats.com/</a>. The webglstats.com site also breaks down specific API availability that relates to WebGL or content commonly used with WebGL.</p><p>This is where WebGL is headed. In this process of moving forward it is good to learn who can really be reached with the newer tech and why they can or can&#8217;t be reached. There are a slew of error messages when drivers don&#8217;t work but that needs some work too.When content doesn’t work, it is good to know if the root cause is lack of support, a blacklisted driver, no GPU, or some other specific error rather than simply knowing the WebGL API call failed.</p><p>On a very technical note, this is a <a href="http://codeflow.org/entries/2013/feb/22/how-to-write-portable-webgl/">great article that talks about portable code from a GPU hardware issue perspective</a>.</p><h3>What about Mobile?</h3><p>WebGL on mobile is making inroads with Chrome and Firefox on Android. The nice thing about the mobile industry is the devices are all new or hardware changes faster. And that means there are newer GPUs and drivers on these devices. There will be less of a graphics driver reach issue for mobile, but there is always the possibility of bad driver support or OS lack of API interfaces. Then it is a matter of getting more OS/browser support to drive the mobile reach.</p><h3>Comments and Future Changes</h3><p>Please share your thoughts about graphic driver reach and other factors that prevent end users from being able to use WebGL. There will definitely be changes in the areas above as time progresses.</p><p><center>&copy; %FIRST Erickson - visit the <a href="http://www.renaun.com">&lt;renaun.com:flexblog text="{ ModelLocator.myThoughts }"/&gt;</a></center></p><p>The post <a href="http://renaun.com/blog/2013/04/how-far-is-the-reach-of-webgl-on-the-desktop/">How Far is the Reach of WebGL on the Desktop</a> appeared first on <a href="http://renaun.com/blog">Renaun Erickson</a>.</p>]]></content:encoded> <wfw:commentRss>http://renaun.com/blog/2013/04/how-far-is-the-reach-of-webgl-on-the-desktop/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Using Flash CS6 and Starling for 8 Way Character Animation</title><link>http://renaun.com/blog/2013/04/using-flash-cs6-and-starling-for-8-way-character-animation/</link> <comments>http://renaun.com/blog/2013/04/using-flash-cs6-and-starling-for-8-way-character-animation/#comments</comments> <pubDate>Thu, 04 Apr 2013 14:33:07 +0000</pubDate> <dc:creator>Renaun Erickson</dc:creator> <category><![CDATA[Blog]]></category><guid isPermaLink="false">http://renaun.com/blog/?p=2112</guid> <description><![CDATA[<p>Creative Cloud Workflow: In this video I am demonstrating one way of creating an 8 way character animation. Moving a character up, down, left, right, and along all the diagonals is a common task in creating games. In this workflow an 80x80px character is animated over 8 x 8 frames. I created a spritesheet using [...]</p><p>The post <a href="http://renaun.com/blog/2013/04/using-flash-cs6-and-starling-for-8-way-character-animation/">Using Flash CS6 and Starling for 8 Way Character Animation</a> appeared first on <a href="http://renaun.com/blog">Renaun Erickson</a>.</p>]]></description> <content:encoded><![CDATA[<h2><a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/04/using-flash-cs6-and-starling-for-8-way-character-animation'); return false;">Creative Cloud</a> Workflow:</h2><p>In this video I am demonstrating one way of creating an 8 way character animation. Moving a character up, down, left, right, and along all the diagonals is a common task in creating games. In this workflow an 80x80px character is animated over 8 x 8 frames. I created a spritesheet using the &#8220;Generate SpriteSheet&#8221; feature in <a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/04/using-flash-cs6-and-starling-for-8-way-character-animation'); return false;">Flash Professional</a>. The feature in <a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/04/using-flash-cs6-and-starling-for-8-way-character-animation'); return false;">Flash Professional</a> to generate spritesheets allows for various framework atlas formats. One of these formats is Starling.</p><p>Here is the Starling code that reads in the texture and atlas data:</p><div class="codecolorer-container actionscript3 railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;height:300px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span><br /> <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>Starling<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>display<span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>display<span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>Touch<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>TouchEvent<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>TouchPhase<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>textures<span style="color: #000066; font-weight: bold;">.</span>Texture<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> starling<span style="color: #000066; font-weight: bold;">.</span>textures<span style="color: #000066; font-weight: bold;">.</span>TextureAtlas<span style="color: #000066; font-weight: bold;">;</span><br /> <br /> <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Game <span style="color: #0033ff; font-weight: bold;">extends</span> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><br /> <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Embed the Atlas XML</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;../../8way.xml&quot;</span><span style="color: #000066; font-weight: bold;">,</span> mimeType=<span style="color: #990000;">&quot;application/octet-stream&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static const AtlasXml<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=class%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:class.html"><span style="color: #004993;">Class</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Embed the Atlas Texture:</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;../../8way.png&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static const AtlasTexture<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=class%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:class.html"><span style="color: #004993;">Class</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Game<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// create atlas</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> texture<span style="color: #000066; font-weight: bold;">:</span>Texture = Texture<span style="color: #000066; font-weight: bold;">.</span>fromBitmap<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> AtlasTexture<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> xml<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a> = <a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> AtlasXml<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> atlas<span style="color: #000066; font-weight: bold;">:</span>TextureAtlas = <span style="color: #0033ff; font-weight: bold;">new</span> TextureAtlas<span style="color: #000000;">&#40;</span>texture<span style="color: #000066; font-weight: bold;">,</span> xml<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// display a sub-texture</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//var textures:Vector.&lt;Texture&gt; = atlas.getTextures(&quot;DirN&quot;);</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> directions<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;DirE&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;DirSE&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;DirS&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;DirSW&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;DirW&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;DirNW&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;DirN&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;DirNE&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> mc<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> <span style="color: #0033ff; font-weight: bold;">in</span> directions<span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mc = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000000;">&#40;</span>atlas<span style="color: #000066; font-weight: bold;">.</span>getTextures<span style="color: #000000;">&#40;</span><span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;00&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">16</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">loop</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; directionAnimations<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>mc<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>mc<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Starling<span style="color: #000066; font-weight: bold;">.</span>juggler<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>mc<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; currentMC = mc<span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//addChild(text);</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ADDED_TO_STAGE</span><span style="color: #000066; font-weight: bold;">,</span> addedToStageHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">text</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=textfield%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:textfield.html"><span style="color: #004993;">TextField</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">360</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">80</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;hello&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> currentMC<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> currentDirection<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> directionAnimations<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> isDown<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> addedToStageHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> mc<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> directionAnimations<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mc = directionAnimations<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span>&nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageWidth</span> <span style="color: #000066; font-weight: bold;">-</span> mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageHeight</span> <span style="color: #000066; font-weight: bold;">-</span> mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>TouchEvent<span style="color: #000066; font-weight: bold;">.</span>TOUCH<span style="color: #000066; font-weight: bold;">,</span> touchHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <br /> &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> touchHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span>TouchEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> touch<span style="color: #000066; font-weight: bold;">:</span>Touch = event<span style="color: #000066; font-weight: bold;">.</span>getTouch<span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">,</span> TouchPhase<span style="color: #000066; font-weight: bold;">.</span>MOVED<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> touch2<span style="color: #000066; font-weight: bold;">:</span>Touch = event<span style="color: #000066; font-weight: bold;">.</span>getTouch<span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">,</span> TouchPhase<span style="color: #000066; font-weight: bold;">.</span>ENDED<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>touch2<span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentMC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>touch<span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> localPos<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a> = touch<span style="color: #000066; font-weight: bold;">.</span>getLocation<span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> sX<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = localPos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> sY<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = localPos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> dirIndex<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">angle</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">atan2</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>sX <span style="color: #000066; font-weight: bold;">-</span> currentMC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> currentMC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#40;</span>sY <span style="color: #000066; font-weight: bold;">-</span> currentMC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span> currentMC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//text.text = &quot;Angle: &quot; + angle;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0.0</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0.6</span><span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dirIndex = <span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// looking down</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.6</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0.0</span><span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dirIndex = <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// bottom left</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1.4</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.6</span><span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dirIndex = <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// left</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">3.0</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1.4</span><span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dirIndex = <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// top left</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//else if ((angle &lt; -2.8 &amp;&amp; angle &gt; -3.2) || (angle &lt; 3.2 &amp;&amp; angle &gt; 2.8))</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">3</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">2.2</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dirIndex = <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// up</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">2.2</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">1.4</span><span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dirIndex = <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// right top</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">1.4</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0.9</span><span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dirIndex = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// right</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0.9</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">angle</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0.6</span><span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dirIndex = <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// right bottom</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>dirIndex <span style="color: #000066; font-weight: bold;">!</span>= currentDirection<span style="color: #000000;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//currentMC.stop();</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentMC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentMC = directionAnimations<span style="color: #000000;">&#91;</span>dirIndex<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentMC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentMC<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br /> <span style="color: #000000;">&#125;</span><br /> <span style="color: #000000;">&#125;</span></div></div><h2><a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/04/using-flash-cs6-and-starling-for-8-way-character-animation'); return false;">Adobe Creative Cloud</a> Products Used:</h2><p><a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/04/using-flash-cs6-and-starling-for-8-way-character-animation'); return false;">Flash Professional</a><br /> <a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/04/using-flash-cs6-and-starling-for-8-way-character-animation'); return false;">Game Developer Tools</a><br /> <br/></p><h2>Source Files:</h2><p><a href="https://github.com/renaun/WorkflowExamples/tree/master/Character8wayAnimation">Source Flash Professional source file and ActionScript 3 files</a><br /> <br/></p><h2>Video:</h2><p><iframe width="480" height="360" src="http://www.youtube.com/embed/KAYBFUn1XU0?rel=0" frameborder="0" allowfullscreen></iframe></p><p><center>&copy; %FIRST Erickson - visit the <a href="http://www.renaun.com">&lt;renaun.com:flexblog text="{ ModelLocator.myThoughts }"/&gt;</a></center></p><p>The post <a href="http://renaun.com/blog/2013/04/using-flash-cs6-and-starling-for-8-way-character-animation/">Using Flash CS6 and Starling for 8 Way Character Animation</a> appeared first on <a href="http://renaun.com/blog">Renaun Erickson</a>.</p>]]></content:encoded> <wfw:commentRss>http://renaun.com/blog/2013/04/using-flash-cs6-and-starling-for-8-way-character-animation/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>AAA 3D Web Game Demos (Flash, Unity, WebGL, NaCL)</title><link>http://renaun.com/blog/2013/04/aaa-3d-web-game-demos-flash-unity-webgl-nacl/</link> <comments>http://renaun.com/blog/2013/04/aaa-3d-web-game-demos-flash-unity-webgl-nacl/#comments</comments> <pubDate>Wed, 03 Apr 2013 15:37:38 +0000</pubDate> <dc:creator>Renaun Erickson</dc:creator> <category><![CDATA[Blog]]></category><guid isPermaLink="false">http://renaun.com/blog/?p=2105</guid> <description><![CDATA[<p>In my recent GDC presentation titled, Are AAA 3D Games for the Web Possible?, I showed a few demos. I am posting a few of the demo links here as people asked for the links. This list is not meant to be an exhaustive list of AAA 3D content on the web. The presentation covers [...]</p><p>The post <a href="http://renaun.com/blog/2013/04/aaa-3d-web-game-demos-flash-unity-webgl-nacl/">AAA 3D Web Game Demos (Flash, Unity, WebGL, NaCL)</a> appeared first on <a href="http://renaun.com/blog">Renaun Erickson</a>.</p>]]></description> <content:encoded><![CDATA[<p>In my recent GDC presentation titled, Are AAA 3D Games for the Web Possible?, I showed a few demos. I am posting a few of the demo links here as people asked for the links. This list is not meant to be an exhaustive list of AAA 3D content on the web. The presentation covers what it takes to create 3D web games between Flash, Unity, WebGL, and Google Native Client as a techinical comparison. The slides for the presentation can be found at <a href="http://www.slideshare.net/renaun/are-aaa-3d-games-for-the-web-possible">http://www.slideshare.net/renaun/are-aaa-3d-games-for-the-web-possible</a>.</p><p>Flash Demos:<br /> <a href="https://www.rumblegames.com/kingsroad">Kings Road by Rumble Games</a> &#8211; Uses modified Away3D framework.<br /> <a href="http://skywarriorsgame.com/">Sky Warriors</a> &#8211; Only video for now, using Away3D<br /> <a href="https://apps.facebook.com/chronoblade/">Chrono Blade</a> &#8211; In beta, uses Unity to Flash exporter<br /> <a href="http://dungeondefenders2.com/forum/showthread.php?95230-Dungeon-Defenders-II-Announced">Dungeon Defenders 2 by Trendy Entertainment</a> &#8211; It is in closed beta, but I showed it with Trendy&#8217;s premission the day of the talk. Using Epic Unreal Engine to Flash exporter.</p><p>WebGL Demos:<br /> <a href="https://developer.mozilla.org/en-US/demos/detail/bananabread/launch">BananaBread by Mozilla</a> &#8211; Using Emscripten<br /> <a href="http://dl.dropbox.com/u/6873971/data/cube2/index.html">Cube 2</a> &#8211; Using Emscripten<br /> <a href="http://hexgl.bkcore.com/">HexGL</a> &#8211; Racing demo game<br /> <a href="http://crypt-webgl.unigine.com/game.html">Crypt WebGL Demo</a> &#8211; Not a game but decent demo</p><p>Unity Demos:<br /> <a href="http://unity3d.com/gallery/demos/live-demos#camper">Camper</a> &#8211; Texture quality for Unity player<br /> <a href="http://unity3d.com/gallery/demos/live-demos#angrybots">Angry Bots</a><br /> Many other unity demos can be found at their showcase and partner pages.</p><p>Google Native Client (Chrome Store Only):<br /> <a href="http://chrome.supergiantgames.com/">Bastion by Warner Games</a><br /> <a href="http://beta.coreonline.com/mini-ninjas/">Mini Ninjas</a></p><p>Again this list is not meant to be an exhaustive list. There are many demos not mentioned here and many yet to come in the fast changing landscape of 3D games on the web. Having said that if you have or know of any cool AAA 3D games on the desktop web place share them in the comments below.</p><p><center>&copy; %FIRST Erickson - visit the <a href="http://www.renaun.com">&lt;renaun.com:flexblog text="{ ModelLocator.myThoughts }"/&gt;</a></center></p><p>The post <a href="http://renaun.com/blog/2013/04/aaa-3d-web-game-demos-flash-unity-webgl-nacl/">AAA 3D Web Game Demos (Flash, Unity, WebGL, NaCL)</a> appeared first on <a href="http://renaun.com/blog">Renaun Erickson</a>.</p>]]></content:encoded> <wfw:commentRss>http://renaun.com/blog/2013/04/aaa-3d-web-game-demos-flash-unity-webgl-nacl/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Using Creative Cloud and CSS Translate3D to Create an 8 Way Character Animation</title><link>http://renaun.com/blog/2013/03/using-creative-cloud-and-css-translate3d-to-create-an-8-way-character-animation/</link> <comments>http://renaun.com/blog/2013/03/using-creative-cloud-and-css-translate3d-to-create-an-8-way-character-animation/#comments</comments> <pubDate>Mon, 25 Mar 2013 18:49:34 +0000</pubDate> <dc:creator>Renaun Erickson</dc:creator> <category><![CDATA[Blog]]></category><guid isPermaLink="false">http://renaun.com/blog/?p=2084</guid> <description><![CDATA[<p>Creative Cloud Workflow: In this video I am demonstrating one way of creating an 8 way character animation. Moving a character up, down, left, right, and along all the diagonals is a common task in creating games. In this workflow an 80x80px character is animated over 8 x 8 frames. This resulted in a 640x640px [...]</p><p>The post <a href="http://renaun.com/blog/2013/03/using-creative-cloud-and-css-translate3d-to-create-an-8-way-character-animation/">Using Creative Cloud and CSS Translate3D to Create an 8 Way Character Animation</a> appeared first on <a href="http://renaun.com/blog">Renaun Erickson</a>.</p>]]></description> <content:encoded><![CDATA[<h2><a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/03/using-creative-cloud-and-css-translate3d-to-create-an-8-way-character-animation'); return false;">Creative Cloud</a> Workflow:</h2><p>In this video I am demonstrating one way of creating an 8 way character animation. Moving a character up, down, left, right, and along all the diagonals is a common task in creating games. In this workflow an 80x80px character is animated over 8 x 8 frames. This resulted in a 640x640px png file that I modified in <a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/03/using-creative-cloud-and-css-translate3d-to-create-an-8-way-character-animation'); return false;">Photoshop</a>. Using a new feature in <a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/03/using-creative-cloud-and-css-translate3d-to-create-an-8-way-character-animation'); return false;">Photoshop from the Creative Cloud</a> edition called smart filters I modified <a href="http://renaun.com/blog/2013/03/using-illustrator-from-the-adobe-creative-cloud-and-pixi-js-to-create-an-8-way-character-animation/">my previously generated green blob spritesheet</a>. The changes gave it a nice effect seen below:<br /> <a href="http://renaun.com/blog/wp-content/uploads/2013/03/greenblobpsd.png"><img src="http://renaun.com/blog/wp-content/uploads/2013/03/greenblobpsd.png" alt="Photoshop Creative Cloud Smart Filter feature changes" width="80" height="80" class="aligncenter size-full wp-image-2087" /></a></p><p>The video (at the end of the post) explains how I used the smart filter feature in <a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/03/using-creative-cloud-and-css-translate3d-to-create-an-8-way-character-animation'); return false;">Photoshop from the Creative Cloud</a>.</p><p><a href="http://renaun.com/blog/wp-content/uploads/2013/03/pssf.png"><img src="http://renaun.com/blog/wp-content/uploads/2013/03/pssf-300x169.png" alt="Photoshop Creative Cloud version and new smart filters feature" width="300" height="169" class="aligncenter size-medium wp-image-2089" /></a></p><p>For rendering the 8 way character animation I wanted to try out the DOM HTML5 way&#8211;no canvas or WebGL. I learned this technique from <a href="http://www.tricedesigns.com/2013/03/11/performance-ux-considerations-for-successful-phonegap-apps/">Andy Trice</a>, who also built a demo game with the same approach called <a href="http://www.tricedesigns.com/2013/03/22/phonegap-legends-a-sample-game-app/">PhoneGap legends</a>. It works nicely but there are GPU memory considerations you have to be aware of. Depending on your content this approach could work for your game.</p><p>The idea is to use CSS spritesheets to load the different animation frames from one image. Then force hardware acceleration by using the CSS translate3d property to move the images around (in this case we are not moving but it forces the image on to the gpu). Here is what the CSS looks like for the spritesheet:</p><div class="codecolorer-container css railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;height:300px;"><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #cc00cc;">#hero</span><span style="color: #00AA00;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><br /> &nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_0_0</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_0_1</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_0_2</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_0_3</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #933;">240px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_0_4</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #933;">320px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_0_5</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_0_6</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #933;">480px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_0_7</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #933;">560px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_1_0</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_1_1</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_1_2</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_1_3</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span> <span style="color: #933;">240px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_1_4</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span> <span style="color: #933;">320px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_1_5</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_1_6</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span> <span style="color: #933;">480px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_1_7</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span> <span style="color: #933;">560px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_2_0</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_2_1</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_2_2</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_2_3</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span> <span style="color: #933;">240px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_2_4</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span> <span style="color: #933;">320px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_2_5</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_2_6</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span> <span style="color: #933;">480px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_2_7</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span> <span style="color: #933;">560px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_3_0</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">240px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_3_1</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">240px</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_3_2</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">240px</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_3_3</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">240px</span> <span style="color: #933;">240px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_3_4</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">240px</span> <span style="color: #933;">320px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_3_5</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">240px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_3_6</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">240px</span> <span style="color: #933;">480px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_3_7</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">240px</span> <span style="color: #933;">560px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_4_0</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_4_1</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_4_2</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_4_3</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span> <span style="color: #933;">240px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_4_4</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span> <span style="color: #933;">320px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_4_5</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_4_6</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span> <span style="color: #933;">480px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_4_7</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">320px</span> <span style="color: #933;">560px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_5_0</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_5_1</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_5_2</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_5_3</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span> <span style="color: #933;">240px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_5_4</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span> <span style="color: #933;">320px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_5_5</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_5_6</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span> <span style="color: #933;">480px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_5_7</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span> <span style="color: #933;">560px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_6_0</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_6_1</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_6_2</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_6_3</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span> <span style="color: #933;">240px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_6_4</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span> <span style="color: #933;">320px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_6_5</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_6_6</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span> <span style="color: #933;">480px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_6_7</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">480px</span> <span style="color: #933;">560px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_7_0</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">560px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_7_1</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">560px</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_7_2</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">560px</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_7_3</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">560px</span> <span style="color: #933;">240px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_7_4</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">560px</span> <span style="color: #933;">320px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_7_5</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">560px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_7_6</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">560px</span> <span style="color: #933;">480px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span><br /> &nbsp; &nbsp; <span style="color: #6666ff;">.hero_7_7</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/8way.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">560px</span> <span style="color: #933;">560px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></div></div><p>And the snippet of JavaScript (using JQuery) to animate and force hardware acceleration with translate3d:</p><div class="codecolorer-container javascript railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">function</span> animate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> animationAgeInMs <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: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> animationFrame <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>animationAgeInMs <span style="color: #339933;">/</span> msPerFrame<span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #339933;">%</span> walkCycleFrameCount<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isMouseDown<span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// do animation</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hero.<span style="color: #660066;">el</span>.<span style="color: #660066;">style</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;-webkit-transform&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;translate3d(&quot;</span><span style="color: #339933;">+</span> hero.<span style="color: #660066;">x</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">'px,'</span><span style="color: #339933;">+</span> hero.<span style="color: #660066;">y</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px,0px) &quot;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">// scale(&quot;+hero.scale+&quot;)&quot;;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hero.$el.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hero_&quot;</span> <span style="color: #339933;">+</span> animationFrame <span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;_&quot;</span><span style="color: #339933;">+</span> hero.<span style="color: #660066;">direction</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; requestAnimFrame<span style="color: #009900;">&#40;</span> animate <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /> &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></div><h2><a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/03/using-creative-cloud-and-css-translate3d-to-create-an-8-way-character-animation'); return false;">Adobe Creative Cloud</a> Products Used:</h2><p><a href="https://creative.adobe.com/apps?promoid=RENAUN"  onClick="trackOutboundLink(this, 'ccm_ol', '2013/03/using-creative-cloud-and-css-translate3d-to-create-an-8-way-character-animation'); return false;">Photoshop from the Adobe Creative Cloud</a><br /> <br/></p><h2>Other Technology:</h2><p><a href="http://www.tricedesigns.com/2013/03/11/performance-ux-considerations-for-successful-phonegap-apps/">CSS translate3d and CSS spritesheet, thanks to Andy Trice</a><br /> <br/></p><h2>Demo:</h2><p><a href="http://renaun.com/html5/csstranslate3d/">Live Demo</a><br /> <br/></p><h2>Source Files:</h2><p><a href="https://github.com/renaun/WorkflowExamples/tree/master/Character8wayAnimation">Source Photoshop source file and CSS Translate3D/Spritesheet HTML/JS files</a><br /> <br/></p><h2>Video:</h2><p><iframe width="480" height="360" src="http://www.youtube.com/embed/Ulg2heslqWs?rel=0" frameborder="0" allowfullscreen></iframe></p><p><center>&copy; %FIRST Erickson - visit the <a href="http://www.renaun.com">&lt;renaun.com:flexblog text="{ ModelLocator.myThoughts }"/&gt;</a></center></p><p>The post <a href="http://renaun.com/blog/2013/03/using-creative-cloud-and-css-translate3d-to-create-an-8-way-character-animation/">Using Creative Cloud and CSS Translate3D to Create an 8 Way Character Animation</a> appeared first on <a href="http://renaun.com/blog">Renaun Erickson</a>.</p>]]></content:encoded> <wfw:commentRss>http://renaun.com/blog/2013/03/using-creative-cloud-and-css-translate3d-to-create-an-8-way-character-animation/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 5/16 queries in 0.028 seconds using disk: basic
Object Caching 1289/1376 objects using disk: basic

 Served from: renaun.com @ 2013-05-22 21:52:42 by W3 Total Cache -->