<?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>Sönke Rohde &#187; RIA</title>
	<atom:link href="http://soenkerohde.com/category/ria/feed/" rel="self" type="application/rss+xml" />
	<link>http://soenkerohde.com</link>
	<description>Flash Platform (Flash, Flex, AIR) thoughts and examples</description>
	<lastBuildDate>Fri, 30 Dec 2011 16:15:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>FlairLoc Public Beta</title>
		<link>http://soenkerohde.com/2009/11/flairloc-public-beta/</link>
		<comments>http://soenkerohde.com/2009/11/flairloc-public-beta/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 09:58:24 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[RIA]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=722</guid>
		<description><![CDATA[<p>FlairLoc is an Adobe® AIR™ application to localize Adobe® Flex® applications.</p>
<p>Today I am happy to announce that the public beta of FlairLoc is available.</p>
<p>Features</p>

Change resources in a user interface with search capability
Extract resource keys from source code and synchronizes it with all locale sets
Automatic translation into 42 languages with the Google Translate API
Add new automatic translated [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flairloc.com">FlairLoc</a> is an Adobe® AIR™ application to localize Adobe® Flex® applications.</p>
<p>Today I am happy to announce that the public beta of FlairLoc is available.</p>
<p><strong>Features</strong></p>
<ul>
<li>Change resources in a user interface with search capability</li>
<li>Extract resource keys from source code and synchronizes it with all locale sets</li>
<li>Automatic translation into 42 languages with the Google Translate API</li>
<li>Add new automatic translated languages in only <strong>4 CLICKS</strong></li>
<li>Generation of locale compile statement and Ant parameters</li>
</ul>
<p>For more information, screenvideo and screenshots and to install the application please visit the <a href="http://flairloc.com">product page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2009/11/flairloc-public-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Swiz 0.6 Released</title>
		<link>http://soenkerohde.com/2009/05/swiz-06-released/</link>
		<comments>http://soenkerohde.com/2009/05/swiz-06-released/#comments</comments>
		<pubDate>Tue, 19 May 2009 15:09:13 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[Swiz]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=413</guid>
		<description><![CDATA[<p>Chris just released a new version of Swiz with some really great additions and improvements. We now also own the domain swizframework.org which forwards to the Google code homepage.</p>
<p>This release makes Swiz faster, more flexible and even easier to use:</p>

Support for mediating bubbled event
Added view attribute in Mediate tag
Autowire views with view attribute in Autowire tag
Ignoring [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cdscott.blogspot.com/" target="_blank">Chris</a> just released a <a href="http://code.google.com/p/swizframework/downloads/list" target="_blank">new version of Swiz</a> with some really great additions and improvements. We now also own the domain <a href="http://swizframework.org" target="_blank">swizframework.org</a> which forwards to the Google code homepage.</p>
<p>This release makes Swiz faster, more flexible and even easier to use:</p>
<ul>
<li>Support for mediating bubbled event</li>
<li>Added view attribute in Mediate tag</li>
<li>Autowire views with view attribute in Autowire tag</li>
<li>Ignoring view classes with underscore for performance optimization</li>
<li>Added viewPackages for performance optimization</li>
<li>Added eventPackages for shorter notation in strict mode</li>
<li>SwizConfig for Swiz MXML declaration</li>
<li>Generic fault handler for executeServiceCall</li>
<li>Autowire bean properties with new property attribute</li>
<li>Prototype supports class reference and constructor arguments</li>
</ul>
<p>Swiz got a new member <a href="http://www.returnundefined.com/" target="_blank">Ben Clinkinbeard</a> who contributed some really cool stuff which makes mediating events more flexible and removed the Swiz dependency from the view because they can now bubble and lot&#8217;s of other stuff. Awesome to have Ben on board!</p>
<p>So here a quick overview for each new feature/improvement:</p>
<p><b>Support for mediating bubbled event</b></p>
<p>Events don&#8217;t have to be dispatched with the central event dispatcher anymore. So when you have a view instead of:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">Swiz.<span style="color: #006600;">dispatchEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> FooEvent<span style="color: #66cc66;">&#40;</span>FooEvent.<span style="color: #006600;">CHANGE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>you can do:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> FooEvent<span style="color: #66cc66;">&#40;</span>FooEvent.<span style="color: #006600;">CHANGE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>When you want to use this approach you have to</p>
<ul>
<li>enable the feature with Swiz.setMediateBubbledEvents(true) or via SwizConfig</li>
<li>set the bubble flag of the event to &#8220;true&#8221;</li>
<li>override clone method of the event</li>
</ul>
<p>So the view has no Swiz import statement anymore and in fact doesn&#8217;t know anything about Swiz except to autowire models.</p>
<p><b>Added view attribute in Mediate tag</b></p>
<p>A dynamic mediator can now listen for view specific events. In the following example the dynamic mediator only listens for events dispatches by the view class &#8220;MyView&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Mediate<span style="color: #66cc66;">&#40;</span>event=<span style="color: #ff0000;">&quot;SomEvent.FOO&quot;</span>, view=<span style="color: #ff0000;">&quot;MyView&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></pre></div></div>

<p>This is also extremely helpful to code more generic itemRenderers.</p>
<p><b>Autowire views with view attribute in Autowire tag</b></p>
<p>You can now autowire views into any bean with:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Autowire<span style="color: #66cc66;">&#40;</span>view=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> myView<span style="color: #66cc66;">&#40;</span>view:MyView<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>...<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The setter is invoked when the view is added to the stage and has fired its creationComplete event so you can access all members of the view which in MXML are all public scope.<br />
For more details and an example <a href="http://soenkerohde.com/2009/05/swiz-autowire-view/">read my post here.</a></p>
<p><b>Ignoring view classes with underscore for performance optimization</b></p>
<p>This is an internal performance optimization where you as a developer don&#8217;t have to change anything except you have view classes with an underscore in the classname.<br />
In Swiz 0.6 view classes with &#8220;_&#8221; are ignored for dependency injection because these are internal classes like skin classes, cursors or internal non-custom item renderers. Because these kind of classes won&#8217;t contain any metadata we can safely ignore them which improves the runtime performance significantly.</p>
<p><b>Added viewPackages for performance optimization</b></p>
<p>For further optimization beyond already ignoring underscore classes you can now define one or multiple view packages. If you set this property only views in these packages will get autowired.<br />
You can set the viewPackage with</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">Swiz.<span style="color: #006600;">addViewPackage</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;com.domain.project.view&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p> or with the new SwizConfig.</p>
<p><b>Added eventPackages for shorter notation in strict mode</b></p>
<p>When you are using Swiz in strict mode you can now define eventPackages to have a shorter notation of the event. I already <a href="http://soenkerohde.com/2009/04/swiz-eventpackages-in-strict-mode/">blogged about this feature here</a>.</p>
<p><b>SwizConfig for Swiz MXML declaration</b></p>
<p>Instead of adding an event listener for the Application/WindowedApplication preInitialize event and the calling Swiz.loadBeans besides configuring Swiz you can now use the new SwizConfig class in MXML. The markup for an AIR app then looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:WindowedApplication</span> <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">&quot;absolute&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">			import mx.rpc.events.FaultEvent;</span>
<span style="color: #339933;">			import mx.logging.LogEventLevel;</span>
&nbsp;
<span style="color: #339933;">			private function genericFault(fe:FaultEvent):void</span>
<span style="color: #339933;">			{</span>
<span style="color: #339933;">				// TODO handle fault</span>
<span style="color: #339933;">			}</span>
&nbsp;
<span style="color: #339933;">		]]&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:TraceTarget</span> <span style="color: #000066;">fieldSeparator</span>=<span style="color: #ff0000;">&quot;-&gt;</span></span>&quot; includeLevel=&quot;true&quot; includeCategory=&quot;true&quot; includeTime=&quot;true&quot; /&gt;
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;swizframework:SwizConfig</span> <span style="color: #000066;">xmlns:swizframework</span>=<span style="color: #ff0000;">&quot;org.swizframework.*&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">strict</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">mediateBubbledEvents</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">eventPackages</span>=<span style="color: #ff0000;">&quot;example.event&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">viewPackages</span>=<span style="color: #ff0000;">&quot;example.view&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">beanLoaders</span>=<span style="color: #ff0000;">&quot;{[Beans]}&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">serviceCallFaultHandler</span>=<span style="color: #ff0000;">&quot;{genericFault}&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">logEventLevel</span>=<span style="color: #ff0000;">&quot;{LogEventLevel.WARN}&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;view:SwizConfigTestView</span> <span style="color: #000066;">xmlns:view</span>=<span style="color: #ff0000;">&quot;example.view.*&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:WindowedApplication<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The SwizConfig itself will listen for the preInitialize event of the application and configure Swiz.</p>
<p><b>Generic fault handler for executeServiceCall</b></p>
<p>When you use Swiz.executeServiceCall or subclass AbstractController and call executeService call you can leave out the fault handler. When a fault comes up Swiz currently shows an Alert window with the fault details. You can override this like in the SwizConfig example above.</p>
<p><b>Autowire bean properties with new property attribute</b></p>
<p>You can now autowire bean members instead of the bean itself. So instead of:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>Autowire<span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> someModel:SomeModel;
&nbsp;
<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">List</span> dataProvider=<span style="color: #ff0000;">&quot;{someModel.someList}&quot;</span> <span style="color: #66cc66;">/&gt;</span></pre></div></div>

<p>you can use:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>Autowire<span style="color: #66cc66;">&#40;</span>bean=<span style="color: #ff0000;">&quot;someModel&quot;</span>, property=<span style="color: #ff0000;">&quot;someList&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> someList:ICollectionView;
&nbsp;
<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">List</span> dataProvider=<span style="color: #ff0000;">&quot;{someList}&quot;</span> <span style="color: #66cc66;">/&gt;</span></pre></div></div>

</p>
<p><b>Prototype supports class reference and constructor arguments</b></p>
<p>Prototype (<a href="http://soenkerohde.com/2009/01/swiz-prototype-bean/" target="_blank">see old post here</a>) now support constructor arguments and you can declare a class reference instead of the full qualified class name.<br />
Example:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>factory:<span style="color: #0066CC;">Prototype</span> xmlns:factory=<span style="color: #ff0000;">&quot;org.swizframework.factory.*&quot;</span>
	classReference=<span style="color: #ff0000;">&quot;{SomeClass}&quot;</span> constructorArguments=<span style="color: #ff0000;">&quot;{['foo', 'bar']}&quot;</span> <span style="color: #66cc66;">/&gt;</span></pre></div></div>

</p>
<p>There will come a lot of new blog posts regarding each new feature soon but I hope this has given an overview about what&#8217;s new in 0.6. Besides that we try to add more documentation and example projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2009/05/swiz-06-released/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Migrate from Cairngorm to Swiz</title>
		<link>http://soenkerohde.com/2009/05/migrate-from-cairngorm-to-swiz/</link>
		<comments>http://soenkerohde.com/2009/05/migrate-from-cairngorm-to-swiz/#comments</comments>
		<pubDate>Mon, 04 May 2009 15:15:13 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[Swiz]]></category>
		<category><![CDATA[swiz cairngorm ria flex]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/?p=366</guid>
		<description><![CDATA[<p>If you are a Flex developer you surely know and probably used the Cairngorm framework from Adobe. I have used it too for almost two years before I switched to Swiz. I don&#8217;t want to bitch against Cairngorm but for me and many others coding with Swiz offered a simplier way building a RIA because of [...]]]></description>
			<content:encoded><![CDATA[<p>If you are a Flex developer you surely know and probably used the <a href="http://opensource.adobe.com/wiki/display/cairngorm/">Cairngorm framework</a> from Adobe. I have used it too for almost two years before I switched to <a href="http://code.google.com/p/swizframework/">Swiz</a>. I don&#8217;t want to bitch against Cairngorm but for me and many others coding with Swiz offered a simplier way building a RIA because of less repetitive tasks (boilerplate code) and more flexibility. In this post I would like to show how easy it is to migrate an existing Cairngorm application to Swiz. More ore less it is about removing code which is always a good thing. Less code means less bugs and less maintenance so &#8211; more time for features!</p>
<p>In Cairngorm you have a few central classes which are accessible as singletons. In Swiz you won&#8217;t have any singletons in your code at all if you don&#8217;t want to but instead you will use the Autowire annotation to let Swiz wire things together for you using dependency injection aka Inversion of Control. These kind of classes are mainly models, controllers, delegates and services.</p>
<p>You can mix Cairngorm and Swiz at the same time while migrating so you are not forced to refactor your application at once but in an iterative way.</p>
<p>Let&#8217;s get started: <a href="http://code.google.com/p/swizframework/downloads/list">Download</a> the latest Swiz library SWC and add it to your project libs. If you want to check out the latest sources from SVN to compile the SWC on your own be sure to add the compiler parameter -keep-as3-metadata+=Autowire,Mediate.</p>
<p>To initialize Swiz you need at least one BeanLoader which will be the place where you declare models, controllers, delegates and services. The terminology &#8220;Bean&#8221; will probably change in one of the next Swiz releases. Imagine the BeanLoader as the place where you set up non-view classes.</p>
<p>Create a new MXML class and call it e.g. MyLoader and let it extend BeanLoader. Then change the namespace to org.swizframework.util.* so it will look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;BeanLoader</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;org.swizframework.util.*&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/BeanLoader<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>So let&#8217;s refactor your first peace of code. Let&#8217;s assume your ModelLocator contains a class ContactModel which holds a list of contacts. The ContactModel instance is bound to one of your views like:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
<span style="color: #000000; font-weight: bold;">var</span> modelLocator:MyModelLocator = MyModelLocator.<span style="color: #006600;">getIntance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">List</span> dataProvider=<span style="color: #ff0000;">&quot;{modelLocator.contactModel.list}&quot;</span> <span style="color: #66cc66;">/&gt;</span></pre></div></div>

<p>Now remove the contactModel from your ModelLocator and add it to the BeanLoader so it will looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;BeanLoader</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;org.swizframework.util.*&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;model:ContactModel</span> <span style="color: #000066;">xmlns:model</span>=<span style="color: #ff0000;">&quot;com.domain.project.model.*&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/BeanLoader<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>and change the view to this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>Autowire<span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> contactModel:ContactModel;
&nbsp;
<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">List</span> dataProvider=<span style="color: #ff0000;">&quot;{contactModel.list}&quot;</span> <span style="color: #66cc66;">/&gt;</span></pre></div></div>

<p>With the Autowire annotation we tell Swiz that we need the the ContactModel. It has to be defined public because otherwise Swiz is not able to inject the instance defined in MyLoader.<br />
Now we have to tell Swiz to use the MyLoader where we have just set up our ContactModel. Switch to your main application MXML and add an event listener for preinitialize and define the event handler like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Application</span> <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">preinitialize</span>=<span style="color: #ff0000;">&quot;preInitHandler()&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">			import org.swizframework.Swiz;</span>
<span style="color: #339933;">			import com.domain.project.MyBeans;</span>
<span style="color: #339933;">			private function preInitHandler():void</span>
<span style="color: #339933;">			{</span>
<span style="color: #339933;">				Swiz.loadBeans([MyBeans]);</span>
<span style="color: #339933;">			}</span>
<span style="color: #339933;">		]]&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>You see that loadBeans expects an array so you can define multiple BeanLoaders if you like.<br />
In this case we have used autowire-by-type. This means Swiz will find the ContactModel because only one instance is defined in the BeanLoader. If you have classes of the same type in the BeanLoader you can also autowire by id. Only give the instance an id like e.g. id=&#8221;contactModel&#8221; and autowire it with [Autowire(bean="contactModel")]</p>
<p>With this refactoring we might have broken a Cairngorm command because now the flow looks like this</p>
<ul>
<li>Command was invoked from a Cairngorm event mapped to in the FrontController</li>
<li>Command instantiated a Business Delegate and added itself as a Responder implementing the Responder interface</li>
<li>Business Delegate gets service from ServiceLocator and calls it</li>
<li>Service returns result/fault and the Command in this case Responder gets notified</li>
</ul>
<p>With Swiz you have no FrontController, no ServiceLocator and the delegates are also only created once because they live in a BeanLoader. The Command will be replaced by a controller so it is easier to have multiple actions in one controller so you don&#8217;t end up with a ContactReadCommand, ContactAddCommand, ContactUpdateCommand or a switch statement in the command itself to determine which event came in.</p>
<p>To refactor do the following:</p>
<ul>
<li>Move the contact service from ServiceLocator to MyLoader</li>
<li>Add the delegate to MyLoader</li>
<li>Create a new controller called ContactController extending AbstractController and add it to MyLoader</li>
</ul>
<p>Your BeanLoader now looks smilar like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;BeanLoader</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;org.swizframework.util.*&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:model</span>=<span style="color: #ff0000;">&quot;example.model.*&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:ctrl</span>=<span style="color: #ff0000;">&quot;example.ctrl.*&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:business</span>=<span style="color: #ff0000;">&quot;example.business.*&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;model:ContactsModel</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ctrl:ContactController</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;business:ContactDelegate</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:HTTPService</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;contactService&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/BeanLoader<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>It is best practice to let delegates implement an interface so other classes only have to deal with a clean interface so the ContactDelegate interface looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package example.<span style="color: #006600;">business</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">AsyncToken</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IContactDelegate
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">function</span> getContacts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:AsyncToken;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>and the implementation like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package example.<span style="color: #006600;">business</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">AsyncToken</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">http</span>.<span style="color: #006600;">HTTPService</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ContactDelegate <span style="color: #0066CC;">implements</span> IContactDelegate
	<span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #66cc66;">&#91;</span>Autowire<span style="color: #66cc66;">&#40;</span>bean=<span style="color: #ff0000;">&quot;contactService&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> service:HTTPService;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getContacts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:AsyncToken
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> service.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>You see that we simply autowire the service instead of having any call to a ServiceLocator.</p>
<p>Now the controller. The ContactController has two dependecies. We will need access to the delegate to call the service and to the model to store the result and both will be autowired:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package example.<span style="color: #006600;">ctrl</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> example.<span style="color: #006600;">business</span>.<span style="color: #006600;">IContactDelegate</span>;
	<span style="color: #0066CC;">import</span> example.<span style="color: #006600;">model</span>.<span style="color: #006600;">ContactModel</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">AsyncToken</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">swizframework</span>.<span style="color: #006600;">controller</span>.<span style="color: #006600;">AbstractController</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ContactController <span style="color: #0066CC;">extends</span> AbstractController
	<span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #66cc66;">&#91;</span>Autowire<span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> model:ContactModel;
&nbsp;
		<span style="color: #66cc66;">&#91;</span>Autowire<span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> delegate:IContactDelegate;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ContactController<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#91;</span>Mediate<span style="color: #66cc66;">&#40;</span>event=<span style="color: #ff0000;">&quot;loadContacts&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> loadContacts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">call</span>:AsyncToken = delegate.<span style="color: #006600;">getContacts</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			executeServiceCall<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">call</span>, contactsResultHandler<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> contactsResultHandler<span style="color: #66cc66;">&#40;</span>re:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> ac:ArrayCollection = re.<span style="color: #006600;">result</span> as ArrayCollection;
			model.<span style="color: #0066CC;">list</span> = ac;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>You see something new which is the Mediate annotation [Mediate(event="loadContacts")]<br />
Instead of a FrontController which maps events to commands Swiz uses a concept called dynamic mediators. In this case we are using a primitive event and there are more sophisticated ways to implement dynamic mediators and also pass parameters (event member variables) etc.</p>
<p>So let&#8217;s say you want to load the contacts when your application starts simply add this line of code to the main application creationComplete event handler:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">Swiz.<span style="color: #006600;">dispatch</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;loadContacts&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Swiz is aware of all mediate annotations and has created event listeners and with the line above our controller method loadContacts gets invoked. You could also use an event class which does not need a special base class like the CairngormEvent but only flash.events.Event. For more info and some shortcuts and runtime validation <a href="http://soenkerohde.com/2009/04/swiz-eventpackages-in-strict-mode/">read on here about eventPackages</a>.</p>
<p>So let&#8217;s some up how the different layers of your application work together:</p>
<ul>
<li>Declare models, controller, delegates and services in the BeanLoader and load them with Swiz.loadBeans</li>
<li>Views get the model autowired and can add data bindings.</li>
<li>Views dispatch events caused by user gestures with Swiz.dispatchEvent or Swiz.dispatch</li>
<li>Controller mediate events with [Mediate(event="...", properties="...")]</li>
<li>Controllers get models autowired which need to be changed by the controller.</li>
<li>If the controller calls a service autowire the delegate</li>
<li>Delegates autowire services and return the AsyncToken from the service call</li>
</ul>
<p>I hope at this post you have learned some concepts of Swiz compared to Cairngorm and see that migrating from Cairngorm to Swiz means more decoupling and removing repetitive code. I had a large project with more than one year development spend on and refactoring was done in a short timeframe and reduced about 30% lines of code.</p>
<p>If you have more questions please drop a comment and/or join the <a href="http://groups.google.com/group/swiz-framework">mailing list</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2009/05/migrate-from-cairngorm-to-swiz/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Hobnox Audiotool now open</title>
		<link>http://soenkerohde.com/2008/04/hobnox-audiotool-now-open/</link>
		<comments>http://soenkerohde.com/2008/04/hobnox-audiotool-now-open/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 08:38:19 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[RIA]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/2008/04/01/hobnox-audiotool-now-open/</guid>
		<description><![CDATA[<p>Andé Michelle anounced that you can now try out the Hobnox Audiotool withouth a beta invitation or registration.</p>
<p>&#8220;Here it is, it’ll supply you with an emulator of some famous little machines, used by DJs, producers and bands all over the planet. Right now, we can equip you with a rebuilt Roland TR-808, TR-909, TB-303 and some [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.andre-michelle.com/">Andé Michelle</a> <a href="http://blog.andre-michelle.com/2008/hobnox-audiotool/">anounced</a> that you can now try out the <a href="http://www.hobnox.com/audiotool-startpage.1046.html">Hobnox Audiotool</a> withouth a beta invitation or registration.</p>
<blockquote><p><em>&#8220;Here it is, it’ll supply you with an emulator of some famous little machines, used by DJs, producers and bands all over the planet. Right now, we can equip you with a rebuilt Roland TR-808, TR-909, TB-303 and some floorboards. Interested? Give it a try!&#8221;</em></p></blockquote>
<p>I tried it out during the beta and really liked the app which works very intuitively as you can simple link the boards and effects by drag-n-drop the cable between them.</p>
<p><img title="Hobnox Audiotool" alt="Hobnox Audiotool" src="/img/hobnox.jpg" /></p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2008/04/hobnox-audiotool-now-open/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Photoshop Express</title>
		<link>http://soenkerohde.com/2008/03/photoshop-express/</link>
		<comments>http://soenkerohde.com/2008/03/photoshop-express/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 16:25:56 +0000</pubDate>
		<dc:creator>Sönke</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[RIA]]></category>

		<guid isPermaLink="false">http://soenkerohde.com/2008/03/28/photoshop-express/</guid>
		<description><![CDATA[<p>Yesterday Photoshop Express went into public beta.</p>
<p>Check the press release or various reviews. As mentioned in the TechCrunch review there are many others in online photo editing like Picnik but also Photoshop Express comes with social networking features as you may edit your photos hosted on Facebook, Photobucket, Picasa and soon Flickr.</p>
<p>Photoshop express is no strip [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday <a href="https://www.photoshop.com/express">Photoshop Express</a> went into public beta.</p>
<p>Check the <a href="http://www.adobe.com/aboutadobe/pressroom/pressreleases/200803/032708PhotoshopExpress.html">press release</a> or <a href="http://www.techcrunch.com/2008/03/26/adobe-unveils-webtop-version-of-photoshop-picnik-is-not-scared/">various reviews</a>. As mentioned in the <a href="http://www.techcrunch.com">TechCrunch</a> <a href="http://www.techcrunch.com/2008/03/26/adobe-unveils-webtop-version-of-photoshop-picnik-is-not-scared/">review</a> there are many others in online photo editing like <a href="http://www.picnik.com">Picnik</a> but also Photoshop Express comes with social networking features as you may edit your photos hosted on <a href="http://www.picnik.com/">Facebook</a>, <a href="http://photobucket.com/">Photobucket</a>, <a href="http://picasaweb.google.de">Picasa</a> and soon <a href="http://flickr.com/">Flickr</a>.</p>
<p>Photoshop express is no strip down of the desktop tool but more about correcting your photos and sharing them with the world. I like the &#8220;Pop Color&#8221; tool where you can select a color and replace it with another with very cool results like here:</p>
<p><img src="/img/photoshop_express.jpg" /></p>
<p>The photo above shows the &#8220;Fischauktionshalle&#8221; (english: fish auctions hall) in Hamburg when the water is higher than normal what normally happens a few times a year.</p>
]]></content:encoded>
			<wfw:commentRss>http://soenkerohde.com/2008/03/photoshop-express/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

