<?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>I swore I wouldn&#039;t &#187; Client</title>
	<atom:link href="http://www.wontblog.com/category/client/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wontblog.com</link>
	<description>Oh no, I&#039;m blogging now?</description>
	<lastBuildDate>Wed, 23 Feb 2011 20:06:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Fun with the Flex component loading order</title>
		<link>http://www.wontblog.com/2010/04/18/flex-component-loading-order/</link>
		<comments>http://www.wontblog.com/2010/04/18/flex-component-loading-order/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 01:27:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Client]]></category>
		<category><![CDATA[component load]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[using flex makes me feel guilty]]></category>

		<guid isPermaLink="false">http://www.wontblog.com/?p=40</guid>
		<description><![CDATA[I have a Flex component that I have written that consists of a tabbed navigator that houses several panels, each panel housing a Flex datagrid.  An action in another component triggers an url to load and populate these datagrids.  The problem that I encountered was that if the datagrid had not yet been viewed, then [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="Flex loading order" src="http://img.skitch.com/20100418-cdanfj2umxdqagsjme5jbf1cui.png" alt="" width="439" height="274" /><br />
I have a Flex component that I have written that consists of a tabbed navigator that houses several panels, each panel housing a Flex datagrid.  An action in another component triggers an url to load and populate these datagrids.  The problem that I encountered was that if the datagrid had not yet been viewed, then the datagrid would not be created yet, and as such, the event listener that populates the datagrid was never fired.</p>
<p>The solution for this was actually quite simple.  <span id="more-40"></span>I attached an event handler to the datagrid&#8217;s creationComplete event:</p>
<blockquote><p><code><br />
...<br />
creationComplete="dgCreated(event);"<br />
...</code></p>
<p><code> protected function dgCreated(event:FlexEvent):void {<br />
dgEventListeners(event.target as DataGrid);<br />
}</code></p>
<p><code>protected function dgEventListeners(dg:DataGrid):void {<br />
dg.addEventListener(DataGridEvent.ITEM_EDIT_BEGINNING,setFieldToEdit);<br />
dg.addEventListener(DataGridEvent.ITEM_EDITOR_CREATE,loadMetaDataCombo);<br />
dg.addEventListener(DataGridEvent.ITEM_EDIT_END,onItemEditEnd);<br />
dgLoad(dg);<br />
}</code></p>
<p><code> </code><code>protected function dgLoad(dg:DataGrid):void {<br />
// code to load the actual datagrid with the appropriate data<br />
}<br />
</code></p></blockquote>
<p>There is some other code in there related to some inline editing code that I wrote, but my approach was essentially for the following to occur:</p>
<p><img class="alignnone" title="Simple flow" src="http://img.skitch.com/20100418-qqjabe9cpfc81n8nyk1pf9cx66.png" alt="" width="370" height="72" /></p>
<p>Given more time, I&#8217;ll likely convert the majority of the Flex to AS3 as I feel that the load process is much more transparent and easier to control, but for now, this is operating as intended.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wontblog.com/2010/04/18/flex-component-loading-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

