<?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>Helmut Granda &#187; RobotLegs</title>
	<atom:link href="http://www.helmutgranda.com/category/robotlegs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.helmutgranda.com</link>
	<description>learning through interaction</description>
	<lastBuildDate>Wed, 18 Jan 2012 16:08:59 +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>RobotLegs and Flash IDE CS4 Injection</title>
		<link>http://www.helmutgranda.com/2009/12/02/robotlegs-and-flash-ide-cs4-injection/</link>
		<comments>http://www.helmutgranda.com/2009/12/02/robotlegs-and-flash-ide-cs4-injection/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 22:58:52 +0000</pubDate>
		<dc:creator>Helmut Granda</dc:creator>
				<category><![CDATA[RobotLegs]]></category>

		<guid isPermaLink="false">http://www.helmutgranda.com/?p=400</guid>
		<description><![CDATA[“UPDATE: It has been discovered that Flash CS3/4 can be instructed to keep metadata after all: Simply select “Export SWC” in your publish settings. Doing so will keep all metadata in tact in your SWF!” - Thanks to shaun for this clarification. So you heard of the RobotLegs framework and downloade their demos so you [...]]]></description>
			<content:encoded><![CDATA[<p><strong><i>“UPDATE: It has been discovered that Flash CS3/4 can be instructed to keep metadata after all: Simply select “Export SWC” in your publish settings. Doing so will keep all metadata in tact in your SWF!” - Thanks to shaun for this clarification.</i></strong> </p>
<p>So you heard of the <a href="http://www.robotlegs.org" target="_blank">RobotLegs</a> framework and downloade their demos so you could compile them on your own computer but the only thing that you have available is CS4, not a problem you can still use the framework and I'm going to update the <a href="http://github.com/robotlegs/robotlegs-demos-Bundle/tree/master/HelloFlash/" target="_blank">"Hello Flash" demo</a> to show you how. After this article you should be able to update any other demo or create your own with CS4.</p>
<p align="center"><a href="http://www.robotlegs.org target="_blank"><img src="http://www.robotlegs.org/images/rl-header-logo-310-253.png"/></a></p>
<p>Accordingly to the <a href="http://knowledge.robotlegs.org/faqs/framework-core/is-robotlegs-compatible-with-the-flash-ide-cs3cs4" target="_blank">Knowledge Base</a> we get a good kick start by letting us know that we need the following:</p>
<div class="syntax_hilite"><strong>ActionScript:</strong>
<div id="as-6">
<div>
<ol style="">//Initializing the injector with XML is done by adding this line to your context's constructor, before the super() call:</p>
<p>injector = new SwiftSuspendersInjector(xmlConfiguration);</p>
<p>//Where xmlConfiguration is your XML object.</ol>
</div>
</div>
</div>
<p>So in our HelloFlashContext file we are going to add our "xmlConfiguration" property that will be passed to the SwiftSuspendersInjector.</p>
<p>So I am going to borrow the XML_CONFIG from the <a href="http://github.com/robotlegs/robotlegs-framework/blob/master/src/org/robotlegs/adapters/SwiftSuspendersInjector.as" target="_blank">SwiftSuspendersInjector</a> and  use it as a guide for my HelloFlashContext class.</p>
<div class="syntax_hilite"><strong>ActionScript:</strong>
<div id="as-7">
<div>
<ol style="">protected static const XML_CONFIG:XML =<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;types&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;type name='org.robotlegs.mvcs::Actor'&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='eventDispatcher'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/type&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;type name='org.robotlegs.mvcs::Command'&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='contextView'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='mediatorMap'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='eventDispatcher'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='injector'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='mediatorMap'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/type&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;type name='org.robotlegs.mvcs::Mediator'&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='contextView'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='mediatorMap'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='eventDispatcher'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/type&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/types&gt;;</p>
<p>public function HelloFlashContext(contextView:DisplayObjectContainer)<br />
&nbsp; &nbsp;&nbsp; &nbsp;{<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;injector = new SwiftSuspendersInjector(XML_CONFIG);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;super(contextView);<br />
&nbsp; &nbsp;&nbsp; &nbsp;}</ol>
</div>
</div>
</div>
<p>Now that we know how our XML has to be formed we can start adding our custom properties that will substitute the [Inject] annotations.</p>
<p>There are only two locations where the inject annotation is being used.</p>
<div class="syntax_hilite"><strong>ActionScript:</strong>
<div id="as-8">
<div>
<ol style="">org.robotlegs.demos.hellowflash.view.BallMediator<br />
org.robotlegs.demos.hellowflash.view.ReadoutMediator</ol>
</div>
</div>
</div>
<p>and there are only 2 properties used in both instances</p>
<div class="syntax_hilite"><strong>ActionScript:</strong>
<div id="as-9">
<div>
<ol style="">view<br />
statsModel</ol>
</div>
</div>
</div>
<p>So with that information we very easily update our XML_CONFIG constant as follows:</p>
<div class="syntax_hilite"><strong>ActionScript:</strong>
<div id="as-10">
<div>
<ol style="">&lt;type name='org.robotlegs.demos.helloflash.view::BallMediator'&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='view'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='statsModel'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/type&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;type name='org.robotlegs.demos.helloflash.view::ReadoutMediator'&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='view'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='statsModel'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/type&gt;</ol>
</div>
</div>
</div>
<p>And here you have the complete HellowFlashContext class updated:</p>
<div class="syntax_hilite"><strong>ActionScript:</strong>
<div id="as-11">
<div>
<ol style="">package org.robotlegs.demos.helloflash<br />
{<br />
&nbsp; &nbsp;import flash.display.DisplayObjectContainer;<br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp;import org.robotlegs.base.ContextEvent;<br />
&nbsp; &nbsp;import org.robotlegs.demos.helloflash.controller.CreateBallCommand;<br />
&nbsp; &nbsp;import org.robotlegs.demos.helloflash.controller.HelloFlashEvent;<br />
&nbsp; &nbsp;import org.robotlegs.demos.helloflash.model.StatsModel;<br />
&nbsp; &nbsp;import org.robotlegs.demos.helloflash.view.Ball;<br />
&nbsp; &nbsp;import org.robotlegs.demos.helloflash.view.BallMediator;<br />
&nbsp; &nbsp;import org.robotlegs.demos.helloflash.view.Readout;<br />
&nbsp; &nbsp;import org.robotlegs.demos.helloflash.view.ReadoutMediator;<br />
&nbsp; &nbsp;import org.robotlegs.mvcs.Context;<br />
&nbsp; &nbsp;</p>
<p>&nbsp; &nbsp;import org.robotlegs.adapters.SwiftSuspendersInjector;</p>
<p>&nbsp; &nbsp;public class HelloFlashContext extends Context<br />
&nbsp; &nbsp;{<br />
&nbsp; &nbsp;&nbsp; &nbsp;protected static const XML_CONFIG:XML =<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;types&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;type name='org.robotlegs.demos.helloflash.view::BallMediator'&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='view'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='statsModel'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/type&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;type name='org.robotlegs.demos.helloflash.view::ReadoutMediator'&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='view'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field name='statsModel'/&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/type&gt;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/types&gt;;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;public function HelloFlashContext(contextView:DisplayObjectContainer)<br />
&nbsp; &nbsp;&nbsp; &nbsp;{<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;injector = new SwiftSuspendersInjector(XML_CONFIG);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;super(contextView);<br />
&nbsp; &nbsp;&nbsp; &nbsp;}<br />
&nbsp; &nbsp;&nbsp; &nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;override public function startup():void<br />
&nbsp; &nbsp;&nbsp; &nbsp;{<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;// Map some Commands to Events<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, CreateBallCommand, ContextEvent, true);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;commandMap.mapEvent(HelloFlashEvent.BALL_CLICKED, CreateBallCommand, HelloFlashEvent );<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;// Create a rule for Dependency Injection<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;injector.mapSingleton(StatsModel);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;// Here we bind Mediator Classes to View Classes:<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;// Mediators will be created automatically when<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;// view instances arrive on stage (anywhere inside the context view)<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;mediatorMap.mapView(Ball, BallMediator);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;mediatorMap.mapView(Readout, ReadoutMediator);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;// Manually add something to stage<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;contextView.addChild(new Readout());<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;// And we're done<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;super.startup();<br />
&nbsp; &nbsp;&nbsp; &nbsp;}<br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp;}<br />
}</ol>
</div>
</div>
</div>
<p>This way you should be able to update any demo and compile with the Flash IDE.</p>
<p><i>Updated: Thanks to <a href="http://twitter.com/josyule" target="_blank">Jos Yule</a> for pointing out that the XML will be concatenated on the existing XML so no need to recreate it all</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.helmutgranda.com/2009/12/02/robotlegs-and-flash-ide-cs4-injection/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

