<?xml version="1.0" encoding="utf-8"?>

			<rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://web.resource.org/cc/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">

			<channel>
			<title>Brian Kotek: Inversion of Control - Flex</title>
			<link>http://www.briankotek.com/blog/index.cfm</link>
			<description>Brian Kotek on ColdFusion, Flex, AIR, Java, Groovy, Design Patterns, and Object-Oriented Programming</description>
			<language>en-us</language>
			<pubDate>Tue, 07 Sep 2010 10:50:16 -0700</pubDate>
			<lastBuildDate>Mon, 16 Aug 2010 13:12:00 -0700</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>brian428@briankotek.com</managingEditor>
			<webMaster>brian428@briankotek.com</webMaster>
			<itunes:subtitle></itunes:subtitle>
			<itunes:summary></itunes:summary>
			<itunes:category text="Technology" />
			<itunes:category text="Technology">
				<itunes:category text="Podcasting" />
			</itunes:category>
			<itunes:category text="Technology">
				<itunes:category text="Tech News" />
			</itunes:category>
			<itunes:keywords></itunes:keywords>
			<itunes:author></itunes:author>
			<itunes:owner>
				<itunes:email>brian428@briankotek.com</itunes:email>
				<itunes:name></itunes:name>
			</itunes:owner>
			
			<itunes:explicit>no</itunes:explicit>
			
			
			
			
			
			<item>
				<title>Swiz Example Application Demonstrating Module Support</title>
				<link>http://www.briankotek.com/blog/index.cfm/2010/8/16/Swiz-Example-Application-Demonstrating-Module-Support</link>
				<description>
				
				I just pushed a new sample application called &lt;a href=&quot;http://github.com/swiz/swiz-examples/tree/master/SwizModuleExample-Flex4/&quot; target=&quot;_blank&quot;&gt;SwizModuleExample-Flex4&lt;/a&gt; to GitHub. This example is meant to demonstrate the various ways that Swiz supports the use of modules. The key ideas demonstrated are:

&lt;ul&gt;
&lt;li&gt;Loading a Module&lt;/li&gt;
&lt;li&gt;Detecting full creation of a Module (not just the ModuleEvent.READY event)&lt;/li&gt;
&lt;li&gt;Dispatching events from a root Swiz instance that are mediated by all Modules&lt;/li&gt;
&lt;li&gt;Dispatching events from a root Swiz instance to a specific Module&lt;/li&gt;
&lt;li&gt;Dispatching events from a Module that are mediated in the root Swiz instance&lt;/li&gt;
&lt;li&gt;Dispatching events from a Module that are mediated by other Modules.&lt;/li&gt;
&lt;li&gt;Injecting Beans that are defined in a root Swiz instance into a child Swiz instance.&lt;/li&gt;
&lt;/ul&gt;

While this example is really meant to be looked through at the code level, I have a &lt;a href=&quot;http://www.briankotek.com/blog/files/swiz_modules_example/Main.html&quot; target=&quot;_blank&quot;&gt;running version with View Source enabled&lt;/a&gt; that you can look at as well. I hope folks find this example helpful!
				
				</description>
				
				
				<category>Flex</category>
				
				<category>Swiz</category>
				
				<pubDate>Mon, 16 Aug 2010 13:12:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2010/8/16/Swiz-Example-Application-Demonstrating-Module-Support</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>CFUnited Clean Code and Swiz Presentations Now Online</title>
				<link>http://www.briankotek.com/blog/index.cfm/2010/8/4/CFUnited-Clean-Code-and-Swiz-Presentations-Now-Online</link>
				<description>
				
				Just a quick note that, as promised, my presentations from CFUnited are now online!

&lt;a href=&quot;http://slidesix.com/view/Brian-Kotek--Clean-Code--CFUnited-2010&quot; target=&quot;_blank&quot;&gt;Clean Code&lt;/a&gt;

&lt;a href=&quot;http://slidesix.com/view/Brian-Kotek--Swiz--CFUnited-2010&quot; target=&quot;_blank&quot;&gt;The Swiz Framework for Flex and ActionScript&lt;/a&gt;

Thanks to all who attended!
				
				</description>
				
				
				<category>Development</category>
				
				<category>Flex</category>
				
				<category>Conferences</category>
				
				<category>Presentations</category>
				
				<category>Swiz</category>
				
				<pubDate>Wed, 04 Aug 2010 15:33:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2010/8/4/CFUnited-Clean-Code-and-Swiz-Presentations-Now-Online</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Latest Chrome breaks Flash Debug player! Here&apos;s how to fix it.</title>
				<link>http://www.briankotek.com/blog/index.cfm/2010/6/30/Latest-Chrome-breaks-Flash-Debug-player-Heres-how-to-fix-it</link>
				<description>
				
				I&apos;ve been using Chrome since someone created an AdBlock plugin for it. I love the browser, but the latest version of Chrome broke my ability to debug Flash and Flex applications using the debug player. This also kills the ability to use the Flash Builder Profiler. The fact that Chrome silently updates itself made this one of those &quot;WTF&quot; moments, since everything was working fine yesterday. It took me a while to track down the problem, so I thought I would save anyone reading this the pain.

It looks like this was caused by having their built-in Flash player enabled by default in the latest version of Chrome. The browser seems to want to use this version of the player even if you have the real Flash debug player installed as well! Luckily, the fix is simple (if not obvious): point Chrome at the URL &quot;about:plugins&quot;, locate the built-in version of Flash player in the list, and disable it. Make sure you have the correct debug player also listed in the plugin list and that it is active. Restart Chrome and you&apos;re good to go.
				
				</description>
				
				
				<category>Flex</category>
				
				<pubDate>Wed, 30 Jun 2010 09:07:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2010/6/30/Latest-Chrome-breaks-Flash-Debug-player-Heres-how-to-fix-it</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Apple HTML 5 Fail</title>
				<link>http://www.briankotek.com/blog/index.cfm/2010/6/21/Apple-HTML-5-Fail</link>
				<description>
				
				This isn&apos;t new news, but I&apos;ve been meaning to make this picture for a week or two and finally got around to it. :-)

&lt;img src=&quot;http://www.briankotek.com/blog/images/apple_html_5_fail.jpg&quot; /&gt;
				
				</description>
				
				
				<category>General</category>
				
				<category>Flex</category>
				
				<pubDate>Mon, 21 Jun 2010 09:37:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2010/6/21/Apple-HTML-5-Fail</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Using the Swiz AutowiredTestCase</title>
				<link>http://www.briankotek.com/blog/index.cfm/2010/6/15/Using-the-Swiz-AutowiredTestCase</link>
				<description>
				
				One of the utility classes that is part of the Swiz library is AutowiredTestCase. As the name implies, you can use this class to help test your Swiz applications. 

In this case, code will show what&apos;s going on much better than doing a lot of typing, so here is a sample FlexUnit 4 test case. First, the class under test:

&lt;code&gt;js|
package com.briankotek.flex4swiztests.control
{
	import com.briankotek.flex4swiztests.event.MyEvent;
	import flash.events.IEventDispatcher;

	public class MyController
	{
		
		[Dispatcher]
		public var dispatcher : IEventDispatcher;
		
		public var didSomething : Boolean = false;
		
		[Mediate( event=&quot;MyEvent.CONTROLLER_ACTION_REQUESTED&quot; )]
		public function handleAction() : void
		{
			didSomething = true;
			actionComplete();
		}
		
		private function actionComplete() : void
		{
			dispatcher.dispatchEvent( new MyEvent( MyEvent.CONTROLLER_ACTION_COMPLETE ) );
		}
		
	}
}
&lt;/code&gt;

You can see this is a simple controller, which responds to the CONTROLLER_ACTION_REQUESTED event, updates a property, and then dispatches CONTROLLER_ACTION_COMPLETE. We want to test that the controller is responding to the correct event, property updating the property, and finally dispatching the completion event.

The event itself is a simple event class:

&lt;code&gt;js|
package com.briankotek.flex4swiztests.event
{
	import flash.events.Event;
	
	public class MyEvent extends Event
	{
		public static const CONTROLLER_ACTION_REQUESTED : String = &quot;controllerActionRequested&quot;;
		public static const CONTROLLER_ACTION_COMPLETE : String = &quot;controllerActionComplete&quot;;
		
		public function MyEvent(type:String)
		{
			super(type, true, false);
		}
	}
}
&lt;/code&gt;

Finally, the test case itself:

&lt;code&gt;js|
package com.briankotek.flex4swiztests.control
{
	import com.briankotek.flex4swiztests.control.MyController;
	import com.briankotek.flex4swiztests.event.MyEvent;
	import org.flexunit.Assert;
	import org.flexunit.async.Async;
	import org.swizframework.core.*;
	import org.swizframework.utils.test.AutowiredTestCase;

	public class MyControllerTestCase extends AutowiredTestCase
	{	
		private var myController : MyController;
		
		[Before]
		public function setUp():void
		{
			myController = new MyController();
			
			swizConfig = new SwizConfig();
			swizConfig.eventPackages = &quot;com.briankotek.flex4swiztests.event.*&quot;;
			
			beanProviders = [new BeanProvider( [myController] )];
		}
		
		[After]
		public function tearDown():void
		{
			myController = null;
		}
		
		[Test(async)]
		public function testControllerActionRequested() : void
		{
			Assert.assertTrue( &quot;Controller property is already true.&quot;, myController.didSomething == false );	
			Async.handleEvent( this, swiz.dispatcher, MyEvent.CONTROLLER_ACTION_COMPLETE, checkEvent ); 
			swiz.dispatcher.dispatchEvent( new MyEvent( MyEvent.CONTROLLER_ACTION_REQUESTED ) );
		}
		
		private function checkEvent( event : Event, passThroughData : Object ) : void
		{
			Assert.assertTrue( &quot;Controller property was not updated.&quot;, myController.didSomething == true );	
		}
		
	}
}
&lt;/code&gt;

I start off setting up an instance of Swiz that my test can use. AutowiredTestCase has a method marked with [Before] metadata, so that FlexUnit runs it before each test. I create an instance of the class under test (MyController), then set the event packages on the SwizConfig. Finally, I place the MyController instance into a BeanProvider, so that Swiz will process it as a bean. This way, any Swiz metadata in MyController is processed.

The test method dispatches a CONTROLLER_ACTION_REQUESTED event. If all goes well, the mediated event in the controller should run, update the property, and then the controller will dispatch the completion event. Running the test produces a passing result, so everything is working as expected!

Note that because Swiz actually processes your test case itself as a bean, you can use Swiz metadata in your test if you want or need to. So injecting a dispatcher, mediating an event, or testing custom metadata processors are all possible as well.
				
				</description>
				
				
				<category>Unit Testing</category>
				
				<category>Flex</category>
				
				<category>Swiz</category>
				
				<pubDate>Tue, 15 Jun 2010 09:27:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2010/6/15/Using-the-Swiz-AutowiredTestCase</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Swiz 1.0RC Released! So here&apos;s an updated example, custom ViewMediator, and more</title>
				<link>http://www.briankotek.com/blog/index.cfm/2010/5/19/Swiz-10RC-Released-So-heres-an-updated-example-custom-ViewMediator-and-more</link>
				<description>
				
				There&apos;s a lot of good news from the Swiz world today. First, we just released the &lt;a href=&quot;http://github.com/swiz/swiz-framework/zipball/v1.0.0-RC1&quot; target=&quot;_blank&quot;&gt;Swiz 1.0 Release Candidate&lt;/a&gt;, which fixes a number of small bugs in the beta and adds numerous new features. This version should be pretty much feature-complete, so at this point we&apos;ll be focused on fixing any issues that come up. A final 1.0 should be out in the next few weeks.

I did my best to help out with this release by working hard on updated documentation. You can see the fruits of this labor on the new &lt;a href=&quot;http://swizframework.jira.com/wiki/display/SWIZ/Home&quot; target=&quot;_blank&quot;&gt;Swiz documentation wiki&lt;/a&gt; we&apos;ve created through JIRA Studio. You can also sign up to enter feature requests or bugs, vote on issues, and all the other good stuff that JIRA provides. If you have any feedback on the documentation, feel free to leave a wiki comment and we&apos;ll do our best to address it.

I&apos;ve also created a &lt;a href=&quot;http://www.briankotek.com/blog/files/swiz_10_rc_example/Main.html&quot; target=&quot;_blank&quot;&gt;Swiz 1.0RC version of my example application&lt;/a&gt;. If you like, you can &lt;a href=&quot;http://www.briankotek.com/blog/files/swiz_10_rc_example/srcview/index.html&quot; target=&quot;_blank&quot;&gt;view or download the source code&lt;/a&gt;. 


Since 1.0RC removes the option for &quot;view injection&quot; into a bean, folks have asked about ways to handle providing a view to a Swiz bean. I created a &lt;a href=&quot;http://wiki.github.com/brian428/swiz-viewmediatorlib/&quot; target=&quot;_blank&quot;&gt;MediateView custom metadata extension&lt;/a&gt; that should handle most of these needs. I&apos;ll do my best to keep it up to date as I get feedback about it.

And finally, in the &quot;better late than never&quot; department, I&apos;ve uploaded the &lt;a href=&quot;http://slidesix.com/view/Swiz--Brian-Kotek--cfObjective&quot; target=&quot;_blank&quot;&gt;Swiz presentation I gave at cf.Objective() 2010&lt;/a&gt; to SlideSix. I&apos;ll also be speaking on Swiz at this year&apos;s &lt;a href=&quot;http://www.cfunited.com&quot; target=&quot;_blank&quot;&gt;CFUnited conference&lt;/a&gt;. If you&apos;re planning on going, I&apos;m happy to talk about Swiz into the wee hours of the morning!
				
				</description>
				
				
				<category>Flex</category>
				
				<category>Conferences</category>
				
				<category>Presentations</category>
				
				<category>Swiz</category>
				
				<pubDate>Wed, 19 May 2010 09:56:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2010/5/19/Swiz-10RC-Released-So-heres-an-updated-example-custom-ViewMediator-and-more</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Swiz Example Application Updated to Support Swiz 1.0 Beta</title>
				<link>http://www.briankotek.com/blog/index.cfm/2010/3/5/Swiz-Example-Application-Updated-to-Support-Swiz-10-Beta</link>
				<description>
				
				Update on 8/16/10: With the release of Swiz RC1, &lt;a href=&quot;http://www.briankotek.com/blog/index.cfm/2010/5/19/Swiz-10RC-Released-So-heres-an-updated-example-custom-ViewMediator-and-more&quot; target=&quot;_blank&quot;&gt;I released an updated version of this example application&lt;/a&gt;.

With the &lt;a href=&quot;http://swizframework.org/2010/03/swiz-1-0-0-beta-now-available/&quot; target=&quot;_blank&quot;&gt;release of the 1.0 Beta of the Swiz framework&lt;/a&gt;, I&apos;ve updated my &lt;a href=&quot;http://www.briankotek.com/blog/files/swiz_10_beta_example/Main.html&quot; id=&quot;l10.&quot; title=&quot;Swiz example application&quot;  target=&quot;_blank&quot;&gt;Swiz example application&lt;/a&gt; to the latest version. You can also &lt;a href=&quot;http://www.briankotek.com/blog/files/swiz_10_beta_example/srcview/&quot; id=&quot;wc4v&quot; title=&quot;view the source code&quot;  target=&quot;_blank&quot;&gt;view the source code&lt;/a&gt; if you like. I&apos;d like to point out a few things that I had to change from the example based on version 0.6.4:&lt;br&gt;
&lt;br&gt;&lt;ul&gt;&lt;li&gt;The instantiation of the framework has changed in order to support multiple instances of Swiz, primarily for Flex module support:&lt;br&gt;
&lt;code&gt;xml|
&lt;swiz:SwizConfig id=&quot;mySwizConfig&quot;
                 eventPackages=&quot;com.briankotek.swizdemo.event&quot;
                 viewPackages=&quot;com.briankotek.swizdemo.view&quot;
                 defaultFaultHandler=&quot;{genericFault}&quot; /&gt;

&lt;swiz:Swiz id=&quot;mySwiz&quot; beanProviders=&quot;{[Beans]}&quot; config=&quot;{mySwizConfig}&quot; /&gt;
&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The static methods on the Swiz class have been removed, due to the fact that there can now be multiple instances of Swiz. This means that instead of doing something like Swiz.dispatchEvent( event ), you now want to inject a dispatcher object into your non-view objects and dispatch events through it instead. The two main ways to do this are to inject the dispatcher in your BeanLoader/BeanProvider, or by having your class implement the IDispatcherAware interface, which will instruct Swiz to inject the dispatcher automatically.&lt;/li&gt;
&lt;li&gt;The [Autowire] metadata tag has been deprecated in favor of the more industry-standard [Inject]. [Autowire] will still work for now, but be aware that this may be removed in a future release.&lt;/li&gt;
&lt;li&gt;The use of the earlier CommandChain has changed to support more robust and extensible chains, as well as supporting internal Flex event-based chains on top of the existing support for chains that make server calls. For example:&lt;br&gt;
&lt;code&gt;js|
var chain : CommandChain = new CommandChain();&lt;br&gt;
chain.addMember( new AsyncChainStepCommand( delegate.deleteUser, [user], userDeleteHandler ) );&lt;br&gt;
chain.addMember( new AsyncChainStepCommand( delegate.deleteUserProfileImage, [user], userProfileImageDeleteHandler ) );&lt;br&gt;
chain.addEventListener( &quot;chainComplete&quot;, userDeleteCompleteHandler, false, 0, true );&lt;br&gt;
chain.start();
&lt;/code&gt;
&lt;/li&gt;&lt;/ul&gt;
Anyway, that&apos;s all for now, but I&apos;ll be posting more about the Swiz updates soon. If you&apos;re interested in seeing more about 1.0, have a look at &lt;a href=&quot;http://blog.foomonger.com/2010/02/26/swiz-signals-and-mediatesignal/&quot; target=&quot;_blank&quot;&gt;Sam Ahn&apos;s demo of Swiz using AS3Signals&lt;/a&gt;. A very cool use of the brand new custom metadata support now available in Swiz!
				
				</description>
				
				
				<category>Flex</category>
				
				<category>Swiz</category>
				
				<pubDate>Fri, 05 Mar 2010 08:59:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2010/3/5/Swiz-Example-Application-Updated-to-Support-Swiz-10-Beta</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Swiz 1.0 Beta is Live!</title>
				<link>http://www.briankotek.com/blog/index.cfm/2010/3/1/Swiz-10-Beta-is-Live</link>
				<description>
				
				This morning, the Swiz team released the &lt;a href=&quot;http://www.swizframework.org/files/swiz-v1.0.0-beta.swc&quot; target=&quot;_blank&quot;&gt;1.0 Beta of the Swiz Framework&lt;/a&gt;. You can view the extensive list of updates at the &lt;a href=&quot;http://swizframework.org/2010/03/swiz-1-0-0-beta-now-available/&quot; target=&quot;_blank&quot;&gt;Swiz web site&lt;/a&gt;. Have a look and try out the new features. We&apos;ll be doing a full update of the documentation as we prepare for the final release. I also have an updated version of my sample application about ready, and I will upload it and highlight the differences between 0.6.4 and 1.0. Stay tuned!
				
				</description>
				
				
				<category>Flex</category>
				
				<category>Swiz</category>
				
				<pubDate>Mon, 01 Mar 2010 11:29:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2010/3/1/Swiz-10-Beta-is-Live</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>My CFinNC Presentations at SlideSix</title>
				<link>http://www.briankotek.com/blog/index.cfm/2009/10/22/My-CFinNC-Presentations-at-SlideSix</link>
				<description>
				
				I&apos;ve uploaded my &lt;a href=&quot;http://www.cfinnc.com&quot; target=&quot;_blank&quot;&gt;CFinNC&lt;/a&gt; presentations to SlideSix for anyone who&apos;s interested:

&lt;a href=&quot;http://slidesix.com/view/Brian-Kotek--CFinNC--OO-Design-Principles-Final&quot; target=&quot;_blank&quot;&gt;Object-Oriented Design Principles&lt;/a&gt;

&lt;a href=&quot;http://slidesix.com/view/Swiz--Brian-Kotek--CFinNC&quot; target=&quot;_blank&quot;&gt;Introduction to Swiz&lt;/a&gt;

Overall, CFinNC was great. I actually had to work for a large chunk of the weekend so aside from presenting and mingling with folks later in the evening, I didn&apos;t get to attend many other sessions. That said, everything looked top-notch while I was there. The conference unfolded very smoothly and all of the attendees seemed very engaged. Hats off to Dan Wilson and the entire volunteer team for pulling this off! This conference definitely held its own against the other CF conferences I&apos;ve attended. It was very difficult to tell that it was completely free. Hopefully we can do it again next year!
				
				</description>
				
				
				<category>Development</category>
				
				<category>ColdFusion</category>
				
				<category>OOP CF</category>
				
				<category>Flex</category>
				
				<category>Conferences</category>
				
				<category>Presentations</category>
				
				<category>Swiz</category>
				
				<pubDate>Thu, 22 Oct 2009 12:02:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2009/10/22/My-CFinNC-Presentations-at-SlideSix</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Flex DataGridColumn Complex Properties Bug and Workaround</title>
				<link>http://www.briankotek.com/blog/index.cfm/2009/10/9/Flex-DataGridColumn-Complex-Properties-Bug-and-Workaround</link>
				<description>
				
				One Flex limitation I&apos;ve had to work around for a long time is the need for having a complex property name as the dataField for a DataGridColumn, like this:

&lt;code&gt;&lt;mx:DataGridColumn headerText=&quot;Client&quot; dataField=&quot;client.name&quot; /&gt;&lt;/code&gt;

I had written a nice, generic, custom labelFunction as well as a custom NestedPropertyDataGridColumn to handle this, and it all seemed to work well.

I just discovered that the Flex team had addressed this in the Flex 3.4 SDK update, though I don&apos;t think you&apos;d ever know it since I couldn&apos;t find any actual note that this was added. The only reason I discovered this was actually looking at the source code, and then finding &lt;a href=&quot;https://bugs.adobe.com/jira/browse/SDK-9801&quot; target=&quot;_blank&quot;&gt;this ticket&lt;/a&gt; in the Flex issue tracker.

So yay, we can use complex properties in our DataGridColumns now! Except...&lt;a href=&quot;http://bugs.adobe.com/jira/browse/SDK-23643&quot; target=&quot;_blank&quot;&gt;it&apos;s broken&lt;/a&gt;.

Ugh. Really, guys on the Flex team? This was added and no one ever bothered to click on the column to sort it? Hmph.

Anyway, as one workaround, you can use a custom DataGridColumn combined with a custom Sort to get proper sorting in most cases:

&lt;code&gt;js|
package com.briankotek.util.datagrid
{

import mx.collections.ListCollectionView;
import mx.controls.DataGrid;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.core.mx_internal;
use namespace mx_internal;

/**
 * A custom DataGridColumn that supports sorting a column that has a nested child property path for the dataField value.
 */
public class DataGridColumnNested extends DataGridColumn
{
	public function DataGridColumnNested( columnName : String = null )
	{
		super( columnName );
	}

	/**
	 * Override itemToLabel to force a ComparableSort custom sort class onto the parent DataGrid dataProvider.
	 * This works around a bug in sorting columns with complex property names in the dataField value.
	 * @param data
	 * @return
	 */
	override public function itemToLabel( data : Object ) : String
	{
		var parent : DataGrid;
		if( owner &amp;&amp; owner is DataGrid )
		{
			parent = owner as DataGrid;

			if( hasComplexFieldName &amp;&amp; parent &amp;&amp; parent.sortableColumns &amp;&amp; parent.dataProvider is ListCollectionView &amp;&amp;
				(
					!( ListCollectionView( parent.dataProvider ).sort ) ||
					!( ListCollectionView( parent.dataProvider ).sort is ComparableSort )
				)
			  )
			{
				ListCollectionView( parent.dataProvider ).sort = new ComparableSort();
			}
		}
		return super.itemToLabel( data );
	}

}
}
&lt;/code&gt;

&lt;code&gt;js|
package com.briankotek.util.datagrid
{
import mx.collections.Sort;
import mx.collections.SortField;

/**
 * Custom Sort class that forces the correct compareFunction for a given field to be used.
 */
public class ComparableSort extends Sort
{
	public function ComparableSort()
	{
		super();
	}

	override public function findItem( items:Array, values:Object, mode:String, returnInsertionIndex:Boolean = false, compareFunction:Function = null ):int
	{
		if( !compareFunction &amp;&amp; fields &amp;&amp; fields.length &amp;&amp; fields[0] is SortField &amp;&amp; SortField( fields[0] ).compareFunction )
		{
			compareFunction = SortField( fields[0] ).compareFunction;
		}
		return super.findItem( items, values, mode, returnInsertionIndex, compareFunction );
	}
}
}
&lt;/code&gt;

This forces the custom Sort class onto the grid&apos;s dataProvider, and then forces the correct compareFunction from the SortField to be used by the Sort&apos;s findItem() method. Hopefully we&apos;ll get a fix for this soon, but in the meantime, maybe this workaround will help out some other folks.
				
				</description>
				
				
				<category>Development</category>
				
				<category>Flex</category>
				
				<pubDate>Fri, 09 Oct 2009 12:57:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2009/10/9/Flex-DataGridColumn-Complex-Properties-Bug-and-Workaround</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>I&apos;m Speaking at the CFinNC Conference...See You There?</title>
				<link>http://www.briankotek.com/blog/index.cfm/2009/9/4/Im-Speaking-at-the-CFinNC-ConferenceSee-You-There</link>
				<description>
				
				Just a quick note that I&apos;ll be speaking at the &lt;a href=&quot;http://www.cfinnc.com/&quot; target=&quot;_blank&quot;&gt;CFinNC&lt;/a&gt; conference on October 17-18th here in Raleigh, NC. My topics are Object-oriented Design Principles and The Swiz Framework for Flex. 

The conference is FREE and the lineup is very impressive, so if you can attend, please register! And if you register, please actually show up! The danger with a free conference is that it&apos;s easy for folks to back out at the last minute, since they lose nothing. But for the organizers, it makes estimating actual attendance difficult. So if you sign up, please do your best to make it. :-)

I&apos;m looking forward to seeing some folks that I normally have to wait until MAX or next year&apos;s CFObjective or CFUnited conferences to see. And I hope to meet a lot of new people as well. See you in Raleigh!
				
				</description>
				
				
				<category>ColdFusion</category>
				
				<category>OOP CF</category>
				
				<category>Flex</category>
				
				<category>Conferences</category>
				
				<category>Swiz</category>
				
				<pubDate>Fri, 04 Sep 2009 12:00:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2009/9/4/Im-Speaking-at-the-CFinNC-ConferenceSee-You-There</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>HTML 5 Isn&apos;t Going to Kill Flash</title>
				<link>http://www.briankotek.com/blog/index.cfm/2009/7/9/HTML-5-Isnt-Going-to-Kill-Flash</link>
				<description>
				
				Lately I&apos;ve seen a number of blog posts and news stories touting HTML 5 as some sort of Flash Killer in the RIA space. Am I the only one shaking my head at this?

First off, let me say I&apos;m thrilled that HTML 5 is in the works, and that the markup language is being improved. I could say it&apos;s about time, but I won&apos;t. (I guess I just did though!)

That said, the people claiming that HTML 5 is going to kill Flash seem to have a pretty poor memory. According to the editor of HTML 5, &lt;a href=&quot;http://blogs.techrepublic.com.com/programming-and-development/?p=718&quot; target=&quot;_blank&quot;&gt;it&apos;s not going to become a proposed recommendation until 2022&lt;/a&gt;. That&apos;s over a decade, folks. That&apos;s a long, looooong time.

Think back a decade. Remember 1999? Most people were using IE 4. There was no AJAX, and there were no RIAs. There were no social networks. There was no Twitter, and no iPhone. Now project that kind of change forward 10 years, only double the rate of change. So much is going to happen before HTML 5 is widely adopted that it&apos;s not even funny. Heck, something might even kill Flash. But it&apos;s not going to be HTML 5.

And even if the new spec offers some kind of parity with Flash, Flex, and Silverlight, it&apos;s not like the existing RIA platforms are going to stand still. There will be huge advances over the next decade. So being, among other things, a Flex developer, I&apos;m probably biased here. But I just don&apos;t see what all the fuss is about. An updated spec is great, and I sure it will find many uses and offer a lot of interesting features. But to trot this out as yet another Flash Killer seems unrealistic at best, and reeks of ulterior motives at worst. What do you think? Am I right? Or am I just blinded by my association with Flex?
				
				</description>
				
				
				<category>Development</category>
				
				<category>Flex</category>
				
				<pubDate>Thu, 09 Jul 2009 07:17:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2009/7/9/HTML-5-Isnt-Going-to-Kill-Flash</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>SilverFlash Beta Released: A Joint RIA Platform from Adobe and Microsoft?!</title>
				<link>http://www.briankotek.com/blog/index.cfm/2009/4/1/SilverFlash-Beta-Released-A-Joint-RIA-Platform-from-Adobe-and-Microsoft</link>
				<description>
				
				Microsoft and Adobe just announced the public availability of a joint RIA platform called SilverFlash. While it is only in early beta, and the future plans are somewhat vague, this looks like it could be something quite interesting for Flash and Flex developers for several reasons.

First, it actually goes far beyond Microsoft&apos;s current Silverlight platform, in that it actually merges the Flash platform with the Windows Presentation Foundation (WPF). In some ways this seems similar to what Adobe AIR provides, except that the WPF extends much more deeply into the Windows operating system. That means a lot more power when doing desktop integration.

But obviously the real draw here is that we&apos;ll have a unified RIA platform that is backed by all the major players in the industry (even Sun is on board) and that runs on any operating system. Just imagine: the power and ubiquity of Flash combined with the stunning calendar widgets of Sliverlight, all wrapped in a Java applet. You can download the beta at &lt;a href=&quot;http://www.techcrunch.com/2009/04/01/april-fools-youtube-flails-amazon-cloud-computing-in-a-blimp-3d-chrome-browsing-google-master-ai/&quot; target=&quot;_blank&quot;&gt;the SilverFlash Launch website&lt;/a&gt;. This is going to do for RIAs what the Apple Newton did for handheld computing!
				
				</description>
				
				
				<category>Development</category>
				
				<category>General</category>
				
				<category>Flex</category>
				
				<pubDate>Wed, 01 Apr 2009 06:41:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2009/4/1/SilverFlash-Beta-Released-A-Joint-RIA-Platform-from-Adobe-and-Microsoft</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Flex Tip: Why ListCollectionView Is Your Friend</title>
				<link>http://www.briankotek.com/blog/index.cfm/2009/3/18/Flex-Tip-Why-ListCollectionView-Is-Your-Friend</link>
				<description>
				
				I&apos;ve been meaning to blog quickly about this topic for a while. But a post from Mike over at &lt;a href=&quot;http://smartpitbullsoftware.blogspot.com/2009/03/cloning-data.html&quot; target=&quot;_blank&quot;&gt;Smart Pitbull&lt;/a&gt; prompted me to go ahead and do it.

Mike was having an issue with having two Flex DataGrids both bound to the same ArrayCollection. When he did something that sorted one grid, both grids would be sorted. This wasn&apos;t what he wanted, so he looked at a couple of solutions.

His first idea was to have the server convert his query into an Array, and use that to create two separate ArrayCollections based on the array. This works, but it required adding the server-side logic to do this translation.

On the advice of some readers, he dropped that solution and instead went with client-side code that loops over the result and adds each item to two separate ArrayCollections.

Actually, I think Mike&apos;s first solution was the better of the two. The second option creates two completely different ArrayCollections, which means &lt;strong&gt;no&lt;/strong&gt; changes to one will be reflected in the other. One can add, remove, and modify elements in one collection and the other will remain completely unaffected. In most cases this is going to be a bad thing. Even if there are two separate grids, you probably don&apos;t want to have to manually synchronize the underlying data. Which is exactly what would have to happen here. If someone adds a User to one of the collections, the other collection (and grid) will not change. In general, you &lt;strong&gt;want&lt;/strong&gt; to have a single data collection so that changes to it are immediately reflected in any views that are bound to it.

The solution that I would offer is to use two ListCollectionViews to act as the binding targets for the DataGrids. Among the many (MANY) benefits of working with my friend &lt;a href=&quot;http://www.firemoss.com/&quot; target=&quot;_blank&quot;&gt;Joe Rinehart&lt;/a&gt; was that he clued me into this option very early in my Flex learning curve.

So in Mike&apos;s case, the solution is to wrap the collection returned from the server in two ListCollectionViews, one of each grid, like so:

&lt;code&gt;js|
modelData = e.result as ArrayCollection
gridData = new ListCollectionView( modelData );
advancedGridData = new ListCollectionView( modelData );
&lt;/code&gt;

With this approach, you can sort the grids independently and not affect the other. This is because the the DataGrid (and indeed anything that sorts a collection) will apply a Sort or filterFunction directly on the bound collection. That is why you&apos;ll see both grids sort together if they are both bound to the same collection, and why the sorting is independent if each grid is bound to a different ListCollectionView. At the same time, since the underlying collection is shared by both of the ListCollectionViews, you don&apos;t need to worry about synchronizing the two collections when has elements added, removed, or changed.

I&apos;ve created a &lt;a href=&quot;http://briankotek.com/examples/listcollectionexample/Main.html&quot; target=&quot;_blank&quot;&gt;simple example to show this in action&lt;/a&gt;. View source is enabled if you want to see what&apos;s going on. Hopefully this makes sense, and shows why using a ListCollectionView wrapper around your underlying data is a very useful option when you need to expose that data in different views.
				
				</description>
				
				
				<category>Development</category>
				
				<category>Flex</category>
				
				<pubDate>Wed, 18 Mar 2009 10:59:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2009/3/18/Flex-Tip-Why-ListCollectionView-Is-Your-Friend</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Swiz Part 5: Simulating Server Calls with a mock AsyncToken</title>
				<link>http://www.briankotek.com/blog/index.cfm/2009/3/16/Swiz-Part-5-Simulating-Server-Calls-with-a-mock-AsyncToken</link>
				<description>
				
				In the last entry in this series on the Swiz framework, I discussed &lt;a
href=&quot;http://www.briankotek.com/blog/index.cfm/2009/2/9/Swiz-Part-4-Dynamic-Responders&quot;
target=&quot;_blank&quot;&gt;the use Dynamic Responders&lt;/a&gt; to make calls to the server as easy as possible. This entry is a short aside on how you can use some nice testing features that are built into Swiz to simulate calls to a server. As before, &lt;a
href=&quot;http://www.briankotek.com/examples/swizdemo_events/Main.html&quot;
target=&quot;_blank&quot;&gt;the current version of the application and its
source code&lt;/a&gt; is available.&lt;br&gt;
&lt;br&gt;
So far, we&apos;ve looked at how Swiz&apos;s inversion of control (IoC) features make managing dependencies in a Flex application dead simple. We&apos;ve dispatched events from the CentralDispatcher, and we&apos;ve executed service calls using our Delegate class. But what is actually happening at the Delegate level? Let&apos;s delve into this.&lt;br&gt;
&lt;br&gt;
You might have noticed that within my Controller, I&apos;m having Swiz wire in an object of type IUserDelegate:&lt;br&gt;

&lt;code&gt;js|
[Autowire]
public var delegate : IUserDelegate;
&lt;/code&gt;

Why am I specifying the type as an interface instead of an actual class name? Flexibility! One of the most basic tenants of object-oriented design is to &quot;design to interfaces&quot;. That doesn&apos;t necessarily mean you have to type everything as an interface. It just means you should keep your typing at the highest level of abstraction that you can. Ideally, that means typing things to interfaces or abstract classes.

Because I&apos;m typing the delegate to IUserDelegate, that means I can have Swiz autowire anything that implements the contract defined by the IUserDelegate interface. And that&apos;s exactly what I&apos;m doing. Here&apos;s the Beans.mxml file again:&lt;br&gt;

&lt;code&gt;xml|
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;BeanLoader 
	xmlns=&quot;org.swizframework.util.*&quot; 
	xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
	xmlns:controller=&quot;com.briankotek.swizdemo.controller.*&quot;
	xmlns:business=&quot;com.briankotek.swizdemo.delegate.*&quot;&gt;

	&lt;controller:UserController id=&quot;userController&quot; /&gt;
	&lt;business:MockUserDelegate id=&quot;userDelegate&quot; /&gt;

&lt;/BeanLoader&gt;
&lt;/code&gt;

You can see that the delegate is actually a MockUserDelegate. Here&apos;s the code for that class:&lt;br&gt;

&lt;code&gt;js|
package com.briankotek.swizdemo.delegate
{
	import com.briankotek.swizdemo.model.User;
	import mx.collections.ArrayCollection;
	import mx.rpc.AsyncToken;
	import org.swizframework.delegate.AbstractDelegate;
	import org.swizframework.util.TestUtil;

	public class MockUserDelegate extends AbstractDelegate implements IUserDelegate
	{
		
		// CONSTRUCTOR
		
		public function MockUserDelegate()
		{
			super();
		}
		
		// PUBLIC METHODS
		
		/**
		 * In a real application this would execute a server call to a remote object
		 */ 
		public function loadUsers() : AsyncToken
		{	
			return TestUtil.mockResult( buildMockUserCollection() );
		}
		
		/**
		 * In a real application this would execute a server call to a remote object
		 */ 
		public function saveUser( user : User ) : AsyncToken
		{
			if( !user.id )
			{
				user.id = Math.round( Math.random() * 100 );
			}
			return TestUtil.mockResult( user );
		}
		
		/**
		 * In a real application this would execute a server call to a remote object
		 */ 
		public function deleteUser( user : User ) : AsyncToken
		{
			return TestUtil.mockResult( user );
		}
		
		/**
		 * In a real application this might execute a call to a third party file server
		 */ 
		public function deleteUserProfileImage( user : User ) : AsyncToken
		{
			// Pretend that this deletes a file from a file server like Amazon S3.
			return TestUtil.mockResult( user ); 
		}

		// PRIVATE METHODS
		
		/**
		 * Build a fake collection of Users as a mock result.
		 */ 
		private function buildMockUserCollection() : ArrayCollection
		{
			var result : ArrayCollection = new ArrayCollection();
			
			var user1 : User = new User();
			user1.id = 1;
			user1.firstName = &quot;Tom&quot;;
			user1.lastName = &quot;Swift&quot;;
			result.addItem( user1 );
			
			var user2 : User = new User();
			user2.id = 2;
			user2.firstName = &quot;Bob&quot;;
			user2.lastName = &quot;Hope&quot;;
			result.addItem( user2 );
			
			var user3 : User = new User();
			user3.id = 3;
			user3.firstName = &quot;Alan&quot;;
			user3.lastName = &quot;Alda&quot;;
			result.addItem( user3 );
			
			var user4 : User = new User();
			user4.id = 4;
			user4.firstName = &quot;Roger&quot;;
			user4.lastName = &quot;York&quot;;
			result.addItem( user4 );
			
			return result;	
		}
	}
}
&lt;/code&gt;

As you can see, I&apos;m not actually making a call to a server. I&apos;m generating an ArrayCollection of &quot;fake&quot; User objects, and then using a handy method called mockResult() in the Swiz TestUtils class. This method generates an AsyncToken for you and adds your result to it. It will even let you simulate a delay, like a real server call would have.

In this way, you can easily test your Swiz application without needing the server side working. This not only makes examples like mine much easier to release, but it lets you unit test your applications, as well as do work on parts of the UI before the server-side code has been implemented yet.

I hope you can see the usefulness of this approach, the handy nature of Swiz&apos;s mockResult() method, and the ease with which Swiz lets you swap out implementations like this. I&apos;ll sign off for now, but in the next entry (which will come more quickly than this one did, I promise) we&apos;ll look at another great Swiz feature: Dynamic Event Mediators.
				
				</description>
				
				
				<category>Development</category>
				
				<category>Flex</category>
				
				<category>Swiz</category>
				
				<pubDate>Mon, 16 Mar 2009 13:16:00 -0700</pubDate>
				<guid>http://www.briankotek.com/blog/index.cfm/2009/3/16/Swiz-Part-5-Simulating-Server-Calls-with-a-mock-AsyncToken</guid>
				
				
			</item>
			
		 	
			</channel></rss>