<?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 } &#187; Flex</title>
	<link>http://pixelwelders.com/blog</link>
	<description>Flash + Flex + Game Dev + Grammar?</description>
	<pubDate>Tue, 04 Nov 2008 14:18:05 +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>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>
		<item>
		<title>Broadcasting Events from Custom MXML Components - The [Event] Tag</title>
		<link>http://pixelwelders.com/blog/flex/2008/mxml-embed-tag/</link>
		<comments>http://pixelwelders.com/blog/flex/2008/mxml-embed-tag/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 09:05:31 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[Flex]]></category>

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

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

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

		<guid isPermaLink="false">http://pixelwelders.com/blog/flex/2008/mxml-embed-tag/</guid>
		<description><![CDATA[Okay, this was hard for me to wrap my brain around, so let me summarize, in case anyone else is stuck on this.  When developing in Flex, all the standard components let you specify a listener when you create them in MXML, like this:

&#60;mx:Button id=&#34;someButton&#34; click=&#34;handleClick( event );&#34;/&#62;

Now when someone clicks on someButton, it [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, this was hard for me to wrap my brain around, so let me summarize, in case anyone else is stuck on this.  When developing in Flex, all the standard components let you specify a listener when you create them in MXML, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx:Button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;someButton&quot;</span> <span style="color: #000066;">click</span>=<span style="color: #ff0000;">&quot;handleClick( event );&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span></pre></div></div>

<p>Now when someone clicks on <code>someButton</code>, it calls the function <code>handleClick()</code>. Although not strictly best practice, it really is a nice little shorthand for adding an event listener to a Flex component.  And since the Adobe components contain this functionality, people are used to it.  If you have any plans of releasing your component into the wild, people will expect it to act like the components they already know and love.</p>
<p>Well, here’s how you do it: with the <code>[Event]</code> metadata tag.</p>
<p>1- First of all, the tag goes before the class declaration because it applies to the entire class.  You can actually have more than one of these tags, for different events that you might broadcast.  In my example, I have two, and they both broadcast <code>ModelEvent</code>s.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript"><span style="color: #808080; font-style: italic;">// create the [Event] tags</span>
<span style="color: #66cc66;">&#91;</span>Event<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;onLoad&quot;</span>, <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;com.pixelwelders.events.ModelEvent&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #66cc66;">&#91;</span>Event<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;onLoadError&quot;</span>, <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;com.pixelwelders.events.ModelEvent&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// declare your class</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DataModel <span style="color: #0066CC;">extends</span> EventDispatcher <span style="color: #0066CC;">implements</span> IModel <span style="color: #66cc66;">&#123;</span> ...</pre></div></div>

<p>2- The <code>type</code> attribute refers to the actual type of event that this class broadcasts, package and all.</p>
<p>3- The <code>name</code> attribute refers to the string you use when you create a new Event of this type.  You have to use an actual literal here; you can’t use a variable like <code>ModelEvent.LOADED</code>.  So if you are dispatching an event like either of these:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript">dispatchEvent<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> ModelEvent<span style="color: #66cc66;">&#40;</span> ModelEvent.<span style="color: #0066CC;">LOADED</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
dispatchEvent<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> ModelEvent<span style="color: #66cc66;">&#40;</span> ModelEvent.<span style="color: #006600;">LOAD_ERROR</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>&#8230;you’ll need to check in your Event class to see what the actual value of <code>LOADED</code> or <code>LOAD_ERROR</code> is.  In my ModelEvent class, I have:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript"><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const <span style="color: #0066CC;">LOADED</span>				: <span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;onLoad&quot;</span>;
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const LOAD_ERROR			: <span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;onLoadError&quot;</span>;</pre></div></div>

<p>Thus, my complete Event metadata tags are:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript"><span style="color: #66cc66;">&#91;</span>Event<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;onLoad&quot;</span>, <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;com.pixelwelders.events.ModelEvent&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #66cc66;">&#91;</span>Event<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;onLoadError&quot;</span>, <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;com.pixelwelders.events.ModelEvent&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></pre></div></div>

<p>Of course, that’s only the first part of the equation.  The second part is listening for the event, which thanks to our <code>[Embed]</code> tags, is now a piece of figurative cake.  Here’s my Flex tag:</p>

<div class="wp_syntax"><div class="code"><pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;model:DataModel</span>
		<span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;dataModel&quot;</span>
		<span style="color: #000066;">xmlURL</span>=<span style="color: #ff0000;">&quot;fileName.xml&quot;</span> 
		<span style="color: #000066;">onLoad</span>=<span style="color: #ff0000;">&quot;handleModelLoaded( event );&quot;</span>
		<span style="color: #000066;">onLoadError</span>=”handleModelError<span style="color: #66cc66;">&#40;</span> event <span style="color: #66cc66;">&#41;</span>;”<span style="font-weight: bold; color: black;">/&gt;</span></span></pre></div></div>

<p>That <code>onLoad</code> and <code>onLoadError</code> attributes have the same value as your name attributes that you specified in step 3 above.  Now put your two handlers in your <code>Script</code> tag, and they will be called any time those events are fired.  Voilà.</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/flex/2008/mxml-embed-tag/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MXML Singletons in Flex 3</title>
		<link>http://pixelwelders.com/blog/flex/2008/mxml-singletons-in-flex-3/</link>
		<comments>http://pixelwelders.com/blog/flex/2008/mxml-singletons-in-flex-3/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 09:04:27 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[ActionScript 3.0]]></category>

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

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

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

		<guid isPermaLink="false">http://pixelwelders.com/blog/flex/2008/mxml-singletons-in-flex-3/</guid>
		<description><![CDATA[Okay, so I've been putting together a little image-viewer component in Flex, and I wanted it to load one data model that all other components would share.  Sounds like a job for a Singleton, right?  However, I also wanted to instantiate said model from MXML, which adds some kinks.  In fact, I've <a href="http://www.onflex.org/ted/2007/01/singleton-in-mxml.php">heard it said</a> that it's not possible at all.  And after some trial and error, I found that apparently it is possible- you just have to hack around a little bit.  ]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re not clear on what a Singleton is, try glancing through my brief yet poignant article here: <a href="http://pixelwelders.com/blog/best-practices/2008/art-and-beauty-of-singletons-in-as3/" >The Art and Beauty of Singletons</a>.</p>
<h3>Creating a Singleton through MXML</h3>
<p>	Okay, so I&#8217;ve been putting together a little image-viewer component in Flex, and I wanted it to load one data model that all other components would share.  Sounds like a job for a Singleton, right?  However, I also wanted to instantiate said model from MXML, which adds some kinks.  In fact, I&#8217;ve <a href="http://www.onflex.org/ted/2007/01/singleton-in-mxml.php" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.onflex.org/ted/2007/01/singleton-in-mxml.php');">heard it said</a> that it&#8217;s not possible at all.  And after some trial and error, I found that apparently it is possible- you just have to hack around a little bit.  </p>
<p>If you instantiate your class (or &#8220;component&#8221;) through MXML, Flex will automatically call its constructor.  Typically, this is a bad thing because you don&#8217;t call constructors directly in Singletons- instead of calling a method that returns a <em>new</em> object (i.e. a constructor), you call a method that returns a reference to an already-created object (<code>getInstance()</code> or <code>instance()</code>).  Flex won&#8217;t do that for you.  However, this is not a deal-breaker.  To make that class a Singleton, you just need to make sure that the constructor is only called once.</p>
<p>So, set up your Singleton like normal:</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;">var</span> _instance: DataModel = <span style="color: #000000; font-weight: bold;">null</span>;
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> instance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>: DataModel
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">return</span> _instance;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Then, in the constructor of said Singleton, add the following:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">!</span>_instance <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	_instance = <span style="color: #0066CC;">this</span>;
<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;DataModel is a Singleton: only one instance allowed.&quot;</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>All I&#8217;ve done here is move the creation of the Singleton from the <code>get instance()</code> method to the constructor.  And if the constructor is called more than once, it throws an error.  Now you can instantiate the class through MXML, just like any other component.</p>

<div class="wp_syntax"><div class="code"><pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;model:DataModel</span>
		<span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;dataModel&quot;</span>
		<span style="color: #000066;">xmlURL</span>=<span style="color: #ff0000;">&quot;fileName.xml&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></pre></div></div>

<p>Meanwhile in Actionscriptland, you can refer to this instance of your class just like it was a normal Singleton:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript">	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> DataModel.<span style="color: #006600;">instance</span> <span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// traces &quot;[object DataModel]&quot;</span></pre></div></div>

<p>	Plus, if you try to create another instance, be it through MXML or through ActionScript, you&#8217;ll get a good ol&#8217; runtime error.  You’ll have to wait until runtime to see it, but that’s certainly better than nothing, right?</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/flex/2008/mxml-singletons-in-flex-3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flex 3 + Game Dev = Awesome</title>
		<link>http://pixelwelders.com/blog/game-design/2008/flex-3-game-dev-is-awesome/</link>
		<comments>http://pixelwelders.com/blog/game-design/2008/flex-3-game-dev-is-awesome/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 16:45:52 +0000</pubDate>
		<dc:creator>Zack Jordan</dc:creator>
		
		<category><![CDATA[Flex]]></category>

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

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

		<guid isPermaLink="false">http://pixelwelders.com/blog/?p=31</guid>
		<description><![CDATA[First of all, a synopsis of this entry so you don't have to read the whole thing. First, I'm going to reminisce in a slightly condescending tone.  Then, I'm going to suddenly switch tacks and turn my reminiscence into a rather awkward metaphor about how Flex rocks.  Then I'll say something like "download Adobe Flex 3 <a href="http://www.adobe.com/products/flex/">here</a> and try it for game development."  So if that's enough to convince you, you can stop reading here.  If not, read on!  There's another link to download the Flex trial at the bottom of this post.]]></description>
			<content:encoded><![CDATA[<p>	<strong>&#60;Synopsis!&#62;</strong><br />
	First of all, a synopsis of this entry so you don&#8217;t have to read the whole thing. First, I&#8217;m going to reminisce in a slightly condescending tone.  Then, I&#8217;m going to suddenly switch tacks and turn my reminiscence into a rather awkward metaphor about how Flex rocks.  Then I&#8217;ll say something like &#8220;download Adobe Flex 3 <a href="http://www.adobe.com/products/flex/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.adobe.com/products/flex/');">here</a> and try it for game development.&#8221;  So if that&#8217;s enough to convince you, you can stop reading here.  If not, read on!  There&#8217;s another link to download the Flex trial at the bottom of this post.<br />
<strong>&#60;/Synopsis!&#62;</strong></p>
<p>	A few years ago, before my brilliant web career, I lived a very different life.  I worked in a small studio in downstate Illinois as a songwriter and producer.  This was not quite as awesome as it sounds.  Usually it meant dealing with clients who were pretty convinced of their own brilliance, who brought me lyrics scratched on stained and wrinkled napkins.  “It goes like this,” they would say, and hum me a series of unrelated notes.</p>
<p><img src='http://pixelwelders.com/blog/wp-content/uploads/2008/03/emo-kid_350.jpg' alt='Emo kid' style="margin-right:10px;" /></p>
<p>	My job was to take this stained napkin and these notes and, through a sort of studio alchemy, synthesize an actual song.  I acted as an amplifier for the natural talent of the client.  If she thought she might want some drums, I was the drummer.  If this called for some keyboard or guitar, then that was my job too.  If there was a note a client didn’t like or a harmony that didn’t seem to work, it was my job to suggest a better one.  I became an extension of the client- the whole point of my employment being to make each artist sound <em>better than they actually were.</em></p>
<p>	Okay, now let’s make the awkward jump to the other side of this too-obvious metaphor.  The hapless client is now the Flash developer.  The studio is now the Flash player and development environment.  And the producer, the guy who amplifies your strengths and fills in for your weaknesses&#8230; that producer is Flex 3.</p>
<p>	Yes, it’s an awkward metaphor.  I realize this.  But it’s very important to me that I evangelize Flex as much as possible, and this particular comparison makes a lot of sense in my head.  Actionscript 3 dropped a ton of new functionality in our laps- the Flash Player 9 API is like five times the size of Flash Player 8’s.  In many ways, the AS2 expert, the Java developer, and the AS newbie are all in the same boat (to mix metaphors) when it comes to starting AS3.  It’s a room full of powerful equipment and there’s no one to ask for help.</p>
<p><img src='http://pixelwelders.com/blog/wp-content/uploads/2008/03/flex1.jpg' alt='Flex Assistance' style="float:none"/></p>
<p>	So that’s why I am evangelizing Flex 3.  If you’ve been using the Flash CS3 compiler, you’re going to freak when you start using the Flex 3 compiler.  Seriously, it’s that awesome.  And Flex itself provides a ridiculous amount of help in the form of auto-completion and code hints.  It’s like that producer.  You say “I’d like to make a call to that BadGuy class I made three weeks ago.”  Flex 3 says, “Awesome!  You’ll need to send it the following five parameters, of these five types, in this order.”  As soon as you mistype a variable name Flex is there with a friendly reminder: “Ahem.  The ScoreKeeper class only accepts Numbers.  I suggest you change your approach.”  No more thirty-second compiles in Flash only to find that you have errors in your code.  It’s instant- Flex checks your syntax <em>and</em> compiles every time you save.</p>
<p><img src='http://pixelwelders.com/blog/wp-content/uploads/2008/03/flex2.jpg' alt='Flex Errors' style='float:none;'/></p>
<p>	Okay, I’m getting carried away here.  I can’t help it- I’ve only recently started using Flex for game development, and it’s changed the way I code.  I know you FlashDevelop and Eclipse folks have had these functions forever, but it&#8217;s new to me.  I can get twice as much done in half the time, with a third of the frustration.  Or something.  So if you haven’t tried Flex for your game development, I suggest you give it a whirl.  Adobe even gives you a 60-day trial <a href="http://www.adobe.com/products/flex/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.adobe.com/products/flex/');">here</a>.  Seriously, how can you lose?</p>
<p><strong>Credits</strong><br />
The studio above is <a href="http://profile.myspace.com/noisegaterecording" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://profile.myspace.com/noisegaterecording');">The Noisegate</a>, in Pekin IL.  It&#8217;s a beautiful studio, and Mike Layne (lead engineer) is a great guy.  Tell &#8216;em I sent you.</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelwelders.com/blog/game-design/2008/flex-3-game-dev-is-awesome/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
