<?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>*drawlogic &#187; HOWTO</title>
	<atom:link href="http://drawlogic.com/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://drawlogic.com</link>
	<description>interactive and game development technologies for the web - flash, flex, unity3d, silverlight, javascript</description>
	<lastBuildDate>Thu, 17 May 2012 13:12:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>More Flash  Unity3D Communication &#8211; u3dObject at Google Code</title>
		<link>http://drawlogic.com/2008/12/23/more-flash-unity3d-communication-u3dobject-at-google-code/</link>
		<comments>http://drawlogic.com/2008/12/23/more-flash-unity3d-communication-u3dobject-at-google-code/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 01:10:26 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[3D ENGINES]]></category>
		<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[APPLICATIONS]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[INTERFACE]]></category>
		<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[LIBRARIES]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[unity3d]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[embedding]]></category>
		<category><![CDATA[swf]]></category>
		<category><![CDATA[swfaddress]]></category>
		<category><![CDATA[swfobject]]></category>
		<category><![CDATA[TOOLS]]></category>
		<category><![CDATA[u3dobject]]></category>
		<category><![CDATA[unity]]></category>
		<category><![CDATA[unityobject]]></category>

		<guid isPermaLink="false">http://drawlogic.com/?p=326</guid>
		<description><![CDATA[I have mentioned before that flash to unity3d communication is a key part of game development for the web now where you are using Unity3D as a higher end renderer and some of your other page elements might be flash. Now there is a new open source kit for this called u3dobject.]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/aquiris-u3dobject/" target="_blank"><img class="alignright" title="u3dobject" src="http://farm4.static.flickr.com/3108/3132296848_9de1576cd1_o.png" alt="" width="366" height="84" /></a>I have <a href="http://drawlogic.com/2008/11/28/as3-flash-flex-and-unity3d-browser-communication-with-javascript/" target="_blank">mentioned before that flash to unity3d communication is a key part of game development</a> for the web now where you are using Unity3D as a higher end renderer and some of your other page elements might be flash. Now there is a new open source kit for this called <strong><a href="http://code.google.com/p/aquiris-u3dobject/" target="_blank">u3dobject</a></strong>.</p>
<p>To get Flash and Unity3D to talk to one another in an HTML/XHTML page is pretty simple with javascript and with the internal Unity3D Application object and the ExternalInterface in Flash.  But there are lots of elements of that communication that can be consolidated and reused so you don&#8217;t have to recreate that over and over.  Various studios and programmers come up with their own kits but when it becomes a shared activity to get the best integration and make it more of a platform that is where things like <a href="http://code.google.com/p/swfobject/" target="_blank">swfobject</a>, <a href="http://www.asual.com/swfaddress/" target="_blank">swfaddress</a> and <a href="http://code.google.com/p/aquiris-u3dobject/" target="_blank">u3dobject </a>come in.</p>
<p>So far swfobject is the standard for flash html embedding and <a href="http://www.unifycommunity.com/wiki/index.php?title=UnityObject" target="_blank">unityObject </a>is a similar take (but a bit dated) on that but now <a href="http://code.google.com/p/aquiris-u3dobject/" target="_blank">we have u3dObject that is open as well and a more official open source project for unity3D &lt;&#8211;&gt; flash integration and test harnesses for development </a>when those two technologies are used together.</p>
<p><strong>Unity3D &lt;-&gt; Flash Embedding Info:<br />
</strong></p>
<ul>
<li><a href="http://code.google.com/p/aquiris-u3dobject/" target="_blank">u3dobject hosted at google code</a></li>
<li><a href="http://www.unifycommunity.com/wiki/index.php?title=UnityObject" target="_blank">Older unityobject from unity3d wiki </a>(outdated)</li>
<li><a href="http://drawlogic.com/2008/11/28/as3-flash-flex-and-unity3d-browser-communication-with-javascript/" target="_blank">Recent post on the same topic and some examples from Paul Tondeur</a></li>
<li><a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html" target="_blank">ExternalInterface </a>for Flash</li>
<li><a href="http://unity3d.com/support/documentation/Manual/Unity%20Web%20Player%20and%20browser%20communication.html">Unity Web Player and browser communication</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/12/23/more-flash-unity3d-communication-u3dobject-at-google-code/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>HOWTO: SharedObjects for Local Storage AS3</title>
		<link>http://drawlogic.com/2008/01/10/howto-sharedobjects-for-local-storage-as3/</link>
		<comments>http://drawlogic.com/2008/01/10/howto-sharedobjects-for-local-storage-as3/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 10:21:41 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[APPLICATIONS]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CODE]]></category>
		<category><![CDATA[DATA]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[GAMES]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[SNIPPETS]]></category>
		<category><![CDATA[STATE]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://drawlogic.com/2008/01/10/howto-sharedobjects-for-local-storage-as3/</guid>
		<description><![CDATA[Using SharedObjects in Flash is very simple. Flash has SharedObjects that have been in the player since Flash6 when the introduction of Flash Communication Server which is now Flash Media Server which is releasing version 3 soon (also remote SharedObjects in Red5 is an open source RTMP media server that is based on Flash Media [...]]]></description>
			<content:encoded><![CDATA[<p>Using SharedObjects in Flash is very simple.  Flash has SharedObjects that have been in the player since Flash6 when the introduction of Flash Communication Server which is now Flash Media Server which is releasing version 3 soon (also remote SharedObjects in <a href="http://osflash.org/red5" target="_blank">Red5</a> is an open source RTMP media server that is based on Flash Media Server).  So we can thank this release for SharedObjects, Camera objects, Audio, lots of the NetConnections, protocol enhancements and many other things. However to keep the tips simple we will just touch on the local usage and post a series of posts on these objects.</p>
<p><b>SharedObjects locally and remote have changed the way offline is thought about and are the backbone of many offline systems and prototypes.</b>  They have been influential in moving storage locally to remote in a lightweight AMF0 or AMF3 format.</p>
<p><b>SharedObject is in the <a href="http://livedocs.adobe.com/flex/2/langref/flash/net/package-detail.html">flash.net</a> namespace in AS3.</b></p>
<p><b>Here we show how to use the local version of a SharedObject to store data in the most simple form.  </b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">net</span>.<span style="color: #660066;">SharedObject</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> so<span style="color: #339933;">:</span>SharedObject <span style="color: #339933;">=</span> SharedObject.<span style="color: #660066;">getLocal</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;userData&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">data</span>.<span style="color: #660066;">username</span><span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;user1377&quot;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">data</span>.<span style="color: #660066;">pwdhash</span><span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;[hash] or pwd&quot;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// writes changes to disk</span></pre></div></div>

<p>You can see this is extremely simple to store data.<b></b><b>Here we show how to use the local version of a SharedObject to retrieve data in the most simple form.  </b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">net</span>.<span style="color: #660066;">SharedObject</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> so<span style="color: #339933;">:</span>SharedObject <span style="color: #339933;">=</span> SharedObject.<span style="color: #660066;">getLocal</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;userData&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> username<span style="color: #339933;">:</span>String <span style="color: #339933;">=</span> so.<span style="color: #660066;">data</span>.<span style="color: #660066;">username</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> pwdhash<span style="color: #339933;">:</span>String <span style="color: #339933;">=</span> so.<span style="color: #660066;">data</span>.<span style="color: #660066;">pwdhash</span><span style="color: #339933;">;</span></pre></div></div>

<p>That is it!  In the most basic form SharedObjects are more simple than cookies and also are quite nice living outside the bounds of the cookies folder.  If a user deletes all cookies it will not delete the SharedObjects.  To delete SharedObjects you need to roght click on the Flash player, go to Settings and delete the objects there.<b></b><b>You can store any type of data Flash supports from objects to numbers to strings in the SharedObject data.  </b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">net</span>.<span style="color: #660066;">SharedObject</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> so<span style="color: #339933;">:</span>SharedObject <span style="color: #339933;">=</span> SharedObject.<span style="color: #660066;">getLocal</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;userData&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">data</span>.<span style="color: #660066;">username</span><span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;user1377&quot;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">data</span>.<span style="color: #660066;">uid</span><span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Number<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1337</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> obj<span style="color: #339933;">:</span>Object <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Object<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
obj.<span style="color: #660066;">prop</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;value&quot;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">data</span>.<span style="color: #660066;">userobj</span><span style="color: #339933;">=</span> obj<span style="color: #339933;">;</span>
so.<span style="color: #660066;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// writes changes to disk</span></pre></div></div>

<p>For large applications SharedObjects local are great because users can have their SharedObject space set to a high amount of space or unlmited for large offline type apps or more complex apps stored in a state object. It gets interesting when you pass this to the server in AMF or extremely compact AMF3 format to a remote stored object, via remoting, Shared Object events or any way you want to.We will be posting more on remote shared objects and some of the other tools such as Camera and Streams for AS3 over the coming weeks and deeper into the Sync Events for remote and local SOs.<b><a href="http://www.sephiroth.it/python/solreader.php" target="_blank">Sephiroth has a great Python tool to peer into the SOs on disk</a></b>.</p>
<blockquote><p>The first version of SharedObject Reader was written in <a href="http://www.python.org/">python 2.2</a>.<br />
This new version is written in <b>C#</b> (C Sharp) as it&#8217;s now part of <b><a href="http://www.flashdevelop.org/">FlashDevelop</a></b> editor.</p></blockquote>
<p>Red5 also does this as well as many AMF kits.</p>
<p><b>Sync Events for SharedObject (as they change they launch a sync event) </b></p>
<p><span class="label">Event object type: </span><a href="http://livedocs.adobe.com/flex/2/langref/flash/events/SyncEvent.html" target="_blank"><code>flash.events.SyncEvent</code></a><br />
<span class="label">SyncEvent.type property = </span><a href="http://livedocs.adobe.com/flex/2/langref/flash/events/SyncEvent.html#SYNC" target="_blank"><code>flash.events.SyncEvent.SYNC</code></a></p>
<p><b>Read more at adobe docs:</b></p>
<p><a href="http://livedocs.adobe.com/flex/2/langref/flash/net/SharedObject.html#includeExamplesSummary" target="_blank">flash.net.SharedObject</a></p>
<p><b>Sample from AS3 docs showing usage</b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">package</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">display</span>.<span style="color: #660066;">Sprite</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #660066;">MouseEvent</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #660066;">NetStatusEvent</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">net</span>.<span style="color: #660066;">SharedObject</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">net</span>.<span style="color: #660066;">SharedObjectFlushStatus</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">text</span>.<span style="color: #660066;">TextField</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">text</span>.<span style="color: #660066;">TextFieldAutoSize</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">text</span>.<span style="color: #660066;">TextFieldType</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">class</span> SharedObjectExample <span style="color: #003366; font-weight: bold;">extends</span> Sprite <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> mySo<span style="color: #339933;">:</span>SharedObject<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> SharedObjectExample<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            buildUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>MouseEvent.<span style="color: #660066;">CLICK</span><span style="color: #339933;">,</span> saveValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>MouseEvent.<span style="color: #660066;">CLICK</span><span style="color: #339933;">,</span> clearValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            mySo <span style="color: #339933;">=</span> SharedObject.<span style="color: #660066;">getLocal</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;application-name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SharedObject loaded...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;loaded value: &quot;</span> <span style="color: #339933;">+</span> mySo.<span style="color: #660066;">data</span>.<span style="color: #660066;">savedValue</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
         <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> saveValue<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>MouseEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;saving value...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            mySo.<span style="color: #660066;">data</span>.<span style="color: #660066;">savedValue</span> <span style="color: #339933;">=</span> input.<span style="color: #660066;">text</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">var</span> flushStatus<span style="color: #339933;">:</span>String <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                flushStatus <span style="color: #339933;">=</span> mySo.<span style="color: #660066;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>error<span style="color: #339933;">:</span>Error<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Error...Could not write SharedObject to disk<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>flushStatus <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>flushStatus<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">case</span> SharedObjectFlushStatus.<span style="color: #660066;">PENDING</span><span style="color: #339933;">:</span>
                        output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Requesting permission to save object...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        mySo.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>NetStatusEvent.<span style="color: #660066;">NET_STATUS</span><span style="color: #339933;">,</span> onFlushStatus<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">case</span> SharedObjectFlushStatus.<span style="color: #660066;">FLUSHED</span><span style="color: #339933;">:</span>
                        output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Value flushed to disk.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> clearValue<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>MouseEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Cleared saved value...Reload SWF and the value should be <span style="color: #000099; font-weight: bold;">\&quot;</span>undefined<span style="color: #000099; font-weight: bold;">\&quot;</span>.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">delete</span> mySo.<span style="color: #660066;">data</span>.<span style="color: #660066;">savedValue</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> onFlushStatus<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>NetStatusEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;User closed permission dialog...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>event.<span style="color: #660066;">info</span>.<span style="color: #660066;">code</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;SharedObject.Flush.Success&quot;</span><span style="color: #339933;">:</span>
                    output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;User granted permission -- value saved.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;SharedObject.Flush.Failed&quot;</span><span style="color: #339933;">:</span>
                    output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;User denied permission -- value not saved.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            mySo.<span style="color: #660066;">removeEventListener</span><span style="color: #009900;">&#40;</span>NetStatusEvent.<span style="color: #660066;">NET_STATUS</span><span style="color: #339933;">,</span> onFlushStatus<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// UI elements</span>
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> inputLbl<span style="color: #339933;">:</span>TextField<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> input<span style="color: #339933;">:</span>TextField<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> output<span style="color: #339933;">:</span>TextField<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> saveBtn<span style="color: #339933;">:</span>Sprite<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> clearBtn<span style="color: #339933;">:</span>Sprite<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> buildUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// input label</span>
            inputLbl <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            addChild<span style="color: #009900;">&#40;</span>inputLbl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            inputLbl.<span style="color: #660066;">x</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            inputLbl.<span style="color: #660066;">y</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            inputLbl.<span style="color: #660066;">text</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Value to save:&quot;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// input TextField</span>
            input <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            addChild<span style="color: #009900;">&#40;</span>input<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">x</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">80</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">y</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">border</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">background</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">type</span> <span style="color: #339933;">=</span> TextFieldType.<span style="color: #660066;">INPUT</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// output TextField</span>
            output <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            addChild<span style="color: #009900;">&#40;</span>output<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">x</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">y</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">35</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">250</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">250</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">multiline</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">wordWrap</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">border</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">background</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// Save button</span>
            saveBtn <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Sprite<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            addChild<span style="color: #009900;">&#40;</span>saveBtn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">x</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">190</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">y</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">useHandCursor</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">lineStyle</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">beginFill</span><span style="color: #009900;">&#40;</span>0xcccccc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">drawRoundRect</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> saveLbl<span style="color: #339933;">:</span>TextField <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">addChild</span><span style="color: #009900;">&#40;</span>saveLbl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveLbl.<span style="color: #660066;">text</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Save&quot;</span><span style="color: #339933;">;</span>
            saveLbl.<span style="color: #660066;">selectable</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// Clear button</span>
            clearBtn <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Sprite<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            addChild<span style="color: #009900;">&#40;</span>clearBtn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">x</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">230</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">y</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">useHandCursor</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">lineStyle</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">beginFill</span><span style="color: #009900;">&#40;</span>0xcccccc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">drawRoundRect</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> clearLbl<span style="color: #339933;">:</span>TextField <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">addChild</span><span style="color: #009900;">&#40;</span>clearLbl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearLbl.<span style="color: #660066;">text</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Clear&quot;</span><span style="color: #339933;">;</span>
            clearLbl.<span style="color: #660066;">selectable</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/01/10/howto-sharedobjects-for-local-storage-as3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Motion Detection In Flash (AS2 and AS3) and C#</title>
		<link>http://drawlogic.com/2007/10/17/motion-detection-in-flash-as2-and-as3-and-c/</link>
		<comments>http://drawlogic.com/2007/10/17/motion-detection-in-flash-as2-and-as3-and-c/#comments</comments>
		<pubDate>Thu, 18 Oct 2007 05:24:34 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[ADOBE]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[DYNAMIC]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[GAMES]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[MOTION]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[VISUALIZATION]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/2007/10/17/motion-detection-in-flash-as2-and-as3-and-c/</guid>
		<description><![CDATA[Currently working on some motion detection with flash/c# and webcams right now. Here&#8217;s a basic overview of some motion detection source files and tricks. Most motion detection is based on snapshots and finding brightness of a pixel with all combined colors, then comparing that to previous snapshots to detect enough variance and thus movement. If [...]]]></description>
			<content:encoded><![CDATA[<p>Currently working on some motion detection with flash/c# and webcams right now.  Here&#8217;s a basic overview of some motion detection source files and tricks.  Most motion detection is based on snapshots and finding brightness of a pixel with all combined colors, then comparing that to previous snapshots to detect enough variance and thus movement. If you have a webcam hooked up, <a href="http://www.shockwave-india.com/blog/?archive=2006_07_01_archive.xml#115310761896152783" target="_blank">this sample in Flash AS3 highlights this well showing the camera on the left, then the brightness snapshots on the right</a>.  It also has an indicator to the amount of movement due to much brightness.</p>
<p><strong>C# </strong></p>
<p>Here is a <a href="http://www.codeproject.com/cs/media/Motion_Detection.asp" target="_blank">nice example of motion detection using various motion detection algorithms in C#</a>. This is built on the very slick <a href="http://code.google.com/p/aforge/" target="_blank">AForge.NET Computer Imaging Library</a>.</p>
<p><img src="http://i81.photobucket.com/albums/j223/drawkbox/4.jpg" height="290" width="354" /></p>
<p>If you ever wanted your own motion detection or recording it is all possible with the basics of checking brightness and snapshots in the most simple form checking how much change or variance their was to bright pixels or the count of bright pixels compared to previous snapshots.</p>
<p><span></span></p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// Calculate white pixels</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">int</span> CalculateWhitePixels<span style="color: #008000;">&#40;</span> Bitmap image <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #6666cc; font-weight: bold;">int</span> count <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
    <span style="color: #008080; font-style: italic;">// lock difference image</span>
    BitmapData data <span style="color: #008000;">=</span> image<span style="color: #008000;">.</span><span style="color: #0000FF;">LockBits</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">new</span> Rectangle<span style="color: #008000;">&#40;</span> <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>, width, height <span style="color: #008000;">&#41;</span>,
        ImageLockMode<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">ReadOnly</span>, PixelFormat<span style="color: #008000;">.</span><span style="color: #0000FF;">Format8bppIndexed</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">int</span> offset <span style="color: #008000;">=</span> data<span style="color: #008000;">.</span><span style="color: #0000FF;">Stride</span> <span style="color: #008000;">-</span> width<span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">unsafe</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #6666cc; font-weight: bold;">byte</span> <span style="color: #008000;">*</span> ptr <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">byte</span> <span style="color: #008000;">*</span><span style="color: #008000;">&#41;</span> data<span style="color: #008000;">.</span><span style="color: #0000FF;">Scan0</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToPointer</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">int</span> y <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> y <span style="color: #008000;">&lt;</span> height<span style="color: #008000;">;</span> y<span style="color: #008000;">++</span> <span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">int</span> x <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> x <span style="color: #008000;">&lt;</span> width<span style="color: #008000;">;</span> x<span style="color: #008000;">++</span>, ptr<span style="color: #008000;">++</span> <span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                count <span style="color: #008000;">+=</span> <span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">*</span>ptr<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&gt;&gt;</span> <span style="color: #FF0000;">7</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
            ptr <span style="color: #008000;">+=</span> offset<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">// unlock image</span>
    image<span style="color: #008000;">.</span><span style="color: #0000FF;">UnlockBits</span><span style="color: #008000;">&#40;</span> data <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> count<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p><strong>Flash AS2</strong></p>
<p>In <a href="http://www.adobe.com/devnet/flash/articles/webcam_motion.html" target="_blank">Flash this is also possible here is a good article from Flash8 that explains cycling through each pixel to compare the image data and implement motion detection from a webcam</a>.</p>
<p>For instance the basics here show how you can compare each pixel and the change in the brightness for each pixel:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//accuracy</span>
tolerance<span style="color: #339933;">=</span><span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//color of the current pixel in the current snapshot</span>
nc<span style="color: #339933;">=</span>now.<span style="color: #660066;">getPixel</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">,</span>y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//red channel</span>
nr<span style="color: #339933;">=</span>nc<span style="color: #339933;">&gt;&gt;</span><span style="color: #CC0000;">16</span><span style="color: #339933;">&amp;</span>0xff<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//green channel</span>
ng<span style="color: #339933;">=</span>nc<span style="color: #339933;">&gt;&gt;</span><span style="color: #CC0000;">8</span><span style="color: #339933;">&amp;</span>0xff<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//blue channel</span>
nb<span style="color: #339933;">=</span>nc<span style="color: #339933;">&amp;</span>0xff<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//brightness</span>
nl<span style="color: #339933;">=</span>Math.<span style="color: #660066;">sqrt</span><span style="color: #009900;">&#40;</span>nr<span style="color: #339933;">*</span>nr <span style="color: #339933;">+</span> ng<span style="color: #339933;">*</span>ng <span style="color: #339933;">+</span> nb<span style="color: #339933;">*</span>nb<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//color of the same pixel in the previous snapshot</span>
bc<span style="color: #339933;">=</span>before.<span style="color: #660066;">getPixel</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">,</span>y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//red channel</span>
br<span style="color: #339933;">=</span>bc<span style="color: #339933;">&gt;&gt;</span><span style="color: #CC0000;">16</span><span style="color: #339933;">&amp;</span>0xff<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//green channel</span>
bg<span style="color: #339933;">=</span>bc<span style="color: #339933;">&gt;&gt;</span><span style="color: #CC0000;">8</span><span style="color: #339933;">&amp;</span>0xff<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//blue channel</span>
bb<span style="color: #339933;">=</span>bc<span style="color: #339933;">&amp;</span>0xff<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//brightness</span>
bl<span style="color: #339933;">=</span>Math.<span style="color: #660066;">sqrt</span><span style="color: #009900;">&#40;</span>br<span style="color: #339933;">*</span>br <span style="color: #339933;">+</span> bg<span style="color: #339933;">*</span>bg <span style="color: #339933;">+</span> bb<span style="color: #339933;">*</span>bb<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//difference in brightness between now and before</span>
d<span style="color: #339933;">=</span>Math.<span style="color: #660066;">round</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">abs</span><span style="color: #009900;">&#40;</span>bl<span style="color: #339933;">-</span>nl<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>d<span style="color: #339933;">&gt;</span>tolerance<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">//there was a change in this pixel</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Flash AS3</strong></p>
<p>Here is a <a href="http://www.shockwave-india.com/blog/?archive=2006_07_01_archive.xml#115310761896152783" target="_blank">link to grab a conversion of the AS2 Flash motion detection above to AS3</a>.</p>
<p>Source of AS3 motion detection <a href="http://www.shockwave-india.com/blog/components/index.php?download=Flash9WebcamMotionDetection.zip" title="Flash9WebcamMotionDetection.zip  12.9 KB">here.</a></p>
<p><a href="http://incomplet.gskinner.com/" target="_blank">Grant Skinner has done some interesting things with motion detection with Flash and webcams in the past in the incomplet</a> gallery.</p>
<p>C# or other hardware accelerated capable kits are faster but AS3 and Flash with the new AVM2 virtual machine  should be about 10 times faster than AS2 as much of the improvement in performance and the virtual machine is on iteration speed increases such as loops (i.e. pixel loop).</p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2007/10/17/motion-detection-in-flash-as2-and-as3-and-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3D Flash Perlin Noise Terrains with AS3 and Sandy</title>
		<link>http://drawlogic.com/2007/07/15/3d-flash-perlin-noise-terrains-with-as3-and-sandy/</link>
		<comments>http://drawlogic.com/2007/07/15/3d-flash-perlin-noise-terrains-with-as3-and-sandy/#comments</comments>
		<pubDate>Sun, 15 Jul 2007 20:28:29 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[ANIMATION]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[PIXEL]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[SANDY]]></category>
		<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/2007/07/15/3d-flash-perlin-noise-terrains-with-as3-and-sandy/</guid>
		<description><![CDATA[Rafajafar posted a great tutorial on 3D Flash Perlin Noise dynamic terrain generations with AS3 and Sandy. Sandy is a flash 3d engine that has been out just a little longer than Papervision3D. The code for Sandy is very clear and it is a great engine. I have experimented with it and found it to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.onlinekarma.net/flash3d/index.php?option=com_content&amp;task=view&amp;id=16&amp;Itemid=1" target="_blank">Rafajafar posted a great tutorial on 3D Flash Perlin Noise dynamic terrain generations with AS3 and Sandy</a>.</p>
<p><a href="http://www.flashsandy.org/demos/" target="_blank">Sandy</a> is a flash 3d engine that has been out just a little longer than Papervision3D.  The code for Sandy is very clear and it is a great engine. I have experimented with it and found it to be a bit slower it seems that papervision but it has great tools, including an extra 3ds file importer in addition to the Collada and ASE formats that most flash 3d engines support.</p>
<p>Using <a href="http://freespace.virgin.net/hugo.elias/models/m_perlin.htm" target="_blank">Perlin Noise</a> is very common in 3d engines to draw large terrains and realistic terrains for 3d games or simulations.  This technique makes it very easy to make dynamic terrains or randomly generated terrains, <a href="http://actionscriptarchitect.com/lab/LiquidMetal/" target="_blank">water</a> <a href="http://larry.onlinekarma.net/tutorials/Sandy3/Terrain/bin/WaterTerrain.swf" target="_blank">effects</a>, <a href="http://actionscriptarchitect.com/lab/FireSphere/">fire</a>, clouds, whatever your need.</p>
<p><a href="http://www.onlinekarma.net/flash3d/index.php?option=com_content&amp;task=view&amp;id=16&amp;Itemid=1" target="_blank">The demo has terrain generation class</a> that can be used to build the dynamic terrain generation and the perlin noise material movement.</p>
<p><a href="http://larry.onlinekarma.net/tutorials/Sandy3/Terrain/bin/WaterTerrain.swf" target="_blank"><img src="http://i81.photobucket.com/albums/j223/drawkbox/perliinsandy.png" alt="" /></a></p>
<ul>
<li><a href="http://larry.onlinekarma.net/tutorials/Sandy3/Terrain/bin/WaterTerrain.swf" target="_blank">Water</a></li>
<li><a href="http://larry.onlinekarma.net/tutorials/Sandy3/Terrain/bin/GentleHillTerrain.swf" target="_blank">Gentle Hills</a></li>
<li><a href="http://larry.onlinekarma.net/tutorials/Sandy3/Terrain/bin/TallHillTerrain.swf" target="_blank">Smooth Hills</a></li>
<li><a href="http://larry.onlinekarma.net/tutorials/Sandy3/Terrain/bin/MountainousTerrain.swf" target="_blank">Mountanous</a></li>
</ul>
<p>Samples using the TerrainCreator class to make different terrains.  This could be used to also make level editors and other components of the game making pipeline in flash 3d.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//Water</span>
ter <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TerrainCreator<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;MyTerrain&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000000</span><span style="color: #339933;">,</span>
<span style="color: #CC0000;">128</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">6000</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">6000</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">,</span><span style="color: #CC0000;">60</span><span style="color: #339933;">,</span><span style="color: #CC0000;">60</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">15</span><span style="color: #339933;">,</span>
BitmapDataChannel.<span style="color: #660066;">BLUE</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Gentle Hills</span>
ter <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TerrainCreator<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;MyTerrain&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">128</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9</span><span style="color: #339933;">,</span>
<span style="color: #CC0000;">6000</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">6000</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">,</span><span style="color: #CC0000;">120</span><span style="color: #339933;">,</span><span style="color: #CC0000;">120</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">15</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">7</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Smooth Hills</span>
ter <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TerrainCreator<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;MyTerrain&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">128</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9</span><span style="color: #339933;">,</span>
<span style="color: #CC0000;">6000</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">6000</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">,</span><span style="color: #CC0000;">120</span><span style="color: #339933;">,</span><span style="color: #CC0000;">120</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">7</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Mountainous</span>
ter <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TerrainCreator<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;MyTerrain&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">128</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span>
<span style="color: #CC0000;">6000</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">6000</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">15</span><span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">7</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a href="http://www.onlinekarma.net/flash3d/index.php?option=com_content&amp;task=view&amp;id=16&amp;Itemid=1" target="_blank">Click here for the full tutorial and source files on 3D Flash Perlin Noise dynamic terrain generations with AS3 and Sandy</a>.</p>
<p><em>Now if we could just fast forward 2-3 years on processor power and speed, or get hardware acceleration for Flash&#8230;</em></p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2007/07/15/3d-flash-perlin-noise-terrains-with-as3-and-sandy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOWTO: Using the ContextMenu in AS3 with FullScreen Mode As a Sample</title>
		<link>http://drawlogic.com/2007/06/12/howto-using-the-contextmenu-in-as3-with-fullscreen-mode-as-a-sample/</link>
		<comments>http://drawlogic.com/2007/06/12/howto-using-the-contextmenu-in-as3-with-fullscreen-mode-as-a-sample/#comments</comments>
		<pubDate>Wed, 13 Jun 2007 04:39:21 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[APPLICATIONS]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[CODE]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[INTERFACE]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/2007/06/12/howto-using-the-contextmenu-in-as3-with-fullscreen-mode-as-a-sample/</guid>
		<description><![CDATA[Right clicking and other mouse support in flash is not really a shining star but in AS2/AS3 you *can* stuff the context menu with items. You can clear out all but Settings and About from the menu and stuff in other items that may pertain to a selected movieclip or the entire app you are [...]]]></description>
			<content:encoded><![CDATA[<p>Right clicking and other mouse support in flash is not really a shining star but in AS2/AS3 you <b>*can*</b> stuff the context menu with items.  You can clear out all but Settings and About from the menu and stuff in other items that may pertain to a selected movieclip or the entire app you are building. This can be good when adding multiple functions into applications and for extra functions that you want to make available from a quick location such as full screen, selecting an item etc.</p>
<p><b>To enable a context menu for full screen capabilities take this example:</b></p>
<p><b> 1) Make your document class of your AS3 Flash CS3 file to the class below.</b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">package</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">display</span>.<span style="color: #339933;">*;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">errors</span>.<span style="color: #339933;">*;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #339933;">*;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">filters</span>.<span style="color: #339933;">*;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">geom</span>.<span style="color: #339933;">*;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">net</span>.<span style="color: #339933;">*;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">media</span>.<span style="color: #339933;">*;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">ui</span>.<span style="color: #339933;">*;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">utils</span>.<span style="color: #339933;">*;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">xml</span>.<span style="color: #339933;">*;</span>
<span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">class</span> FullScreenTest <span style="color: #003366; font-weight: bold;">extends</span> MovieClip
<span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> FullScreenTest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// create the context menu, remove the built-in items,</span>
<span style="color: #006600; font-style: italic;">// and add our custom items</span>
<span style="color: #003366; font-weight: bold;">var</span> fullscreenCM<span style="color: #339933;">:</span>ContextMenu <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ContextMenu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fullscreenCM.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>ContextMenuEvent.<span style="color: #660066;">MENU_SELECT</span><span style="color: #339933;">,</span> onContextMenuHandler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fullscreenCM.<span style="color: #660066;">hideBuiltInItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> fs<span style="color: #339933;">:</span>ContextMenuItem <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ContextMenuItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Show Full Screen&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fs.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>ContextMenuEvent.<span style="color: #660066;">MENU_ITEM_SELECT</span><span style="color: #339933;">,</span> onShowFullScreen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fullscreenCM.<span style="color: #660066;">customItems</span>.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span> fs <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> xfs<span style="color: #339933;">:</span>ContextMenuItem <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ContextMenuItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Exit Full Screen&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xfs.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>ContextMenuEvent.<span style="color: #660066;">MENU_ITEM_SELECT</span><span style="color: #339933;">,</span> onShowNormalScreen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fullscreenCM.<span style="color: #660066;">customItems</span>.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span> xfs <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// THIS ASSUMES YOU HAVE A MOVIECLIP IN THE LIBRARY</span>
<span style="color: #006600; font-style: italic;">// THAT IS SET TO A CLASS NAMED 'mc' that inherits from MovieClip</span>
<span style="color: #003366; font-weight: bold;">var</span> m<span style="color: #339933;">:</span>MovieClip <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> mc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
m.<span style="color: #660066;">contextMenu</span> <span style="color: #339933;">=</span> fullscreenCM<span style="color: #339933;">;</span>
addChild<span style="color: #009900;">&#40;</span>m<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">// functions to enter and leave full screen mode</span>
<span style="color: #003366; font-weight: bold;">function</span> onShowFullScreen<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>ContextMenuEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
stage.<span style="color: #660066;">displayState</span> <span style="color: #339933;">=</span> StageDisplayState.<span style="color: #660066;">FULL_SCREEN</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> onShowNormalScreen<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>ContextMenuEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
stage.<span style="color: #660066;">displayState</span> <span style="color: #339933;">=</span> StageDisplayState.<span style="color: #660066;">NORMAL</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">// function to enable and disable the context menu items,</span>
<span style="color: #006600; font-style: italic;">// based on what mode we are in.</span>
<span style="color: #003366; font-weight: bold;">function</span> onContextMenuHandler<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>ContextMenuEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>stage.<span style="color: #660066;">displayState</span> <span style="color: #339933;">==</span> StageDisplayState.<span style="color: #660066;">NORMAL</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
event.<span style="color: #660066;">target</span>.<span style="color: #660066;">customItems</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">enabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// show full screen button</span>
event.<span style="color: #660066;">target</span>.<span style="color: #660066;">customItems</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">enabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// hide normal screen button</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span>
<span style="color: #009900;">&#123;</span>
event.<span style="color: #660066;">target</span>.<span style="color: #660066;">customItems</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">enabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// hide full screen button</span>
event.<span style="color: #660066;">target</span>.<span style="color: #660066;">customItems</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">enabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// shoe normal screen button</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><b>2) Now Export to HTML and be sure to change the exported parameters in the HTML file to allowFullScreen = true (for the fullscreen effect) and menu = true (for the ability to add in context menu items) to whatever library you use for embedding flash:</b></p>
<pre>   'menu', 'true',
   'allowFullScreen', 'true'</pre>
<p>OR if using HTML parameters</p>
<pre>&lt;param name="allowFullScreen" value="true" /&gt;
&lt;param name="menu" value="true" /&gt;</pre>
<pre></pre>
<p><b><a href="http://labs.drawlabs.com/tutorial/flash/as3/fullscreen/fullscreentest.html" target="_blank">You can view a sample here. </a></b>(right click on the movie clip and &#8216;show full screen&#8217;, then &#8216;hide full screen&#8217;)</p>
<p><b>You can <a href="http://lab.drawlabs.com/tutorial/flash/as3/fullscreen/fullscreentest.zip" target="_blank">download a sample FlashCS3/AS3 version here</a>.</b></p>
<p>If you want more information on fullscreen <a href="http://www.adobe.com/devnet/flashplayer/articles/full_screen_mode_03.html" target="_blank">check here</a> and <a href="http://labs.adobe.com/wiki/index.php/Flash_Player:9:Update:Full-Screen_Mode_HW" target="_blank">here</a> (downloadable sample and component).</p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2007/06/12/howto-using-the-contextmenu-in-as3-with-fullscreen-mode-as-a-sample/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>AS3 Mouse Events, No More Invisible Buttons</title>
		<link>http://drawlogic.com/2007/05/16/as3-mouse-events-no-more-invisible-buttons/</link>
		<comments>http://drawlogic.com/2007/05/16/as3-mouse-events-no-more-invisible-buttons/#comments</comments>
		<pubDate>Thu, 17 May 2007 03:12:30 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[HOWTO]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/2007/05/16/as3-mouse-events-no-more-invisible-buttons/</guid>
		<description><![CDATA[Here is a small tutorial on scripting and its great changes in AS3 from AS2/AS1 thinking, we are focusing on mouse events currently. The great thing about Flash9 and specifically AS3 (Actionscript3) is that it is starting to become a real programming platform and losing many of the silly hacks that is used to have. [...]]]></description>
			<content:encoded><![CDATA[<p><em>Here is a small tutorial on scripting and its great changes in AS3 from AS2/AS1 thinking, we are focusing on mouse events currently.</em></p>
<p>The great thing about Flash9 and specifically AS3 (Actionscript3) is that it is starting to become a real programming platform and losing many of the silly hacks that is used to have. This is a good thing.</p>
<p>Old <a href="http://livedocs.adobe.com/flex/2/langref/migration.html" target="_blank">hacks like tellTarget are finally gone</a>. <a href="http://lab.andre-michelle.com/bitmap-particles-2" target="_blank">Pixel level manipulation</a> is possible and even faster. <a href="http://lab.polygonal.de/ds/" target="_blank">Real frameworks</a>, <a href="http://code.google.com/p/tweener/" target="_blank">excellent structured animation kits</a> and even <a href="http://www.papervision3d.org/" target="_blank">3d engines</a> are being built everyday. And invisible buttons are not needed anymore!</p>
<p>Like when people migrated from desktop to web, or VB6 to .NET, or OO to functional, we tend to try to reimplement the same solutions in new platforms even if there are better options because it worked before.</p>
<p><strong>How to make movieclip buttons without invisible buttons via AS3 script&#8230;</strong></p>
<p>Anything can be clickable and a button in AS3.  Link a class to an object in a movie, dynamicly drawn asset or external asset and you are ready to make it a button.</p>
<p><strong>Take for instance:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">package</span> draw.<span style="color: #660066;">logic</span>.<span style="color: #660066;">tests</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">display</span>.<span style="color: #339933;">*;</span>
 <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #339933;">*;</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">class</span> GamePlayButton <span style="color: #003366; font-weight: bold;">extends</span> MovieClip
 <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> GamePlayButton <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>MouseEvent.<span style="color: #660066;">CLICK</span><span style="color: #339933;">,</span> onMouseClickEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">function</span> onMouseClickEvent<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>Event<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
  <span style="color: #009900;">&#123;</span>
    trace<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mouse clicked on me&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You will note the addition of the event to the movie clip which makes it clickable.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>MouseEvent.<span style="color: #660066;">CLICK</span><span style="color: #339933;">,</span> onMouseClickEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This again makes the movieclip clickable by listenting for the MouseEvent.CLICK event. This sample class can be linked to a movieclip for instance from the FLA library by going to <strong>Library &gt; Properties</strong> then linking the class which would be draw.logic.tests.GamePlayButton in the above sample.</p>
<p>Great so we have a button now, on the MouseEvent.CLICK we are going to go to trace a message. All done right?  Nope if you will notice the button does not get the linkable hand.</p>
<p><strong>Make the Button Show the Mouse Cursor Hand<br />
</strong><br />
Well in old skool  AS we might just slap an invisible button on there or make it a button type.  Better yet let&#8217;s just set the <strong>this.buttonMode = true;</strong> in code which makes it a clickable button, listens to the click event, and get the hand to notify the user that it is a clickable item.</p>
<p><strong>Sample script for a &#8216;play&#8217; button</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">package</span> draw.<span style="color: #660066;">logic</span>.<span style="color: #660066;">tests</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">display</span>.<span style="color: #339933;">*;</span>
 <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #339933;">*;</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">class</span> GamePlayButton <span style="color: #003366; font-weight: bold;">extends</span> MovieClip
 <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> GamePlayButton <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">buttonMode</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>MouseEvent.<span style="color: #660066;">CLICK</span><span style="color: #339933;">,</span> onMouseClickEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">function</span> onMouseClickEvent<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>Event<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
  <span style="color: #009900;">&#123;</span>
    parent.<span style="color: #660066;">gotoAndPlay</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;game&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Good Architecture and Design<br />
</strong><br />
In the past most items could be moved to .as files but you would have this mix of people that still put onEnterFrames or button click on(release) code in the FLA itself.  AS3 I think finally makes it fully possible to remove code entirely from the FLA with only stop(); scripts for different frames.</p>
<p>A nice way to be is to have all script in external libraries and files removing all script from the FLA if possible.  The script for buttons to the script for the main document class.  The FLA is essentially just needed for library movieclips and AS3 real forces this separation. That combined with its general better structure makes this a much better platform than AS2 and Flash8, stop wasting your time developing in that and get to AS3 (take <a href="http://livedocs.adobe.com/flex/2/langref/migration.html" target="_blank">a gander at the better structured libraries in this migration link</a>).</p>
<p>Best part of AS3 is the new clean event model, the basis on Javascript 2 spec and the clearer separation of code and assets for flash.  More on the Mouse and Event model  in AS3 and Timers, Loaders and more coming soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2007/05/16/as3-mouse-events-no-more-invisible-buttons/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>HOWTO: Using the MouseWheel Event in AS3</title>
		<link>http://drawlogic.com/2007/05/13/mousewheel-event-in-as3/</link>
		<comments>http://drawlogic.com/2007/05/13/mousewheel-event-in-as3/#comments</comments>
		<pubDate>Sun, 13 May 2007 09:12:21 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[CODE]]></category>
		<category><![CDATA[FLASH]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[INTERFACE]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/2007/05/13/mousewheel-event-in-as3/</guid>
		<description><![CDATA[Mousewheel usage has been increasing now that almost everyone has a mouse with a wheel on it. Flash and specifically AS3 has capabilities to get lots of information about the mouse wheel movement and mouse movements in general. In AS3 you wire up events like this: stage.addEventListener&#40;Event.RESIZE, onResizeEvent&#41;; For mouse events you wire them up [...]]]></description>
			<content:encoded><![CDATA[<p>Mousewheel usage has been increasing now that almost everyone has a mouse with a wheel on it.  Flash and specifically AS3 has capabilities to get lots of information about the mouse wheel movement and mouse movements in general.</p>
<p>In AS3 you wire up events like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">stage.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>Event.<span style="color: #660066;">RESIZE</span><span style="color: #339933;">,</span> onResizeEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>For mouse events you wire them up using the Mouse pseudo static enumeration <strong>MouseEvent</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">stage.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>MouseEvent.<span style="color: #660066;">MOUSE_WHEEL</span><span style="color: #339933;">,</span> onMouseWheelEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Inside of our flash class that we are wiring up events for we need to put the event function that we pass as an argument.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> onMouseWheelEvent<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>Event<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
trace<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;onMouseWheelEvent!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
trace<span style="color: #009900;">&#40;</span>event.<span style="color: #660066;">delta</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As you can see the method passes the object in the event.  Here we are getting the <strong>delta</strong> property of the object returned for the <strong>mousewheel event</strong>.  You can get any of these properties that return (you can see this if you trace out the object).</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"> <span style="color: #006600; font-style: italic;">//[MouseEvent type=&quot;mouseWheel&quot; bubbles=true cancelable=false eventPhase=2 localX=261 localY=241 stageX=261 stageY=241 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=-6]</span>
&nbsp;
<span style="color: #009900;">&#91;</span>
MouseEvent
type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;mouseWheel&quot;</span>
bubbles<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span>
cancelable<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span>
eventPhase<span style="color: #339933;">=</span><span style="color: #CC0000;">2</span>
localX<span style="color: #339933;">=</span><span style="color: #CC0000;">261</span>
localY<span style="color: #339933;">=</span><span style="color: #CC0000;">241</span>
stageX<span style="color: #339933;">=</span><span style="color: #CC0000;">261</span>
stageY<span style="color: #339933;">=</span><span style="color: #CC0000;">241</span>
relatedObject<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">null</span>
ctrlKey<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span>
altKey<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span>
shiftKey<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span>
delta<span style="color: #339933;">=-</span><span style="color: #CC0000;">6</span>
<span style="color: #009900;">&#93;</span></pre></div></div>

<p>The <strong>delta</strong> property is the amount and direction that the mouse wheel was moved up or down.  <strong>If the delta is a positive integer then the mouse wheel was moved up, if negative it was moved down. </strong></p>
<p>On my computer I have scrolling set to pages so it sets to 6 or -6 on all movements. Others that have different mouse customizations might only move 1 or 2 in either direction, mine moves six.  This is important to note for game development or browsing with zoomable applications. <em>Not all mousewheels are the same.</em></p>
<p>You can also see that there is a <strong>ctrlKey</strong> property and an <strong>altKey</strong> and <strong>shiftKey</strong> property to check if the user also has these down. This could be beneficial for navigation like in a 3d program or map where if you hold down shift or ctrl the application does different actions with the mouse wheel.</p>
<p>The mouse positions are also passed so you could check if what to scroll specifically or zoom.  <strong>These mouse positional properties are available in other mouse events as well, you can always trace(event) to the passed event to see what it contains.</strong>  You can also attach these events inside individual classes so that they only reacte to their own mouse wheel events rather than on the main stage.</p>
<p>SAMPLE MouseWheel script test file (make a new file and set this to the document class)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">package</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">display</span>.<span style="color: #339933;">*;</span>
 <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #339933;">*;</span>
 <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">ui</span>.<span style="color: #339933;">*;</span>
  <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">class</span> MouseWheelMain <span style="color: #003366; font-weight: bold;">extends</span> MovieClip
  <span style="color: #009900;">&#123;</span>
   <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> MouseWheelMain<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
    stage.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>MouseEvent.<span style="color: #660066;">MOUSE_WHEEL</span><span style="color: #339933;">,</span>   onMouseWheelEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">function</span> onMouseWheelEvent<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>Event<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
    <span style="color: #009900;">&#123;</span>
     trace<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;onMouseWheelEvent&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     trace<span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     trace<span style="color: #009900;">&#40;</span>event.<span style="color: #660066;">delta</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// amount mouse wheel moved</span>
     <span style="color: #006600; font-style: italic;">// could do something like</span>
     <span style="color: #006600; font-style: italic;">//movieToMove.x += event.delta/6; // or any property like scaleX, scaleY, y, depth etc.</span>
    <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span></pre></div></div>

<p>More on <a href="http://livedocs.adobe.com/flex/201/langref/flash/events/MouseEvent.html" target="_blank">Mouse Events in AS3/Flash9/Flex here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2007/05/13/mousewheel-event-in-as3/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>HOWTO: Setup Orthographic Camera in Maya</title>
		<link>http://drawlogic.com/2007/05/06/howto-setup-orthographic-camera-in-maya/</link>
		<comments>http://drawlogic.com/2007/05/06/howto-setup-orthographic-camera-in-maya/#comments</comments>
		<pubDate>Mon, 07 May 2007 04:12:59 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[MAYA]]></category>
		<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/2007/05/06/howto-setup-orthographic-camera-in-maya/</guid>
		<description><![CDATA[We recently had a tutorial on making isometric assets for 3dsmax but this is the same tutorial for Maya.  Orthographic cameras are again an isometric rendering that has no correct perspective, all edges are parallel, there is no vanishing point.  This is great for gaming or maps where you need the items at the bottom of [...]]]></description>
			<content:encoded><![CDATA[<p><em>We recently had a tutorial on making isometric assets for 3dsmax but this is the same tutorial for Maya.</em> </p>
<p><a target="_blank" href="http://en.wikipedia.org/wiki/Orthographic_projection">Orthographic cameras </a>are again an isometric rendering that has no correct perspective, all edges are parallel, there is no vanishing point.  This is great for gaming or maps where you need the items at the bottom of the screen to be the same size as the items in the distance.</p>
<p>Many popular RTS or strategy games use this technique.  What it does is make it possible to create assets that can be exported and placed all over the game without the need to render at different distances.</p>
<p><strong>Here&#8217;s the HOWTO to make Maya orthographic views for isometric gaming assets:</strong></p>
<ol>
<li>Open your file in Maya (<a target="_blank" href="http://www.turbosquid.com/FullPreview/Index.cfm/ID/256662">here is a great free one from turboquid.com</a>). You will usually be in persp or perspective view.  If not go to <strong>Panels &gt; Perspective &gt; persp.<br />
</strong><img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/mb1.png" alt="Photo Sharing and Video Hosting at Photobucket" /></li>
<li>Create a new camera by going to <strong>Create &gt; Cameras &gt; Create Camera and Aim</strong> (this creates a target camera rather than a free camera)</li>
<li>Position the camera (not the camera aim) by using the move tool on the camera to get it at a 45 degree angle at the corner). Then make sure the camera aim is at the base of the object (if you places it at 0,0,0 then it should be all set).</li>
<li>Select the Camera.</li>
<li>Now go to <strong>Panels &gt; Cameras &gt; View through Selected</strong></li>
<li>You are now viewing through the camera. <img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/mb3.png" alt="Photo Sharing and Video Hosting at Photobucket" /></li>
<li>Usually you have to adjust it a bit here so get it so that the camera is pointed at the corner of the building with the move tools on the selected camera.  Since this is a camera with aim you only have to move the camera and not worry about rotation and aim.  I have my aim set to the bottom of the building.</li>
<li>After you get the view right (you can manually set the angle at 45 degrees up and to the side or aim it manually) jump into the camera by selecting it with the list, <img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/mblist.png" alt="Photo Sharing and Video Hosting at Photobucket" /> then clicking <strong>Panels &gt; View though Selected</strong>.</li>
<li>To make it orthographic in the properties select the Orthographic panel, then check &#8220;Orthographic&#8221;.<br />
<img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/maya_step2.png" alt="Photo Sharing and Video Hosting at Photobucket" /></li>
<li>At this point it will proabably zoom in so you need to move the view by zooming in our out to make it fit. <br />
<a target="_blank" href="http://i81.photobucket.com/albums/j223/drawkbox/maya_step1.png"><img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/maya1_step1sm.png" alt="Photo Sharing and Video Hosting at Photobucket" /></a></li>
<li>Now your model is in orthographic or isometric view so you can export it out to your game. <br />
<img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/mayarender22.png" alt="Photo Sharing and Video Hosting at Photobucket" /></li>
<li>The ideal solution is to create a maya scene and import all your buildings, cars, or other game assets in individually and then export them individually with the same light and direction/angle so you can piece it together in the game and take advantage of reuse and loading only areas being shown.<img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/mayarender33.png" alt="Photo Sharing and Video Hosting at Photobucket" /></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2007/05/06/howto-setup-orthographic-camera-in-maya/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOW TO: Setup an Orthographic Camera in 3dsMax9</title>
		<link>http://drawlogic.com/2007/04/21/how-to-setup-an-orthographic-camera-in-3dsmax9/</link>
		<comments>http://drawlogic.com/2007/04/21/how-to-setup-an-orthographic-camera-in-3dsmax9/#comments</comments>
		<pubDate>Sat, 21 Apr 2007 08:58:16 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[3DSMAX]]></category>
		<category><![CDATA[GAMES]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://drawk.wordpress.com/2007/04/21/how-to-setup-an-orthographic-camera-in-3dsmax9/</guid>
		<description><![CDATA[{ draw logic } will be presenting HOWTOs every once in a while based on current projects or very simple, targeted actions in game development, programming, data design etc.  Setup an Orthographic Camera in 3dsMax9 Axonometric Projection allows you to make flat Isometric game assets or views sometimes needed for maps layouts where false or flat 3D is used so [...]]]></description>
			<content:encoded><![CDATA[<p>{ draw logic } will be presenting HOWTOs every once in a while based on current projects or very simple, targeted actions in game development, programming, data design etc. </p>
<h3>Setup an Orthographic Camera in 3dsMax9</h3>
<p><a href="http://en.wikipedia.org/wiki/Axonometric_projection">Axonometric Projection</a> allows you to make flat <a href="http://en.wikipedia.org/wiki/Isometric_projection">Isometric</a> game assets or views sometimes needed for maps layouts where false or flat 3D is used so you can see the items up close as well as you can see the items off in the distance. This view was common in the early <a target="_blank" href="http://upload.wikimedia.org/wikipedia/en/9/9b/SC4_Graphics.png">sim city</a>games and many RPGs like Command and Conquer Red Alert (<strong>oh no not the blimps!).</strong> <img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/shot2.jpg" alt="Photo Sharing and Video Hosting at Photobucket" /></p>
<p><a target="_blank" href="http://en.wikipedia.org/wiki/Orthographic_projection">Orthographic </a>views are a camera setting that makes it so there is no vanishing point or correct perspective but instead parallel external lines. Sometimes this is key in scrolling 2d games or maps like I said but its also to help reuse assets over and over to create a better cache to pull from.  <a target="_blank" href="http://en.wikipedia.org/wiki/Orthographic_projection">Orthographic views</a>can also make flattening textures to be used in texturing in isometric games very simple.</p>
<p><strong>To setup a camera in 3d Studio Max for orthographic renders follow these steps:</strong></p>
<ol>
<li>Open up your file and get a perspective you want. Usually this is a diagonal 45 degree view or a 45 degree angle where 2/3 of one side shows and 1/3 of the other shows<img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/3dsmax_house_render_perspec.png" alt="Photo Sharing and Video Hosting at Photobucket" /></li>
<li>Go to the perspective view and click in it. </li>
<li>Create a new camera by clicking <strong>CTRL+C</strong>. This will create a new &#8216;<strong>Camera01</strong>&#8216;.</li>
<li>Click <strong>C </strong>to jump into your new camera.<br />
<img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/3dsmax_house_render_camera.png" alt="Photo Sharing and Video Hosting at Photobucket" /></li>
<li>As you can see this view has the perspective vanishing point and the lines on the outside of the model will eventually meet on the horizon.  For game assets this doesn&#8217;t always work when making an isometric or axonometric view.<strong>We want to make it an orthographic view</strong> so that there is a void of perspective and correct vanishing lines.</li>
<li>To flatten this true perspective make sure the camera is still selected by clicking on the camera or by pressing &#8216;C&#8217; (brings up all cameras as &#8216;P&#8217; does the perspective view again) or selecting it from the object list.</li>
<li> Then under the modifiers tabs check the &#8220;Orthographic Projection&#8221; checkmark.<img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/3dsmax_house_render_ortho.png" alt="Photo Sharing and Video Hosting at Photobucket" /> </li>
<li>All done, now make a boatload more assets for your game/project!</li>
</ol>
<p>See the difference in renders here:</p>
<p><strong>True Perspective View:</strong><br />
<img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/house_render2blue.jpg" alt="Photo Sharing and Video Hosting at Photobucket" /></p>
<p><strong>Orthographic View:<br />
</strong><img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/houseortho_render2blue.jpg" alt="Photo Sharing and Video Hosting at Photobucket" /> </p>
<p>You can see that if the homes were to be stacked in rows where their walls are parallel (like the command and conquer screenshot above) the orthographic view is more suited for games or maps where you need to see all items the same size or scale. <a target="_blank" href="http://www.drawk.com/lab/isometric/">Click here to see a flash version of this that stretched full screen fluid flash</a>.</p>
<p><a target="_blank" href="http://www.drawk.com/lab/isometric/"><img border="0" src="http://i81.photobucket.com/albums/j223/drawkbox/homes-lined-up.png" alt="Photo Sharing and Video Hosting at Photobucket" /></a></p>
<p>Here&#8217;s the <a target="_blank" href="http://www.baseplane.com/files/HOUSE_BLUE_1.zip">MAX file source</a> of the house. I used 3dsmax9 and built on a model I found online making it more cartoonish and simplistic/vector-like. For this tutorial some of the settings may be changed in your version but all 3d programs have this setting somewhere even if you are not using 3dsmax. </p>
]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2007/04/21/how-to-setup-an-orthographic-camera-in-3dsmax9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

