<?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>Floorplanner Tech Blog &#187; Flash+ActionScript</title>
	<atom:link href="http://techblog.floorplanner.com/category/flashactionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://techblog.floorplanner.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 19 Nov 2009 04:00:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Build ActionScript3 projects with TextMate in 5 easy steps</title>
		<link>http://techblog.floorplanner.com/2009/09/05/build-actionscript3-projects-with-textmate-in-5-easy-steps/</link>
		<comments>http://techblog.floorplanner.com/2009/09/05/build-actionscript3-projects-with-textmate-in-5-easy-steps/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 11:51:34 +0000</pubDate>
		<dc:creator>Gert-Jan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash+ActionScript]]></category>
		<category><![CDATA[textmate actionscript flex sdk]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=704</guid>
		<description><![CDATA[The text editor of choice of our Rails team is TextMate. Our Flash team is a bit divided between Eclipse+FDT and FlexBuilder. I wanted to see if TextMate is a good alternative for building Flash/ActionScript projects.
There are a couple of good sources on using TexMate for ActionScript projects, but it&#8217;s a little fragmented and sometimes [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F09%2F05%2Fbuild-actionscript3-projects-with-textmate-in-5-easy-steps%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F09%2F05%2Fbuild-actionscript3-projects-with-textmate-in-5-easy-steps%2F" height="61" width="51" /></a></div><p>The text editor of choice of our Rails team is TextMate. Our Flash team is a bit divided between Eclipse+FDT and FlexBuilder. I wanted to see if TextMate is a good alternative for building Flash/ActionScript projects.</p>
<p>There are a couple of good sources on using TexMate for ActionScript projects, but it&#8217;s a little fragmented and sometimes outdated. I found <a href="http://www.pixelate.de/blog/setting-up-a-as3-project-in-textmate">pixelate&#8217;s blog post</a> and <a href="http://blog.simongregory.com/">Simon&#8217;s blog</a> very useful.</p>
<h3>1. TextMate</h3>
<p>First of all, you need have MacroMates&#8217; <a href="http://macromates.com/">TexMate</a> of course. If you don&#8217;t already own a copy, you can download a <a href="http://download-b.macromates.com/TextMate_1.5.9.dmg">30-day-trial</a>.</p>
<h3>2. ActionScript3 bundle</h3>
<p><a href="http://blog.simongregory.com/">Simon Gregory</a> did some fine work by creating a TextMate bundle for ActionScript3. The most important things that the bundle handles are <a href="http://blog.simongregory.com/09/as3-autocompletion-in-textmate/">auto-completion</a> and <a href="http://blog.simongregory.com/02/improved-auto-import-for-actionscript-3-in-textmate/">auto-import</a>.  You can <a href="http://blog.simongregory.com/wp-content/assets/bundles/ActionScript%203.tmbundle.zip">download it</a> directly from his blog, or fetch it with Git or SVN.</p>
<p>To install via Subversion:</p>

<div class="wp_syntax"><div class="code"><pre class="console" style="font-family: Monaco,monospace;">export LC_CTYPE=en_US.UTF-8
cd ~/&quot;Library/Application Support/TextMate/Bundles/&quot;
svn co http://svn.textmate.org/trunk/Review/Bundles/ActionScript\ 3.tmbundle
osascript -e 'tell app &quot;TextMate&quot; to reload bundles'</pre></div></div>

<p>To install via Git:</p>

<div class="wp_syntax"><div class="code"><pre class="console" style="font-family: Monaco,monospace;">cd ~/&quot;Library/Application Support/TextMate/Bundles/&quot;
git clone git://github.com/simongregory/actionscript3-tmbundle.git &quot;ActionScript 3.tmbundle&quot;
osascript -e 'tell app &quot;TextMate&quot; to reload bundles'</pre></div></div>

<h3>3. Flex SDK</h3>
<p>The actual building of your project is done by the free <a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flexbuilder3&#038;promoid=DJGYF">Flex 3 SDK</a>. Download it and move the extracted folder into your /Developer/SDKs/ folder. The SDK has to be accessible throughout your whole system. You can do this by adding it to the PATH variable in the /etc/profile file. Open terminal and type:</p>

<div class="wp_syntax"><div class="code"><pre class="console" style="font-family: Monaco,monospace;">sudo mate /etc/profile</pre></div></div>

<p>Then add the folder &#8220;/Developers/SDKs/flex_sdk_3/bin&#8221; to the file and save it. It should look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="console" style="font-family: Monaco,monospace;">PATH=&quot;/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/mysql/bin:/Developer/SDKs/flex_sdk_3/bin&quot;</pre></div></div>

<h3>4. TextMate settings</h3>
<p>Before we can start the ActionScript fun we have to setup a few things in TextMate. Open TextMate and select File→New Project. Click on the info button located in the bottom of the Project Drawer. Add two shell variables so that the ActionScript Bundle knows where to look for your files:</p>

<div class="wp_syntax"><div class="code"><pre class="console" style="font-family: Monaco,monospace;">TM_FLEX_FILE_SPECS    src/Main.as
TM_FLEX_OUTPUT        bin/Main.swf</pre></div></div>

<p>We also need to let TextMate know where the Flex SDK is located. Go to TextMate→Preferences→Advanced→Shell Variables and add a new global variable:</p>

<div class="wp_syntax"><div class="code"><pre class="console" style="font-family: Monaco,monospace;">TM_FLEX_PATH    Developer/SDKs/flex_sdk_3</pre></div></div>

<h3>5. Hello World</h3>
<p>With all that out of the way, we can finally start working on a ActionScript project: Hello World. Create a folder on your system that will hold this project. Drag this folder to TextMate&#8217;s Project Drawer. Create two new folders named bin and src in your project folder. Then create a new file in the src folder and name it Main.as. It should look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family: Monaco,monospace;">package <span style="color: #66cc66;">&#123;</span>        
    <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
    <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextField</span>;
&nbsp;
    <span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">'0xFFFFFF'</span>, frameRate=<span style="color: #ff0000;">'30'</span>, <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">'200'</span>, <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">'200'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> Sprite <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">textField</span>: <span style="color: #0066CC;">TextField</span>;
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #0066CC;">textField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #0066CC;">textField</span>.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;Hello World.&quot;</span>;
&nbsp;
            addChild<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">textField</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>        
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Choose Bundles→ActionScript 3→Build to build your project. A terminal window pops up which runs the Flex SDK to build your project. You can find the resulting Main.swf file in your bin folder. Yay!</p>
<h3>Notes</h3>
<p>If you want to build Flash Player 10 specific stuff (like me) you have to let the Flex SDK know. Open /Developer/SDKs/flex_sdk_3/frameworks/flex-config.xml and set the target-player tag to 10.0.0</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family: Monaco,monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target-player<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>10.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target-player<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The easiest way to work with libraries, the so called SWC files, in this setup is to drop them directly into /Developer/SDKs/flex_sdk_3/frameworks/libs folder. That way the Flex SDK has no problem finding them.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/09/05/build-actionscript3-projects-with-textmate-in-5-easy-steps/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Papervision3D 2.1 &#8211; alpha</title>
		<link>http://techblog.floorplanner.com/2009/05/26/papervision3d-21-alpha/</link>
		<comments>http://techblog.floorplanner.com/2009/05/26/papervision3d-21-alpha/#comments</comments>
		<pubDate>Tue, 26 May 2009 20:57:53 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash+ActionScript]]></category>
		<category><![CDATA[Papervision3D]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=659</guid>
		<description><![CDATA[Just committed rev. 911 to the Papervision3D SVN trunk. Rev. 911 and upwards will become Papervision3D 2.1 because the changes made are quite big.
Major changes where made to the DAE, MD2 and animation classes.
NOTE:
This revision is considerably different then previous revisions. Use with care!
At this point its not advised to use rev. 911 for production.
This [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F05%2F26%2Fpapervision3d-21-alpha%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F05%2F26%2Fpapervision3d-21-alpha%2F" height="61" width="51" /></a></div><p>Just committed rev. 911 to the <a href="http://code.google.com/p/papervision3d/">Papervision3D SVN trunk</a>. Rev. 911 and upwards will become Papervision3D 2.1 because the changes made are quite big.<br />
Major changes where made to the DAE, MD2 and animation classes.</p>
<p>NOTE:<br />
This revision is considerably different then previous revisions. Use with care!<br />
At this point its not advised to use rev. 911 for production.</p>
<p>This revision fixes several issues regarding the <a href="http://code.google.com/p/papervision3d/source/browse/trunk/as3/trunk/src/org/papervision3d/objects/parsers/DAE.as?r=911">DAE class</a>:</p>
<ol>
<li>vertex-animation</li>
<li>nested animations</li>
<li>Cinema4D support</li>
<li>morph-weight animation</li>
<li>splines</li>
<li>cloning</li>
<li>play(), play(&#8221;clipName&#8221;), stop(), pause(), resume()</li>
<li>more&#8230;</li>
</ol>
<p>The whole <a href="http://code.google.com/p/papervision3d/source/browse/trunk/as3/trunk/src/org/papervision3d/?r=911#papervision3d/core/animation">org.papervision3d.core.animation.*</a> package has been revamped <strong>completely</strong> to allow for the changes in the <a href="http://code.google.com/p/papervision3d/source/browse/trunk/as3/trunk/src/org/papervision3d/objects/parsers/DAE.as?r=911">DAE class</a>.</p>
<p><strong>DAE Example</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family: Monaco,monospace;"><span style="color: #000000; font-weight: bold;">var</span> autoPlay : <span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>; <span style="color: #808080; font-style: italic;">// don't play animations automatically</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> dae : DAE = <span style="color: #000000; font-weight: bold;">new</span> DAE<span style="color: #66cc66;">&#40;</span> autoPlay, <span style="color: #ff0000;">&quot;myCollada&quot;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
dae.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>FileLoadEvent.<span style="color: #006600;">LOAD_COMPLETE</span>, onDaeComplete<span style="color: #66cc66;">&#41;</span>;
dae.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>FileLoadEvent.<span style="color: #006600;">LOAD_PROGRESS</span>, onDaeLoadProgress<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// optionally pass materials to DAE</span>
<span style="color: #808080; font-style: italic;">// NOTE: here's a change with previous revs :</span>
<span style="color: #808080; font-style: italic;">// 1. lookup the &lt;material&gt; elements in the COLLADA file (inside &lt;library_materials&gt;).</span>
<span style="color: #808080; font-style: italic;">// 2. write down / remember the @id attribute of the &lt;material&gt; element.</span>
<span style="color: #808080; font-style: italic;">// 3. materials.addMaterial( myMaterial, materialElementID ).</span>
<span style="color: #808080; font-style: italic;">// ==&gt; this will probably change in future revs</span>
<span style="color: #000000; font-weight: bold;">var</span> materials : MaterialsList = <span style="color: #000000; font-weight: bold;">new</span> MaterialsList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// If textures fail to load optionally add some search-paths </span>
<span style="color: #808080; font-style: italic;">// (relative to the swf):</span>
dae.<span style="color: #006600;">addFileSearchPath</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;images&quot;</span> <span style="color: #66cc66;">&#41;</span>;
dae.<span style="color: #006600;">addFileSearchPath</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;textures&quot;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// set to true if you get a script-timeout error</span>
<span style="color: #000000; font-weight: bold;">var</span> asyncParsing : <span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// load it!</span>
dae.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;/path/to/dae&quot;</span>, materials, asyncParsing <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">/**
 * The DAE has loaded completely
 */</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onDaeComplete<span style="color: #66cc66;">&#40;</span>event : FileLoadEvent<span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">var</span> dae : DAE = event.<span style="color: #0066CC;">target</span> as DAE;
&nbsp;
     <span style="color: #808080; font-style: italic;">// add to scene</span>
     scene.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> dae <span style="color: #66cc66;">&#41;</span>;
&nbsp;
     <span style="color: #808080; font-style: italic;">// start playing animation (if any available)</span>
     <span style="color: #808080; font-style: italic;">// other animation controls include :</span>
     <span style="color: #808080; font-style: italic;">// 1. play( &quot;clipName &quot;)</span>
     <span style="color: #808080; font-style: italic;">// 2. stop()</span>
     <span style="color: #808080; font-style: italic;">// 3. pause()</span>
     <span style="color: #808080; font-style: italic;">// 4. resume()</span>
     <span style="color: #808080; font-style: italic;">// 5. playing (getter: bool indicating if playing)</span>
     dae.<span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
     <span style="color: #808080; font-style: italic;">// lets create a clone</span>
     <span style="color: #808080; font-style: italic;">// NOTE: DAE#clone() is somewhat bugged still, </span>
     <span style="color: #808080; font-style: italic;">// but seems to work in most cases</span>
     <span style="color: #000000; font-weight: bold;">var</span> clone : DAE = dae.<span style="color: #006600;">clone</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as DAE;
&nbsp;
     <span style="color: #808080; font-style: italic;">// add clone to scene</span>
     scene.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> clone <span style="color: #66cc66;">&#41;</span>;
&nbsp;
     <span style="color: #808080; font-style: italic;">// move it a bit</span>
     clone.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">200</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onDaeLoadProgress<span style="color: #66cc66;">&#40;</span>event : FileLoadEvent<span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>MD2 Example</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family: Monaco,monospace;"><span style="color: #000000; font-weight: bold;">var</span> md2 : MD2 = <span style="color: #000000; font-weight: bold;">new</span> MD2<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> material : MaterialObject3D = <span style="color: #000000; font-weight: bold;">new</span> WireframeMaterial<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
md2.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>FileLoadEvent.<span style="color: #006600;">LOAD_COMPLETE</span>, onMD2Complete<span style="color: #66cc66;">&#41;</span>;
&nbsp;
md2.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/path/to/md2&quot;</span>, material<span style="color: #66cc66;">&#41;</span>;
&nbsp;
scene.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>md2<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onMD2Complete<span style="color: #66cc66;">&#40;</span>event : FileLoadEvent<span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
       <span style="color: #000000; font-weight: bold;">var</span> md2 : MD2 = event.<span style="color: #0066CC;">target</span> as MD2;
&nbsp;
       md2.<span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
       <span style="color: #808080; font-style: italic;">// or play some clip :</span>
       <span style="color: #808080; font-style: italic;">// md2.play( &quot;run&quot; )</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>Animation</strong>:</p>
<p>Click the image below to show an example of the new animation controls.<br />
<a href="http://lab.floorplanner.com/pv3d/21/animation/"><img src="http://techblog.floorplanner.com/wp-content/uploads/2009/05/picture-3.png" alt="Animation Test" title="Animation Test" width="511" height="371" class="alignnone size-full wp-image-686" /></a><br />
Download the source of this example <a href="http://lab.floorplanner.com/pv3d/21/animation/AnimationTest.as">here</a>.</p>
<p>The DAE and MD2 class implement <a href="http://code.google.com/p/papervision3d/source/browse/trunk/as3/trunk/src/org/papervision3d/core/animation/IAnimatable.as">IAnimatable</a>, <a href="http://code.google.com/p/papervision3d/source/browse/trunk/as3/trunk/src/org/papervision3d/core/animation/IAnimationProvider.as">IAnimationProvider</a> and <a href="http://code.google.com/p/papervision3d/source/browse/trunk/as3/trunk/src/org/papervision3d/core/controller/IControllerProvider.as">IControllerProvider</a>, which can be found in the org.papervision3d.core.animation.* package.</p>
<ul>
<li>IAnimatable provides the play(), stop(), pause() and resume() methods.</li>
<li>IAnimationProvider provides a getter / setter #animation for low level access to <a href="http://code.google.com/p/papervision3d/source/browse/trunk/as3/trunk/src/org/papervision3d/core/controller/AnimationController.as">org.papervision3d.core.controllers.AnimationController</a></li>
<li>IControllerProvider provides a getter / setter #controllers for low level access to the different controllers:
<ul>
<li><a href="http://code.google.com/p/papervision3d/source/browse/trunk/as3/trunk/src/org/papervision3d/core/controller/MorphController.as">org.papervision3d.core.controllers.MorphController</a></li>
<li><a href="http://code.google.com/p/papervision3d/source/browse/trunk/as3/trunk/src/org/papervision3d/core/controller/SkinController.as">org.papervision3d.core.controllers.SkinController</a></li>
<li><a href="http://code.google.com/p/papervision3d/source/browse/trunk/as3/trunk/src/org/papervision3d/core/controller/AnimationController.as">org.papervision3d.core.controllers.AnimationController</a></li>
</ul>
</li>
</ul>
<p>As so much has changed I&#8217;m sure some bugs are introduced. Please let me know!</p>
<p>PS: I&#8217;ll be on vacation until june 8th, so its unlikely I&#8217;ll be able to fix any bugs before that time.<br />
PS2: Many people have helped by submitting code-snips, reporting bugs etc. I&#8217;ll credit you all when I&#8217;m back <img src='http://techblog.floorplanner.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/05/26/papervision3d-21-alpha/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>Load, modify and save local images with Flash Player 10</title>
		<link>http://techblog.floorplanner.com/2009/05/04/load-modify-and-save-local-images-with-flash-player-10/</link>
		<comments>http://techblog.floorplanner.com/2009/05/04/load-modify-and-save-local-images-with-flash-player-10/#comments</comments>
		<pubDate>Mon, 04 May 2009 11:53:10 +0000</pubDate>
		<dc:creator>Gert-Jan</dc:creator>
				<category><![CDATA[Flash+ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flash player 10]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[flex builder]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[local file system]]></category>
		<category><![CDATA[pixel bender]]></category>
		<category><![CDATA[save]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=609</guid>
		<description><![CDATA[ // 



One of the cool new things about Flash Player 10 is that you now have access to the local file system. This means that you can load, modify and save files directly on the client side without any server interaction. Mike Chambers wrote a post about reading and writing text files and I [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F05%2F04%2Fload-modify-and-save-local-images-with-flash-player-10%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F05%2F04%2Fload-modify-and-save-local-images-with-flash-player-10%2F" height="61" width="51" /></a></div><p><script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js" type="text/javascript"></script> <script type="text/javascript">// <![CDATA[
 window.onload = function() { swfobject.embedSWF("http://techblog.floorplanner.com/wp-content/uploads/2009/05/main.swf", 'thumbr', '280', '265', '10.0.0'); }
// ]]&gt;</script></p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top">One of the cool new things about Flash Player 10 is that you now have access to the local file system. This means that you can load, modify and save files directly on the client side without any server interaction. <a href="http://twitter.com/mesh">Mike Chambers</a> wrote a post about <a href="http://www.mikechambers.com/blog/2008/08/20/reading-and-writing-local-files-in-flash-player-10/">reading and writing text files</a> and I was wondering if it was possible to do this with image files too.</td>
<td>
<div id="thumbr">thumbr here</div>
</td>
<td valign="top"></td>
</tr>
</tbody>
</table>
<h3>Publish Flash Player 10 content</h3>
<p>To test this, I first needed a way to make my Flex Builder compile Flash Player 10 content. I found a rather old post by <a href="http://www.flexer.info/author/webdevandrei/">Andrei Ionescu</a> about<a href="http://www.flexer.info/2008/05/21/how-to-build-flash-player-10-applications-using-flex-sdk/"> building Flash Player 10 applications</a> that told me exactly what I was looking for. I downloaded the latest Flex SDK (3.3) from <a href="http://www.adobe.com/products/flex/flexdownloads/">Adobe&#8217;s Flex Download page</a>, followed the tutorial and I was ready to go.</p>
<h3>Load image from local file system</h3>
<p>Reading a local file was no biggie, just copied and pasted the code from Mike&#8217;s sample. What I needed now was a way to convert the loaded data into an image. As usual <a href="http://twitter.com/timknip">Tim</a> helped me out by sending me a snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family: Monaco,monospace;"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">data</span>:ByteArray = fileRef<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'data'</span><span style="color: #66cc66;">&#93;</span>;
<span style="color: #000000; font-weight: bold;">var</span> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #006600;">loadBytes</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span>loader<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<h3>Modify image</h3>
<p>Now that I could load the image, I wanted to modify it before having it rendered. I extended the snippet to use BitmapData and a Matrix to resize the image to a thumb image (240&#215;180px).</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family: Monaco,monospace;"><span style="color: #000000; font-weight: bold;">var</span> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onDataLoadComplete<span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #006600;">loadBytes</span><span style="color: #66cc66;">&#40;</span>loadFileRef.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onDataLoadComplete<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> bitmapData:BitmapData = Bitmap<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">content</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">bitmapData</span>;
  <span style="color: #000000; font-weight: bold;">var</span> matrix:Matrix = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  matrix.<span style="color: #006600;">scale</span><span style="color: #66cc66;">&#40;</span>THUMB_WIDTH<span style="color: #66cc66;">/</span>bitmapData.<span style="color: #0066CC;">width</span>, THUMB_HEIGHT<span style="color: #66cc66;">/</span>bitmapData.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
  imageView.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  imageView.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">beginBitmapFill</span><span style="color: #66cc66;">&#40;</span>bitmapData, matrix, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;
  imageView.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, THUMB_WIDTH, THUMB_HEIGHT<span style="color: #66cc66;">&#41;</span>;
  imageView.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h3>Save image to local file system</h3>
<p>Now that it&#8217;s possible to load and modify an image, saving it is the last step. To save an image, it has to be encoded to a ByteArray. I used the open source <a href="http://code.google.com/p/as3corelib/">as3corelib</a> to help me out. Saving the ByteArray to a file is rather straight forward.</p>
<p><strong>Update 1:</strong> You don&#8217;t need to use the as3corelib anymore, Flex 3.3 has it own <a href="http://livedocs.adobe.com/flex/3/langref/mx/graphics/codec/JPEGEncoder.html">JPEGEncoder</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family: Monaco,monospace;"><span style="color: #000000; font-weight: bold;">var</span> encoder:JPEGEncoder = <span style="color: #000000; font-weight: bold;">new</span> JPEGEncoder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> rawBytes:ByteArray = encoder.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span>bitmapData<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> saveFileRef:FileReference = <span style="color: #000000; font-weight: bold;">new</span> FileReference<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
saveFileRef.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span>rawBytes<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><strong>Update 2:</strong> <a href="http://www.bytearray.org/">Thibault Imbert</a> figured out a way to <a href="http://www.bytearray.org/?p=775">speed up JPEG encoding</a> using the new FP10 Vector class. Good stuff!</p>
<p><strong>Update 3</strong>: You can now also use Alchemy for the encoding. It&#8217;s much, much faster then the other options! See this post from <a href="http://www.websector.de/blog/">Jens Krause</a>: <a href="http://www.websector.de/blog/2009/06/21/speed-up-jpeg-encoding-using-alchemy/">Speed up JPEG encoding using Alchemy</a></p>
<p>This sample shows that it&#8217;s not only possible to load, modify and save images directly from the local file system, but that it&#8217;s actually very simple to do so. Add some <a href="http://labs.adobe.com/technologies/pixelbender/">PixelBender</a> image processing power to the game and you almost have a Photoshop killer running completly client side!</p>
<h3>Code sample</h3>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family: Monaco,monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> backgroundGradientColors=<span style="color: #ff0000;">&quot;[0xFFFFFF,0xFFFFFF]&quot;</span> <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">&quot;0xFFFFFF&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">codec</span>.<span style="color: #006600;">JPEGEncoder</span>;
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">binding</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">BindingUtils</span>;
			<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponent</span>;
&nbsp;
			<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">FileReference</span>;
			<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">FileFilter</span>;
			<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">IOErrorEvent</span>;
			<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
			<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">ByteArray</span>;
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> loadFileRef:FileReference;
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const FILE_TYPES:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #000000; font-weight: bold;">new</span> FileFilter<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Image Files&quot;</span>, <span style="color: #ff0000;">&quot;*.jpg;*.jpeg;*.gif;*.png;*.JPG;*.JPEG;*.GIF;*.PNG&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>;
			<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const THUMB_WIDTH:uint = <span style="color: #cc66cc;">240</span>;
			<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const THUMB_HEIGHT:uint = <span style="color: #cc66cc;">180</span>;
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> loadFile<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
				loadFileRef = <span style="color: #000000; font-weight: bold;">new</span> FileReference<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				loadFileRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">SELECT</span>, onFileSelect<span style="color: #66cc66;">&#41;</span>;
				loadFileRef.<span style="color: #006600;">browse</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> saveFile<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>		
				<span style="color: #000000; font-weight: bold;">var</span> bitmapData:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>THUMB_WIDTH, THUMB_HEIGHT<span style="color: #66cc66;">&#41;</span>;
				bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>imageView<span style="color: #66cc66;">&#41;</span>;
&nbsp;
				<span style="color: #000000; font-weight: bold;">var</span> encoder:JPEGEncoder = <span style="color: #000000; font-weight: bold;">new</span> JPEGEncoder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #000000; font-weight: bold;">var</span> rawBytes:ByteArray = encoder.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span>bitmapData<span style="color: #66cc66;">&#41;</span>;
&nbsp;
 				<span style="color: #000000; font-weight: bold;">var</span> saveFileRef:FileReference = <span style="color: #000000; font-weight: bold;">new</span> FileReference<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				saveFileRef.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span>rawBytes<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onFileSelect<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
				loadFileRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onFileLoadComplete<span style="color: #66cc66;">&#41;</span>;
				loadFileRef.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onFileLoadComplete<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			   	<span style="color: #000000; font-weight: bold;">var</span> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			   	loader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onDataLoadComplete<span style="color: #66cc66;">&#41;</span>;
			   	loader.<span style="color: #006600;">loadBytes</span><span style="color: #66cc66;">&#40;</span>loadFileRef.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
				loadFileRef = <span style="color: #000000; font-weight: bold;">null</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onDataLoadComplete<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> bitmapData:BitmapData = Bitmap<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">content</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">bitmapData</span>;
&nbsp;
                <span style="color: #000000; font-weight: bold;">var</span> matrix:Matrix = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                matrix.<span style="color: #006600;">scale</span><span style="color: #66cc66;">&#40;</span>THUMB_WIDTH<span style="color: #66cc66;">/</span>bitmapData.<span style="color: #0066CC;">width</span>, THUMB_HEIGHT<span style="color: #66cc66;">/</span>bitmapData.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
				imageView.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				imageView.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">beginBitmapFill</span><span style="color: #66cc66;">&#40;</span>bitmapData, matrix, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>; 
				imageView.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, THUMB_WIDTH, THUMB_HEIGHT<span style="color: #66cc66;">&#41;</span>;
				imageView.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
				saveButton.<span style="color: #0066CC;">enabled</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:Panel title=<span style="color: #ff0000;">&quot;Create thumb image&quot;</span> paddingBottom=<span style="color: #ff0000;">&quot;5&quot;</span> paddingLeft=<span style="color: #ff0000;">&quot;5&quot;</span> paddingRight=<span style="color: #ff0000;">&quot;5&quot;</span> paddingTop=<span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:VBox<span style="color: #66cc66;">&gt;</span>
			<span style="color: #66cc66;">&lt;</span>mx:Canvas id=<span style="color: #ff0000;">&quot;imageView&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;240&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;180&quot;</span> borderThickness=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #0066CC;">borderColor</span>=<span style="color: #ff0000;">&quot;#CCCCCC&quot;</span> borderStyle=<span style="color: #ff0000;">&quot;solid&quot;</span><span style="color: #66cc66;">/&gt;</span>
			<span style="color: #66cc66;">&lt;</span>mx:HBox paddingTop=<span style="color: #ff0000;">&quot;5&quot;</span> borderThickness=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #66cc66;">&gt;</span>
				<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;Load image&quot;</span> click=<span style="color: #ff0000;">&quot;loadFile()&quot;</span><span style="color: #66cc66;">/&gt;</span>
				<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;Save image&quot;</span> click=<span style="color: #ff0000;">&quot;saveFile()&quot;</span> id=<span style="color: #ff0000;">&quot;saveButton&quot;</span> <span style="color: #0066CC;">enabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">/&gt;</span>
			<span style="color: #66cc66;">&lt;/</span>mx:HBox<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;/</span>mx:VBox<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Panel<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/05/04/load-modify-and-save-local-images-with-flash-player-10/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Unproject with useProjectionMatrix = true</title>
		<link>http://techblog.floorplanner.com/2009/04/29/unproject-with-useprojectionmatrix-true/</link>
		<comments>http://techblog.floorplanner.com/2009/04/29/unproject-with-useprojectionmatrix-true/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 00:45:40 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Collaboration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash+ActionScript]]></category>
		<category><![CDATA[Floorplanner]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[unproject]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=580</guid>
		<description><![CDATA[I just updated Papervision3D to allow the CameraObject3D#unproject method to work when CameraObject3D#useProjectionMatrix = true.
Papervision3D has two methods of &#8216;projecting&#8217; vectors onto the screen:

useProjectionMatrix = false, this is the default &#8216;fast&#8217; method
useProjectionMatrix = true, this is the method where projection is done by a matrix

Note that Papervision3D switches to method #2 in &#8216;ortho mode&#8217;.
So what [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F04%2F29%2Funproject-with-useprojectionmatrix-true%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F04%2F29%2Funproject-with-useprojectionmatrix-true%2F" height="61" width="51" /></a></div><p>I just updated <a href="http://blog.papervision3d.org">Papervision3D</a> to allow the CameraObject3D#unproject method to work when CameraObject3D#useProjectionMatrix = true.</p>
<p>Papervision3D has two methods of &#8216;projecting&#8217; vectors onto the screen:</p>
<ol>
<li>useProjectionMatrix = false, this is the default &#8216;fast&#8217; method</li>
<li>useProjectionMatrix = true, this is the method where projection is done by a matrix</li>
</ol>
<p>Note that Papervision3D switches to method #2 in &#8216;ortho mode&#8217;.</p>
<p>So what is the difference exactly between these two kinds of projection? First we need to define what projection is. Projection is what adds &#8216;perspective&#8217; to a scene and makes sure your scene fits to the viewport. Its the last step in the so-called &#8216;render pipeline&#8217;. </p>
<p>We can derive the &#8216;fore shortening&#8217; effect of perspective in several ways. Method #1 is simple, effective and fast. It uses the camera&#8217;s focus and zoom values. Method #2 uses a more classic way of projection : it uses a dedicated matrix. Tech buffs: very much like OpenGL&#8217;s <a href="http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml">gluPerspective</a>.</p>
<p><a href="http://blog.zupko.info/">Andy Zupko</a> has a great <a href="http://blog.zupko.info/?p=143">post</a> on unproject using method #1.</p>
<p>We will discuss unproject using method #2, which works slightly different.</p>
<p>The difference is that when #useProjectionMatrix is set to true, then CameraObject3D#unproject  returns a point in world-space, rather then a ray. Let me explain with some code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="actionscript3" style="font-family: Monaco,monospace;"><span style="color: #009900;">// we want to use a projection matrix</span>
camera.useProjectionMatrix = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
<span style="color: #009900;">// '0' indicates we want a point on the near plane</span>
<span style="color: #6699cc; font-weight: bold;">var</span> pointOnNearPlane <span style="color: #000000; font-weight: bold;">:</span> Number3D = camera.unproject<span style="color: #000000;">&#40;</span> screenX, screenY, <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// '1' indicates we want a point on the far plane</span>
<span style="color: #6699cc; font-weight: bold;">var</span> pointOnFarPlane <span style="color: #000000; font-weight: bold;">:</span> Number3D = camera.unproject<span style="color: #000000;">&#40;</span> screenX, screenY, <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// Construct the ray's direction</span>
<span style="color: #6699cc; font-weight: bold;">var</span> dir <span style="color: #000000; font-weight: bold;">:</span> Number3D = Number3D.sub<span style="color: #000000;">&#40;</span> pointOnFarPlane, pointOnNearPlane <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// Normalize</span>
dir.<span style="color: #004993;">normalize</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// So, now you have a ray with its origin at 'pointOnNearPlane',</span>
<span style="color: #009900;">// and direction 'dir'</span></pre></td></tr></table></div>

<p>Optimization: could save some cycles by doing (*not* in ortho mode!, see below):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="actionscript3" style="font-family: Monaco,monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> camPosition <span style="color: #000000; font-weight: bold;">:</span> Number3D = <span style="color: #0033ff; font-weight: bold;">new</span> Number3D<span style="color: #000000;">&#40;</span> camera.<span style="color: #004993;">x</span>, camera.<span style="color: #004993;">y</span>, camera.z <span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">// Construct the ray's direction</span>
<span style="color: #6699cc; font-weight: bold;">var</span> dir <span style="color: #000000; font-weight: bold;">:</span> Number3D = Number3D.sub<span style="color: #000000;">&#40;</span> pointOnFarPlane, camPosition <span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">// Normalize</span>
dir.<span style="color: #004993;">normalize</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">// So, now you have a ray with its origin at the camera's position</span>
<span style="color: #009900;">// and direction 'dir'</span></pre></td></tr></table></div>

<p>Why can&#8217;t we use above optimization in ortho mode?<br />
In perspective mode all &#8216;rays&#8217; originate from the camera&#8217;s position: the &#8216;view cone&#8217; has shape of a pyramid. Hence we can assume &#8216;pointOnNearPlane&#8217; to coincide with the camera&#8217;s position.<br />
In ortho mode however the &#8216;view cone&#8217; has the shape of a cube, all rays are parallel. Hence we need to unproject *two* points to construct our ray.</p>
<p>Now simply follow <a href="http://blog.zupko.info/?p=143">Andy Zupko &#8217;s post</a> to drag objects around.<br />
Or perform &#8216;picking&#8217;, or&#8230;</p>
<p>Update:<br />
Created a little demo to visualize what I&#8217;m ranting about, check it out <a href='http://techblog.floorplanner.com/wp-content/uploads/2009/04/unprojecttest1.swf'>here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/04/29/unproject-with-useprojectionmatrix-true/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating a REST API for a Flash application</title>
		<link>http://techblog.floorplanner.com/2009/02/25/creating-a-rest-api-for-a-flash-application/</link>
		<comments>http://techblog.floorplanner.com/2009/02/25/creating-a-rest-api-for-a-flash-application/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 16:49:47 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Flash+ActionScript]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[caveats]]></category>
		<category><![CDATA[DELETE]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[PUT]]></category>
		<category><![CDATA[request]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=486</guid>
		<description><![CDATA[We have been working hard to implement an XML-based REST-style API for Floorplanner and some of our partners are using it already to access their users and plans. We now have started to use this API ourselves.
The Floorplanner Flash application communicates with our servers to load and save projects and designs. The backend for this [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F02%2F25%2Fcreating-a-rest-api-for-a-flash-application%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F02%2F25%2Fcreating-a-rest-api-for-a-flash-application%2F" height="61" width="51" /></a></div><p>We have been working hard to implement an XML-based REST-style API for Floorplanner and some of our partners are using it already to access their users and plans. We now have started to use this API ourselves.</p>
<p>The Floorplanner Flash application communicates with our servers to load and save projects and designs. The backend for this functionality used to be written in PHP. Eliminating this PHP application simplifies our server setup, eases development and reduces our maintenance burden. To rewrite this functionality in Rails, we decided to eat our own dogfood and use the REST API to load and save designs. Why reinvent the wheel?</p>
<p>However, while implementing the changes it the Flash application, we found that it did not work out of the box, because of some limitations in ActionScript. Note that we still use ActionScript 2, so some of these issues may not be relevant for ActionScript 3. In this post, we will detail what these issues are and how we overcame them.</p>
<h3> Using a separate format </h3>
<p>Our REST API uses the XML format supplied by Rails. Because we had to make some changes to make it work from ActionScript, we decided to add a distinct format that we could implement differently without altering the behavior of the default XML API. Adding a new format, called &#8220;flash&#8221; can be done in Rails by adding a MIME alias to your environment:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family: Monaco,monospace;"><span style="color:#6666ff; font-weight:bold;">Mime::Type</span>.<span style="color:#9900CC;">register_alias</span> <span style="color:#996600;">&quot;application/xml&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:flash</span></pre></div></div>

<p>Now we can send different responses based on this format:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family: Monaco,monospace;">respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>format<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span>   <span style="color:#006600; font-weight:bold;">&#123;</span> ... <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#008000; font-style:italic;"># default API behavior</span>
  <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">flash</span> <span style="color:#006600; font-weight:bold;">&#123;</span> ... <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#008000; font-style:italic;"># do something different</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<h3> HTTP status codes </h3>
<p>REST APIs use HTTP status codes to return whether a call succeeded, and if not, why. Flash however uses the browser to perform HTTP requests. The browser only returns something to Flash if the request was successful. So, if an error code is used if a request failed together with some error messages, these error messages will not be delivered to Flash and cannot be displayed to the user. We resolved this by always sending the HTTP OK status.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family: Monaco,monospace;">respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>format<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span>   <span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:xml</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@project</span>.<span style="color:#9900CC;">errors</span>, <span style="color:#ff3333; font-weight:bold;">:status</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">422</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">flash</span> <span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:xml</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> XML.<span style="color:#9900CC;">failure</span><span style="color:#006600; font-weight:bold;">&#40;</span>@project.<span style="color:#9900CC;">errors</span>, <span style="color:#006666;">422</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Our <code>XML.failure</code> method will return something like:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family: Monaco,monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;failure</span> <span style="color: #000066;">status</span>=<span style="color: #ff0000;">&quot;422&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;error</span> <span style="color: #000066;">on</span>=<span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>A project should have a name!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/error<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/failure<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Note that other HTTP success statuses than 200 work in Safari and Firefox, but not in Internet Explorer. So, never return a 201 (<code>:created</code>), because Internet Explorer will not send the result to Flash!</p>
<h3> PUT and DELETE requests </h3>
<p>REST-style APIs use HTTP PUT requests to alter objects and DELETE requests to destroy objects. Most browsers do not support these request type. It is not supported by ActionScript either, because Flash uses the browser to send the request. </p>
<p>To overcome this problem, these types of requests can be simulated in Rails by sending a <code>_method</code> parameter along with a POST request. Unfortunately, this does not work when calling the REST API. The POST request body cannot be used to send additional variables, because it is used for the XML payload.</p>
<p>We solved this issue by creating additional routes for POST requests to the <code>update</code> and <code>destroy</code> actions of our resource controllers. Our <code>routes.rb</code> file now looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family: Monaco,monospace;">  map.<span style="color:#9900CC;">resources</span> <span style="color:#ff3333; font-weight:bold;">:projects</span>, <span style="color:#ff3333; font-weight:bold;">:member</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:update</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:post</span>, <span style="color:#ff3333; font-weight:bold;">:destroy</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:post</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>These routes route to exactly the same methods as the default REST actions (<code>ProjectsController#update</code> and <code>ProjectsController#destroy</code>), so no additional code is needed. The following calls are now equivalent:</p>
<pre>
PUT    /projects/123.xml
POST   /projects/123/update.xml
POST   /projects/123/update.flash

DELETE /projects/123.xml
POST   /projects/123/destroy.xml
POST   /projects/123/destroy.flash
</pre>
<h3>The result </h3>
<p>It requires some stretching of the pure REST principles, but doing so is worth it: we can now reuse the code we use for our API to handle Flash application calls and we can eliminate the PHP backend.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/02/25/creating-a-rest-api-for-a-flash-application/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Write JAVA, publish SWF</title>
		<link>http://techblog.floorplanner.com/2009/02/15/write-java-publish-swf/</link>
		<comments>http://techblog.floorplanner.com/2009/02/15/write-java-publish-swf/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 20:27:16 +0000</pubDate>
		<dc:creator>Gert-Jan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash+ActionScript]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[flex builder]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=474</guid>
		<description><![CDATA[Ted Patrick (Senior Manager Developer Communities at Adobe Systems) has posted an interesting article about the first milestone of the Eclipse E4 project.
It seems that the SWT project has added compilation support for SWF from JAVA. Write your app in JAVA and publish as SWF to Flash Player. The cool part is that you get full [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F02%2F15%2Fwrite-java-publish-swf%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F02%2F15%2Fwrite-java-publish-swf%2F" height="61" width="51" /></a></div><p>Ted Patrick (Senior Manager Developer Communities at Adobe Systems) has posted <a title="Write JAVA, publish SWF" href="http://onflash.org/ted/2009/02/publish-swt-to-flash-player.php" target="_blank">an interesting article</a> about the first milestone of the <a title="Ecilpse E4 project" href="http://download.eclipse.org/e4/downloads/drops/S-0.9M1-200902061045/e4-news-M1.html" target="_blank">Eclipse E4 project</a>.</p>
<blockquote><p><em>It seems that the SWT project has added compilation support for SWF from JAVA. Write your app in JAVA and publish as SWF to Flash Player. The cool part is that you get full JAVA development in Eclipse with all debugging and tooling but you get a SWF file on publish. </em></p></blockquote>
<p>We&#8217;re using Flex Builder for our Flex/AS3 stuff, but this could become a very interesting option since the JAVA development in Eclipse is a lot more sophisticated than Flex Builder at the moment.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/02/15/write-java-publish-swf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FITC Amsterdam 2009</title>
		<link>http://techblog.floorplanner.com/2009/01/24/fitc-amsterdam-2009/</link>
		<comments>http://techblog.floorplanner.com/2009/01/24/fitc-amsterdam-2009/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 10:52:57 +0000</pubDate>
		<dc:creator>Gert-Jan</dc:creator>
				<category><![CDATA[Flash+ActionScript]]></category>
		<category><![CDATA[amsterdam]]></category>
		<category><![CDATA[fitc]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=419</guid>
		<description><![CDATA[
On February 22-24th the Flash In The Can event is back in town! Design, Technology. Cool shit. I will be just a visitor, but Tim is going to help Ralph with his workshop Papervision3D from the Core. If you want to meet up, give us a ping.
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F01%2F24%2Ffitc-amsterdam-2009%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F01%2F24%2Ffitc-amsterdam-2009%2F" height="61" width="51" /></a></div><p><a href="http://fitc.ca"><img class="alignnone size-full wp-image-421" title="FITC Amsterdam 2009" src="http://techblog.floorplanner.com/wp-content/uploads/2009/01/afbeelding-1.png" alt="FITC Amsterdam 2009" width="598" height="150" /></a></p>
<p>On February 22-24th the Flash In The Can event is back in town! Design, Technology. Cool shit. I will be just a visitor, but Tim is going to help <a title="Ralph Hauwert" href="http://www.unitzeroone.com/blog/" target="_blank">Ralph</a> with his workshop <a title="Papervision3D from the Core" href="http://www.fitc.ca/presentation_detail.cfm?festival_id=80&amp;presentation_id=749" target="_blank">Papervision3D from the Core</a>. If you want to meet up, give us a ping.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/01/24/fitc-amsterdam-2009/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Papervision3D forum</title>
		<link>http://techblog.floorplanner.com/2009/01/20/papervision3d-forum/</link>
		<comments>http://techblog.floorplanner.com/2009/01/20/papervision3d-forum/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 15:45:34 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[CAD]]></category>
		<category><![CDATA[Flash+ActionScript]]></category>
		<category><![CDATA[Floorplanner]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[forum]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=415</guid>
		<description><![CDATA[On request of many: Papervision3D now has a forum : http://forum.papervision3d.org/
Read more at the Papervision3D blog.
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F01%2F20%2Fpapervision3d-forum%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2009%2F01%2F20%2Fpapervision3d-forum%2F" height="61" width="51" /></a></div><p>On request of many: Papervision3D now has a forum : http://forum.papervision3d.org/</p>
<p>Read more at the <a href="http://blog.papervision3d.org/2009/01/19/forumpapervision3dorg/">Papervision3D blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2009/01/20/papervision3d-forum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Papervision3D wins Innovation Of The Year award</title>
		<link>http://techblog.floorplanner.com/2008/12/09/papervision3d-wins-innovation-of-the-year-award/</link>
		<comments>http://techblog.floorplanner.com/2008/12/09/papervision3d-wins-innovation-of-the-year-award/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 20:15:17 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash+ActionScript]]></category>
		<category><![CDATA[Floorplanner]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[award]]></category>
		<category><![CDATA[papervisi]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=309</guid>
		<description><![CDATA[Papervision3D has won the INNOVATION OF THE YEAR in this year’s .net Awards!
Other nominees included Google Android and App Engine, Microsoft Telescope, Open Social and Silverlight 2. I&#8217;m very proud to be part of the Papervision3D team!

Read more on the Papervision3D blog.
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2008%2F12%2F09%2Fpapervision3d-wins-innovation-of-the-year-award%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2008%2F12%2F09%2Fpapervision3d-wins-innovation-of-the-year-award%2F" height="61" width="51" /></a></div><p>Papervision3D has won the INNOVATION OF THE YEAR in this year’s <a href="http://www.thenetawards.com/">.net Awards</a>!<br />
Other nominees included Google Android and App Engine, Microsoft Telescope, Open Social and Silverlight 2. I&#8217;m very proud to be part of the Papervision3D team!</p>
<p><img title="dotnet innovation award 2008" src="http://papervision3d.files.wordpress.com/2008/12/web_rgb_logo2.gif?w=240&amp;h=198" alt="dotnet innovation award 2008" width="240" height="198" /></p>
<p>Read more on the <a href="http://blog.papervision3d.org/2008/12/09/innovation-of-the-year/">Papervision3D blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2008/12/09/papervision3d-wins-innovation-of-the-year-award/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Alchemy &#8211; first looks</title>
		<link>http://techblog.floorplanner.com/2008/11/23/alchemy-first-looks/</link>
		<comments>http://techblog.floorplanner.com/2008/11/23/alchemy-first-looks/#comments</comments>
		<pubDate>Sun, 23 Nov 2008 15:30:26 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[CAD]]></category>
		<category><![CDATA[Flash+ActionScript]]></category>
		<category><![CDATA[Floorplanner]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[alchemy flash as3 swc triangulation]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=261</guid>
		<description><![CDATA[Adobe has recently released a preview version of Alchemy. From their site:
Welcome the preview release of codename &#8220;Alchemy.&#8221; Alchemy is a research project that allows users to compile C and C++ code that is targeted to run on the open source ActionScript Virtual Machine (AVM2). The purpose of this preview is to assess the level [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2008%2F11%2F23%2Falchemy-first-looks%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2008%2F11%2F23%2Falchemy-first-looks%2F" height="61" width="51" /></a></div><p>Adobe has recently released a preview version of <a href="http://labs.adobe.com/technologies/alchemy/">Alchemy</a>. From their site:</p>
<blockquote><p>Welcome the preview release of codename &#8220;Alchemy.&#8221; Alchemy is a research project that allows users to compile C and C++ code that is targeted to run on the open source ActionScript Virtual Machine (AVM2). The purpose of this preview is to assess the level of community interest in reusing existing C and C++ libraries in Web applications that run on Adobe® Flash® Player and Adobe AIR®.</p></blockquote>
<p>So, what does this mean? This means that we can use existing C/C++ code and compile that down to AS3. Initially I though that this implied a hefty increase in code execution speed, but as all is compiled down to AS3 this is <strong>not</strong> true in most cases. Code will only run faster if you &#8217;stay&#8217; on the C-side and only return to &#8216;AS3&#8242; when your C code is done processing. The reason is that AS3 method-calls are sloooow (params need to be &#8216;unboxed&#8217; etc.)! When in C this slowness doesn&#8217;t occur and hence execution speed will be faster (Adobe claims a potential speed increase by a factor 2 to 10 I beleive). Wow! That of course made me wonder whether Alchemy would be usefull for 3D engines like Papervision3D, more soon! <img src='http://techblog.floorplanner.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://www.automatastudios.com">Branden Hall</a> did a nice <a href="http://www.automatastudios.com/2008/11/21/understanding-adobe-alchemy/">writeup</a> on Alchemy explaining above better then me.</p>
<p>I couldn&#8217;t resist myself and started off immediately with something I always wanted to code for our 3D engine: <a href="http://en.wikipedia.org/wiki/Polygon_triangulation">Polygon Triangulation</a> with support for holes.</p>
<p>I installed the <a href="http://labs.adobe.com/downloads/alchemy.html">Alchemy Toolkit</a>, got the Flex 3.2 SDK and got some C code from the <a href="http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html">Department of Computer Science, UNC Chapel Hill</a>.</p>
<p>Setting up the toolkit was bit tricky, but with help from <a href="http://labs.adobe.com/wiki/index.php/Alchemy:Documentation:Getting_Started">this page</a> I finally succeeded to get my environment right (OSX). Then I hit &#8216;make&#8217; and presto! Got my swc! <a href="http://www.assembla.com/spaces/floorplanner-alchemy/documents">Download the swc and sample code</a> or <a href="http://www.assembla.com/spaces/floorplanner-alchemy/documents/agZ5W8Uxir3y-mab7jnrAJ/download/TriangulationTest.swf">view a live example</a>.</p>
<p>Some notes on swc usage:<br />
1] &#8216;outer&#8217; polygons must be defined anti-clockwise<br />
2] &#8216;inner&#8217; polygons (holes) must be defined clock-wise</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="actionscript3" style="font-family: Monaco,monospace;"><span style="color: #009900;">// import</span>
<span style="color: #0033ff; font-weight: bold;">import</span> cmodule.triangulation.CLibInit;
&nbsp;
<span style="color: #009900;">// initialize</span>
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000000; font-weight: bold;">:</span>CLibInit = <span style="color: #0033ff; font-weight: bold;">new</span> CLibInit;
<span style="color: #6699cc; font-weight: bold;">var</span> lib<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = <span style="color: #004993;">loader</span>.<span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// @vertices is an array of XY-pairs: [ [], [x0, y0], [x1, y1], ...]</span>
<span style="color: #009900;">//                NOTE: @vertices[0] should always be [] </span>
<span style="color: #009900;">// @contours is an array containing the number of points of each polygon</span>
<span style="color: #009900;">//                =&gt; [4, 3, 3, 3] indicates 4 polygons with the first poly having 4 points, the second 3, etc.</span>
<span style="color: #009900;">// @ncontours is the number of polygons (in our example: 4)</span>
<span style="color: #009900;">//</span>
<span style="color: #009900;">// @return An array of indices into the vertices array in form: [ [p0, p1, p2], [p0, p1, p2], ...]</span>
<span style="color: #6699cc; font-weight: bold;">var</span> indices <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Array</span> = lib.triangulate<span style="color: #000000;">&#40;</span> vertices, contours, ncontours <span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<p>Here&#8217;s the relevant C code which was simply added to tri.c :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
</pre></td><td class="code"><pre class="c" style="font-family: Monaco,monospace;"><span style="color: #993333;">static</span> AS3_Val triangulate<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">*</span> self<span style="color: #339933;">,</span> AS3_Val args<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">int</span> ncontours <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
	<span style="color: #993333;">int</span> ccount<span style="color: #339933;">;</span>
	<span style="color: #993333;">int</span> npoints<span style="color: #339933;">,</span> first<span style="color: #339933;">,</span> last<span style="color: #339933;">,</span> n<span style="color: #339933;">,</span> nmonpoly<span style="color: #339933;">;</span>
	<span style="color: #993333;">register</span> <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
	<span style="color: #993333;">int</span> op<span style="color: #009900;">&#91;</span>SEGSIZE<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> ntriangles<span style="color: #339933;">;</span>
	AS3_Val dataVal<span style="color: #339933;">;</span>
	AS3_Val contourVal<span style="color: #339933;">;</span>
	AS3_Val retVal<span style="color: #339933;">;</span>
	AS3_Val temp<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/* initialze the AS3 values */</span>
	dataVal <span style="color: #339933;">=</span> AS3_Undefined<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	contourVal <span style="color: #339933;">=</span> AS3_Undefined<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	retVal <span style="color: #339933;">=</span> AS3_Undefined<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	temp <span style="color: #339933;">=</span> AS3_Undefined<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//parse the arguments.</span>
	AS3_ArrayValue<span style="color: #009900;">&#40;</span> args<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;AS3ValType, AS3ValType, IntType&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>dataVal<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>contourVal<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>ncontours <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//if no argument is specified</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>dataVal <span style="color: #339933;">==</span> NULL <span style="color: #339933;">||</span> contourVal <span style="color: #339933;">==</span> NULL <span style="color: #339933;">||</span> ncontours <span style="color: #339933;">&lt;=</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		AS3_Trace<span style="color: #009900;">&#40;</span> AS3_String<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Invalid input data!&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> AS3_Null<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	ccount <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
	i <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>ccount <span style="color: #339933;">&lt;</span> ncontours<span style="color: #009900;">&#41;</span>
   	<span style="color: #009900;">&#123;</span>
		<span style="color: #993333;">int</span> j<span style="color: #339933;">;</span>
		<span style="color: #993333;">int</span> k<span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//fscanf(infile, &quot;%d&quot;, &amp;npoints);</span>
&nbsp;
		npoints <span style="color: #339933;">=</span> AS3_IntValue<span style="color: #009900;">&#40;</span> AS3_Get<span style="color: #009900;">&#40;</span>contourVal<span style="color: #339933;">,</span> AS3_Int<span style="color: #009900;">&#40;</span>ccount<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		first <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
		last <span style="color: #339933;">=</span> first <span style="color: #339933;">+</span> npoints <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> k <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> npoints<span style="color: #339933;">;</span> j<span style="color: #339933;">++,</span> i<span style="color: #339933;">++,</span> k <span style="color: #339933;">+=</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//fscanf(infile, &quot;%lf%lf&quot;, &amp;seg[i].v0.x, &amp;seg[i].v0.y);</span>
			temp <span style="color: #339933;">=</span> AS3_Get<span style="color: #009900;">&#40;</span>dataVal<span style="color: #339933;">,</span> AS3_Int<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">v0</span>.<span style="color: #202020;">x</span> <span style="color: #339933;">=</span> AS3_NumberValue<span style="color: #009900;">&#40;</span> AS3_Get<span style="color: #009900;">&#40;</span>temp<span style="color: #339933;">,</span> AS3_Int<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">v0</span>.<span style="color: #202020;">y</span> <span style="color: #339933;">=</span> AS3_NumberValue<span style="color: #009900;">&#40;</span> AS3_Get<span style="color: #009900;">&#40;</span>temp<span style="color: #339933;">,</span> AS3_Int<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">==</span> last<span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">next</span> <span style="color: #339933;">=</span> first<span style="color: #339933;">;</span>
				seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">prev</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
				seg<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #202020;">v1</span> <span style="color: #339933;">=</span> seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">v0</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">==</span> first<span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">next</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
				seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">prev</span> <span style="color: #339933;">=</span> last<span style="color: #339933;">;</span>
				seg<span style="color: #009900;">&#91;</span>last<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">v1</span> <span style="color: #339933;">=</span> seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">v0</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #009900;">&#123;</span>
				seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">prev</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
				seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">next</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
				seg<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #202020;">v1</span> <span style="color: #339933;">=</span> seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">v0</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			seg<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">is_inserted</span> <span style="color: #339933;">=</span> FALSE<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		ccount<span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	n <span style="color: #339933;">=</span> i <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
	initialise<span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	construct_trapezoids<span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	nmonpoly <span style="color: #339933;">=</span> monotonate_trapezoids<span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	ntriangles <span style="color: #339933;">=</span> triangulate_monotone_polygons<span style="color: #009900;">&#40;</span>n<span style="color: #339933;">,</span> nmonpoly<span style="color: #339933;">,</span> op<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	retVal <span style="color: #339933;">=</span> AS3_Array<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;AS3ValType&quot;</span><span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> ntriangles<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
   	<span style="color: #009900;">&#123;</span>
		AS3_Val data <span style="color: #339933;">=</span> AS3_Array<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;IntType, IntType, IntType&quot;</span><span style="color: #339933;">,</span> op<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> op<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> op<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		AS3_Set<span style="color: #009900;">&#40;</span>retVal<span style="color: #339933;">,</span> AS3_Int<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> retVal<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//entry point for code</span>
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//define the methods exposed to ActionScript</span>
	<span style="color: #666666; font-style: italic;">//typed as an ActionScript Function instance</span>
	AS3_Val echoMethod <span style="color: #339933;">=</span> AS3_Function<span style="color: #009900;">&#40;</span> NULL<span style="color: #339933;">,</span> echo <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	AS3_Val triMethod <span style="color: #339933;">=</span> AS3_Function<span style="color: #009900;">&#40;</span> NULL<span style="color: #339933;">,</span> triangulate <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// construct an object that holds references to the functions</span>
	AS3_Val result <span style="color: #339933;">=</span> AS3_Object<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;echo: AS3ValType&quot;</span><span style="color: #339933;">,</span> echoMethod <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	AS3_SetS<span style="color: #009900;">&#40;</span>result<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;triangulate&quot;</span><span style="color: #339933;">,</span> triMethod<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Release</span>
	AS3_Release<span style="color: #009900;">&#40;</span> echoMethod <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	AS3_Release<span style="color: #009900;">&#40;</span> triMethod <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// notify that we initialized -- THIS DOES NOT RETURN!</span>
	AS3_LibInit<span style="color: #009900;">&#40;</span> result <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// should never get here!</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2008/11/23/alchemy-first-looks/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
