<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>{ P I X E L W E L D E R S }</title>
	<link>http://pixelwelders.com/blog</link>
	<description>Flash + Flex + Game Dev + Grammar?</description>
	<pubDate>Wed, 20 Aug 2008 12:20:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Flash/Flex Integration: SWFLibrary v1.5</title>
		<link>http://pixelwelders.com/blog/best-practices/2008/flashflex-integration-swflibrary-v15/</link>
		<comments>http://pixelwelders.com/blog/best-practices/2008/flashflex-integration-swflibrary-v15/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 01:28:48 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[ActionScript 3.0]]></category>

		<category><![CDATA[Best Practices]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[Flash/Flex Integration]]></category>

		<guid isPermaLink="false">http://pixelwelders.com/blog/best-practices/2008/flashflex-integration-swflibrary-v15/</guid>
		<description><![CDATA[
Usually I like to post glamorous stuff, like 3D swirly things and experiments.  Occasionally, however, I feel the need to release a little code in the interest of helping a few people out.  This code is a review of sorts, since I already posted a similar utility back in June.  However, since [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://pixelwelders.com/blog/wp-content/themes/tma/images/latest/SWFLibrary_470x175.jpg"/ style="float:none"></p>
<p>Usually I like to post glamorous stuff, like 3D swirly things and experiments.  Occasionally, however, I feel the need to release a little code in the interest of helping a few people out.  This code is a review of sorts, since I already posted a <a href="http://pixelwelders.com/blog/best-practices/2008/runtime-libraries-in-as3/" >similar utility</a> back in June.  However, since then I have been expanding my code library and I thought I&#8217;d share the latest and much improved version.  It&#8217;s really a simple concept, but having this in my toolbox has lightened my workload as an ActionScripter considerably.</p>
<h3>Advantages</h3>
<p>This utility allows you to publish any symbol from Flash and access it at runtime from an ActionScript-only project, such as in Flex Builder.  This has a few advantages:</p>
<ul>
<li>Easy storage of many assets in one file</li>
<li>Ability to change graphics without recompiling the main application</li>
<li>Faster load times with only one HTTP request (as opposed to many separate images and sounds)</i>
<li>Ability to import vector graphics and animations at runtime</li>
<li>Smaller main SWF size</li>
</ul>
<p>The one disadvantage that I can think of is that you&#8217;ll need to recompile your library SWF every time you make a change.  However, I think the advantages above outweigh this.</p>
<h3>Differences in v1.5</h3>
<p>Here are the main differences from the last version:</p>
<ul>
<li>The class is no longer static.  This allows for more than one instance of SWFLibrary at a time.</li>
<li>The class can now return instances of Sprites, MovieClips, and Sounds from a library SWF.</li>
</ul>
<h3>Usage</h3>
<p>1 - In Flash, select &#8220;Export for ActionScript&#8221; in the symbol&#8217;s Linkage settings in the Library (ex. &#8216;Character&#8217;).<br />
2 - Publish the Flash file as a SWF.<br />
3 - Load the SWF into an instance of SWFLibrary<br />
4 - Access the symbol through SWFLibrary, using the class name chosen in Step 1.</p>
<p>A SWFLibrary can be used with four lines of code.  Here&#8217;s what you&#8217;ll need:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript"><span style="color: #808080; font-style: italic;">// creates an instance of SWFLibrary, adds a listener, and loads a SWF</span>
<span style="color: #000000; font-weight: bold;">var</span> gameAssets:SWFLibrary = <span style="color: #000000; font-weight: bold;">new</span> SWFLibrary
gameAssets.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">COMPLETE</span>, handleAssetsLoaded <span style="color: #66cc66;">&#41;</span>;
gameAssets.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;myCustomGameAssets.swf&quot;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// accesses the asset (assumes there is a symbol exported as 'Character' in the loaded SWF, as seen in step 1 above)</span>
<span style="color: #808080; font-style: italic;">// this code should run after the Event above has fired</span>
<span style="color: #000000; font-weight: bold;">var</span> mySprite:Sprite = gameAssets.<span style="color: #006600;">getSprite</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;Character&quot;</span> <span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span> mySprite <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// gets the asset as a MovieClip (assuming, of course, that it actually is a movieclip)</span>
<span style="color: #000000; font-weight: bold;">var</span> myMC:<span style="color: #0066CC;">MovieClip</span> = gameAssets.<span style="color: #006600;">getSprite</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;Character&quot;</span> <span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span> myMC <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// getting a sound</span>
<span style="color: #000000; font-weight: bold;">var</span> mySound:<span style="color: #0066CC;">Sound</span> = gameAssets.<span style="color: #006600;">getSound</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;SoundLinkageNameHere&quot;</span> <span style="color: #66cc66;">&#41;</span>;
mySound.<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;">// === ===</span></pre></div></div>

<p>After a symbol has been retrieved from SWFLibrary, it may be treated like any other object.</p>
<h3>Download</h3>
<p><a href="http://pixelwelders.com/open_source/SWFLibrary/SWFLibrary.zip" onclick="javascript:pageTracker._trackPageview('/downloads/open_source/SWFLibrary/SWFLibrary.zip');">DOWNLOAD SOURCE</a></p>
<p>So have fun with this.  Hopefully it saves you as much time as it saves me.</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/best-practices/2008/flashflex-integration-swflibrary-v15/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Presenting: Tutorio.us!</title>
		<link>http://pixelwelders.com/blog/best-practices/2008/presenting-tutorious/</link>
		<comments>http://pixelwelders.com/blog/best-practices/2008/presenting-tutorious/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 18:20:18 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[Best Practices]]></category>

		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://pixelwelders.com/blog/best-practices/2008/presenting-tutorious/</guid>
		<description><![CDATA[After a couple of months working on this project, I am ready to release my labor of love.  Presenting: Tutorio.us!]]></description>
			<content:encoded><![CDATA[<p>After a couple of months working on this project, I am ready to release my labor of love.  Presenting: Tutorio.us!</p>
<p><a href="http://tutorio.us"><br />
<img style="float:none;" src='http://pixelwelders.com/blog/wp-content/uploads/2008/07/logo2_500.jpg' alt='Tutorious Logo' /><br />
</a></p>
<p>To explain what this is, and instead of writing something new, I&#8217;ll just quote directly directly from the website:</p>
<div style="background:#eee; padding:15px;">
<h3>The Scenario</h3>
<p>So you want to learn Flash. Great! A noble endeavor. And you want to do it on your own, harnessing the vast resources of the internet. Also a good idea, with only one problem: which resources?</p>
<p>The Internet is a vast place. According to <a href="http://adamant.typepad.com/seitz/2007/04/weighing_the_we.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://adamant.typepad.com/seitz/2007/04/weighing_the_we.html');">some estimates</a>, it contains nearly two ounces of information (which is more than you think when you’re counting electrons). If that doesn’t awe you, consider <a href="http://blog.managednetworks.co.uk/it-support/googles-20-petabytes/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://blog.managednetworks.co.uk/it-support/googles-20-petabytes/');">this article</a>, which tells us that if a byte is a grain of rice, Google processes enough rice daily for every person on earth to have sixteen bowls full. <em>Daily</em>.</p>
<h3>The Problem</h3>
<p>The main point is this: there is a lot of information out there. There is more than enough to teach you everything you want to know about Flash. If you’ve spent any time searching, you’ve probably seen hundreds of tutorials already- maybe dozens today alone. However, the problem is this: a lot of them kinda suck. You’ve probably noticed this too. Incorrect information, bad (even crippling) practices, ancient Flash versions… the list goes on.</p>
<p>The second problem is this: If you’re new to ActionScript, what do you learn first? XML? Text formatting? Class structure? And where do you go after that? What are the pre-requisites of each tutorial? All this knowledge is out there (somewhere in that two ounces of electrons) but the majority of it is alone, without context, floating in the void.</p>
<h3>The Solution</h3>
<p>So here’s our solution. Tutorio.us is our attempt to index the best Flash instruction on the Internet, in a context that makes sense. We are dedicated to finding the clearest, best-written content for the most cutting-edge technology and putting it together in ways that everyone can understand.
</p></div>
<p><br/><br />
So there you have it.  Go take a look and let me know what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/best-practices/2008/presenting-tutorious/feed/</wfw:commentRss>
		</item>
		<item>
		<title>FIVe3D Custom Primitive: VectorCube Class</title>
		<link>http://pixelwelders.com/blog/actionscript-3/2008/five3d-custom-primitive-vectorcube-class/</link>
		<comments>http://pixelwelders.com/blog/actionscript-3/2008/five3d-custom-primitive-vectorcube-class/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 22:48:09 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[3D]]></category>

		<category><![CDATA[ActionScript 3.0]]></category>

		<category><![CDATA[Featured]]></category>

		<category><![CDATA[FIVe3D]]></category>

		<guid isPermaLink="false">http://pixelwelders.com/blog/actionscript-3/2008/five3d-custom-primitive-vectorcube-class/</guid>
		<description><![CDATA[After a long Papervision-induced hiatus, I've come back to FIVe3D- mainly because I still think it's a great library.  Since it's still relatively new, however, there's not a lot of example code out there.  Thus, here's another chunk from your friends here at Pixelwelders.]]></description>
			<content:encoded><![CDATA[<p>After a long Papervision-induced hiatus, I&#8217;ve come back to FIVe3D- mainly because I still think it&#8217;s a great library.  Since it&#8217;s still relatively new, however, there&#8217;s not a lot of example code out there.  Thus, here&#8217;s another chunk from your friends here at Pixelwelders.  This class creates a cube out of Sprite3D planes.</p>
<h3>Fig. 1: 27 Cubes</h3>

<object	type="application/x-shockwave-flash"
			data="http://pixelwelders.com/experiments/FIVe3D_cube/RubiksCube.swf"
			width="700"
			height="450">
	<param name="movie" value="http://pixelwelders.com/experiments/FIVe3D_cube/RubiksCube.swf" />
</object>
<h3>Fig.2: The VectorCube Class</h3>

<div class="wp_syntax"><div class="code"><pre class="actionscript"><span style="color: #808080; font-style: italic;">/**
 * A vector Cube class for Mathieu Badimon's excellent FIVe3D library
 * @author Zack Jordan
 * { P I X E L W E L D E R S . C O M }
 */</span>
package com.<span style="color: #006600;">pixelwelders</span>.<span style="color: #006600;">five3d</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> five3D.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite3D</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> VectorCube <span style="color: #0066CC;">extends</span> Sprite3D
	<span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> faces		: <span style="color: #0066CC;">Array</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> VectorCube<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">size</span>:<span style="color: #0066CC;">Number</span>, colors:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">!</span>colors <span style="color: #66cc66;">&#41;</span> colors = <span style="color: #66cc66;">&#91;</span> 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000 <span style="color: #66cc66;">&#93;</span>;
			createCube<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">size</span>, colors <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		 * Creates a new cube at the size specified
		 * 
		 * @param		size			Size of the cube to be created
		 * @return					The new cube
		 */</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> createCube<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">size</span>:<span style="color: #0066CC;">Number</span>, colors:<span style="color: #0066CC;">Array</span> <span style="color: #66cc66;">&#41;</span>: <span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			faces = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> xP:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span>	<span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">size</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>,	<span style="color: #cc66cc;">0</span>, -<span style="color: #0066CC;">size</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> yP:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span>	<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>,	<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>,	-<span style="color: #0066CC;">size</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>, <span style="color: #0066CC;">size</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> zP:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span>	-<span style="color: #0066CC;">size</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">size</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>	<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> xR:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span>	<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>,	<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">-90</span>, <span style="color: #cc66cc;">90</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> yR:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span>	<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">-90</span>, <span style="color: #cc66cc;">180</span>, <span style="color: #cc66cc;">90</span>,	<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> zR:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span>	<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>,	<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> <span style="color: #cc66cc;">6</span>; i++ <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> face:Sprite3D = <span style="color: #000000; font-weight: bold;">new</span> Sprite3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				face.<span style="color: #006600;">graphics3D</span>.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">1</span>, 0x000000, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
				face.<span style="color: #006600;">graphics3D</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span> colors<span style="color: #66cc66;">&#91;</span> i <span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#41;</span>;
				face.<span style="color: #006600;">graphics3D</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span> -<span style="color: #0066CC;">size</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>, -<span style="color: #0066CC;">size</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>, <span style="color: #0066CC;">size</span>, <span style="color: #0066CC;">size</span> <span style="color: #66cc66;">&#41;</span>;
				face.<span style="color: #006600;">graphics3D</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				face.<span style="color: #006600;">singleSided</span> = <span style="color: #000000; font-weight: bold;">true</span>;
&nbsp;
				face.<span style="color: #006600;">x</span> = xP<span style="color: #66cc66;">&#91;</span> i <span style="color: #66cc66;">&#93;</span>;
				face.<span style="color: #006600;">y</span> = yP<span style="color: #66cc66;">&#91;</span> i <span style="color: #66cc66;">&#93;</span>;
				face.<span style="color: #006600;">z</span> = zP<span style="color: #66cc66;">&#91;</span> i <span style="color: #66cc66;">&#93;</span>;
				face.<span style="color: #006600;">rotationX</span> = xR<span style="color: #66cc66;">&#91;</span> i <span style="color: #66cc66;">&#93;</span>;
				face.<span style="color: #006600;">rotationY</span> = yR<span style="color: #66cc66;">&#91;</span> i <span style="color: #66cc66;">&#93;</span>;
				face.<span style="color: #006600;">rotationZ</span> = zR<span style="color: #66cc66;">&#91;</span> i <span style="color: #66cc66;">&#93;</span>;
&nbsp;
				faces<span style="color: #66cc66;">&#91;</span> i <span style="color: #66cc66;">&#93;</span> = face;
				addChild<span style="color: #66cc66;">&#40;</span> face <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>So what is this good for?  Really, it&#8217;s just an easy way to create six faces and arrange them into a cube.  You don&#8217;t have to worry about depth sorting or any of that stuff because each of the faces is one-sided.  However, if you are using more than one of these in your presentation, make sure you specify that <code>container.childrenSorted = true</code>, where <code>container</code> is the Sprite3D containing your Cubes.  Otherwise you&#8217;ll get some weird results.</p>
<p>Another note: the <code>faces</code> Array is public so you can continue to draw on each face of the cube, and even add children.  So really, this is just a starting point; I&#8217;ll let you find something useful to do with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/actionscript-3/2008/five3d-custom-primitive-vectorcube-class/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Pokervision3D</title>
		<link>http://pixelwelders.com/blog/game-design/2008/pokervision3d/</link>
		<comments>http://pixelwelders.com/blog/game-design/2008/pokervision3d/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 13:34:51 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[3D]]></category>

		<category><![CDATA[Game Design]]></category>

		<category><![CDATA[Papervision3D]]></category>

		<guid isPermaLink="false">http://pixelwelders.com/blog/game-design/2008/pokervision3d/</guid>
		<description><![CDATA[I just spent the last three weeks a little bit out of the action, wandering Europe in a motorcoach.  On said motorcoach, there were only two things to do: play with my laptop, and play poker with the other passengers.  By the end of the trip, I ended up winning about thirty Euros [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent the last three weeks a little bit out of the action, wandering Europe in a motorcoach.  On said motorcoach, there were only two things to do: play with my laptop, and play poker with the other passengers.  By the end of the trip, I ended up winning about thirty Euros from my playing partners (most of which were 17 and younger).  Obviously, I have no ethical qualms about gambling with minors.  The only thing that disturbed me about this scenario was the fact that 30 Euros is pocket money in France and practically a mortgage payment in the US.  Stupid dollar.</p>
<p>So between games, I started this little project in Papervision.  I&#8217;m not sure how far I&#8217;ll take it, but it might end up being my entry into the <a href="http://blog.papervision3d.org/2008/07/02/paperking3d-the-papervision3d-contest/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://blog.papervision3d.org/2008/07/02/paperking3d-the-papervision3d-contest/');">PaperKing3D</a> contest.  I found some great images of a Victorian-style deck of cards, and painstakingly clone-brushed a full deck out of the few cards I could find.  I then put together the actual game&#8211; which is obviously not finished.  However, it does actually deal out the cards and keep track of players- the next step is to actually make it judge hands (flush vs. full house, etc.).</p>
<p>The best part of this little demo is what happens when you mouse over your cards (the closest hand).  That is Bartek Drozdz&#8217;s <a href="http://www.everydayflash.com/blog/index.php/2008/06/16/bend-modifier-papervision3d-2/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.everydayflash.com/blog/index.php/2008/06/16/bend-modifier-papervision3d-2/');">bend modifier</a> in action.  I think it&#8217;s pretty eye-catching.</p>

<object	type="application/x-shockwave-flash"
			data="http://pixelwelders.com/games/Pokervision3D/Flex/Pokervision_UI.swf"
			width="700"
			height="550">
	<param name="movie" value="http://pixelwelders.com/games/Pokervision3D/Flex/Pokervision_UI.swf" />
</object>
<p><br/><br />
Anyway, that&#8217;s it on Pokervision for today; hopefully I&#8217;ll have the time to finish this (multiplayer 3D poker, anyone?).  In the meantime, I&#8217;ll be working on another, possibly more awesome project that I&#8217;ll be presenting at tomorrow&#8217;s <a href="http://flash.meetup.com/11/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://flash.meetup.com/11/');">Chicago Flash Meetup</a>.  I&#8217;ll post more details here later this week.</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/game-design/2008/pokervision3d/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Speed Tests: Objects vs. Arrays vs. Dictionaries</title>
		<link>http://pixelwelders.com/blog/best-practices/2008/speed-tests-objects-vs-arrays-vs-dictionaries/</link>
		<comments>http://pixelwelders.com/blog/best-practices/2008/speed-tests-objects-vs-arrays-vs-dictionaries/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 09:27:12 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[ActionScript 3.0]]></category>

		<category><![CDATA[Best Practices]]></category>

		<guid isPermaLink="false">http://pixelwelders.com/blog/best-practices/2008/speed-tests-objects-vs-arrays-vs-dictionaries/</guid>
		<description><![CDATA[	I’ve been taking buses around Europe for a couple weeks now, and sometimes those trips get extremely long.  Yesterday I took a bus from Venice to Seefeld (Austria), a trip that would have taken about five hours if not for the hurricane-like downpour they were having in Italy.  Seriously, it was ridiculous- all traffic was on the side of the highway, and all the motorcyclists were huddled under the overpasses.  But on the bright side, it did give me a lot of time to try out some things that I normally wouldn’t take the time to do, such as this experiment.]]></description>
			<content:encoded><![CDATA[<p>	I’ve been taking buses around Europe for a couple weeks now, and sometimes those trips get extremely long.  Yesterday I took a bus from Venice to Seefeld (Austria), a trip that would have taken about five hours if not for the hurricane-like downpour they were having in Italy.  Seriously, it was ridiculous- all traffic was on the side of the highway, and all the motorcyclists were huddled under the overpasses.  But on the bright side, it did give me a lot of time to try out some things that I normally wouldn’t take the time to do, such as this experiment.</p>
<p>	I make a lot of decisions daily based on things I think I know, but really have just always assumed.  And so, on this bus ride, I decided to get to the bottom of a few of them.  The first experiment I tried was with the read and write speeds of Objects, Arrays, and Dictionaries.  In the past, I have always used Arrays when I need all the nifty sorting and organization methods, Dictionaries when I need fast access, object keys, or weak references, and Objects pretty much never (because they’re messy and slow).  So yesterday I decided to see if my assumptions were actually valid, or if I had been doing things wrong this whole time.</p>
<p>	So I set up a quick class to test.  I created a Dictionary, an Object, and an Array, and then I put 100,000 integers in each one for the write test, and read them back out for the read test.  This is what I got (all times are average and in milliseconds).</p>
<table>
<tr>
<th/>
<th>Object</th>
<th>Array</th>
<th>Dictionary</th>
</tr>
<tr>
<th>Read (integer key)</th
<td>868</td>
<td>19</td>
<td>573</td>
</tr>
<tr>
<th>Write (integer key)</th>
<td>24</td>
<td>17</td>
<td>22</td>
</tr>
<tr>
<th>Read (string key)</th>
<td>586</td>
<td>N/A</td>
<td>573</td>
</tr>
<tr>
<th>Write (string key)</th>
<td>329</td>
<td>N/A</td>
<td>333</td>
</tr>
</table>
<p>	Obviously there are many more benchmarks that I could have run, but I also had a pretty good book on that bus.  I think I’ve done enough experimentation to prove that, once again, my assumptions are invalid.</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/best-practices/2008/speed-tests-objects-vs-arrays-vs-dictionaries/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flash + Google = ?</title>
		<link>http://pixelwelders.com/blog/flashosphere/2008/flash-google/</link>
		<comments>http://pixelwelders.com/blog/flashosphere/2008/flash-google/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 18:53:29 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[Flashosphere]]></category>

		<guid isPermaLink="false">http://pixelwelders.com/blog/flashosphere/2008/flash-google/</guid>
		<description><![CDATA[Although we've all heard for years that Google does index SWFs in some mysterious way, no one has really understood exactly what that meant.  All we knew was that it was pretty much useless.  But, if my sources are correct, things may be changing.]]></description>
			<content:encoded><![CDATA[<p><img src="http://pixelwelders.com/blog/wp-content/themes/tma/images/latest/suisse_470x175.jpg" style="float:none"/></p>
<p>Sorry for the lack of updates, everyone: I&#8217;m currently in Switzerland enjoying the fondue (true story).  However, I did stumble across something interesting during my last five-Franc Internet session.  Although we&#8217;ve all heard for years that Google does index SWFs in some mysterious way, no one has really understood exactly what that meant.  All we knew was that it was pretty much useless.  However, it looks like Google is getting a little more serious about it, as mentioned in the links below.</p>
<p>Google&#8217;s blog:<br />
<a href="http://googleblog.blogspot.com/2008/06/google-learns-to-crawl-flash.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://googleblog.blogspot.com/2008/06/google-learns-to-crawl-flash.html');">Google Learns to Crawl Flash</a></p>
<p>Adobe&#8217;s press release:<br />
<a href="http://www.adobe.com/aboutadobe/pressroom/pressreleases/200806/070108AdobeRichMediaSearch.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.adobe.com/aboutadobe/pressroom/pressreleases/200806/070108AdobeRichMediaSearch.html');">Adobe Advances Rich Media Search on the Web</a></p>
<p>However, I still have no idea what this means.  After all, any Flash RIA developer worth his salt will be bringing in all his/her data dynamically instead of embedding it in the SWF.  I would assume this is the data that Google will be reading, non?  Otherwise I&#8217;m not sure how it would be different than what we&#8217;ve got now.  And also because I like to hope for the best, and that would be pretty slick.  Game-changing, I&#8217;d even say.</p>
<p>So anyway, I&#8217;ll leave the in-depth analysis to <a href="http://blogs.zdnet.com/Stewart/?p=871" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://blogs.zdnet.com/Stewart/?p=871');">others</a>.  The Alps, after all, are calling.</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/flashosphere/2008/flash-google/feed/</wfw:commentRss>
		</item>
		<item>
		<title>AS3 Broadcaster Class</title>
		<link>http://pixelwelders.com/blog/best-practices/2008/as3-broadcaster-class/</link>
		<comments>http://pixelwelders.com/blog/best-practices/2008/as3-broadcaster-class/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 14:52:31 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[ActionScript 3.0]]></category>

		<category><![CDATA[Best Practices]]></category>

		<category><![CDATA[AS2 vs AS3]]></category>

		<category><![CDATA[Broadcaster]]></category>

		<guid isPermaLink="false">http://pixelwelders.com/blog/best-practices/2008/as3-broadcaster-class/</guid>
		<description><![CDATA[This is something simple enough that I hesitate to post it, but maybe someone else can benefit.  Plus, I always try to have something new on Mondays.  Anyway, this a technique I once used back in the dark ages of ActionScript development (meaning AS2).  Last week, however, I suddenly had need of it again.]]></description>
			<content:encoded><![CDATA[<p><img src="http://pixelwelders.com/blog/wp-content/themes/tma/images/latest/satellite_470x175.jpg" style="float:none"/></p>
<p>This is something simple enough that I hesitate to post it, but maybe someone else can benefit.  Plus, I always try to have something new on Mondays.  Anyway, this a technique I once used back in the dark ages of ActionScript development (meaning AS2).  Last week, however, I suddenly had need of it again.</p>
<h3>The Scenario</h3>
<p>The AS3 event model is a pretty slick deal- much better than the six different ways we used to do it back in AS2.  However, I ran into a spot last week in which it failed me.  I had several different components in completely different parts of an application, and I wanted them all to listen to each other.  That in itself is no problem.  The problem was that I also wanted them to be completely <em>unaware</em> of each other, in hopes of keeping the code a bit more encapsulated.  So how does one listen for an event that comes from a source whose very existence is unknown?</p>
<h3>Option #1</h3>
<p>Option #1 was to make all my events bubble, and have each component add event listeners to some display list parent that all the components shared.  This would ensure that everyone got their events, but it makes everyone dependent on the current setup.  What if I wanted to move a component elsewhere and now it didn&#8217;t share that parent?  Plus, it&#8217;s not a solution that is guaranteed to work in a different app.  <em>Plus</em>, it involves children referencing their parent, which I am against on a fundamental, perhaps even a <em>spiritual</em> level.  So, scratch Option #1.</p>
<h3>Option #2</h3>
<p>Then I thought maybe each component should store a reference to all the other components.  But once again, you can throw the whole “loosely-coupled” idea out the window.  Something about this solution just didn’t feel right.</p>
<h3>Option #3</h3>
<p>Option #3 was the old AS2 method of creating a central static Broadcaster class and telling everyone to listen to <em>it</em>.  Now the only dependency each component had was to one static communication class.  Everything else could change as long as they were listening to the Broadcaster.  And so, as my great-grandmother has told me, sometimes the old ways are best.</p>
<h3>Source</h3>
<p>There’s really not much to explain with this class.  The only challenge was making a static class into an EventDispatcher, but that turned out to be pretty easy (thanks to <a href="http://gskinner.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://gskinner.com/');">G. Skinner</a>, who originally gave me the idea for a static EventDispatcher).  Behold:</p>
<pre lang=”Actionscript”>
/**
 * A central event broadcaster
 *
 * @author	Zack Jordan
 * 			{ P I X E L W E L D E R S . C O M }
 */
package com.pixelwelders.events
{
	import flash.events.Event;
	import flash.events.EventDispatcher;

	public class Broadcaster
	{

		private static var eventDispatcher			: EventDispatcher;

		/**
		 * Broadcasts an event to all listeners
		 * To listen to any and all events, use Broadcaster.addEventListener()
		 *
		 * @param	event		The Event to broadcast
		 * @return				nothing
		 */
		public static function broadcast( event:Event ): void
		{
			dispatchEvent( event );
		}

		// === S T A T I C   E V E N T   D I S P A T C H E R ===
		public static function addEventListener( type:String, listener:Function, useCapture:Boolean=false,
			priority:int=0, useWeakReference:Boolean=true ):void
		{
			if ( !eventDispatcher ) eventDispatcher = new EventDispatcher();
			eventDispatcher.addEventListener( type, listener, useCapture, priority, useWeakReference );
		}

		public static function removeEventListener( type:String, listener:Function, useCapture:Boolean=false ):void
		{
			if ( eventDispatcher ) eventDispatcher.removeEventListener( type, listener, useCapture );
  	    	}

		public static function dispatchEvent( p_event:Event ):void
		{
			if ( eventDispatcher ) eventDispatcher.dispatchEvent( p_event );
		}

	}
}
</pre>
<p>As you can see, this is just a static wrapper for an instance of EventDispatcher.  I just route all the methods of the EventDispatcher to static methods, and voilá.  As always, if you can think of a better way, just drop it in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/best-practices/2008/as3-broadcaster-class/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Custom Shapes in FIVe3D: The Arc</title>
		<link>http://pixelwelders.com/blog/actionscript-3/2008/custom-shapes-in-five3d-the-arc/</link>
		<comments>http://pixelwelders.com/blog/actionscript-3/2008/custom-shapes-in-five3d-the-arc/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 05:38:24 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[3D]]></category>

		<category><![CDATA[ActionScript 3.0]]></category>

		<category><![CDATA[FIVe3D]]></category>

		<guid isPermaLink="false">http://pixelwelders.com/blog/actionscript-3/2008/custom-shapes-in-five3d-the-arc/</guid>
		<description><![CDATA[The beauty of FIVe3D (other than its size, ease of use, and a few other things) is how easily extendable it is.  For a <a href="http://pixelwelders.com/blog/actionscript-3/2008/best-five3d-experiment-yet-seriously-its-awesome/">previous experiment</a>, I needed a way to draw an arc in 3D space.  This isn't something that FIVe3D provides, and in fact it was a little challenging to find the math I needed.  However!  Once I found it, I was able to easily use FIVe3D's drawing API to put it into action.]]></description>
			<content:encoded><![CDATA[<p>The beauty of FIVe3D (other than its size, ease of use, and a few other things) is how easily extendable it is.  For a <a href="http://pixelwelders.com/blog/actionscript-3/2008/best-five3d-experiment-yet-seriously-its-awesome/" >previous experiment</a>, I needed a way to draw an arc in 3D space.  This isn&#8217;t something that FIVe3D provides, and in fact it was a little challenging to find the math I needed.  However!  Once I found it, I was able to easily use FIVe3D&#8217;s drawing API to put it into action.  </p>
<p>The arc code, by the way, is from an ancient AS2 function called drawWedge() by Ric Ewing, which drew pizza-style wedges.  Close enough.  With a little elbow grease I managed to bend it to my will.  Here&#8217;s an example of a bunch of arcs doing their thing:</p>

<object	type="application/x-shockwave-flash"
			data="http://pixelwelders.com/experiments/FIVe3D_Arc/FIVe3D_Arc.swf"
			width="750"
			height="400">
	<param name="movie" value="http://pixelwelders.com/experiments/FIVe3D_Arc/FIVe3D_Arc.swf" />
</object>
<p>And here is the code that draws the arc, which extends FIVe3D&#8217;s Drawing class.  This could probably be cleaned up a bit, since I run through Ric&#8217;s arc code twice to create the thing; it wasn&#8217;t originally that way, but getting the fill on the <em>inside</em> of the arc proved more difficult than I originally thought.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript"><span style="color: #808080; font-style: italic;">/**
 * An extension of Mathieu Badimon's FIVe3D Drawing class.
 * This class draws an additional shape onto a FIVe3D Graphics3D instance.
 * This class includes code from by Ric Ewing.
 * 
 * @author 	Zack Jordan
 * 			{ P I X E L W E L D E R S }
 */</span>
package com.<span style="color: #006600;">pixelwelders</span>.<span style="color: #006600;">five3d</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> five3D.<span style="color: #006600;">display</span>.<span style="color: #006600;">Graphics3D</span>;
	<span style="color: #0066CC;">import</span> five3D.<span style="color: #006600;">utils</span>.<span style="color: #006600;">Drawing</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PXWDrawing <span style="color: #0066CC;">extends</span> Drawing
	<span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		 * Draws a wedge shape onto a Graphics3D instance.
		 * 
		 * @param 	graphics		a Graphics3D instance on which to draw
		 * @param 	x				x position of the center of this wedge
		 * @param	y				y position of the center of this wedge
		 * @param	startAngle		the angle of one straight line of this wedge
		 * @param	arc				the angle (in degrees) of the total arc of this wedge
		 * @param	xRadius			the external radius along the x axis
		 * @param	yRadius			the external radius along the y axis
		 * @param	innerXRadius	the internal radius along the x axis
		 * @param	innerYRadius	the internal radius along the y axis
		 * @param	color			the color of the wedge fill
		 * @param	fillAlpha		the alpha value of the wedge fill
		 * 
		 * @return					nothing
		 */</span>
		<span style="color: #0066CC;">static</span> <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> drawWedge<span style="color: #66cc66;">&#40;</span> 
			graphics:Graphics3D, 
			x:<span style="color: #0066CC;">Number</span>, 
			y:<span style="color: #0066CC;">Number</span>, 
			startAngle:<span style="color: #0066CC;">Number</span>, 
			arc:<span style="color: #0066CC;">Number</span>, 
			xRadius:<span style="color: #0066CC;">Number</span>, 
			yRadius:<span style="color: #0066CC;">Number</span>, 
			innerXRadius:<span style="color: #0066CC;">Number</span>, 
			innerYRadius:<span style="color: #0066CC;">Number</span>, 
			<span style="color: #0066CC;">color</span>:uint = 0xFF0000, 
			fillAlpha:<span style="color: #0066CC;">Number</span> = .<span style="color: #cc66cc;">5</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> segAngle	: <span style="color: #0066CC;">Number</span>
			<span style="color: #000000; font-weight: bold;">var</span> theta		: <span style="color: #0066CC;">Number</span>
			<span style="color: #000000; font-weight: bold;">var</span> angle		: <span style="color: #0066CC;">Number</span>
			<span style="color: #000000; font-weight: bold;">var</span> angleMid	: <span style="color: #0066CC;">Number</span>
			<span style="color: #000000; font-weight: bold;">var</span> segs		: <span style="color: #0066CC;">Number</span>
			<span style="color: #000000; font-weight: bold;">var</span> bx		: <span style="color: #0066CC;">Number</span>
			<span style="color: #000000; font-weight: bold;">var</span> by		: <span style="color: #0066CC;">Number</span>
			<span style="color: #000000; font-weight: bold;">var</span> cx		: <span style="color: #0066CC;">Number</span>
			<span style="color: #000000; font-weight: bold;">var</span> cy		: <span style="color: #0066CC;">Number</span>;
&nbsp;
			segs = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">ceil</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span> arc <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">45</span> <span style="color: #66cc66;">&#41;</span>;
			segAngle = arc <span style="color: #66cc66;">/</span> segs;
			theta = -<span style="color: #66cc66;">&#40;</span> segAngle <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">180</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span>;
			angle = -<span style="color: #66cc66;">&#40;</span> startAngle <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">180</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span>;
&nbsp;
			graphics.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">1</span>, 0x000000, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
			graphics.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">color</span>, fillAlpha <span style="color: #66cc66;">&#41;</span>;
			graphics.<span style="color: #0066CC;">moveTo</span><span style="color: #66cc66;">&#40;</span> 
				x + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span> startAngle <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">180</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> innerXRadius,
				y + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span> -startAngle<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">180</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> innerYRadius 
			<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">// line 1</span>
			graphics.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span> 
				x + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span> startAngle <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">180</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> xRadius,
				y + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span> -startAngle <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">180</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> yRadius 
			<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">// outer arc</span>
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> segs; i++ <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				angle += theta;
				angleMid = angle - <span style="color: #66cc66;">&#40;</span> theta <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span>;
				bx = x + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span> angle <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> xRadius;
				by = y + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span> angle <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> yRadius;
				cx = x + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span> angleMid <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#40;</span> xRadius <span style="color: #66cc66;">/</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span> theta <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				cy = y + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span> angleMid <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#40;</span> yRadius <span style="color: #66cc66;">/</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span> theta <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">curveTo</span><span style="color: #66cc66;">&#40;</span> cx, cy, bx, by <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">// line 2</span>
			graphics.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span> 
				x + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span> startAngle + arc <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">180</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> innerXRadius, 
				y + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span> -<span style="color: #66cc66;">&#40;</span> startAngle + arc <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">180</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> innerYRadius 
			<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			theta = -<span style="color: #66cc66;">&#40;</span> segAngle <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">180</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span>;
			angle = -<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span> startAngle + arc <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">180</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">// inner arc</span>
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> j:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; j <span style="color: #66cc66;">&lt;</span> segs; j++ <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				angle -= theta;
				angleMid = angle + <span style="color: #66cc66;">&#40;</span> theta <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span>;
				bx = x + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span> angle <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> innerXRadius;
				by = y + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span> angle <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> innerYRadius;
				cx = x + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span> angleMid <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#40;</span> innerXRadius <span style="color: #66cc66;">/</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span> theta <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				cy = y + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sin</span><span style="color: #66cc66;">&#40;</span> angleMid <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#40;</span> innerYRadius <span style="color: #66cc66;">/</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span> theta <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				graphics.<span style="color: #0066CC;">curveTo</span><span style="color: #66cc66;">&#40;</span> cx, cy, bx, by <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>			
			graphics.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</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>Another note on this experiment: the SWF is 16k.  Holy crap.</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/actionscript-3/2008/custom-shapes-in-five3d-the-arc/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Runtime Libraries in Flex ActionScript Projects</title>
		<link>http://pixelwelders.com/blog/best-practices/2008/runtime-libraries-in-as3/</link>
		<comments>http://pixelwelders.com/blog/best-practices/2008/runtime-libraries-in-as3/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 09:15:33 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[ActionScript 3.0]]></category>

		<category><![CDATA[Best Practices]]></category>

		<guid isPermaLink="false">http://pixelwelders.com/blog/best-practices/2008/runtime-libraries-in-as3/</guid>
		<description><![CDATA[When working with Flash, there is really only one vector format worth worrying about, and that is SWF.  And furthermore, it turns out that there is a kinda slick way to import all the assets contained in a SWF into a Flex ActionScript project.  In the following class, I've just smoothed the process a little bit.]]></description>
			<content:encoded><![CDATA[<p><img src="http://pixelwelders.com/blog/wp-content/themes/tma/images/latest/library_470x175.jpg" alt="Runtime library" style="float:none"/></p>
<p>This is something I&#8217;ve begun using recently, and I thought I would post about it to see if I can help anyone else who&#8217;s been thinking about this.  I&#8217;ve seen some other articles on this, but they&#8217;ve had some shortcomings that I think I have improved on.  Of course, there&#8217;s room for tons of improvement on my class as well, so feel free to extend this to your little collective hearts&#8217; content.  The source is downloadable at the bottom of the page, or you can continue to the second page of this article to view it all without downloading.  Anyway: onward!</p>
<h3>The Need</h3>
<p>Okay, so: as a Flex developer who does a lot of ActionScript-only projects, I often run into situations in which I need to import some artwork.  This artwork may be in any number of formats, and they all require different solutions.  However, for a project that I&#8217;m working on now (which I would expound upon if it wasn&#8217;t [apparently] top-secret), I needed to import hundreds of little images in a vector format.  Furthermore, the client hinted that it would be nice, if not mandatory, to be able to swap out images later without sending it back to me for a recompile.  So, I had to do a bit of thinking.</p>
<p>However, it turns out that the solution is really not that hard.  When working with Flash, there is really only one vector format worth worrying about, and that is SWF.  And furthermore, it turns out that there is a kinda slick way to import all the assets contained in a SWF into a Flex ActionScript project.  In the following class, I&#8217;ve just smoothed the process a little bit.</p>
<h3>The Theory</h3>
<p>1- Create a MovieClip in Flash CS3 and check Export for ActionScript in its linkage properties.  Remember the class name that you give it, because you&#8217;re going to need that to pull this asset back out of its mother SWF.</p>
<p>2- Publish your SWF.  Make a note of where it&#8217;s going so you can load it in Flex.</p>
<p>3- In Flex, set up a Loader with the typical listeners (see my source below for details) and load the SWF.</p>
<p>4- Once the Loader has successfully loaded the SWF, the part you are interested in is the Loader&#8217;s contentLoaderInfo property (which is an instance of the LoaderInfo class, if you&#8217;d like to check the Flash help files for more information).  This property now contains the data from your Flash CS3 SWF.  Interestingly enough, a LoaderInfo class contains an instance of the ApplicationDomain class, which in turns contains all class definitions that are contained in that SWF.  Since you checked Export for ActionScript on your MovieClip, that means there is a definition for it in the ApplicationDomain of this LoaderInfo.  You just need to pull it out and instantiate it.</p>
<p>5- You have to do a little dancing around with types to get your MovieClip back out, since you will be pulling it out as an instance of Class, not as an instance of MovieClip.  However, with a couple lines of code, it&#8217;s easy enough to actually create an instance of your original Flash CS3-authored MovieClip.</p>
<h3>The Code</h3>
<p>Here are the vital parts of the code, as seen below in the source download link at the bottom of the page.  These are contained in a wrapper class that I wrote that surrounds Loader.contentLoaderInfo.</p>
<p>This is the handler that is called when the Loader successfully loads the SWF.  Notice that we save the LoaderInfo (called &#8220;contentLoaderInfo&#8221;) for later use.  This is the package of all the assets we have just imported.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript"><span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> handleLoadComplete<span style="color: #66cc66;">&#40;</span> event:Event <span style="color: #66cc66;">&#41;</span>: <span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	loaderInfo = loader.<span style="color: #006600;">contentLoaderInfo</span>;
	dispatchEvent<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">COMPLETE</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>And here is where the real magic happens, and it must be called after the above handler.  Notice how we get a real live Sprite instance from the definition in our LoaderInfo instance.  Plus, it looks just like the asset you created in Flash at the beginning of this article.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript"><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> getAsset<span style="color: #66cc66;">&#40;</span> id:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>: Sprite
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> Asset:<span style="color: #000000; font-weight: bold;">Class</span> = loaderInfo.<span style="color: #006600;">applicationDomain</span>.<span style="color: #006600;">getDefinition</span><span style="color: #66cc66;">&#40;</span> id <span style="color: #66cc66;">&#41;</span> as <span style="color: #000000; font-weight: bold;">Class</span>;			
	<span style="color: #b1b100;">return</span> Sprite<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> Asset<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h3>Summary</h3>
<p>This is as basic as it gets.  My source below extends this enough for me to use it in the aforementioned project (as well as adding some basic error handling), but this could be extended for all types of applications.  For instance, my class only returns instances of Sprites because that is what I am interested in.  However, you could also return the class itself (un-instantiated), or anything that you might find in LoaderInfo.applicationDomain.  The possibilities are&#8230; well, not limitless.  But more than you might think.</p>
<h3>Source</h3>
<p>The zip contains a RuntimeLibrary class (shown below), an example using it, and some sample assets in a SWF (with the matching FLA so you can see that they are nothing special- just Exported for ActionScript).  As you can see, I&#8217;m doing some basic error handling, but you may want to do something a little more robust; or, you may want the error.  Feel free to change whatever you want- that&#8217;s the beauty of open-source!</p>
<p><a href="http://pixelwelders.com/downloads/RuntimeLibrary/Pixelwelders_RuntimeLibrary.zip" onclick="javascript:pageTracker._trackPageview('/downloads/downloads/RuntimeLibrary/Pixelwelders_RuntimeLibrary.zip');">DOWNLOAD SOURCE</a></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript"><span style="color: #808080; font-style: italic;">/**
 * A utility to load a SWF at runtime.
 * This makes all definitions in the loaded SWF available.
 * You can use this to load graphics elements created in Flash CS3 into Flex ActionScript projects
 * 
 * @author	Zack Jordan
 * 			{ P I X E L W E L D E R S }
 * 			pixelwelders.com/blog
 */</span>
package com.<span style="color: #006600;">pixelwelders</span>.<span style="color: #006600;">graphics</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Loader</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">LoaderInfo</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: #006600;">events</span>.<span style="color: #006600;">ErrorEvent</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;">events</span>.<span style="color: #006600;">EventDispatcher</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;">net</span>.<span style="color: #006600;">URLRequest</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RuntimeLibrary <span style="color: #0066CC;">extends</span> EventDispatcher
	<span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> request				: URLRequest;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> loader				: Loader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> loaderInfo			: LoaderInfo;
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		 * Constructor- creates a new RuntimeLibrary
		 * 
		 * @param			nothing
		 * @return			The newly-created RuntimeLibrary 
		 */</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> RuntimeLibrary<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			request = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			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;">INIT</span>, handleLoadComplete <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> IOErrorEvent.<span style="color: #006600;">IO_ERROR</span>, handleIOError <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// === A P I ===</span>
		<span style="color: #808080; font-style: italic;">/**
		 * Loads a swf into this RuntimeLibrary
		 * 
		 * @param	url		the URL of the SWF to load
		 * @return			nothing
		 */</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">url</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>: <span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			request.<span style="color: #0066CC;">url</span> = <span style="color: #0066CC;">url</span>;
			loader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span> request <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		 * Creates and returns an instance of the specified class from the loaded SWF
		 * If the specified class does not exist, dispatches an ErrorEvent and returns an empty Sprite
		 * 
		 * @param	id		Name of the class in the loaded SWF
		 * @return			An instance of the specified class, or an empty Sprite if the class is not found
		 */</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getAsset<span style="color: #66cc66;">&#40;</span> id:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>: Sprite
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">try</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> Asset:<span style="color: #000000; font-weight: bold;">Class</span> = loaderInfo.<span style="color: #006600;">applicationDomain</span>.<span style="color: #006600;">getDefinition</span><span style="color: #66cc66;">&#40;</span> id <span style="color: #66cc66;">&#41;</span> as <span style="color: #000000; font-weight: bold;">Class</span>;
			<span style="color: #66cc66;">&#125;</span> <span style="color: #0066CC;">catch</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">error</span>:ReferenceError <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;Asset not found.&quot;</span> <span style="color: #66cc66;">&#41;</span>;
				dispatchEvent<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> ErrorEvent<span style="color: #66cc66;">&#40;</span> ErrorEvent.<span style="color: #0066CC;">ERROR</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">return</span> Asset ? Sprite<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> Asset<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// === E V E N T   H A N D L E R S ===</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleLoadComplete<span style="color: #66cc66;">&#40;</span> event:Event <span style="color: #66cc66;">&#41;</span>: <span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loaderInfo = loader.<span style="color: #006600;">contentLoaderInfo</span>;
			dispatchEvent<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">COMPLETE</span> <span style="color: #66cc66;">&#41;</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> handleIOError<span style="color: #66cc66;">&#40;</span> event:IOErrorEvent <span style="color: #66cc66;">&#41;</span>: <span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;load error: &quot;</span> + event.<span style="color: #0066CC;">text</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/best-practices/2008/runtime-libraries-in-as3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Compiling Astro with Flex 3</title>
		<link>http://pixelwelders.com/blog/flex/2008/setting-up-flash-player-10/</link>
		<comments>http://pixelwelders.com/blog/flex/2008/setting-up-flash-player-10/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 19:50:55 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[Flash 10 / Astro]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[Flash 10]]></category>

		<guid isPermaLink="false">http://pixelwelders.com/blog/flex/2008/setting-up-flash-player-10/</guid>
		<description><![CDATA[From my experience, I estimate that actually reading Adobe's instructions before trying this will save you approximately four and a half hours.]]></description>
			<content:encoded><![CDATA[<p><img src='http://pixelwelders.com/blog/wp-content/uploads/2008/06/astro2.jpg' alt='Flash Player 10' style="float:none" /></p>
<p>Nothing revolutionary today, folks, on account of the ridiculous amount of time I spent today trying to get Flex 3 to compile Flash 10 SWFs.  I had to use a combination of information from several sources, including the below:  </p>
<h3>Flash 10 / Astro Installation Guides</h3>
<table>
<tr>
<td><a href="http://labs.adobe.com/technologies/flashplayer10/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://labs.adobe.com/technologies/flashplayer10/');">Adobe&#8217;s official page</a></td>
<td>This is probably the place to start.</td>
</tr>
<tr>
<td><a href="http://www.boostworthy.com/blog/?p=240" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.boostworthy.com/blog/?p=240');">Ryan Taylor / Boostworthy</a></td>
<td>There are some interesting notes here.</td>
</tr>
<tr>
<td><a href="http://www.flexer.info/2008/05/21/how-to-build-flash-player-10-applications-using-flex-sdk/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.flexer.info/2008/05/21/how-to-build-flash-player-10-applications-using-flex-sdk/');">FLEX{er}</a></td>
<td>This is a rather terse (but illustrated!) guide.</td>
</tr>
</table>
<p>It would be pointless for me to go through it again, since I think they&#8217;ve pretty much got it covered.  However, there are a couple valuable things I learned:</p>
<h3>Setup Tips</h3>
<p>1- I couldn&#8217;t get things to work with the last &#8220;stable&#8221; build (May 16- v3.0.1.1732), so my advice would be to go with one of the more recent ones.  I&#8217;m using v3.0.1.1954, myself.</p>
<p>2- There is in fact a debug player, and it is <a href="http://opensource.adobe.com/svn/opensource/flex/sdk/branches/3.0.x/in/player/10/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://opensource.adobe.com/svn/opensource/flex/sdk/branches/3.0.x/in/player/10/');">here</a>.  I&#8217;m not sure why this isn&#8217;t mentioned in the documentation.</p>
<p>3- The debug player is standalone, so you won&#8217;t be able to debug in your browser.  Instead, in your launch configuration (Project > Properties > Run/Debug Settings > New (or Edit)), point the Debug URL to the actual SWF you&#8217;re producing, not the generated HTML page.  Then you can tell your OS to run SWFs with the standalone debug player, and then you&#8217;ll be able to actually see what you&#8217;re doing.</p>
<p>4- From my experience, I estimate that actually reading Adobe&#8217;s instructions before trying this will save you approximately four and a half hours.</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/flex/2008/setting-up-flash-player-10/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
