<?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>digitaldogbyte.com</title>
	<atom:link href="http://www.digitaldogbyte.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.digitaldogbyte.com</link>
	<description>powered by kilobits n' bytes</description>
	<lastBuildDate>Mon, 30 Aug 2010 02:27:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Robotlegs using a shared eventdispatcher between multiple contexts</title>
		<link>http://www.digitaldogbyte.com/2010/08/29/robotlegs-using-a-shared-eventdispatcher-between-multiple-contexts/</link>
		<comments>http://www.digitaldogbyte.com/2010/08/29/robotlegs-using-a-shared-eventdispatcher-between-multiple-contexts/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 02:17:47 +0000</pubDate>
		<dc:creator>Herman Wong</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[robotlegs]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=133</guid>
		<description><![CDATA[My last couple posts discussed two different methods of writing modular applications using the Robotlegs framework. This post will demonstrate yet another method of writing modular applications in Robotlegs using a shared eventDispatcher between the modules. This approach requires the creation of a getter method for the eventDispatcher from the Application Shell&#8217;s context. The eventDispatcher [...]]]></description>
			<content:encoded><![CDATA[<p>My last couple posts discussed two different methods of writing modular applications using the Robotlegs framework. This post will demonstrate yet another method of writing modular applications in Robotlegs using a shared eventDispatcher between the modules.</p>
<p>This approach requires the creation of a getter method for the eventDispatcher from the Application Shell&#8217;s context. The eventDispatcher is then injected into the contexts of each module using:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900;">// injects the application shell's eventDispatcher into the module's context</span>
injector.mapValue<span style="color: #000000;">&#40;</span><span style="color: #004993;">EventDispatcher</span>, Application.application.applicationEventDispatcher, <span style="color: #990000;">&quot;ApplicationEventDispatcher&quot;</span><span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<p>The &#8220;ApplicationEventDispatcher&#8221; is then used to listen to events and to dispatch events throughout the entire application.</p>
<p>Here is the <a href="http://www.digitaldogbyte.com/downloads/rl_shared_eventdispatcher/RL_Modular_Multiple_Contexts_Shared_Eventdispatcher.html" target="_blank">demo</a> and the <a href="http://www.digitaldogbyte.com/downloads/rl_shared_eventdispatcher/srcview/index.html" target="_blank">source</a> code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2010/08/29/robotlegs-using-a-shared-eventdispatcher-between-multiple-contexts/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Robotlegs modular application with multiple contexts</title>
		<link>http://www.digitaldogbyte.com/2010/08/20/robotlegs-modular-application-with-multiple-contexts/</link>
		<comments>http://www.digitaldogbyte.com/2010/08/20/robotlegs-modular-application-with-multiple-contexts/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 14:16:20 +0000</pubDate>
		<dc:creator>Herman Wong</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[robotlegs]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=113</guid>
		<description><![CDATA[My previous post demonstrated modular programming in the Robotlegs framework using the Robotlegs modular utilities. This post will discuss a workaround that I came up with to handle inter-context communication between modules before the Robotlegs Modular Utilities were released. The benefits of using this workaround is that you can have modules in their own encapsulated [...]]]></description>
			<content:encoded><![CDATA[<p>My previous post demonstrated modular programming in the <a href="http://www.robotlegs.org/" target="_blank">Robotlegs</a> framework using the Robotlegs modular utilities. This post will discuss a workaround that I came up with to handle inter-context communication between modules before the <a href="http://github.com/joelhooks/robotlegs-utilities-Modular" target="_blank">Robotlegs Modular Utilities</a> were released.</p>
<p>The benefits of using this workaround is that you can have modules in their own encapsulated contexts, the disadvantage is that this solution is not very scalable if you have lots of events that need to be mapped between the contexts.</p>
<p>The basic idea is to create a getter for the _eventDispatcher property in the context of each module. Once the root application has fired the creationComplete event, the handler for creationComplete needs to use the getters so that the root application can perform the necessary event mapping which will allow the two modules to communicate.</p>
<p>Here is the <a href="http://www.digitaldogbyte.com/downloads/rl_modular_multiple_contexts_demo/RL_Modular_Multiple_Contexts.html" target="_blank">demo</a> and the <a href="http://www.digitaldogbyte.com/downloads/rl_modular_multiple_contexts_demo/srcview/index.html" target="_blank">source code</a>.</p>
<p>I&#8217;ve added inline comments within the source code explaining how to map the events between the modules.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2010/08/20/robotlegs-modular-application-with-multiple-contexts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Robotlegs Modular Utilities Tutorial</title>
		<link>http://www.digitaldogbyte.com/2010/08/17/robotlegs-modular-utilities-tutorial/</link>
		<comments>http://www.digitaldogbyte.com/2010/08/17/robotlegs-modular-utilities-tutorial/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 05:05:56 +0000</pubDate>
		<dc:creator>Herman Wong</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[robotlegs]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=84</guid>
		<description><![CDATA[In the past year I have been using the Robotlegs MVCS framework for AS3 extensively; one of the bigger challenges that I encountered was creating an application with several self contained modules that needed to communicate with each other. Joel Hooks &#038; Stray, a couple of the main contributors to the Robotlegs framework created a [...]]]></description>
			<content:encoded><![CDATA[<p>In the past year I have been using the <a href="http://www.robotlegs.org/" target="_blank">Robotlegs</a> MVCS framework for AS3 extensively; one of the bigger challenges that I encountered was creating an application with several self contained modules that needed to communicate with each other. Joel Hooks &#038; Stray, a couple of the main contributors to the Robotlegs framework created a modular utility which resolves this particular issue within the Robotlegs framework. Joel Hooks also has a very informative post and a tutorial / demo posted on his <a href="http://joelhooks.com/2010/05/02/modular-robotlegs/" target="_blank">blog</a>.</p>
<p>I created a very simple demo which I used to learn how to implement the Robotlegs Modular Utility and this post will provide a step by step walkthrough of how to setup a modular Robotlegs project in Flex 3.5. This tutorial is for people that have some knowledge of the Robotlegs framework &#038; Flex. You can learn more about Robotlegs at the Robotlegs <a href="http://knowledge.robotlegs.org/" target="_blank">knowledgebase</a>.</p>
<p>To get started you will need the following:</p>
<ul>
<li>Flex Builder 3 or Flash Builder 4 with the Flex 3.5 SDK</li>
<li><a href="http://github.com/joelhooks/robotlegs-utilities-Modular" target="_blank">Robotlegs framework &#038; Robotlegs Modular Utility</a></li>
</ul>
<p>The simple demo application features two modules and an application shell. The first module is a button which will send the timestamp from the Date Object&#8217;s getTime() method to the second module, which will then display the timestamp. The application shell simple holds the two modules.</p>
<p>Here is the <a href="http://www.digitaldogbyte.com/downloads/rl_modular_demo/RL_Modular_Demo.html" target="_blank">demo</a> &#038; <a href="http://www.digitaldogbyte.com/downloads/rl_modular_demo/srcview/index.html" target="_blank">source code</a> for those of you that don&#8217;t want to read the whole tutorial. The links are provided again at the end of the posting for those that want to finish reading the tutorial.</p>
<p>The first step is to create a new project in Flex and then to copy the files for the Robotlegs Modular Utilities into the src folder of your project and then to create the project structure for the sample application. The project tree in Flex should look like the following image after you have completed setting up the project.</p>
<p><img src="http://www.digitaldogbyte.com/images/rl_modular_demo/rl_modular_project_tree.png" alt="Flex Project Structure" /></p>
<p><strong>Part 1 &#8211; setting up the first module &#8211; ButtonModule</strong></p>
<p>Now that the project has been setup, we&#8217;ll begin with creating the view for the ButtonModule; simply create a new MXML Component named ButtonModule.mxml under the buttonModule folder.</p>
<p>Code for ButtonModule.mxml:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Canvas xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;200&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;200&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
			<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.utilities.modular.core.IModuleContext;
			<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.core.IInjector;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> context<span style="color: #000000; font-weight: bold;">:</span>IModuleContext;
&nbsp;
			<span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span>
			<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> parentInjector<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span>IInjector<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
			<span style="color: #000000;">&#123;</span>
				context = <span style="color: #0033ff; font-weight: bold;">new</span> ButtonModuleContext<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span>, <span style="color: #004993;">value</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Button id=<span style="color: #990000;">&quot;myButton&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Canvas<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>The ButtonModule.mxml view defines the UI of the ButtonModule and also initializes the ButtonModuleContext by specifying the contextView and the injector when<br />
the ButtonModule view is instantiated. The contextView is specifies the view that scopes the ModuleContext; i.e. the ModuleContext is only able to map injections/mediators within the contextView. The injector is used to insert  classes into any other classes that as long as both the target and source classes are mapped within the scope of the ModuleContext.</p>
<p>Next, we need to create the a context for the ButtonModule; create an ActionScript Class named ButtonModuleContext.as with a superclass of ModuleContext under the buttonModule folder.</p>
<p>Code for ButtonModuleContext.as:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.digitaldogbyte.buttonModule
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.digitaldogbyte.buttonModule.views.ButtonModuleMediator;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">DisplayObjectContainer</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.system</span>.<span style="color: #004993;">ApplicationDomain</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.core.IInjector;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.utilities.modular.mvcs.ModuleContext;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ButtonModuleContext extends ModuleContext
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ButtonModuleContext<span style="color: #000000;">&#40;</span>contextView<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">DisplayObjectContainer</span>, injector<span style="color: #000000; font-weight: bold;">:</span>IInjector<span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>contextView, <span style="color: #0033ff; font-weight: bold;">true</span>, injector<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> startup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;button module context&quot;</span><span style="color: #000000;">&#41;</span>;
			mediatorMap.mapView<span style="color: #000000;">&#40;</span>ButtonModule, ButtonModuleMediator<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>The ButtonModuleContext simply maps the ButtonModule view to the ButtonModuleMediator. The mediator acts as the &#8220;code-behind&#8221; for the view; it is often used to map event listeners to event handlers for the view and is often contains business logic &#038; presentation logic for view.</p>
<p>The mediator is the last piece required to complete the ButtonModule; create an ActionScript Class named ButtonModuleMediator.as with a superclass of ModuleMediator under the buttonModule/views folder.</p>
<p>Code for ButtonModuleMediator.as:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.digitaldogbyte.buttonModule.views
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.digitaldogbyte.buttonModule.ButtonModule;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.digitaldogbyte.labelModule.events.LabelModuleEvent;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">MouseEvent</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.utilities.modular.mvcs.ModuleMediator;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ButtonModuleMediator extends ModuleMediator
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> view<span style="color: #000000; font-weight: bold;">:</span>ButtonModule;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ButtonModuleMediator<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> onRegister<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			view.myButton.label = <span style="color: #990000;">&quot;display timestamp&quot;</span>;
			addViewListener<span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span>, onButtonClicked, <span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onButtonClicked<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">date</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Date</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			dispatchToModules<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> LabelModuleEvent<span style="color: #000000;">&#40;</span>LabelModuleEvent.DISPLAY_MESSAGE, <span style="color: #004993;">date</span>.<span style="color: #004993;">getTime</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>In the ButtonModuleMediator, we are telling the mediator to listen for a mouse click on the view and handle the mouse click by invoking the onButtonClicked method. The onButtonClicked method then invokes the dispatchToModules method (inherited from ModuleMediator) which checks to see which module has a listener for the LabelModuleEvent.DISPLAY_MESSAGE event and then dispatches the event to that module.</p>
<p>At this point, your project explorer should look like this:</p>
<p><img src="http://www.digitaldogbyte.com/images/rl_modular_demo/rl_modular_project_tree_part1.png" alt="Flex Project Structure with ButtonModule" /></p>
<p><strong>Part 2 &#8211; setting up the second module &#8211; LabelModule</strong></p>
<p>The steps for creating the LabelModule are nearly identical to the steps taken to create the ButtonModule. You will need to create a view, context and mediator.</p>
<p>Code for LabelModule view &#8211; LabelModule.mxml:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Canvas xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;200&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;200&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
			<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.utilities.modular.core.IModuleContext;
			<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.core.IInjector;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> context<span style="color: #000000; font-weight: bold;">:</span>IModuleContext;
&nbsp;
			<span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span>
			<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> parentInjector<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span>IInjector<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
			<span style="color: #000000;">&#123;</span>
				context = <span style="color: #0033ff; font-weight: bold;">new</span> LabelModuleContext<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span>, <span style="color: #004993;">value</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Label id=<span style="color: #990000;">&quot;myLabel&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Canvas<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>Code for LabelModule context &#8211; LabelModuleContext.as with a superclass of ModuleContext:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.digitaldogbyte.labelModule
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.digitaldogbyte.labelModule.view.LabelModuleMediator;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">DisplayObjectContainer</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.system</span>.<span style="color: #004993;">ApplicationDomain</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.core.IInjector;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.utilities.modular.mvcs.ModuleContext;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> LabelModuleContext extends ModuleContext
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> LabelModuleContext<span style="color: #000000;">&#40;</span>contextView<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">DisplayObjectContainer</span>, injector<span style="color: #000000; font-weight: bold;">:</span>IInjector<span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>contextView, <span style="color: #0033ff; font-weight: bold;">true</span>, injector<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> startup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;label module context&quot;</span><span style="color: #000000;">&#41;</span>;
			mediatorMap.mapView<span style="color: #000000;">&#40;</span>LabelModule, LabelModuleMediator<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Code for LabelModule mediator &#8211; LabelModuleMediator.as with a superclass of ModuleMediator in the labelModule/views folder:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.digitaldogbyte.labelModule.view
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.digitaldogbyte.labelModule.LabelModule;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.digitaldogbyte.labelModule.events.LabelModuleEvent;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.utilities.modular.mvcs.ModuleMediator;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> LabelModuleMediator extends ModuleMediator
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> view<span style="color: #000000; font-weight: bold;">:</span>LabelModule;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> LabelModuleMediator<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> onRegister<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			setMessage<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;timestamp will display here&quot;</span><span style="color: #000000;">&#41;</span>;
			eventMap.mapListener<span style="color: #000000;">&#40;</span>moduleDispatcher, LabelModuleEvent.DISPLAY_MESSAGE, onDisplayMessage<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onDisplayMessage<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>LabelModuleEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>event <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>event.<span style="color: #004993;">data</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					setMessage<span style="color: #000000;">&#40;</span>event.<span style="color: #004993;">data</span>.<span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
				<span style="color: #0033ff; font-weight: bold;">else</span>
				<span style="color: #000000;">&#123;</span>
					setMessage<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;event data was null&quot;</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">else</span>
			<span style="color: #000000;">&#123;</span>
				setMessage<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;event was null&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> setMessage<span style="color: #000000;">&#40;</span><span style="color: #004993;">message</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			view.myLabel.<span style="color: #004993;">text</span> = <span style="color: #004993;">message</span>;	
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>In the LabelModuleMediator you will notice that we are register the onDisplayMessage event handler for the LabelModuleEvent.DISPLAY_MESSAGE event.</p>
<p>To allow communication between the ButtonModule and LabelModule, we need to create a custom event. I decided to create the event as the LabelModuleEvent since the LabelModule is the module that will be listening and handling the event, while the ButtonModule only needs to dispatch the event.</p>
<p>The event can be created by adding a new ActionScript class named LabelModuleEvent.as with a superclass of Event in the labelModule/events folder.</p>
<p>Code for LabelModuleEvent.as:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.digitaldogbyte.labelModule.events
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> LabelModuleEvent extends <span style="color: #004993;">Event</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static const DISPLAY_MESSAGE<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;displayMessage&quot;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _data<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> LabelModuleEvent<span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>, <span style="color: #004993;">data</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>, <span style="color: #004993;">bubbles</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span>, <span style="color: #004993;">cancelable</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			_data = <span style="color: #004993;">data</span>;
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span>, <span style="color: #004993;">bubbles</span>, <span style="color: #004993;">cancelable</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">clone</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> LabelModuleEvent<span style="color: #000000;">&#40;</span><span style="color: #004993;">type</span>, <span style="color: #004993;">bubbles</span>, <span style="color: #004993;">cancelable</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> <span style="color: #004993;">data</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> _data;
		<span style="color: #000000;">&#125;</span>		
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>At this point, your project explorer should look like this:</p>
<p><img src="http://www.digitaldogbyte.com/images/rl_modular_demo/rl_modular_project_tree_part2.png" alt="Flex Project Structure with LabelModule" /></p>
<p><strong>Part 3 &#8211; setting up the application shell &#8211; ApplicationShell</strong></p>
<p>You will need to create a view, context and mediator for the ApplicationShell.</p>
<p>Code for ApplicationShell view &#8211; ApplicationShell.mxml:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Canvas xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> preinitialize=<span style="color: #990000;">&quot;preinit();&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span> xmlns<span style="color: #000000; font-weight: bold;">:</span>buttonModule=<span style="color: #990000;">&quot;com.digitaldogbyte.buttonModule.*&quot;</span> xmlns<span style="color: #000000; font-weight: bold;">:</span>labelModule=<span style="color: #990000;">&quot;com.digitaldogbyte.labelModule.*&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
			<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.utilities.modular.mvcs.ModuleContext;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> _context<span style="color: #000000; font-weight: bold;">:</span>ApplicationShellContext;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> preinit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
			<span style="color: #000000;">&#123;</span>
				_context = <span style="color: #0033ff; font-weight: bold;">new</span> ApplicationShellContext<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>HBox<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>buttonModule<span style="color: #000000; font-weight: bold;">:</span>ButtonModule id=<span style="color: #990000;">&quot;buttonModule&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;</span>labelModule<span style="color: #000000; font-weight: bold;">:</span>LabelModule id=<span style="color: #990000;">&quot;labelModule&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>HBox<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Canvas<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>Code for the ApplicationShell context &#8211; ApplicationShellContext.as with superclass of ModuleContext:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.digitaldogbyte.applicationShell
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.digitaldogbyte.applicationShell.views.ApplicationShellMediator;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.digitaldogbyte.buttonModule.ButtonModule;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.digitaldogbyte.labelModule.LabelModule;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">DisplayObjectContainer</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.system</span>.<span style="color: #004993;">ApplicationDomain</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.core.IInjector;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.utilities.modular.mvcs.ModuleContext;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ApplicationShellConteThext extends ModuleContext
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ApplicationShellContext<span style="color: #000000;">&#40;</span>contextView<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">DisplayObjectContainer</span>=<span style="color: #0033ff; font-weight: bold;">null</span>, autoStartup<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">true</span>, parentInjector<span style="color: #000000; font-weight: bold;">:</span>IInjector=<span style="color: #0033ff; font-weight: bold;">null</span>, <span style="color: #004993;">applicationDomain</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ApplicationDomain</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>contextView, autoStartup, parentInjector, <span style="color: #004993;">applicationDomain</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> startup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;application shell context&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			viewMap.mapType<span style="color: #000000;">&#40;</span>ButtonModule<span style="color: #000000;">&#41;</span>;
			viewMap.mapType<span style="color: #000000;">&#40;</span>LabelModule<span style="color: #000000;">&#41;</span>;
&nbsp;
			mediatorMap.mapView<span style="color: #000000;">&#40;</span>ApplicationShell, ApplicationShellMediator<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Code for the ApplicationShell mediator &#8211; ApplicationShellMediator.as with superclass of ModuleMediator within the applicationShell/views folder:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.digitaldogbyte.applicationShell.views
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.digitaldogbyte.applicationShell.ApplicationShell;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.utilities.modular.mvcs.ModuleMediator;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ApplicationShellMediator extends ModuleMediator
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> view<span style="color: #000000; font-weight: bold;">:</span>ApplicationShell;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ApplicationShellMediator<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>		
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>The final project structure should look like this:</p>
<p><img src="http://www.digitaldogbyte.com/images/rl_modular_demo/rl_modular_project_tree_part3.png" alt="Flex Project Structure with ApplicationShell" /></p>
<p><a href="http://www.digitaldogbyte.com/downloads/rl_modular_demo/RL_Modular_Demo.html" target="_blank">Demo</a> &#038; <a href="http://www.digitaldogbyte.com/downloads/rl_modular_demo/srcview/index.html" target="_blank">source</a> files for the tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2010/08/17/robotlegs-modular-utilities-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nokia WRT Extension for Dreamweaver</title>
		<link>http://www.digitaldogbyte.com/2009/06/10/nokia-wrt-extension-for-dreamweaver/</link>
		<comments>http://www.digitaldogbyte.com/2009/06/10/nokia-wrt-extension-for-dreamweaver/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 17:46:41 +0000</pubDate>
		<dc:creator>Herman Wong</dc:creator>
				<category><![CDATA[Dreamweaver]]></category>
		<category><![CDATA[Nokia]]></category>
		<category><![CDATA[plug-in]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=50</guid>
		<description><![CDATA[The Nokia WRT Extension for Dreamweaver CS4 project that I&#8217;ve been working on for the past few months has gone live. The extension can be downloaded from Nokia WRT Forums and Adobe Exchange. The Nokia Extension allows users to author, validate, package and deploy Nokia WRT widgets. The validation, packaging and deployment features were the [...]]]></description>
			<content:encoded><![CDATA[<p>The Nokia WRT Extension for Dreamweaver CS4 project that I&#8217;ve been working on for the past few months has gone live. The extension can be downloaded from <a href="http://www.forum.nokia.com/Tools_Docs_and_Code/Tools/Runtimes/Web_Runtime/Dreamweaver_Extension/" target="_blank">Nokia WRT Forums</a> and <a href="http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&amp;loc=en_us&amp;extid=1794522" target="_blank">Adobe Exchange</a>.</p>
<p>The Nokia Extension allows users to author, validate, package and deploy Nokia WRT widgets.</p>
<p>The validation, packaging and deployment features were the most challenging to implement.</p>
<p>The validation calls the <a href="http://validator.w3.org/" target="_blank">W3C Markup Validation Service</a> which reads the DocType tag in the info.plist (widget configuration file) file to determine the DTD file that is used to validate the info.plist. Documentation on how to use the W3C Validator can be found <a href="http://validator.w3.org/docs/users.html" target="_blank">here</a>.</p>
<p>The packager used for the extension is a Java class written by Alexey Mykhaylov and his team from <a href="http://www.xplorex.com/" target="_blank">Xplorex</a>; the packager is used to compress the files so that they can be deployed to Nokia S60 phones.</p>
<p>The deployment feature required the extension to send packaged widgets to a bluetooth paired phone. To implment this functionality I  had to lean on Alexey and his team to  create a Java wrapper so that I could use the <a href="http://www.bluecove.org/" target="_blank">BlueCove Java library</a>.</p>
<p>I&#8217;d like to give thanks:</p>
<ul>
<li><a href="http://blog.affirmix.com/" target="_blank">Andrew Odri</a> from <a href="http://www.konductor.net/" target="_blank">Konductor</a> for helping me out with his knowledge the Dreamweaver API.</li>
<li>Alexey Mykhaylov and Xplorex for their assistance with the Java integration.</li>
<li><a href="http://weblogs.macromedia.com/sfegette/" target="_blank">Scott Fegette</a> and Chris Bank from Adobe for taking the time to answer my questions.</li>
<li>Michael Bierman and Matt Evered from Nokia for their patience and professionalism when managing the project under tight deadlines.</li>
<li>Otto Salminen and Timo Klinga from Sasken for their hard work in finding most (if not all) of my bugs.</li>
<li>Derek Zarbrook from Xplorex for acting as the contact between Nokia and Nitobi.</li>
<li>My colleague <a href="http://blogs.nitobi.com/chris/" target="_blank">Chris Stone</a> for his awesome UX work and managing the project from <a href="http://www.nitobi.com/" target="_blank">Nitobi</a>&#8216;s side.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2009/06/10/nokia-wrt-extension-for-dreamweaver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dreamweaver CS4&#8242;s JavaScript Codehinting</title>
		<link>http://www.digitaldogbyte.com/2009/05/13/dreamweaver-cs4s-javascript-codehinting/</link>
		<comments>http://www.digitaldogbyte.com/2009/05/13/dreamweaver-cs4s-javascript-codehinting/#comments</comments>
		<pubDate>Thu, 14 May 2009 01:35:10 +0000</pubDate>
		<dc:creator>Herman Wong</dc:creator>
				<category><![CDATA[Dreamweaver]]></category>
		<category><![CDATA[codehinting]]></category>
		<category><![CDATA[extension]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=24</guid>
		<description><![CDATA[One of Dreamweaver CS4&#8242;s new features is the ability to create codehints for JavaScript classes. To create the codehints for a static javascript class you need to follow this xml structure in your codehints file: 1 2 3 4 5 6 7 &#160; &#60;menu pattern=&#34;exampleObject.&#34; casesensitive=&#34;true&#34;&#62; &#60;menuitem label=&#34;identifier&#34; icon=&#34;shared/mm/images/hintProperty.gif&#34; source=&#34;Example Project&#34; object=&#34;exampleObject&#34; /&#62; &#60;menuitem label=&#34;onShow&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>One of Dreamweaver CS4&#8242;s new features is the ability to create codehints for JavaScript classes.</p>
<p>To create the codehints for a static javascript class you need to follow this xml structure in your codehints file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;menu</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;exampleObject.&quot;</span> <span style="color: #000066;">casesensitive</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;menuitem</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;identifier&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;shared/mm/images/hintProperty.gif&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;Example Project&quot;</span> <span style="color: #000066;">object</span>=<span style="color: #ff0000;">&quot;exampleObject&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;menuitem</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;onShow&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;shared/mm/images/hintProperty.gif&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;Example Project&quot;</span> <span style="color: #000066;">object</span>=<span style="color: #ff0000;">&quot;exampleObject&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;menuitem</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;onHide&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;shared/mm/images/hintProperty.gif&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;Example Project&quot;</span> <span style="color: #000066;">object</span>=<span style="color: #ff0000;">&quot;exampleObject&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/menu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;function</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;exampleObject.openURL(String url)&quot;</span> <span style="color: #000066;">casesensitive</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;shared/mm/images/hintFunction.gif&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;Example Project&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<div class="wp-caption alignnone" style="width: 601px"><img title="Codehinting Example for Static Classes" src="http://www.digitaldogbyte.com/images/dw_codehints/StaticClass_CodeHint.png" alt="Codehinting Example for Static Classes" width="591" height="140" /><p class="wp-caption-text">Codehinting Example for Static Classes</p></div>
<p>To create the codehints for an instantiated javascript class you need to follow this xml structure in your codehints file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;function</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;ExampleItem()&quot;</span> <span style="color: #000066;">casesensitive</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;shared/mm/images/hintClass.gif&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;Example Project&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;menu</span> <span style="color: #000066;">classpattern</span>=<span style="color: #ff0000;">&quot;ExampleItem&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;append(ExampleItem childExampleItem)&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;shared/mm/images/hintFunction.gif&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;menuitem</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;ExampleItemStateChanged&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;shared/mm/images/hintEvent.gif&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>	
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;menuitem</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;onSelect&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;shared/mm/images/hintProperty.gif&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;remove(ExampleItem childExampleItem)&quot;</span> <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;shared/mm/images/hintFunction.gif&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/menu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<div class="wp-caption alignnone" style="width: 613px"><img title="Codehinting Example for Instantiated Class" src="http://www.digitaldogbyte.com/images/dw_codehints/InstantiatedClass_CodeHint.png" alt="Codehinting Example for Instantiated Class" width="603" height="126" /><p class="wp-caption-text">Codehinting Example for Instantiated Class</p></div>
<p>The JavaScript codehinting works perfectly in .js files; however I&#8217;ve noticed that the codehints for instantiated JavaScript classes do not display when you are working within &lt;script&gt; tags in .html files.</p>
<p>I&#8217;ve included a simple example Dreamweaver Extension that implements the exampleObject and ExampleItem JavaScript classes in the codehints. You can use the Example_CodeHints.xml file in the <a href="http://www.digitaldogbyte.com/downloads/dw_codehints/Example_CodeHints.zip" target="_blank">source</a> as a reference point.</p>
<p><a href="http://www.digitaldogbyte.com/downloads/dw_codehints/Example_CodeHints.zip" target="_blank">Link to source code download</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2009/05/13/dreamweaver-cs4s-javascript-codehinting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dreamweaver&#8217;s Hidden Extension Eventhandlers</title>
		<link>http://www.digitaldogbyte.com/2009/05/07/dreamweavers-hidden-extension-eventhandlers/</link>
		<comments>http://www.digitaldogbyte.com/2009/05/07/dreamweavers-hidden-extension-eventhandlers/#comments</comments>
		<pubDate>Fri, 08 May 2009 01:23:45 +0000</pubDate>
		<dc:creator>Herman Wong</dc:creator>
				<category><![CDATA[Dreamweaver]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[plug-in]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=15</guid>
		<description><![CDATA[For the last couple of months, I&#8217;ve been tinkering around in Adobe Dreamweaver&#8217;s Extension APIs and uncovering alot of hidden or undocumented features in Dreamweaver&#8217;s API. This will be my first post in a series regarding the Dreamweaver API. In this post I will be discussing the hidden extension eventhandlers in the Dreamweaver API. There [...]]]></description>
			<content:encoded><![CDATA[<p>For the last couple of months, I&#8217;ve been tinkering around in Adobe Dreamweaver&#8217;s Extension APIs and uncovering alot of hidden or undocumented features in Dreamweaver&#8217;s API. This will be my first post in a series regarding the Dreamweaver API. In this post I will be discussing the hidden extension eventhandlers in the Dreamweaver API.</p>
<p>There are three eventhandlers:</p>
<ol>
<li>after save event &#8211; this is triggered when the changes to a file have been saved.</li>
<li>before save event &#8211; this is triggered before the changes to a file have been saved.</li>
<li>on open event &#8211; this is triggered when Dreamweaver (and when documents) are opened.</li>
</ol>
<p>You can find the global events in Dreamweaver&#8217;s default Commands directory.</p>
<p>Mac: Macintosh HD:Applications:Adobe Dreamweaver CS4:configuration:Commands</p>
<p>Windows: C:\Program Files\Adobe\Adobe Dreamweaver CS4\configuration\Commands</p>
<p>The eventhandler files are:</p>
<ol>
<li>_afterSave.htm</li>
<li>_beforeSave.htm</li>
<li>_onOpen.htm</li>
</ol>
<p>To create your own eventhandlers you simple create a prefixed version of the eventhandler command (e.g. alert_afterSave.htm). You can include the necessary JavaScript within &lt;script&gt; tags in your .htm file or you can write a corresponding .js (alert_afterSave.js) file that needs to be included in your .htm file.</p>
<p>I&#8217;ve created a very simple example extension that demonstrates how the eventhandlers work. The .mxp installer and source code can be <a title="Dreamweaver Example Extension" href="http://www.digitaldogbyte.com/downloads/dw_eventhandlers/hello_world_dw_events.zip" target="_blank">downloaded</a> at the end of this post. The example extension will install into your user account&#8217;s application data folder.</p>
<p>Mac: Macintosh HD:Users:&lt;userName&gt;:Library:Application Support:Adobe:Dreamweaver CS4:en_US:Configuration:Commands</p>
<p>Windows: C:\Documents and Settings\&lt;userName&gt;\Application Data\Adobe\Dreamweaver CS4\en_US\Configuration\Commands</p>
<p><a title="Dreamweaver Example Extension" href="http://www.digitaldogbyte.com/downloads/dw_eventhandlers/hello_world_dw_events.zip" target="_blank">Link to source code download</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2009/05/07/dreamweavers-hidden-extension-eventhandlers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AIR Time Tracking Application &#8211; harvestcoop</title>
		<link>http://www.digitaldogbyte.com/2009/02/24/air-time-tracking-application-harvestcoop/</link>
		<comments>http://www.digitaldogbyte.com/2009/02/24/air-time-tracking-application-harvestcoop/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 04:00:39 +0000</pubDate>
		<dc:creator>Herman Wong</dc:creator>
				<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[harvestcoop]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[time tracking]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/2009/02/24/air-time-tracking-application-harvestcoop/</guid>
		<description><![CDATA[I&#8217;ve recently written an AIR time tracking application that uses the Harvest &#38; Coopapp APIs. The code and AIR application can be found on the harvestcoop project page on Google Code. Harvest does provide an iPhone application and also a Harvest Widget for Mac OS X &#38; MS Vista. I decided to create an AIR [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently written an AIR time tracking application that uses the <a href="http://www.getharvest.com/" title="Harvest - Simple Online Time Tracking" target="_blank">Harvest</a> &amp; <a href="http://www.coopapp.com/" title="Co-op App" target="_blank">Coopapp</a> APIs. The code and AIR application can be found on the <a href="http://code.google.com/p/harvestcoop/" title="harvestcoop - Google Code" target="_blank">harvestcoop</a> project page on Google Code.</p>
<p>Harvest does provide an iPhone application and also a Harvest Widget for Mac OS X &amp; MS Vista. I decided to create an AIR application so that users on operating systems that don&#8217;t have widget support can do their time tracking from the comfort of their own desktops.</p>
<p>The harvestcoop AIR application currently works with Harvest accounts that have widget support.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2009/02/24/air-time-tracking-application-harvestcoop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PureMVC Framework for ActionScript 3.0</title>
		<link>http://www.digitaldogbyte.com/2009/02/19/puremvc-framework-for-actionscript-30/</link>
		<comments>http://www.digitaldogbyte.com/2009/02/19/puremvc-framework-for-actionscript-30/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 18:47:08 +0000</pubDate>
		<dc:creator>Herman Wong</dc:creator>
				<category><![CDATA[framework]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[PureMVC]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/2009/02/19/puremvc-framework-for-actionscript-30/</guid>
		<description><![CDATA[I&#8217;ll be presenting on the PureMVC framework next week (February 26) at the Vancouver Flash Platform February Meetup. Here are the links to the presentation&#8217;s slides, sample application and code.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be presenting on the <a title="PureMVC Framework" href="http://www.puremvc.org/" target="_blank">PureMVC</a> framework next week (February 26) at the <a title="Vancouver Flash Platform February Meetup" href="http://flash.meetup.com/110/calendar/9632527/" target="_blank">Vancouver Flash Platform February Meetup</a>.</p>
<p>Here are the links to the presentation&#8217;s <a title="Presentation Slides" href="http://www.digitaldogbyte.com/downloads/puremvc/assets/MVC_Frameworks.ppt" target="_blank">slides</a>, sample <a title="PureMVC Sample Application" href="http://www.digitaldogbyte.com/downloads/puremvc/PureMVCExample.html" target="_blank">application</a> and <a title="PureMVC Sample Application Code" href="http://www.digitaldogbyte.com/downloads/puremvc/srcview/index.html" target="_blank">code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2009/02/19/puremvc-framework-for-actionscript-30/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLite Encryption in AIR 1.5</title>
		<link>http://www.digitaldogbyte.com/2009/02/10/sqlite-encryption-in-air-15/</link>
		<comments>http://www.digitaldogbyte.com/2009/02/10/sqlite-encryption-in-air-15/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 03:28:44 +0000</pubDate>
		<dc:creator>Herman Wong</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[AIR]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=9</guid>
		<description><![CDATA[The Adobe AIR runtime includes a SQLite database so that you can create data driven applications. The following are the default locations for the SQLite database: Mac OS X: /Users/&#60;userName&#62;/Library/Preferences/&#60;applicationName&#62;/Local Store/&#60;databaseFileName&#62;.db Windows: C:\Documents and Settings\&#60;userName&#62;\Application Data\&#60;applicationName&#62;\Local Store\&#60;databaseFileName&#62;.db Adobe AIR 1.5 introduces a feature to encrypt the SQLite database so that you can secure the contents [...]]]></description>
			<content:encoded><![CDATA[<p>The Adobe AIR runtime includes a <a href="http://www.sqlite.org/index.html" title="sqlite.org" target="_blank">SQLite</a> database so that you can create data driven applications.</p>
<p>The following are the default locations for the SQLite database:</p>
<p>Mac OS X:</p>
<p>/Users/&lt;userName&gt;/Library/Preferences/&lt;applicationName&gt;/Local Store/&lt;databaseFileName&gt;.db</p>
<p>Windows:</p>
<p>C:\Documents and Settings\&lt;userName&gt;\Application Data\&lt;applicationName&gt;\Local Store\&lt;databaseFileName&gt;.db</p>
<p>Adobe AIR 1.5 introduces a feature to encrypt the SQLite database so that you can secure the contents of database. This is could come in handy if you are writing an application that stores information such as customer contact data.</p>
<p>The <a href="http://livedocs.adobe.com/flex/3/langref/flash/data/SQLConnection.html#open()" title="Open Method" target="_blank">Open</a> method and the <a href="http://livedocs.adobe.com/flex/3/langref/flash/data/SQLConnection.html#openAsync()" title="OpenAsync Method" target="_blank">OpenAsync</a> method of the <a href="http://livedocs.adobe.com/flex/3/langref/flash/data/SQLConnection.html" title="SQLConnection Class" target="_blank">SQLConnection</a> class include an encryptionKey parameter; this parameter tells AIR to encrypt the database file.</p>
<p>The code sample below shows you how to create / open an encrypted SQLite database. Links to an example application &amp; code can be found at the end of this article.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> com.digitaldogbyte.util.Encryption;
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> dbConn<span style="color: #000000; font-weight: bold;">:</span>SQLConnection;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> dbFile<span style="color: #000000; font-weight: bold;">:</span>File;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> dbKey<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span>;
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	dbKey = Encryption.retrieveKey<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	dbFile = File.applicationStorageDirectory.resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;EncryptionExample.db&quot;</span><span style="color: #000000;">&#41;</span>;
	dbFile.createDirectory<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	dbConn = <span style="color: #0033ff; font-weight: bold;">new</span> SQLConnection<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	dbConn.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>SQLEvent.<span style="color: #004993;">OPEN</span>, handleDbOpen<span style="color: #000000;">&#41;</span>;
	dbConn.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>SQLErrorEvent.<span style="color: #004993;">ERROR</span>, handleDbError<span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #009900;">// by passing in the dbKey variable as the encryptionKey parameter we are telling AIR to encrypt the SQLite database</span>
	dbConn.openAsync<span style="color: #000000;">&#40;</span>dbFile, SQLMode.CREATE, <span style="color: #0033ff; font-weight: bold;">null</span>, <span style="color: #0033ff; font-weight: bold;">false</span>, <span style="color: #000000; font-weight:bold;">1024</span>, dbKey<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Let&#8217;s take a look at the Encryption class to see how the dbKey ByteArray is created. The dbKey value is assigned the return value of the retrieveKey method from the Encryption class. The retrieveKey method checks to see if a key already exists in the application&#8217;s EncryptedLocalStore. If the key already exists the retrieveKey method will return the existing key, however if the key does not exist; the generateKey method is called to create a key.</p>
<p>The generateKey method uses the <a href="http://code.google.com/p/as3crypto/" title="as3crypto library" target="_blank">as3crypto</a> library&#8217;s Random type to create a key. This key is required to read &amp; write to the encrypted database.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.digitaldogbyte.util
<span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.hurlant.crypto.Crypto;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.hurlant.crypto.prng.Random;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.hurlant.crypto.symmetric.AESKey;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.hurlant.crypto.symmetric.ECBMode;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.hurlant.crypto.symmetric.ICipher;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.hurlant.util.Hex;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> flash.<span style="color: #004993;">data</span>.EncryptedLocalStore;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">ByteArray</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Encryption
	<span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> _key<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #339966; font-weight: bold;">function</span> generateKey<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// create key - write to encrypted local store</span>
			_key = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ByteArray</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">random</span><span style="color: #000000; font-weight: bold;">:</span>Random = <span style="color: #0033ff; font-weight: bold;">new</span> Random<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">random</span>.nextBytes<span style="color: #000000;">&#40;</span>_key, <span style="color: #000000; font-weight:bold;">16</span><span style="color: #000000;">&#41;</span>;
			flash.<span style="color: #004993;">data</span>.EncryptedLocalStore.setItem<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;key&quot;</span>,_key<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> retrieveKey<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// try to retrieve key from encrypted local store</span>
			_key = flash.<span style="color: #004993;">data</span>.EncryptedLocalStore.getItem<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;key&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// if no key found in encrypted local store - create a key</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_key == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				generateKey<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> _key;
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>After you&#8217;ve created the encrypted database you can navigate to the database file and try to open it. The database file will not open in your <a href="http://sqlitebrowser.sourceforge.net" target="_blank" title="SQLite Database Browser">database browser</a> application since the actual database file has been encrypted.</p>
<p><img src="http://www.digitaldogbyte.com/images/sqlite_encryption/sqlite_open_error.png" alt="SQLite open error" border="0" height="417" width="511" /></p>
<p>Here are the download links to the example <a href="http://www.digitaldogbyte.com/downloads/sqlite_encryption/SQLiteEncryption.air" title="SQLite Encryption Sample Application" target="_blank">application</a> &amp; <a href="http://www.digitaldogbyte.com/downloads/sqlite_encryption/SQLiteEncryption.zip" title="SQLite Encryption Sample Application Code" target="_blank">code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2009/02/10/sqlite-encryption-in-air-15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Encrypting Local Data with Adobe AIR</title>
		<link>http://www.digitaldogbyte.com/2009/01/17/encrypting-local-data-with-adobe-air/</link>
		<comments>http://www.digitaldogbyte.com/2009/01/17/encrypting-local-data-with-adobe-air/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 19:39:51 +0000</pubDate>
		<dc:creator>Herman Wong</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[AIR]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=8</guid>
		<description><![CDATA[The Adobe AIR 1.1 runtime provides built-in encryption for the local store. This feature can be used to secure sensitive information like usernames &#38; passwords for web services. The encrypted local store can be found at these locations on a user&#8217;s computer: Windows: C:\Documents and Settings\&#60;username&#62;\Application Data\Adobe\AIR\ELS\ Mac OS: /Users/&#60;username&#62;/Library/Application Support/Adobe/AIR/ELS/ To use the AIR&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>The Adobe AIR 1.1 runtime provides built-in encryption for the local store.</p>
<p>This feature can be used to secure sensitive information like usernames &amp; passwords for web services.</p>
<p>The encrypted local store can be found at these locations on a user&#8217;s computer:</p>
<p>Windows: C:\Documents and Settings\&lt;username&gt;\Application Data\Adobe\AIR\ELS\</p>
<p>Mac OS: /Users/&lt;username&gt;/Library/Application Support/Adobe/AIR/ELS/</p>
<p>To use the AIR&#8217;s encrypted local store you will need to include the following packages:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> flash.<span style="color: #004993;">data</span>.EncryptedLocalStore;
&nbsp;
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">ByteArray</span>;</pre></td></tr></table></div>

<p>The following code shows an example of encrypting a string and then storing it in the EncryptedLocalStore object. The strToEncrypt string needs to be converted into a ByteArray since the EncryptedLocalStore stores all of it&#8217;s data as a hash table that uses strings as keys and byte arrays for the data. In our example, we convert the strToEncrypt into a byteArray as the myByteArray variable using the ByteArray object&#8217;s writeUTFBytes method. We are now ready to save our data into the EncryptedLocalStore, which is done by using the EncryptedLocalStore&#8217;s setItem method. The setItem method takes a string parameter that it uses as the key for the hash table and then a byte array as the data that it needs to store.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> strToEncrypt<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;Herman&quot;</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> myByteArray<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ByteArray</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
myByteArray.<span style="color: #004993;">writeUTFBytes</span><span style="color: #000000;">&#40;</span>strToEncrypt<span style="color: #000000;">&#41;</span>;
&nbsp;
EncryptedLocalStore.setItem<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;firstName&quot;</span>, myByteArray<span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<p>To retrieve the encrypted data from the EncryptedLocaStore you will need to use the getItem method and the string key for the data that you want to retrieve from the hash table.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> storedValue<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span> = EncryptedLocalStore.getItem<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;firstName&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// get the string from the storedValue byte array and store in the strDecrypted variable</span>
<span style="color: #6699cc; font-weight: bold;">var</span> strDecrypted<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = storedValue.<span style="color: #004993;">readUTFBytes</span><span style="color: #000000;">&#40;</span>storedValue.<span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>strDecrypted<span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// &quot;Herman&quot;</span>
&nbsp;
<span style="color: #009900;">// read the string from the storedValue byte array</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>storedValue.<span style="color: #004993;">readUTFBytes</span><span style="color: #000000;">&#40;</span>storedValue.<span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// &quot;Herman&quot;</span></pre></td></tr></table></div>

<p>More documentation can on the EncryptedLocalStore class can be found on <a href="http://help.adobe.com/en_US/AIR/1.1/devappsflex/WS5b3ccc516d4fbf351e63e3d118666ade46-7e31.html" target="_blank">Adobe&#8217;s site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2009/01/17/encrypting-local-data-with-adobe-air/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
