<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>guy in the chair . com &#187; Flex</title>
	<atom:link href="http://guyinthechair.com/tag/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://guyinthechair.com</link>
	<description>//the blog of Paul Taylor</description>
	<lastBuildDate>Fri, 18 Nov 2011 01:22:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>The Flex Framework and Modularity: A Manifesto</title>
		<link>http://guyinthechair.com/2010/01/modularity-a-manifesto/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=modularity-a-manifesto</link>
		<comments>http://guyinthechair.com/2010/01/modularity-a-manifesto/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 08:33:46 +0000</pubDate>
		<dc:creator>Paul Taylor</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[bitching]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[LayoutManager]]></category>
		<category><![CDATA[modularity]]></category>
		<category><![CDATA[UIComponent]]></category>

		<guid isPermaLink="false">http://guyinthechair.com/?p=164</guid>
		<description><![CDATA[If you haven&#8217;t watched Greg Burch&#8217;s excellent presentation on Slider at RIAdventure, you freakin should. Seriously, stop right now and watch it. But don&#8217;t forget about this blog post. Make sure to come back here after you&#8217;re done. The Soul of Flex Ok, from this point on I am going to assume you&#8217;ve done exactly as I [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-weight: normal; font-size: 13px;">If you haven&#8217;t watched Greg Burch&#8217;s <a title="Greg Burch's RIAdventure Slider Presentation" href="http://www.screencast.com/users/jwilker/folders/RIAdventure%202009/media/03101638-66d9-4792-97de-77a8fc7c053f" target="_blank">excellent presentation on Slider</a> at RIAdventure, you freakin should. Seriously, stop right now and watch it. But don&#8217;t forget about this blog post. Make sure to come back here after you&#8217;re done.</span></p>
<h2>The Soul of Flex<br />
<span style="font-weight: normal; font-size: 13px;">Ok, from this point on I am going to assume you&#8217;ve done exactly as I told you and watched Greg Burch&#8217;s <a title="Greg Burch's RIAdventure Slider Presentation" href="http://www.screencast.com/users/jwilker/folders/RIAdventure%202009/media/03101638-66d9-4792-97de-77a8fc7c053f" target="_blank">excellent presentation on Slider</a> at RIAdventure. Around 6 minutes in, Greg starts talking about the Soul of Flex. I didn&#8217;t have much time to consider it, but two things immediately came to mind: invalidation and styles. In the video you&#8217;ll hear me mention CSS but later agree with Greg that CSS or not, styles is the true feature.</span></h2>
<p>Of course, I agree with all the others he said were also part of the Soul: MXML, databinding, states, skinning, item renderers, containers, and components. But as I watched him remove items that weren&#8217;t part of the Soul of Flex, I thought to myself:</p>
<p style="padding-left: 30px;">&#8220;Self, this list is completely subjective and based entirely on my opinion. It is extremely likely that someone else&#8217;s definition of the Soul of Flex is different than mine, and who&#8217;s to say which one is right? Is it Adobe&#8217;s job? Now that they&#8217;ve packed a framework full of features that real people use, they&#8217;re going to remove a good many features simply because the they do not fall into Adobe&#8217;s definition of what the Soul is? That&#8217;s not right. The community is too diverse for that. Flex is the Soul of Flex.&#8221;</p>
<div id="attachment_170" class="wp-caption alignleft" style="width: 160px"><a href="http://guyinthechair.com/wp-content/uploads/2010/01/soul-of-flex.png" target="_blank"><img class="size-thumbnail wp-image-170" title="Soul of Flex" src="http://guyinthechair.com/wp-content/uploads/2010/01/soul-of-flex-150x150.png" alt="The real Soul of Flex" width="150" height="150" /></a><p class="wp-caption-text">I say Flex is the Soul of Flex.</p></div>
<p>This got me thinking about Flex with regards to mobile development. At the time of this writing, every Flex 4 component has a base class that is <a title="UIComponent" href="http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/projects/framework/src/mx/core/UIComponent.as" target="_blank">13,246 lines of code</a> (<a title="CLOC parser in JS" href="http://dnalot.com/SparkDataGrids/clocFx.html" target="_blank"><strong>1412</strong> blank lines, <strong>6423</strong> comment lines, and <strong>5411</strong> actual code lines.</a>) If you&#8217;re using Flex 4 and skinning, you have two components, so multiply potentially everything the UIComponent does by 2:</p>
<ul style="list-style-position: inside;">
<li>2x the UIComponents to initialize</li>
<li>2x the UIComponents added to the inheriting style chain</li>
<li>2x the UIComponents to make validation passes on</li>
<li>2x the event listeners that are registered</li>
<li>2x the number of objects for the DragProxy (in the DragManager) to find in its getObjectsUnderPoint() implementation</li>
<li>and on and on&#8230;</li>
</ul>
<p>This means one of two things. Either the decision to abstract skins into another UIComponent was monumentally retarded, or the UIComponent is too large and tries to do to many things. Since I believe the new skins are wonderful from an architectural/modularity standpoint, I have to pick the second choice: <strong>the UIComponent is too damn big</strong>. It tries to do too damn much. Let me reiterate: <strong>I love the new Spark skins. I hate the size of the UIComponent.</strong></p>
<h2>The Question of Responsibility<br />
<span style="font-weight: normal; font-size: 13px;">Why is the UIComponent (at the time of this writing) 13,246 lines long? The answer is features. The UIComponent violates the <a title="Single Responsibility Principle" href="http://en.wikipedia.org/wiki/Single_responsibility_principle" target="_blank">Single Responsibility Principle</a>. Here&#8217;s a list of most of the features the UIComponent encapsulates:</span></h2>
<ul>
<li>Invalidation &#8211; Implements IInvalidating.
<ul>
<li>Defines invalidate properties/size/displayList functions.</li>
<li>Defines validateNow function.</li>
</ul>
</li>
<li>Validation &#8211; Implements ILayoutManagerClient.
<ul>
<li>Defines the initialized, nestLevel, processedDescriptors, and updateCompletePendingFlag properties.</li>
<li>Defines validate properties/size/displayList functions.</li>
</ul>
</li>
<li>Styles &#8211; Implements IAdvancedStyleClient, the only visual class that does.</li>
<li>States &#8211; Implements IStateClient and IStateClient2 to support the new Fx4 states syntax.</li>
<li>Tooltips &#8211; Implements IToolTipManagerClient, the only component class that does.</li>
<li>Constraint-based layout.</li>
<li>IRepeaterClient &#8211; UIComponents (and subclasses) can be created by Repeaters.</li>
<li>Databinding.</li>
<li>Related to Databinding, implements IPropertyChangeNotifier.</li>
<li>Embedded fonts.</li>
<li>Focus &#8211; Doesn&#8217;t implement IFocusManagerComponent by name, but does implement the functions. Has a reference to the FocusManager and a focusPane property.</li>
<li>Validators &#8211; Implements IValidatorListener, which allows the UIComponent to respond to ValidationResultEvents dispatched by the Validator classes.</li>
<li>Modules &#8211; Implements IFlexModule, so if created by an IFlexModuleFactory, the factory stores a reference of itself on the UIComponent.</li>
<li>Explicit/measured- max/min &#8211; widths/heights.</li>
<li>Percent widths/heights.</li>
<li>Enabled/disabled.</li>
<li>Effects.</li>
<li>Special logic for adding/removing children.</li>
<li>All the events it creates and dispatches, including
<ol>
<li>Initialization events, like preInit and creationComplete.</li>
<li>FlexEvents like show, hide, move, resize</li>
<li>StateChangeEvents.</li>
<li>DragEvents for the List classes. Not part of the public API.</li>
<li>ToolTipEvents</li>
<li>FlexMouseEvents</li>
</ol>
</li>
</ul>
<p>Man, the UIComponent does a ton of stuff. We haven&#8217;t even gotten into the measurement, layout, containment, children handling, skinning, item renderers, or graphics functionality of Flex yet!</p>
<h2>The UIComponent is the base class for&#8230; everything<br />
<span style="font-weight: normal; font-size: 13px;">At least, everything visual. Not including Flex 3 skins. It&#8217;s the base class for all non-Fx3-skin-related visual elements.</span></h2>
<p>The UIComponent has so many responsibilities because it is the base class for so many controls. You want a Label or TextArea? They&#8217;re UIComponents. You want a Button? It&#8217;s a UIComponent. You want a container of Buttons? It&#8217;s a UIComponent.</p>
<p><span style="font-weight: normal; font-size: 13px;">But there are a few things I can&#8217;t figure out about this configuration:</span></p>
<ol>
<li>Why does a container need logic in its base class that accesses embedded fonts, or creates UITextFields from embedded font contexts (I checked, UITextField is the only class passed into createInFontContext()).</li>
<li>Similarly, why does a Label require any knowledge about processedDescriptors, states, or validators? Labels can&#8217;t have children, states, or validators. In fact, Labels can&#8217;t do much except display text. Why do they need to be IFlexModule objects? I could go on, but I think you get the point.</li>
</ol>
<p>There is a trend of WTFs like this about the UIComponent that can only be explained by, &#8220;it&#8217;s <strong>the</strong> base class and we&#8217;re trying to keep our API super clean.&#8221;</p>
<h2>There is a better way: Composited Modularity<br />
<span style="font-weight: normal; font-size: 13px;">Most of the functionality is already segregated by the liberal use of interfaces&#8230; now lets actually implement it that way.</span></h2>
<p>Almost all the functionality that the UIComponent (and subclasses of UIComponent for that matter) contains can be grouped into smaller, more discreet classes. Lets call them modules. Once this is done, the UIComponent simply exists to provide a unified API to the developer and glue with which to assemble the modules. More complex controls and components are simply composed of more complex modules.</p>
<p>For example, the functionality for embedded fonts should be isolated into its own module. Then, only the Label, Text, TextArea, and maybe some other controls that require direct access to embedded fonts need to include the &#8220;EmbeddedFontsModule.&#8221; This way, the VBox doesn&#8217;t have to include functionality for accessing embedded fonts.</p>
<p>Similarly, a VBox would include special modules for adding children, measurement, and layout. See, this is easy.</p>
<p><span style="font-weight: normal; font-size: 13px;">And while we&#8217;re at it, let&#8217;s rewrite the LayoutManager.</span></p>
<h2>You heard me. The LayoutManager. It&#8217;s in my sights.<br />
<span style="font-weight: normal; font-size: 13px;">What&#8217;s so special about 3-phased validation that it has to be hard-coded into the Flex framework? Is it phase ordering? Nest-level ordering? That&#8217;s not special. That&#8217;s algorithms.</span></h2>
<p>First, for those who don&#8217;t know, the LayoutManager is what enables Flex components to do the awesome 3-phase component lifecycle that we&#8217;ve all come to know and love. When a component is invalidated for a phase (say, invalidateProperties()), he registers with the LayoutManager. The LayoutManager adds the component to the proper invalidation queue. There are 3 invalidation queues, one for each validation phase. The invalidation queues are a special PriorityQueue implementation. This is important, because there is an order to the validation process.</p>
<p>Components have a nestLevel, which is really just their position in the display list. The Application&#8217;s nestLevel is 3. The nestLevel increases from there, so the lowest component in the display tree has the highest number.</p>
<p>When a component is added to the invalidatePropertiesQueue, it is added at its nestLevel priority. When the invalidatePropertiesQueue is processed, components with the lowest nestLevel, the ones closest to 0, are processed first. This is called &#8220;top-down&#8221; processing, because it starts at the top of the display list and processes to the bottom.</p>
<p>The commit phase does top-down processing, because generally parents can commit properties on themselves and change properties on their children, which will then get committed. The measure phase is from the bottom-up (can you guess what that means? If not, put it in the comments.), because a parent will often make a decision on his size based on the sizes of his children. The update phase is another top-down queue, because now that the sizes and positions are calculated, it&#8217;s time to lay them out. This is what makes percent widths/heights, scrollbars, etc. possible.</p>
<h3>Rethinking validation<br />
<span style="font-weight: normal; font-size: 13px;">Does validation have to be hardcoded? Are the 3 phases all that are needed? How hard would it be to switch to just 2? 4? 100?</span></h3>
<p>The fact is, the developer should be able to hook into the power of phased updates for himself. Why have a manager that only validates 3 hard-coded phases, when you could have a manager that validates an unlimited number of dynamic phases?<br />
<span style="font-weight: normal; font-size: 13px;">Well sure Paul, that sounds great and all, but it&#8217;s kind of a tough problem.</span> &lt;&#8211; Shut up alternate text, I&#8217;ve got a solution.</p>
<p>Keep the idea of nestLevel. It&#8217;s clear, clean, and definite. Change the idea of 3 hard-coded phases into an unlimited number of injected phases, based on priorities. Similar to nestLevel for components, priorities are arbitrarily defined by the developer. A priority is an Array of ints. It can be as simple as &#8220;1&#8243; or as complex as &#8220;1.2.3.4.&#8221; It is only used as a basis for comparison between other priorities. For example, priority 1.2 is greater than priority 1.2.1, since it is assumed 1.2.1 is a subset of 1.2. However, 1.200 is much greater than 1.2, because 200 &gt; 2. Do priorities make sense? If the answer is no, put it in the comments.</p>
<p>The idea is that a developer can invalidate a component for a certain phase. The phase has a priority (like 1.3), and a direction (UP or DOWN). The ValidationManager keeps a Heap of Heaps, sorted by priority. If it doesn&#8217;t find a Heap at the priority specified, it creates a new Heap, adds the IValidationClient to it, sets the proper sort direction (UP or DOWN) on it, then adds the new Heap to the Heap of Heaps. If it does find a Heap, it adds the IValidationClient to the Heap that it found.</p>
<p>When it comes time to Validate (on the next enter_frame event), the ValidationManager dequeues each Heap from the Heap of Heaps. Then it dequeues each item from each individual Heap, validating it as it goes.</p>
<p>The beauty of this is that the Flex component lifecycle can be perfectly mimicked. Set the three phases to happen one after another, and you can get the same results. For APIs sake, lets add a gap between them, so a third party developer can come by later and inject his own phases between the 3 usual phases. If we set commit at 1.3, measure at 1.5, and update at 1.7, this should give us enough of a gap for developers to use.</p>
<p>Say Developer X wants to add some extra <strong>umph</strong> to his custom component, but needs this processing needs to happen in-phase and inbetween the measure and update phases. He simply needs to inject his own validation phase anywhere between measure at 1.5 and update at 1.7, lets keep it simple and say 1.6, and BAM. ValidationManager will validate his phase right after measure and right before update.</p>
<p>This allows the developers a whole new avenue of development, something that they would have had to tack onto one of Flex&#8217;s 3 hard-coded phases before.</p>
<p><span style="font-weight: normal; font-size: 13px;"> This is all words. Where are the actions. You fail.</span></p>
<h2>This is where I introduce FlashWorks<br />
<span style="font-weight: normal; font-size: 13px;">FlashWorks is a component set for Flash and FlashBuilder, designed around the concepts of a tiny core API and modularity.</span></h2>
<p>It includes the ValidationManager and validation scheme I&#8217;ve outlined here, as well as a few other things:</p>
<ul>
<li>MXML development</li>
<li>Skinning similar to Flex 4</li>
<li>Graphics primitives (extend EventDispatcher)</li>
<li>Measurement and Layout controllers with support for percent widths/heights</li>
<li>Injectable Validation phases</li>
<li>States, including support for FB4&#8242;s new States syntax</li>
<li>Styles, through a controller that interfaces with <a title="F*CSS Flash CSS parsing" href="http://fcss.flashartofwar.com/" target="_blank">Jesse Freeman&#8217;s F*CSS</a></li>
<li>Databinding</li>
<li>SystemManager that works with FB4&#8242;s code generation, so the FlashWorks movie is 2 frames, just like Flex.</li>
<li>A modular, pay-as-you-go system, so functionality is only included when it&#8217;s used. For instance, the States controller isn&#8217;t included unless States are defined on the component.</li>
</ul>
<h2>Alright, here&#8217;s the code and demos</h2>
<p><font color="#000099">[Edit]</font> I&#8217;ve since moved from this project onto <a href="http://github.com/guyinthechair/reflex">Reflex</a>. I feel it has more of a chance for success than a solo framework by me would.<br />
I&#8217;m keeping the demo and demo code here as a proof of concept:<br />
Demo: <a title="FlashWorks demo" href="http://guyinthechair.com/misc/flashworks/FlashWorks.html" target="_blank">http://guyinthechair.com/misc/flashworks/FlashWorks.html</a><br />
Source code for demo: <a title="FlashWorks Demo Source" href="http://guyinthechair.com/misc/flashworks/srcview/index.html" target="_blank">http://guyinthechair.com/misc/flashworks/srcview/index.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://guyinthechair.com/2010/01/modularity-a-manifesto/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Understanding the Flex SystemManager</title>
		<link>http://guyinthechair.com/2010/01/understanding-the-flex-systemmanager/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=understanding-the-flex-systemmanager</link>
		<comments>http://guyinthechair.com/2010/01/understanding-the-flex-systemmanager/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 22:06:50 +0000</pubDate>
		<dc:creator>Paul Taylor</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[SystemManager]]></category>

		<guid isPermaLink="false">http://guyinthechair.com/?p=113</guid>
		<description><![CDATA[Before I start, let me say that there has been a lot of discussion about the SystemManager on various blogs. Deepa posted a fantastic write-up on the SystemManager back in October 07, which really got me interested in learning about it more. Working on Flex-less MXML is what finally pushed me to understand exactly why [...]]]></description>
			<content:encoded><![CDATA[<p>Before I start, let me say that there has been a lot of discussion about the SystemManager on various blogs. <a title="Deepa's fantastic blog on Flex" href="http://iamdeepa.com/blog/" target="_blank">Deepa</a> posted a fantastic <a title="SystemManager: Every Flex application's best friend" href="http://iamdeepa.com/blog/?p=11" target="_blank">write-up</a> on the SystemManager back in October 07, which really got me interested in learning about it more. Working on Flex-less MXML is what finally pushed me to understand exactly why it&#8217;s such a critical class. There&#8217;s a lot to cover about the SystemManager, from the behavior of the Flash Player to the behavior of the Flex compiler, so buckle up, cause this is a long one.</p>
<p><strong>Note 1: A recurring theme in this post is the fundamental behavior of the Flash Player. Flex would be nowhere without Flash, so if we desire true understanding of Flex, we must also understand the Flash Player.<br />
Note 2: For some of this, it is helpful to turn on the -keep-generated-actionscript flag in the FlashBuilder compiler options. To do this, go to Project &#8211;&gt; Properties &#8211;&gt; Flex Compiler. In the &#8220;Additional compiler arguments&#8221; field, type &#8220;-keep&#8221; at the end of the arguments list. FlashBuilder generates ActionScript from all your MXML, including a dynamic subclass of SystemManager. This will instruct FlashBuilder to place that code in the bin-debug/generated folder.</strong></p>
<p><span style="font-weight: normal; font-size: 14px;">To understand the SystemManager, you must first understand that&#8230;</span></p>
<h2>Every Flex Application is a 2-Frame Flash Movie</h2>
<p><img class="alignleft size-full wp-image-114" title="2 Frame Flash Movie" src="http://guyinthechair.com/wp-content/uploads/2010/01/loader_content_flash.png" alt="2 Frame Flash Movie" width="302" height="63" /> Yes, every one of them. The Flash Player is capable of downloading just the data for the first frame and streaming the rest of the movie. Therefore a trend started in the earlier days of Flash-only developing; you typically put a very small loader object on your first frame that displays the loading progress of the rest of the SWF to the user. That way the user has a visual indication that something is happening, and the movie gets preloaded to a point where the user won&#8217;t experience any playback hiccups.</p>
<h2>That is awesome&#8230; why do I care?<br />
<span style="font-weight: normal; font-size: 14px;">Good question. First, lets examine the implications of Flash&#8217;s load-and-stream feature:</span></h2>
<p>From a movie perspective if frames aren&#8217;t loaded, the movie stops until they are loaded. If the movie is constantly experiencing this, the movie&#8217;s framerate essentially becomes a function of the speed of the user&#8217;s internet connection.<br />
From a code perspective, <strong>if frames aren&#8217;t fully loaded, classes can&#8217;t be accessed</strong>. Calling <code>new MyObject()</code> will throw a runtime error, &#8220;1065: Variable MyObject is not defined.&#8221; This is because the frame that contains the definition for that class hasn&#8217;t been fully loaded.</p>
<h2>Oh I see now, so we need a small preloader on the first frame?<br />
<span style="font-weight: normal; font-size: 14px;">Exactly. All that silly Flash that we thought we left behind when we became &#8220;Enterprise Flex Developers&#8221; has come back to bite us in the ass. But never fear, the SystemManager is here.</span></h2>
<p><strong>The SystemManager is a fancy MovieClip</strong>. The SystemManager has a few duties, including:</p>
<ul>
<li>Create and initialize the pre-loader to show to the user during app load and startup.</li>
<li>Manage loading in RSLs.</li>
<li>Manage module logic. If the SystemManager is the root of the SWF, he knows he is a Flex Application. If he is not the root of the SWF, he knows he is a module, and must communicate with whichever SystemManager is the root of the SWF (see if you can spot the logical flaw of the assumption made in that sentence, there will be a quiz later). SystemManager must communicate events both ways between modules/app, such as mouse and keyboard events.</li>
<li>Manage Event.RESIZE events dispatched from the Stage.</li>
<li>Manages the embedded fonts list</li>
<li>Initializes the various manager singletons, such as ResourceManager and StylesManager.</li>
<li>Manages top-level application windows. The SystemManager maintains a <code>cursorChildren</code> list and a <code>popUpChildren</code> list, for tooltips and pop-up windows respectively.</li>
<li>Once all the code for the movie is loaded, SystemManager creates your actual Application instance and calls <code>initialize()</code>.</li>
<li>Adds the Application to the stage once the Application dispatches its FlexEvent.CREATION_COMPLETE event. This is why the Application doesn&#8217;t have a reference to the stage when its FlexEvent.CREATION_COMPLETE is dispatched, when all the other components do.</li>
</ul>
<h2>How it works<br />
<span style="font-weight: normal; font-size: 14px;">How the SystemManager does its thing. Matching colors are event listening/dispatching pairs.</span></h2>
<table border="0">
<tbody>
<tr>
<td>
<h3>Frame 1</h3>
</td>
<td>
<h3>Frame 2</h3>
</td>
</tr>
<tr>
<td width="50%">
<ul>
<li>stop()</li>
<li>listen for player <span style="color: #ff0000;">init</span> event</li>
<li><span style="color: #ff0000;">init</span> dispatched:
<ol>
<li>get root SystemManager (if we&#8217;re not the top level)</li>
<li> listen for <span style="color: #ff6600;">enterFrame event</span></li>
<li>create preloader</li>
<li>listen for <span style="color: #66FF00;">preloaderDocFrameReady</span> from preloader</li>
<li>listen for <span style="color: #999900;">complete</span> from preloader</li>
<li>load RSLs and wait</li>
<li>RSLs loaded. <span style="color: #66FF00;">preloaderDocFrameReady</span> dispatched by preloader
<ul>
<li><span style="color: #3366ff;">Timer created</span> to go run nextFrame() after 100 milliseconds</li>
</ul>
</li>
<li>Exactly 10 milliseconds after preloaderDocFrameReady dispatched, <span style="color: #999900;">complete</span> dispatched by preloader</li>
<li><span style="color: #3366ff;">Timer event</span> dispatched, nextFrame() called/<span style="color: #ff6600;">enterFrame handler</span> triggered</li>
</ol>
</li>
</ul>
</td>
<td width="50%">
<ul>
<li>Managers initialized.</li>
<li>Stage Resize listener added.</li>
<li>Application instance created.</li>
<li>listener for Application <span style="color: #ff00ff;">creationComplete</span> added</li>
<li>nextFrame()</li>
<li>Application <span style="color: #ff00ff;"> creationComplete</span> dispatched
<ol>
<li>Preloader removed</li>
<li>Application added to the stage</li>
<li>applicationComplete event dispatched</li>
</ol>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<h2>Hold on, I&#8217;m a Flex developer. I don&#8217;t work with frames.<br />
<span style="font-weight: normal; font-size: 14px;">I don&#8217;t have access to the timeline of my SWF. Actually, you do.</span></h2>
<p>It&#8217;s through an undocumented meta tag, [Frame], which is really just a shortcut for the -frames compiler option. You can <a title="[Frame] meta tag explanation" href="http://blogs.adobe.com/rgonzalez/2006/06/modular_applications_part_2.html" target="_blank">read all about the frame meta tag</a> at Roger Gonzalez&#8217;s blog, but here&#8217;s the gist of it: If you add the [Frame] meta tag to the top of the Application class of your project, the Flex compiler will insert a frame before the frame that your Application is on. If you specify the factoryClass property on the meta tag, the Flex compiler will generate a subclass of whichever class you specify as the factory, and put that on the frame it creates. If you open up the mx.core.Application class, you&#8217;ll see the line [Frame(factoryClass="mx.managers.SystemManager")] near the top. This tells the Flex compiler to create a frame before the mx.core.Application, and attach a generated subclass of mx.managers.SystemManager.</p>
<p>The Flex compiler will generate a subclass of your factory class that implements <code>IFlexModuleFactory</code>. As long as your SystemManager implements IFlexModuleFactory, your code will compile. The Flex compiler overrides the info() method and returns information specific to your Application, such as a list of embedded fonts and the name of your Application.</p>
<p>And with this meta tag, you can override the default SystemManager implementation. As Roger says, &#8220;if the [Frame] metadata exists on the base class of your application, a subclass of the factory will be generated. If the metadata is directly on your application class, it will be honored, but no subclass will be generated; its assumed that you&#8217;ve already written the appropriate factory.&#8221;</p>
<h2>Why this is cool</h2>
<p>Most Flex developers will never even know the SystemManager exists, and they shouldn&#8217;t have to. Adobe has done a good job of masking Flash behind a more professional, Java-like framework with Flex. If you want to write an app with zero dependence on the Flex framework, but still use the fantastic FlashBuilder IDE, debugger/profiler, MXML, and binding, this is really good to know. You can write an Application based on Sprite, write your own stripped down version of the SystemManager, and then write MXML and take advantage of Flex&#8217;s bindings and generated code. Rock on.</p>
]]></content:encoded>
			<wfw:commentRss>http://guyinthechair.com/2010/01/understanding-the-flex-systemmanager/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Particle Emitter Publishing Tool</title>
		<link>http://guyinthechair.com/2009/11/particle-emitter-publishing-tool/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=particle-emitter-publishing-tool</link>
		<comments>http://guyinthechair.com/2009/11/particle-emitter-publishing-tool/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 07:19:34 +0000</pubDate>
		<dc:creator>Paul Taylor</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[BitmapFilter]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Tweensy]]></category>

		<guid isPermaLink="false">http://guyinthechair.com/?p=61</guid>
		<description><![CDATA[I&#8217;m tired, so I&#8217;m going to keep this quick. The Emitter class by Tweensy is fantastic and fun to use, but it&#8217;s not easy to imagine what an effect will look like without coding up an example. That&#8217;s why I&#8217;ve put together a publishing tool for Tweensy&#8217;s particle Emitter. I&#8217;m using 15 sample particles embedded [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m tired, so I&#8217;m going to keep this quick. The <a href="http://docs.flashdynamix.com/tweensy/fx/index.html?com/flashdynamix/motion/extras/Emitter.html&amp;com/flashdynamix/motion/extras/class-list.html" target="_blank">Emitter</a> class by <a href="http://www.lostinactionscript.com/blog/index.php/2009/01/05/tweensy-goes-public/" target="_blank">Tweensy</a> is fantastic and fun to use, but it&#8217;s not easy to imagine what an effect will look like without coding up an example.</p>
<p>That&#8217;s why I&#8217;ve put together a publishing tool for Tweensy&#8217;s particle Emitter. I&#8217;m using 15 sample particles embedded in a SWF, <a href="http://guyinthechair.com/wp-content/flex/emitterfx/assets/particles/particles.swf" target="_blank">which you can download here</a>. <a href="http://guyinthechair.com/wp-content/flex/emitterfx/index.html" target="_blank">Launch the editor here</a>.</p>
<p>Some features of this editor include:</p>
<ul>
<li>The ability to save configurations to a file to be loaded again later (serializing the data to AMF and reading it in to restore state). This means your designers can fiddle with the animations and then email you the configuration.</li>
<li>A code generater for each Emitter and each BitmapFilter applied, which means you can load up the configuration the designers sent you and pretty much copy/paste the code into your project.</li>
</ul>
<p>I will update to add more effects, like the <a href="http://docs.flashdynamix.com/tweensy/fx/index.html?com/flashdynamix/motion/effects/PerlinDisplacementEffect.html&amp;com/flashdynamix/motion/effects/class-list.html" target="_blank">PerlinDisplacementEffect</a> that helps with the <a href="http://www.tweensy.org/examples/fireSmokeFX.html" target="_blank">really cool fire effects</a> Tweensy is capable of, but for now this is what I&#8217;ve got.</p>
<p>Once you add an emitter, you&#8217;ll need to set at least the emission frequency, emission randomness, and particle life to see anything happen. After that I suggest moving the X/Y coords and turning on either the Blur filter or the ColorTransform filter. Changing the start and end colors does some dramatic things, as well as fiddling with the blendMode (I suggest either Normal or Add). If you&#8217;ve got any questions or feature requests, leave them in the comments. Good luck!</p>
<p><span style="color: #339966;">Update</span>: Here&#8217;s two sample emitters to start off with: <a href="http://guyinthechair.com/wp-content/flex/emitterfx/configurations/particleEffect1.amf">Effect 1</a> and <a href="http://guyinthechair.com/wp-content/flex/emitterfx/configurations/fireworks.amf">Fireworks</a> (right click and &#8220;Save as&#8230;&#8221;, keeping the .amf extension).</p>
<p><span style="color: #339966;">Update 2</span>: Added the PerlinDisplacementEffect. Try it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://guyinthechair.com/2009/11/particle-emitter-publishing-tool/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Physics and Flex: Box2DFlashAS3 meets Flex</title>
		<link>http://guyinthechair.com/2009/10/physics-and-flex-box2dflashas3-meets-flex/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=physics-and-flex-box2dflashas3-meets-flex</link>
		<comments>http://guyinthechair.com/2009/10/physics-and-flex-box2dflashas3-meets-flex/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 09:17:51 +0000</pubDate>
		<dc:creator>Paul Taylor</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[MXML]]></category>

		<guid isPermaLink="false">http://guyinthechair.com/?p=26</guid>
		<description><![CDATA[Update: I have since abandoned this project in favor of the PushButton Engine, which wraps Box2D and provides a better graphics and component set than I could hope to achieve on my own. So far this has served as a useful academic exercise, and I will keep the code here for future reference. The Setup [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ffcc00;">Update</span><span style="color: #ffcc00;">:</span> I have since abandoned this project in favor of the <a title="PushButton Engine" href="http://pushbuttonengine.com/" target="_blank">PushButton Engine</a>, which wraps Box2D and provides a better graphics and component set than I could hope to achieve on my own. So far this has served as a useful academic exercise, and I will keep the code here for future reference.</p>
<h3>The Setup</h3>
<p>For those not in the know, <a title="Box2D" href="http://www.box2d.org/" target="_blank">Box2D</a> is an open source 2D physics engine for C++. There are many ports of it, and luckily there&#8217;s one for <a title="Box2D Flash AS3" href="http://box2dflash.sourceforge.net/" target="_blank">AS3 (Box2DFlashAS3)</a>. The current version (2.0.2) looks very similar to the C++ version, and might be a straight port (I&#8217;m not entirely sure). It follows the C++ syntax of class prefixes and allows public access to (what should be) internal member variables. 2.1 promises cleaned up syntax and fixed accessor types, but until then, the library can seem daunting to the uninitiated.</p>
<h3>The Problem</h3>
<p>The main problem is that Box2D doesn&#8217;t define a (reusable) way to graphically represent objects on the screen. It only simulates the interactions between the objects mathematically. This is very efficient, but not very convenient if you need to rapidly prototype a physics based application. There are <a title="Box2d Flash World Construction Kit" href="http://www.sideroller.com/wck/" target="_blank">tools</a> to <a title="b2ide Flash components" href="http://code.google.com/p/b2ide/" target="_blank">build</a> Box2D worlds for the Flash environment, but they emphasize working within the Flash IDE. I hate and loathe the Flash IDE (not AS3 projects themselves, mind you). I want something tailored for Flex. I want something that fits into the rapid application development cycle of most Flex apps, which means I want to use MXML. I want to stay up to date with the Box2D project, so when 2.1 does roll around, I won&#8217;t have to rewrite application code.</p>
<h3>The Solution</h3>
<p>Enter FlexWorld. FlexWorld is a framework for graphical representation of Box2D bodies. It is most similar to the <a title="Box2D Flash World Construction Kit" href="http://www.sideroller.com/wck/" target="_blank">World Construction Kit</a>, but is meant exclusively for Flex. You get all the benefits of Flex, including the <a href="http://livedocs.adobe.com/flex/3/langref/mx/managers/LayoutManager.html" target="_blank">LayoutManager</a>, styles, events, data binding, and MXML.</p>
<h3>The Demo</h3>
<p><a href="http://guyinthechair.com/wp-content/flex/flexWorld/demo/index.html" target="_blank">FlexWorld Demo (launches in a new window)</a></p>
<h3>How it Works</h3>
<p>FlexWorld starts with a PhysicalWorld, which is a subclass of <a title="The Container class" href="http://livedocs.adobe.com/flex/3/langref/mx/core/Container.html" target="_blank">Container</a>. PhysicalWorld has boundaries determined by its width and height. Children of the PhysicalWorld are typically subclasses of the abstract class PhysicalBody (which extends <a title="The UIComponent class" href="http://livedocs.adobe.com/flex/3/langref/mx/core/UIComponent.html" target="_blank">UIComponent</a>). Right now, only the PhysicalBox and PhysicalCircle classes are available. World initialization happens only when you say it does, and clean up is as efficient as can be. To get going, initialize the world: PhysicalWorld#createWorld. Then, you can register each PhysicalBody with the world by calling PhysicalWorld#registerBody. This is to ensure proper instantiation and update. When the world is ready to go, just call PhysicalWorld#activate, and it will start rendering.</p>
<h3>In-Phase updates</h3>
<p>PhysicalWorld renders by calling PhysicalBody#update on each PhysicalBody registered with it. This render cycle falls into the commitProperties phase of the component lifecycle (more on that <a title="About the component instantiation life cycle" href="https://www.adobe.com/livedocs/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&amp;file=ascomponents_advanced_148_05.html" target="_blank">here</a> and <a title="About the steps for creating a component" href="https://www.adobe.com/livedocs/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&amp;file=ascomponents_advanced_148_06.html#219779" target="_blank">here</a>). This ensures that properties are changed at the beginning of the lifecycle, just before commits will happen. If the render is meant to continue, updateDisplayList (which is at the end of the update cycle) will call UIComponent#invalidateProperties on the PhysicalWorld.</p>
<h3>Where is this going</h3>
<p>This is a very alpha release. Everything that you see works, and not much else. The shapes aren&#8217;t interactive yet, and they don&#8217;t do much drawing beyond what you see. Nothing is documented (and I&#8217;m horrible at keeping up with it), I don&#8217;t even have an SVN repository set up yet. Right now it&#8217;s primarily an interesting proof-of-concept rather than a useful tool. I&#8217;ll be developing it more for a project I&#8217;m currently on, and hopefully I&#8217;ll roll those changes in.</p>
<h3>The Source</h3>
<p>The source for the demo is <a title="FlexWorld demo source" href="http://guyinthechair.com/wp-content/flex/flexWorld/demo/srcview/index.html" target="_blank">here</a>.<br />
The source for the library (including Box2DFlashAS3 2.0.2) is <a title="FlexWorld library source" href="http://guyinthechair.com/wp-content/flex/flexWorld/source/FlexWorld.zip" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://guyinthechair.com/2009/10/physics-and-flex-box2dflashas3-meets-flex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex Equalizer</title>
		<link>http://guyinthechair.com/2009/01/flex-equalizer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-equalizer</link>
		<comments>http://guyinthechair.com/2009/01/flex-equalizer/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 02:00:04 +0000</pubDate>
		<dc:creator>Paul Taylor</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://guyinthechair.com/?p=13</guid>
		<description><![CDATA[This is not a new concept in Flash, but as far as I could tell, there weren&#8217;t many solutions for this in Flex. Here&#8217;s my stab at doing an equalizer. Watch out for your ears, the volume is set to 100% by default. http://guyinthechair.com/wp-content/flex/equalizer/EqualizerApplication.html Fixed I do have one small problem with it, and I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>This is not a new concept in Flash, but as far as I could tell, there weren&#8217;t many solutions for this in Flex. Here&#8217;s my stab at doing an equalizer. Watch out for your ears, the volume is set to 100% by default.</p>
<p><a title="Equalizer" href="http://guyinthechair.com/wp-content/flex/equalizer/EqualizerApplication.html" target="_self">http://guyinthechair.com/wp-content/flex/equalizer/EqualizerApplication.html</a></p>
<p><span style="color: #00ff00;">Fixed</span><br />
I do have one small problem with it, and I&#8217;m working to figure it out&#8230; for reasons unknown to me the <span style="font-family: 'Courier New'; white-space: pre;">SoundMixer.computeSpectrum</span> function will return a null array sometimes. I have absolutely no clue why, and I&#8217;m open to any suggestions as to why. It only errors in the first 5 seconds.</p>
<p><span style="color: #ffff00;"><span style="color: #00ff00;">Update:</span></span> Figured it out. The problem was that I was relying on EnterFrame to call the render method on the equalizer. Unfortunately, EnterFrame could potentially be dispatched before the sound file was loaded from the server, therefore <span style="font-family: 'Courier New'; white-space: pre;">computeSpectrum</span> wouldn&#8217;t have any sound data to work with. This would cause <span style="font-family: 'Courier New'; white-space: pre;">computeSpectrum</span> to return me a null array.</p>
]]></content:encoded>
			<wfw:commentRss>http://guyinthechair.com/2009/01/flex-equalizer/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Flex 3 Debugger anomaly</title>
		<link>http://guyinthechair.com/2009/01/flex-3-debugger-anomaly/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-3-debugger-anomaly</link>
		<comments>http://guyinthechair.com/2009/01/flex-3-debugger-anomaly/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 20:36:45 +0000</pubDate>
		<dc:creator>Paul Taylor</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[debugger]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://guyinthechair.com/?p=11</guid>
		<description><![CDATA[Working today, I discovered the debugger does something silly with for loops. If you have code formatted like so: var i:int = 0;var foo:int = 3;for(; i &#60; foo; i++){        //Code here} If you set a breakpoint on line 3, where the for loop is defined, the Flex debugger will only stop after it [...]]]></description>
			<content:encoded><![CDATA[<p>Working today, I discovered the debugger does something silly with <span style="font-family: 'Courier New'; white-space: pre;">for</span> loops. If you have code formatted like so:<br/><br />
<span style="font-family: 'Courier New'; white-space: pre;">var i:int = 0;<br/>var foo:int = 3;<br/>for(; i &lt; foo; i++){<br/>        //Code here<br/>}</span><br/><br />
If you set a breakpoint on line 3, where the for loop is defined, the Flex debugger will only stop <strong>after it has been through one iteration of the loop</strong>. This caught me off guard, and for a minute I thought it was immediately incrementing the iterator. Only when I breakpointed on both the line of the <span style="font-family: 'Courier New'; white-space: pre;">for</span> loop and on the first line inside my loop did I realize what was happening. The debugger stopped on the first line of my loop, not when it executed the condition the first time. This does not seem like standard debugger behavior at all. Does this happen to everyone? I know if you define the iterator inline, the debugger stops. Huh.</p>
]]></content:encoded>
			<wfw:commentRss>http://guyinthechair.com/2009/01/flex-3-debugger-anomaly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

