<?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>GridLinked to RUX &#187; Flex</title>
	<atom:link href="http://www.gridlinked.info/Flex/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gridlinked.info</link>
	<description>Patterns with Flex, RUX, and software</description>
	<lastBuildDate>Fri, 26 Feb 2010 22:18:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flex i18n with LocalizationMaps &#8211; Video Tutorial &amp; Source</title>
		<link>http://www.gridlinked.info/flex-i18n-with-localizationmaps-video-tutorial-source/</link>
		<comments>http://www.gridlinked.info/flex-i18n-with-localizationmaps-video-tutorial-source/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 20:41:34 +0000</pubDate>
		<dc:creator>thomasb</dc:creator>
				<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Localization]]></category>
		<category><![CDATA[Mate]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[l10n]]></category>
		<category><![CDATA[resourceManager]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://www.gridlinked.info/?p=576</guid>
		<description><![CDATA[In this Part 2 on Flex l10n solutions, I provide (1) an architecture diagram, (2) a localized Registration demo application, and (3) a video tutorial on why and how to use LocalizationMaps for your own custom solutions. Also included is the source code for both the Registration demo and the "l10n LocaleMap" library.<br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=9.8" /></div><div>Rating: 9.8/<strong>10</strong> (8 votes cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p>
In a previous article, I blogged about <span style="text-decoration: underline;"><a href="http://www.gridlinked.info/amazing-i18n-solutions-for-flex-3-4/"></span> Flex i18n and an &#8220;Inversion of Control&#8221;</a> (IOC) approach to radically simplify localization issues within your Flex solutions. That article discussed the issues with the current, traditional localization implementations [used in Flex applications] and then presented the new LocalizationMap solution. </p>
<p>In this Part 2 on Flex l10n solutions, I offer a video tutorial, a demo of a Registration application localized to support Spanish and English, and an architecture diagram of LocalizationMap usages. </p>
<p>Also included with the live Flex demo is <a href="http://github.com/ThomasBurleson/l10nInjection_Samples/archives/master" style="text-decoration: underline; color: rgb(153, 0, 0);">source code</a> for both the demo and the l10n LocaleMap library.</p>
<p>Below is a screencast video tutorial; in which I provide a narrated overview of the issue involved with enabling your Flex application to support multiple languages (and locales). I also present LocalizationMaps as a great solution to easily and rapidly provide l10n (localization) features within your custom Flex apps. </p>
<div class="img aligncenter" style="width:422px;">
	<a rel="lightbox;height=490;width=650" href="http://www.gridlinked.info/flash/podcasts/Podcast_Flexi18nLocalizationMaps.html" style="color: #999999;" ><img src="/images/2009/12/PodcastPlayer.jpg" alt="Figure 3: Video Tutorial" width="422" height="317" /></a>
	<div>Figure 1: Video Tutorial (click to play)</div>
</div>
<p>Note that the video/podcast tutorial may take 5-10 seconds for streaming to start.</p>
<p>Shown below is a live demo of the localized Registration application. This application has l10n (localization) support for English and Spanish.  In the live demo, select the Spanish or English flags to change the current locale. Watch what happens to all the strings and styles. </p>
<p>Be sure to complete the registration fields and click the Register button to see the view state changes to show a localized Thank you with fullname and email parameters (sounds confusing&#8230; just try it)!</p>
<div class="img aligncenter" style="width:278px;">
	<a rel="lightbox;height=700;width=600" href="http://www.gridlinked.info/flash/l10nRegistration/RegistrationDemo_i18n.html" style="color: #eaeaea;" ><img src="/images/2009/12/RegistrationDemo_l10n.png" alt="LocalizationMap Usage Diagram" width="278" height="335" /></a>
	<div>Figure 2: RegistrationDemo w/ Locales (click to launch)</div>
</div>
<p>Simply right-click to access the source code for both the demo and the l10n LocaleMap library. Or click here to <a href="http://github.com/ThomasBurleson/l10nInjection_Samples/archives/master" style="text-decoration: underline; color: rgb(153, 0, 0);">download</a> the source code.  Before you review the source code, however, I encourage you to review the architecture diagram shown Figure 3 and listen to the Screencast tutorial (Figure 1). </p>
<p>
Here is a high-level diagram that illustrates how the LocalizationMap is used within your custom applications. I encourage you to conceptualize the LocalizationMap as a plug-in to your application&#8230; an extension that is completely transparent (hidden) from your presentation/GUI layer.</p>
<div class="img aligncenter" style="width:490px;">
	<a rel="lightbox;height=592;width=981" href="http://www.gridlinked.info/images/2009/12/localemap_overview.png" style="color: #ffffff;" ><img src="/images/2009/12/localemap_overview.png" alt="LocalizationMap Usage Diagram" width="490" height="296" /></a>
	<div>Figure 3: LocalizationMap Usage Diagram (click to zoom)</div>
</div>
<br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=9.8" /></div><div>Rating: 9.8/<strong>10</strong> (8 votes cast)</div><br /><hr />
<p><small>© Thomas Burleson for <a href="http://www.gridlinked.info">GridLinked to RUX</a>, 2009.   
&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;  
<a href="http://feedburner.google.com/fb/a/mailverify?uri=GridlinkedToRux&amp;loc=en_US"><span style="color:#900">Subscribe by Email</span></a> |
<a href="mailto:ThomasBurleson@GMail.com">Contact Author</a> 	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;
<a href="http://www.gridlinked.info/flex-i18n-with-localizationmaps-video-tutorial-source/">Permalink</a> |    
<a href="http://www.gridlinked.info/flex-i18n-with-localizationmaps-video-tutorial-source/#comments">20 comments</a>
<br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.gridlinked.info/flex-i18n-with-localizationmaps-video-tutorial-source/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Amazing i18n IOC solutions for Flex</title>
		<link>http://www.gridlinked.info/amazing-i18n-solutions-for-flex-3-4/</link>
		<comments>http://www.gridlinked.info/amazing-i18n-solutions-for-flex-3-4/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 16:15:40 +0000</pubDate>
		<dc:creator>thomasb</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Localization]]></category>
		<category><![CDATA[Mate]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[bundles]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[l10n]]></category>
		<category><![CDATA[resourceManager]]></category>
		<category><![CDATA[translators]]></category>

		<guid isPermaLink="false">http://www.gridlinked.info/?p=453</guid>
		<description><![CDATA[The Flex platform provides capabilities that allow deveopers to deploy Flex apps localized for cultural and language differences. Developers can easily extend their applications to support localized content such as strings, stylesheets, skinning code/classes, and embedding graphics.  Adobe has provided significant documentation and recommended solutions that are becoming an industry standard for localizing Flex apps. Use the Adobe/industry localization standards, however, and you are SCREWED! The industry-recommended changes for l10n becomes a maintenance nightmare and is - IMHO - completely unusable! Why not use Flex Behavior Injection IOC techniques to inject localized assets during runtime? This feature is very similar to that used in the SWIZ, Mate, and other IOC frameworks. So now you, as the developer, never need to embed resourceManager calls in any of your view components. That is really COOL! <br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=9.6" /></div><div>Rating: 9.6/<strong>10</strong> (18 votes cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p>At some point, Flash and Flex developers encounter the issues of modifying a Flex/Flash rich internet application (RIA) to support another language and accomodate software changes for specific cultural preferences. This article focuses on localization of Flash solutions implemented with Flex 3 or Flex 4. Both Flash CS4 and the Flex frameworks provide localization tools and programmatic support features for Flash applications and widgets. Unfortunately the support for localization differs significantly between the toolsets and frameworks offered.<br />
<br/>Internationalization (i18n) is the process of generalizing a product so that it can handle multiple languages and cultural conventions without the need for redesign. i18n processes usually take place at the level of program design and documentation development. Localization (l10n) is the process of adapting products and services (web sites, documents, data files, videos, manuals, and software interfaces). Software localization is the adaptation of static text, skins, images, sytles, fonts [etc.] in accordance to linguistic, cultural, technical, and other locale-specific requirements of the target market. </p>
<p>With cloud-services, market globalization, and radical growths in both online and mobile applications, Flash i18n solutions will play critical roles in product differentiation and market acquisition. The importance and growth of the localization market is illustrated in the chart below.</p>
<p><img src="http://www.gridlinked.info/images/2009/11/i18n/marketGrowths.gif" width="598" height="259" alt="Localization Market Growths" longdesc="Market Growths for Localization Services" /></p>
<p>As mentioned earlier, localization is the process of including assets to support multiple locales. A locale is the combination of a language and a country code. This is required for country differences in language syntatics and culture. For example, an application in the en_US (USA) locale might spell the word &quot;color&quot;, whereas the word would be &quot;colour&quot; in the en_GB (Great Britain) locale. Localization goes beyond just translating Strings used in your application. It can also include any type of asset such as audio files, images, and videos. Because the meanings of colors and images may vary based on the culture, you should change the styles used by your application &#8211; in addition to the language used &#8211; based on the locale.</p>
<div style="margin: 1px 0pt;" id="pullquote-con">What are the <span style="color:#900">i18n</span> technology impacts for Flash applications ?</div>
<p>In order to localize (l10n) Flex 4 applications, you may use built-in support for accessing compiled resource bundles or create your own solution to access localized assets stored in remote database tables. To use the built-in Flex mx framework solutions, you first </p>
<ul>
<li>Create properties files (key/value pairs) that define the localized assets. </li>
<li>Use ANT scripts to compile these properties files into resource modules from the properties files </li>
<li>Use custom code to request specific localized bundles</li>
<li>Use custom code to on-demand load the &quot;compiled resource bundles&quot; OR statically compile all bundles into the application (not recommended).</li>
<li>Lastly, you must resolve i18n business processes and complexities when involving out-sourced translators; required to provide localized translations to each text string.</li>
</ul>
<p>Flex allows the developer to localize strings, skinning code/classes, and embedding graphics. These allows Flex apps to localize for cultural differences also (stylesheets, colors, images, etc.) Note that many Flex applications load dynamic xml content; content that may also need to be localized. Using &quot;best practices&quot; approaches to localization will provide for easy maintenance and on-demand additions of localized resource bundles. As noted above, Java ANT scripts are usually employed to compile the localized files and assets into run-time loadable bundles.</p>
<ul>
<li><a href="http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:_Runtime_Localization" target="_blank">Flex 3: Runtime Localizations</a> </li>
<li><a href="http://www.webkitchen.be/2008/12/09/how-to-localize-your-flexair-applications/" target="_blank">How to Localize your Flex Air applications (video)</a></li>
</ul>
<p>Flash IDE tools do not support the Flex solution for resource bundles and compiled resource swfs. Instead a Locale class is provided that supports loading locale-based XML files and provides support for string look-ups by locale and ID codes. While localized content can by dynamically loaded at runtime, the GUI controls must be programmatically updated [after the localized text or XML data has loaded]. Note that the Locale class does not support loading of localized skins and images; only string-based content is supported.</p>
<p>Adobe and the developer community offer a plethora of articles and videos for developers to self-train and implement Flex l10n solutions. Recently, two Flex entrepreneurs created an open-source tool called ResourceManager and a Flex/AIR solution called <a href="http://www.dehats.com/drupal/?q=node/93"  target="_blank"><span style="text-decoration: underline; color:#900">Lupo Manager</span></a>;both focused on providing tools to easily manage properties files and modify source code to accommodate l10n features.
</p>
<p>Those tools are a step in the right direction and I give a big shout out to David Deraedt for his efforts. In fact, Adobe has provided significant documentation and recommended solutions to be used as an industry standard for localizing Flex apps. The Flex community has myriad blogs and snippets that discuss the issues. But&#8230;</p>
<div style="margin: 1px 0pt;" id="pullquote-con">Use the Adobe/industry localization standard&#8230; and you are <span style="color:#900">SCREWED!</span></div>
<p>Now before you get really offended, realize that I deliberately used crude expletives to (a) grab your attention, (b) highlight my dismay and (c) set the stage for a better solution. Let me show you what I mean. Consider a typical registration [shown below] that has validation, remembers last login, supports english error messages, and more. Note that this version of the application does not yet support l10n:</p>
<div class="img aligncenter" style="width:232px;">
	<a rel="lightbox;height=600;width=500" href="http://www.gridlinked.info/flash/i18n/i18nDemo.html"><img src="/images/2009/11/i18n/playDemo1.jpg" alt="Registration Demo (w/out i18n)" width="232" height="275" /></a>
	<div>Figure 1: Registration Demo (click to launch)</div>
</div>
</p>
<p><br/><br />
To appreciate the impacts of l10n support, let&#8217;s first look at the code used in the demo. In particular let&#8217;s look at the MXML BEFORE it has l10n-enabling code modifications:</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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;!--</span>
       Component<span style="color: #000000; font-weight: bold;">:</span> Sign<span style="color: #000000; font-weight: bold;">-</span><span style="color: #0033ff; font-weight: bold;">in</span> Form has <span style="color: #990000;">&quot;registration&quot;</span> and <span style="color: #990000;">&quot;already registered 
                           child components.
--&gt;
&lt;?xml version=&quot;</span><span style="color: #000000; font-weight:bold;">1.0</span><span style="color: #990000;">&quot; encoding=&quot;</span>utf<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">8</span><span style="color: #990000;">&quot;?&gt;
&lt;mx:Canvas id=&quot;</span>registerArea<span style="color: #990000;">&quot;
		   x=&quot;</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #990000;">&quot; top=&quot;</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #990000;">&quot; bottom=&quot;</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #990000;">&quot; 
		   cacheAsBitmap=&quot;</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #990000;">&quot;
		   horizontalScrollPolicy=&quot;</span>off<span style="color: #990000;">&quot; verticalScrollPolicy=&quot;</span>off<span style="color: #990000;">&quot;
		   styleName=&quot;</span>registrationForm<span style="color: #990000;">&quot; &gt;
&nbsp;
	&lt;forms:RegistrationForm 	id=&quot;</span>frmRegister<span style="color: #990000;">&quot; 	account=&quot;</span><span style="color: #000000;">&#123;</span>visitor<span style="color: #000000;">&#125;</span><span style="color: #990000;">&quot; 		x=&quot;</span><span style="color: #000000; font-weight:bold;">25</span><span style="color: #990000;">&quot; top=&quot;</span><span style="color: #000000; font-weight:bold;">33</span><span style="color: #990000;">&quot;		width=&quot;</span><span style="color: #000000; font-weight:bold;">386</span><span style="color: #990000;">&quot; height=&quot;</span><span style="color: #000000; font-weight:bold;">290</span><span style="color: #990000;">&quot; mouseDown=&quot;</span>frmSignin.clearErrors<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<span style="color: #990000;">&quot;	/&gt;
	&lt;forms:AlreadyRegisteredForm 	id=&quot;</span>frmSignin<span style="color: #990000;">&quot;		email=&quot;</span><span style="color: #000000;">&#123;</span>visitor.email<span style="color: #000000;">&#125;</span><span style="color: #990000;">&quot; 	x=&quot;</span><span style="color: #000000; font-weight:bold;">25</span><span style="color: #990000;">&quot; top=&quot;</span><span style="color: #000000; font-weight:bold;">343</span><span style="color: #990000;">&quot;	width=&quot;</span><span style="color: #000000; font-weight:bold;">386</span><span style="color: #990000;">&quot; height=&quot;</span><span style="color: #000000; font-weight:bold;">111</span><span style="color: #990000;">&quot; mouseDown=&quot;</span>frmRegister.clearErrors<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<span style="color: #990000;">&quot;	/&gt;
&nbsp;
&lt;/mx:Canvas&gt;</span></pre></td></tr></table></div>

<p><br/></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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;!--</span> 
       Component<span style="color: #000000; font-weight: bold;">:</span>  New Account Registration  
<span style="color: #000000; font-weight: bold;">--&gt;</span>
<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 	<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;386&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;290&quot;</span>
			clipContent=<span style="color: #990000;">&quot;false&quot;</span>
		 	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: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<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: #3f5fbf;">/** Removed while displaying in blog... */</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>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> id=<span style="color: #990000;">&quot;registrationValidators&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>StringValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtFirstName}&quot;</span> 	property=<span style="color: #990000;">&quot;text&quot;</span> 		 required=<span style="color: #990000;">&quot;true&quot;</span> minLength=<span style="color: #990000;">&quot;2&quot;</span> requiredFieldError=<span style="color: #990000;">&quot;First name is required!&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>StringValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtLastName}&quot;</span> 		property=<span style="color: #990000;">&quot;text&quot;</span> 		 required=<span style="color: #990000;">&quot;true&quot;</span> minLength=<span style="color: #990000;">&quot;2&quot;</span> requiredFieldError=<span style="color: #990000;">&quot;Last name is required!&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>EmailValidator  <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtEmail}&quot;</span> 		property=<span style="color: #990000;">&quot;text&quot;</span>			 required=<span style="color: #990000;">&quot;true&quot;</span> 			   requiredFieldError=<span style="color: #990000;">&quot;A valid email is required!&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>StringValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtCompany}&quot;</span> 		property=<span style="color: #990000;">&quot;text&quot;</span> 		 required=<span style="color: #990000;">&quot;true&quot;</span> minLength=<span style="color: #990000;">&quot;2&quot;</span> requiredFieldError=<span style="color: #990000;">&quot;A company name is required!&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>StringValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtPostal}&quot;</span> 		property=<span style="color: #990000;">&quot;text&quot;</span> 		 required=<span style="color: #990000;">&quot;true&quot;</span> minLength=<span style="color: #990000;">&quot;2&quot;</span> requiredFieldError=<span style="color: #990000;">&quot;What is your Postal Code?&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>PhoneNumberValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtPhone}&quot;</span>	property=<span style="color: #990000;">&quot;text&quot;</span>			 required=<span style="color: #990000;">&quot;true&quot;</span> minDigits=<span style="color: #990000;">&quot;10&quot;</span> requiredFieldError=<span style="color: #990000;">&quot;A valid phone # is required; e.g (515.221.3216)&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>NumberValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{cmbCountry}&quot;</span>		property=<span style="color: #990000;">&quot;selectedIndex&quot;</span> required=<span style="color: #990000;">&quot;true&quot;</span> minValue=<span style="color: #990000;">&quot;0&quot;</span>  lowerThanMinError=<span style="color: #990000;">&quot;Please select your Country of residence&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>NumberValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{cmbState}&quot;</span>			property=<span style="color: #990000;">&quot;selectedIndex&quot;</span> required=<span style="color: #990000;">&quot;true&quot;</span> minValue=<span style="color: #990000;">&quot;0&quot;</span>  lowerThanMinError=<span style="color: #990000;">&quot;Please select a US State of residence&quot;</span> <span style="color: #004993;">enabled</span>=<span style="color: #990000;">&quot;{cmbCountry.selectedItem == Countries.USA}&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>Array<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<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;lblTitle&quot;</span> 	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Register Now&quot;</span> styleName=<span style="color: #990000;">&quot;siHeader&quot;</span>   <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;0&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>Label id=<span style="color: #990000;">&quot;lblSubTitle&quot;</span> 	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;It only takes a few seconds&quot;</span> styleName=<span style="color: #990000;">&quot;siText&quot;</span>  <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;2&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;35&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>Label id=<span style="color: #990000;">&quot;lblMsg&quot;</span> 		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;(All fields are required)&quot;</span> styleName=<span style="color: #990000;">&quot;siText&quot;</span> <span style="color: #004993;">fontStyle</span>=<span style="color: #990000;">&quot;italic&quot;</span> textAlign=<span style="color: #990000;">&quot;right&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;37&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;232&quot;</span> <span style="color: #004993;">fontSize</span>=<span style="color: #990000;">&quot;10&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblFirstName&quot;</span> 	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;First Name:&quot;</span> styleName=<span style="color: #990000;">&quot;siFieldLabel&quot;</span>   <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;65&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;-2&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>TextInput 	id=<span style="color: #990000;">&quot;txtFirstName&quot;</span> 	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.firstName}&quot;</span> 	minWidth=<span style="color: #990000;">&quot;168&quot;</span> 								
									<span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>  <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;81&quot;</span> <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;1&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>Label 	id=<span style="color: #990000;">&quot;lblLastName&quot;</span>	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Last Name:&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;181&quot;</span>  minWidth=<span style="color: #990000;">&quot;70&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;65&quot;</span>			styleName=<span style="color: #990000;">&quot;siFieldLabel&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>TextInput 	id=<span style="color: #990000;">&quot;txtLastName&quot;</span>  	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.lastName}&quot;</span>		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;168&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;183&quot;</span> 						
									<span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>  <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;81&quot;</span> <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;2&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblEmail&quot;</span> 		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;eMail:&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;70&quot;</span>  <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;-3&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;111&quot;</span> 	styleName=<span style="color: #990000;">&quot;siFieldLabel&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>TextInput 	id=<span style="color: #990000;">&quot;txtEmail&quot;</span> 		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.email}&quot;</span>			<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;168&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;127&quot;</span> 						
									<span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>  <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;3&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>Label 	id=<span style="color: #990000;">&quot;lblCompany&quot;</span>		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Company:&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;181&quot;</span>	 <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;70&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;111&quot;</span>			styleName=<span style="color: #990000;">&quot;siFieldLabel&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>TextInput 	id=<span style="color: #990000;">&quot;txtCompany&quot;</span> 	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.company}&quot;</span> 		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;168&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;127&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;183&quot;</span> 				
									<span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>   <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;4&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblZip&quot;</span> 		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Postal&quot;</span>	 <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;70&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;159&quot;</span>   <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;240&quot;</span>  styleName=<span style="color: #990000;">&quot;siFieldLabel&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>TextInput 	id=<span style="color: #990000;">&quot;txtPostal&quot;</span>		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.postal}&quot;</span> 		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;109&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;242&quot;</span> 						
									<span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>  <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;175&quot;</span> <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;6&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblCountry&quot;</span>		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Country&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;-2&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;70&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;159&quot;</span>			styleName=<span style="color: #990000;">&quot;siFieldLabel&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>ComboBox 	id=<span style="color: #990000;">&quot;cmbCountry&quot;</span> 	dataProvider=<span style="color: #990000;">&quot;{_countries}&quot;</span>		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;230&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;176&quot;</span>					
									<span style="color: #004993;">change</span>=<span style="color: #990000;">&quot;onCountryChanged();&quot;</span>			
									prompt=<span style="color: #990000;">&quot;Please select your Country...&quot;</span>  <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;5&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblState&quot;</span>		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;State:&quot;</span>	 <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;70&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;-1&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;205&quot;</span>	styleName=<span style="color: #990000;">&quot;siFieldLabel&quot;</span> 					 
									<span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;{(cmbCountry.selectedItem == Countries.USA) ? 1 : .3}&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>ComboBox 	id=<span style="color: #990000;">&quot;cmbState&quot;</span>		dataProvider=<span style="color: #990000;">&quot;{_states}&quot;</span>		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;230&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;222&quot;</span> 					
									<span style="color: #004993;">change</span>=<span style="color: #990000;">&quot;onStateChanged();&quot;</span>	 			selectedIndex=<span style="color: #990000;">&quot;-1&quot;</span>									
									prompt=<span style="color: #990000;">&quot;Please select a State...&quot;</span> 	<span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;7&quot;</span>		<span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblPhone&quot;</span> 		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Phone:&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;70&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;240&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;205&quot;</span>     styleName=<span style="color: #990000;">&quot;siFieldLabel&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>TextInput 	id=<span style="color: #990000;">&quot;txtPhone&quot;</span>		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.phone}&quot;</span> 		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;109&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;242&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;222&quot;</span>  				
									<span style="color: #004993;">restrict</span>=<span style="color: #990000;">&quot;0-9,.-&quot;</span> <span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>   <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;8&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Image id=<span style="color: #990000;">&quot;btnRegister&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;onSaveProfile()&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;2&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;258&quot;</span>  <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;9&quot;</span> <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;@Embed('/assets/images/btn_register.png')&quot;</span> <span style="color: #004993;">useHandCursor</span>=<span style="color: #990000;">&quot;true&quot;</span> <span style="color: #004993;">buttonMode</span>=<span style="color: #990000;">&quot;true&quot;</span> focusEnabled=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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>A design-mode view from FlashBuilder shows nothing surprising&#8230; just your standard <span style="color: #0070C0;">WYSIWYG</span> renderering shown in Figure 2. Now let&#8217;s apply <span style="color: #0070C0;">Adobe-recommended</span> code changes to support localization (l10n) for English and Spanish. Figure 3 shows the design-view impacts as a result of source code modifications; necessary to databind to the resourceManager.</p>
<p style="float:right;">
<div class="gallery" style="align:center;width:100%">
<dl class="gallery-item">
<dt class="gallery-icon"> <div class="img size-thumbnail" style="width:137px;">
	<a href="http://www.gridlinked.info/images/2009/11/i18n/designView_noi18n.jpg" rel="shadowbox[designViews];width=670;height=590;caption="...no standard i18n support"options={resizeDuration:.05,fadeDuration:.05,counterType:'skip',continuous:true,animSequence:'sync'}"><img src="http://www.gridlinked.info/images/2009/11/i18n/thumb_designView_noi18n.jpg" alt="" width="137" height="119" /></a>
	<div>Figure 2:Design view of Sign-in form (no i18n support)</div>
</div> </dt>
</dl>
<dl class="gallery-item">
<dt class="gallery-icon"><div class="img size-thumbnail" style="width:137px;">
	<a href="http://www.gridlinked.info/images/2009/11/i18n/designView_withResourceManager.jpg" rel="shadowbox[designViews];width=670;height=590;caption="...with standard i18n support";options={resizeDuration:.05,fadeDuration:.05,counterType:'skip',continuous:true,animSequence:'sync'}"><img src="http://www.gridlinked.info/images/2009/11/i18n/thumb_designView_resourceMngr.jpg" alt="" width="137" height="119" /></a>
	<div>Figure 3: Design view of Sign-in form (with standard i18n support)</div>
</div> </dt>
</dl>
</div>
<p><br/><br />
<br/></p>
<p><br/></p>
<p><br/></p>
<p><br/></p>
<p><br/></p>
<p><br/></p>
<p><br/></p>
<p>Are here is the MXML code associated with the Figure 3 design-view snapshot:</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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
</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 <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;386&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;290&quot;</span>
			  clipContent=<span style="color: #990000;">&quot;false&quot;</span>
			  xmlns<span style="color: #000000; font-weight: bold;">:</span>frm=<span style="color: #990000;">&quot;com.thunderbay.i18nDemo.views.forms.*&quot;</span>
			  xmlns<span style="color: #000000; font-weight: bold;">:</span>comp=<span style="color: #990000;">&quot;com.thunderbay.i18nDemo.control.*&quot;</span>
			  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: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Metadata<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="display:block;background-color: #ffc;">	<span style="color: #000000;">&#91;</span>ResourceBundle<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;registration&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span></span><span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Metadata<span style="color: #000000; font-weight: bold;">&gt;</span>	
&nbsp;
<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: #3f5fbf;">/** Removed while displaying in blog... */</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>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> id=<span style="color: #990000;">&quot;registrationValidators&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>StringValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtFirstName}&quot;</span> 	property=<span style="color: #990000;">&quot;text&quot;</span> 		 required=<span style="color: #990000;">&quot;true&quot;</span> minLength=<span style="color: #990000;">&quot;2&quot;</span> requiredFieldError=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.validationError.firstName')}&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>StringValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtLastName}&quot;</span> 		property=<span style="color: #990000;">&quot;text&quot;</span> 		 required=<span style="color: #990000;">&quot;true&quot;</span> minLength=<span style="color: #990000;">&quot;2&quot;</span> requiredFieldError=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.validationError.lastName')}&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>EmailValidator  <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtEmail}&quot;</span> 		property=<span style="color: #990000;">&quot;text&quot;</span>			 required=<span style="color: #990000;">&quot;true&quot;</span> 			   requiredFieldError=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.validationError.email')}&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>StringValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtCompany}&quot;</span> 		property=<span style="color: #990000;">&quot;text&quot;</span> 		 required=<span style="color: #990000;">&quot;true&quot;</span> minLength=<span style="color: #990000;">&quot;2&quot;</span> requiredFieldError=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.validationError.company')}&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>StringValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtPostal}&quot;</span> 		property=<span style="color: #990000;">&quot;text&quot;</span> 		 required=<span style="color: #990000;">&quot;true&quot;</span> minLength=<span style="color: #990000;">&quot;2&quot;</span> requiredFieldError=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.validationError.postal')}&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>PhoneNumberValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{txtPhone}&quot;</span>	property=<span style="color: #990000;">&quot;text&quot;</span>			 required=<span style="color: #990000;">&quot;true&quot;</span> minDigits=<span style="color: #990000;">&quot;10&quot;</span> requiredFieldError=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.validationError.phone')}&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>NumberValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{cmbCountry}&quot;</span>		property=<span style="color: #990000;">&quot;selectedIndex&quot;</span> required=<span style="color: #990000;">&quot;true&quot;</span> minValue=<span style="color: #990000;">&quot;0&quot;</span>  lowerThanMinError=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.validationError.country')}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>NumberValidator <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{cmbState}&quot;</span>			property=<span style="color: #990000;">&quot;selectedIndex&quot;</span> required=<span style="color: #990000;">&quot;true&quot;</span> minValue=<span style="color: #990000;">&quot;0&quot;</span>  lowerThanMinError=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.validationError.state')}&quot;</span> 
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Array<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<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;lblTitle&quot;</span> 	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.title')}&quot;</span> styleName=<span style="color: #990000;">&quot;siHeader&quot;</span>   <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;351&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblSubTitle&quot;</span> 	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.subtitle')}&quot;</span> styleName=<span style="color: #990000;">&quot;siText&quot;</span>  <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;2&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;35&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;199&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>Label id=<span style="color: #990000;">&quot;lblMsg&quot;</span> 		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.allRequired')}&quot;</span> styleName=<span style="color: #990000;">&quot;siText&quot;</span> <span style="color: #004993;">fontStyle</span>=<span style="color: #990000;">&quot;italic&quot;</span> textAlign=<span style="color: #990000;">&quot;right&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;37&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;232&quot;</span> <span style="color: #004993;">fontSize</span>=<span style="color: #990000;">&quot;10&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;!--</span> Each <span style="color: #004993;">text</span> input <span style="color: #0033ff; font-weight: bold;">is</span> horizontally aligned on column markers <span style="color: #0033ff; font-weight: bold;">each</span> at <span style="color: #000000; font-weight:bold;">184</span> pixels wide <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;lblFirstName&quot;</span> 	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.firstName')}&quot;</span>				
									styleName=<span style="color: #990000;">&quot;siFieldLabel&quot;</span>   <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;65&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;-2&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;170&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>TextInput 	id=<span style="color: #990000;">&quot;txtFirstName&quot;</span> 	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.firstName}&quot;</span> 	<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;168&quot;</span> 								
									<span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>  <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;81&quot;</span> <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;1&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>Label 	id=<span style="color: #990000;">&quot;lblLastName&quot;</span>	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.lastName')}&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;181&quot;</span> 		
									<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;170&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;65&quot;</span>			styleName=<span style="color: #990000;">&quot;siFieldLabel&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>TextInput 	id=<span style="color: #990000;">&quot;txtLastName&quot;</span>  	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.lastName}&quot;</span>		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;168&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;183&quot;</span> 						
									<span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>  <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;81&quot;</span> <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;2&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblEmail&quot;</span> 		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.email')}&quot;</span>				
									<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;171&quot;</span>  <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;-3&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;111&quot;</span> 	styleName=<span style="color: #990000;">&quot;siFieldLabel&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>TextInput 	id=<span style="color: #990000;">&quot;txtEmail&quot;</span> 		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.email}&quot;</span>			<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;168&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;127&quot;</span> 						
									<span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>  <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;3&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>Label 	id=<span style="color: #990000;">&quot;lblCompany&quot;</span>		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.company')}&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;181&quot;</span>		
									<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;170&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;111&quot;</span>			styleName=<span style="color: #990000;">&quot;siFieldLabel&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>TextInput 	id=<span style="color: #990000;">&quot;txtCompany&quot;</span> 	<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.company}&quot;</span> 		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;168&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;127&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;183&quot;</span> 				
									<span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>   <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;4&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblZip&quot;</span> 		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.postal')}&quot;</span>				
									<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;111&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;159&quot;</span>   <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;240&quot;</span>  styleName=<span style="color: #990000;">&quot;siFieldLabel&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>TextInput 	id=<span style="color: #990000;">&quot;txtPostal&quot;</span>		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.postal}&quot;</span> 		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;109&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;242&quot;</span> 						
									<span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>  <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;175&quot;</span> <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;6&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblCountry&quot;</span>		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.country')}&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;-2&quot;</span> 		
									<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;234&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;159&quot;</span>			styleName=<span style="color: #990000;">&quot;siFieldLabel&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>ComboBox 	id=<span style="color: #990000;">&quot;cmbCountry&quot;</span> 	dataProvider=<span style="color: #990000;">&quot;{_countries}&quot;</span>		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;230&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;176&quot;</span>					
									<span style="color: #004993;">change</span>=<span style="color: #990000;">&quot;onCountryChanged();&quot;</span>			
									prompt=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.prompt.country')}&quot;</span>  <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;5&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblState&quot;</span>		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.state')}&quot;</span>				
									<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;233&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;-1&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;205&quot;</span>	styleName=<span style="color: #990000;">&quot;siFieldLabel&quot;</span> 					 
									<span style="color: #004993;">alpha</span>=<span style="color: #990000;">&quot;{(cmbCountry.selectedItem == Countries.USA) ? 1 : .3}&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>ComboBox 	id=<span style="color: #990000;">&quot;cmbState&quot;</span>		dataProvider=<span style="color: #990000;">&quot;{_states}&quot;</span>		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;230&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;222&quot;</span> 					
									<span style="color: #004993;">change</span>=<span style="color: #990000;">&quot;onStateChanged();&quot;</span>	 			selectedIndex=<span style="color: #990000;">&quot;-1&quot;</span>									
									prompt=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.prompt.state')}&quot;</span> 	<span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;7&quot;</span>		<span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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;lblPhone&quot;</span> 		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{resourceManager.getString('registration','register.phone')}&quot;</span>				
									<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;111&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;240&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;205&quot;</span>     styleName=<span style="color: #990000;">&quot;siFieldLabel&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>TextInput 	id=<span style="color: #990000;">&quot;txtPhone&quot;</span>		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_account.phone}&quot;</span> 		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;109&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;242&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;222&quot;</span>  				
									<span style="color: #004993;">restrict</span>=<span style="color: #990000;">&quot;0-9,.-&quot;</span> <span style="color: #004993;">focusOut</span>=<span style="color: #990000;">&quot;onCheckValidation(event);&quot;</span>   <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;8&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Image 	id=<span style="color: #990000;">&quot;btnSubmit&quot;</span> 		<span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;onSaveProfile()&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;2&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;258&quot;</span>  <span style="color: #004993;">tabIndex</span>=<span style="color: #990000;">&quot;9&quot;</span> 
									<span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;{resourceManager.getClass('registration','register.btnRegister'}&quot;</span> 
									<span style="color: #004993;">useHandCursor</span>=<span style="color: #990000;">&quot;true&quot;</span> <span style="color: #004993;">buttonMode</span>=<span style="color: #990000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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>
<p>
The changes for l10n results in a maintenance nightmare and is &#8211; IMHO &#8211; completely unusable! And what are the biggest issues with these industry l10n code techniques/solutions?</p>
<div style="margin: 1px 0pt;" id="pullquote-con">Imagine a pigeon <span style="text-decoration: underline; color:#900">pooping</span> all over your code!</div>
<ol>
<li>The Design-view is no longer usable. </li>
<li>No compile-time checks are performed to determine whether or not the bundle name are correct. No checks to validate spellings of the key or existence of the key.</li>
<li>Each and every .mxml and .as file needs similar changes in order to support l10n.</li>
<li>No facility for centralized management of bundles, keys, and locales.</li>
<li>No accommodations for localized effects to text compression or text expansion </li>
</ol>
<p>Now realize that I would not condemn an industry standard without presenting a viable &#8211; and superior &#8211; solution.
</p>
<div style="margin: 1px 0pt;" id="pullquote-con">Why not use Flex Behavior Injection techniques to <span style="text-decoration: underline; color:#900">inject</span> localized assets during runtime?</div>
<p>
For those familiar with my previous presentations, talks, and blogs on <span style="color: #0070C0;">Flex Behavior Injection</span>, let&#8217;s consider a new approach to i18n.  So instead of modifying your source code with resourceManager invocations, &#8220;inject&#8221; the results of the locale changes from &#8220;outside&#8221; your components. Now your views and components no longer know <span style="color: #99000;">anything</span> about locale changes and requirements. Now your design views render properly. <br/><br />
This feature is very similar to that used in the SWIZ, Mate, and other IOC frameworks. So now you, as the developer, never need to embed resourceManager calls in <span style="font-weight:bold;font-size:1.1em;color: #990000;">any</span> of your view components. That is really COOL!  <br/></p>
<div style="margin: 1px 0pt;" id="pullquote-con">Use a LocalizationMap and one (1) <span style="text-decoration: underline; color:#900">single mxml tag</span> for l10n!</div>
<p>So how does this new l10n injection work? What changes are needed to your source code?  Below is the application MXML code for the demo. This code (and demo shown above) does NOT support l10n.</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
</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>Application pageTitle=<span style="color: #990000;">&quot;i18n Demo without l10n&quot;</span>
				preloader=<span style="color: #990000;">&quot;com.thunderbay.i18nDemo.views.preloader.Preloader&quot;</span>
				creationComplete=<span style="color: #990000;">&quot;signIn.visible = true;&quot;</span>
				<span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;#777777&quot;</span>  backgroundGradientColors=<span style="color: #990000;">&quot;[#777777,#BABABA]&quot;</span>
				layout=<span style="color: #990000;">&quot;absolute&quot;</span> horizontalScrollPolicy=<span style="color: #990000;">&quot;off&quot;</span> verticalScrollPolicy=<span style="color: #990000;">&quot;off&quot;</span>
				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: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Style <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;locale/en_US/assets/css/styles.css&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;!--</span> Classic Cairngorm MVC structures <span style="color: #000000; font-weight: bold;">--&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>model<span style="color: #000000; font-weight: bold;">:</span>Model id=<span style="color: #990000;">&quot;_model&quot;</span> 							xmlns<span style="color: #000000; font-weight: bold;">:</span>model=<span style="color: #990000;">&quot;com.thunderbay.i18nDemo.model.*&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>mvc<span style="color: #000000; font-weight: bold;">:</span>i18nController									xmlns<span style="color: #000000; font-weight: bold;">:</span>mvc=<span style="color: #990000;">&quot;com.thunderbay.i18nDemo.control.*&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>views<span style="color: #000000; font-weight: bold;">:</span>SignInPage  id=<span style="color: #990000;">&quot;signIn&quot;</span>						xmlns<span style="color: #000000; font-weight: bold;">:</span>views=<span style="color: #990000;">&quot;com.thunderbay.i18nDemo.views.*&quot;</span>
					   visitor=<span style="color: #990000;">&quot;{_model.account}&quot;</span>
					   <span style="color: #004993;">visible</span>=<span style="color: #990000;">&quot;false&quot;</span> 
					   <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;854&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;526&quot;</span> 
					   horizontalCenter=<span style="color: #990000;">&quot;0&quot;</span> 
					   verticalCenter=<span style="color: #990000;">&quot;0&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>Application<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>And below is the same MXML application code with <span style="color:#900">1 line</span> change to support l10n for the entire application:
</p>
<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
</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>Application pageTitle=<span style="color: #990000;">&quot;i18n Demo with LocalizationMaps&quot;</span>
				preloader=<span style="color: #990000;">&quot;com.thunderbay.i18nDemo.views.preloader.Preloader&quot;</span>
				creationComplete=<span style="color: #990000;">&quot;signIn.visible = true;&quot;</span>
				<span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;#777777&quot;</span>  backgroundGradientColors=<span style="color: #990000;">&quot;[#777777,#BABABA]&quot;</span>
				layout=<span style="color: #990000;">&quot;absolute&quot;</span> horizontalScrollPolicy=<span style="color: #990000;">&quot;off&quot;</span> verticalScrollPolicy=<span style="color: #990000;">&quot;off&quot;</span>
				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: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Style <span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;locale/en_US/assets/css/styles.css&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;!--</span> Classic Cairngorm MVC structures <span style="color: #000000; font-weight: bold;">--&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>model<span style="color: #000000; font-weight: bold;">:</span>Model id=<span style="color: #990000;">&quot;_model&quot;</span> 							xmlns<span style="color: #000000; font-weight: bold;">:</span>model=<span style="color: #990000;">&quot;com.thunderbay.i18nDemo.model.*&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>mvc<span style="color: #000000; font-weight: bold;">:</span>i18nController									xmlns<span style="color: #000000; font-weight: bold;">:</span>mvc=<span style="color: #990000;">&quot;com.thunderbay.i18nDemo.control.*&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>views<span style="color: #000000; font-weight: bold;">:</span>SignInPage  id=<span style="color: #990000;">&quot;signIn&quot;</span>						xmlns<span style="color: #000000; font-weight: bold;">:</span>views=<span style="color: #990000;">&quot;com.thunderbay.i18nDemo.views.*&quot;</span>
					   visitor=<span style="color: #990000;">&quot;{_model.account}&quot;</span>
					   <span style="color: #004993;">visible</span>=<span style="color: #990000;">&quot;false&quot;</span> 
					   <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;854&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;526&quot;</span> 
					   horizontalCenter=<span style="color: #990000;">&quot;0&quot;</span> 
					   verticalCenter=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;!--</span> Single tag used to provide l10n features <span style="color: #0033ff; font-weight: bold;">for</span> the entire application and all sub views 	<span style="color: #000000; font-weight: bold;">--&gt;</span>
<span style="display:block;background-color: #ffc;">	<span style="color: #000000; font-weight: bold;">&lt;</span>local<span style="color: #000000; font-weight: bold;">:</span>LocalizationMap  account=<span style="color: #990000;">&quot;{_model.account}&quot;</span>	xmlns<span style="color: #000000; font-weight: bold;">:</span>local=<span style="color: #990000;">&quot;*&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Application<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

</p>
<p>
Now, whenever the locale changes (at app startup detection, or based on user profile, or user interaction) ALL your views and application l10n features are auto-magically updated. How is this achieved? In the code above, we used a LocalizationMap to configure or &#8220;map&#8221; injectors to &#8220;inject&#8221; localized values into your runtime components and models.
</p>
<p>
Here is the LocalizationMap source for the demo presented in this blog:</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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;?</span>xml version<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;1.0&quot;</span> encoding<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;utf-8&quot;</span><span style="color: #339933;">?&gt;</span>
<span style="color: #339933;">&lt;</span>map<span style="color: #339933;">:</span>SmartLocaleMap targets<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{[i18nDemo]}&quot;</span> 
					targetReady<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;onUpdateTarget(event);&quot;</span>
					xmlns<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;com.asfusion.mate.injectors.*&quot;</span>
					xmlns<span style="color: #339933;">:</span>map<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;com.asfusion.mate.maps.*&quot;</span> 
					xmlns<span style="color: #339933;">:</span>mx<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://www.adobe.com/2006/mxml&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>mx<span style="color: #339933;">:</span>Script<span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;!</span><span style="color: #009900;">&#91;</span>CDATA<span style="color: #009900;">&#91;</span>
		<span style="color: #003366; font-weight: bold;">import</span> com.<span style="color: #660066;">asfusion</span>.<span style="color: #660066;">mate</span>.<span style="color: #660066;">maps</span>.<span style="color: #660066;">LocaleMapEvent</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">import</span> com.<span style="color: #660066;">thunderbay</span>.<span style="color: #660066;">i18nDemo</span>.<span style="color: #660066;">views</span>.<span style="color: #660066;">SignInPage</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">import</span> com.<span style="color: #660066;">thunderbay</span>.<span style="color: #660066;">i18nDemo</span>.<span style="color: #660066;">views</span>.<span style="color: #660066;">forms</span>.<span style="color: #660066;">RequestNotification</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">import</span> com.<span style="color: #660066;">thunderbay</span>.<span style="color: #660066;">i18nDemo</span>.<span style="color: #660066;">vo</span>.<span style="color: #660066;">AccountVO</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#91;</span>Bindable<span style="color: #009900;">&#93;</span> <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">var</span> account 	<span style="color: #339933;">:</span> AccountVO <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>	
&nbsp;
		<span style="color: #006600; font-style: italic;">/**
		 *  EventHandler when the target class has been instantiated.
		 *  We then use the new instance to update ResourceProxies and fire locale updates
		 */</span>
		<span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> onUpdateTarget<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>LocaleMapEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> who <span style="color: #339933;">:</span> Object <span style="color: #339933;">=</span> event.<span style="color: #660066;">targetInst</span> <span style="color: #000066; font-weight: bold;">as</span> Object<span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>who <span style="color: #000066; font-weight: bold;">is</span> i18nDemo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				signInPage 	<span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>who <span style="color: #000066; font-weight: bold;">as</span> i18nDemo<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">signIn</span><span style="color: #339933;">;</span>	
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009900;">&#91;</span>Bindable<span style="color: #009900;">&#93;</span> <span style="color: #003366; font-weight: bold;">private</span>  <span style="color: #003366; font-weight: bold;">var</span> signInPage	 <span style="color: #339933;">:</span> SignInPage 			<span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>mx<span style="color: #339933;">:</span>Script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;!--</span> <span style="color: #339933;">******************************************************************************************************</span> 
	<span style="color: #000066; font-weight: bold;">This</span> solution leverages compile<span style="color: #339933;">-</span>time type checking but suffers from<span style="color: #339933;">:</span>
       <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> Have to <span style="color: #003366; font-weight: bold;">use</span> the onUpdateTarget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> to get a reference <span style="color: #009900;">&#91;</span>after <span style="color: #3366CC;">'creationComplete'</span><span style="color: #009900;">&#93;</span>
       <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> Only supports a single unique instance of the target <span style="color: #003366; font-weight: bold;">class</span>
    But it does support property chain references <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">g</span>. <span style="color: #660066;">signInPage</span>.<span style="color: #660066;">frmSignin</span>.<span style="color: #660066;">validator</span><span style="color: #009900;">&#41;</span>
&nbsp;
     <span style="color: #339933;">******************************************************************************************************</span> <span style="color: #339933;">--&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>ResourceInjector bundleName<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;registration&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmSignin}&quot;</span> 									property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;alertTitle&quot;</span> 			key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;signing.invalid&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmSignin.validator}&quot;</span> 						property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;requiredFieldError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;signin.validationError.email&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmSignin.lblTitle}&quot;</span>   						property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;signin.title&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmSignin.lblEmail}&quot;</span>   						property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;signin.email&quot;</span> <span style="color: #339933;">/&gt;</span>
&nbsp;
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister}&quot;</span> 								property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;alertTitle&quot;</span> 			key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.invalidProfile&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.registrationValidators[0]}&quot;</span> 		property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;requiredFieldError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.firstName&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.registrationValidators[1]}&quot;</span> 		property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;requiredFieldError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.lastName&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.registrationValidators[2]}&quot;</span> 		property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;requiredFieldError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.email&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.registrationValidators[3]}&quot;</span> 		property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;requiredFieldError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.company&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.registrationValidators[4]}&quot;</span> 		property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;requiredFieldError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.postal&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.registrationValidators[5]}&quot;</span> 		property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;requiredFieldError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.phone&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.registrationValidators[6]}&quot;</span> 		property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lowerThanMinError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.country&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.registrationValidators[7]}&quot;</span> 		property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lowerThanMinError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.state&quot;</span> <span style="color: #339933;">/&gt;</span>
&nbsp;
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.lblTitle}&quot;</span>     					property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.title&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.lblSubTitle}&quot;</span>   					property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.subtitle&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.lblMsg}&quot;</span>   						property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.allRequired&quot;</span> <span style="color: #339933;">/&gt;</span>
&nbsp;
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.lblFirstName}&quot;</span>   				property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.firstName&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.lblLastName}&quot;</span>   					property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.lastName&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.lblEmail}&quot;</span>   					property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.email&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.lblPhone}&quot;</span>   					property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.phone&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.lblCompany}&quot;</span>   					property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.company&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.lblZip}&quot;</span>   						property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.postal&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.lblState}&quot;</span>   					property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.state&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.cmbState}&quot;</span>   					property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;prompt&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.prompt.state&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.lblCountry}&quot;</span>   					property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.country&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{signInPage.frmRegister.cmbCountry}&quot;</span>   					property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;prompt&quot;</span> 				key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.prompt.country&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>ResourceInjector<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
<span style="color: #339933;">&lt;!--</span> <span style="color: #339933;">******************************************************************************************************</span> <span style="color: #339933;">--&gt;</span>
<span style="color: #339933;">&lt;!--</span> SmartInjectors <span style="color: #000066; font-weight: bold;">for</span> targeted <span style="color: #003366; font-weight: bold;">class</span> instantiations<span style="color: #339933;">;</span> where the <span style="color: #003366; font-weight: bold;">class</span> will have multiple instances created <span style="color: #339933;">--&gt;</span>
<span style="color: #339933;">&lt;!--</span> <span style="color: #339933;">******************************************************************************************************</span> <span style="color: #339933;">--&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>SmartResourceInjector target<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{RequestNotification}&quot;</span>	bundleName<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;registration&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;alertTitle&quot;</span> 									key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.invalidProfile&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;registrationValidators[0].requiredFieldError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.firstName&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;registrationValidators[1].requiredFieldError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.lastName&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;registrationValidators[2].requiredFieldError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.email&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;registrationValidators[3].requiredFieldError&quot;</span> 	key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.validationError.company&quot;</span> <span style="color: #339933;">/&gt;</span>
&nbsp;
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lblTitle.text&quot;</span> 								key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;request.title&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lblSubTitle.text&quot;</span> 								key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;request.subtitle&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lblMsg.text&quot;</span> 									key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.allRequired&quot;</span> <span style="color: #339933;">/&gt;</span>
&nbsp;
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lblFirstName.text&quot;</span> 							key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.firstName&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lblLastName.text&quot;</span> 								key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.lastName&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lblEmail.text&quot;</span> 								key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.email&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lblCompany.text&quot;</span> 								key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;register.company&quot;</span> <span style="color: #339933;">/&gt;</span>
&nbsp;
	<span style="color: #339933;">&lt;!--</span> 
		Inject localized text <span style="color: #000066; font-weight: bold;">with</span> parameterized<span style="color: #339933;">,</span> current values of account details
	    e.<span style="color: #660066;">g</span>.  <span style="color: #3366CC;">&quot;Thanks for registering {0}!&quot;</span>  <span style="color: #339933;">==&gt;</span> <span style="color: #3366CC;">&quot;Thanks for registering Thomas Burleson!&quot;</span> 
	 <span style="color: #339933;">--&gt;</span>
&nbsp;
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lblThanks.htmlText&quot;</span> 							key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;request.thanks.title&quot;</span> parameters<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{[account.fullName]}&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>ResourceProxy property<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lblThanksMessage.htmlText&quot;</span>						key<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;request.thanks.text&quot;</span>  parameters<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{[account.email]}&quot;</span><span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>SmartResourceInjector<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>map<span style="color: #339933;">:</span>SmartLocaleMap<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Here are some key points regarding the amazing benefits of using a LocalizationMap:</p>
<ol>
<li>All localized changes are in <span style="text-decoration: underline;">one file</span> </li>
<li>Compile-time <span style="text-decoration: underline;">type-checking</span> is easily supported </li>
<li>Runtime instantiation injection is supported (for deferred creation) </li>
<li><span style="text-decoration: underline;">Parameterized values</span> are injected (see account.email) </li>
<li>Property <span style="text-decoration: underline;">chains</span> are supported </li>
<li>Model <span style="text-decoration: underline;">changes</span> can trigger updates with current localized values </li>
<li><span style="text-decoration: underline;">Skins</span> and Embedded assets (images, sounds) are supported </li>
<li>Easily extended to allow scan <span style="text-decoration: underline;">cross-referencing for errors</span> is key names or orphaned keys </li>
<li>Easily extended to allow transparent access to <span style="text-decoration: underline;">remote databases</span> instead of compiled bundles </li>
<li>Easily extended to allow runtime support for <span style="text-decoration: underline;">stylesheets</span> </li>
</ol>
<p>Notice that LocalizationMap extends SmartLocaleMap; which is a parent class available in a soon-to-be-released extension of the open-source <a href="http://mate.asfusion.com/"  target="_blank"><span style="text-decoration: underline; color:#900">Mate</span></a> framework. Let&#8217;s pause while I give a major shout-out to <a href="http://www.asfusion.com"  target="_blank">Nahuel Foronda</a> and <a href="http://www.asfusion.com"  target="_blank">Laura Arguello</a>!<br />
<br/><br />
Best of all, is the fact that the SmartLocaleMap can be used outside of Mate with a MVC framework of your choice&#8230; notice that the demo here uses the Cairngorm MVC framework.  You can use this easily with Cairngorm, Swiz, Mate, PureMVC, etc.
</p>
<p><div style="margin: 1px 0pt;" id="pullquote-con">So what is still <span style="color:#900">missing</span> ?</div>
<p>Within the next week, I will publish two important additions within this blog:</p>
<ol>
<li>A <span style="text-decoration: underline;">video walkthru</span> demonstrating to you the construction of the LocalizationMap and the logic that works behind the scenes.</li>
<li>A localized version of this demo; with runtime support for switching between English and Spanish</li>
</ol>
<div style="margin: 1px 0pt;" id="pullquote-con">Here are <span style="color:#900">some questions</span> that I present to you&#8230; </div>
<p>Consider the implications of this blog on your product, projects, and processes. Perhaps you can optimize your ROI and engage ThunderBay Software to help with your product deliveries and development improvements?</p>
<ul>
<li>Want a <span style="text-decoration: underline;">presentation</span> to your management?</li>
<li>Want to see a whitepaper on <span style="text-decoration: underline;">localization issues and best practices</span>?</li>
<li>Want to easily embed localization into your flex app? Then you will&#8230;
<ol>
<li>need ANT scripts, bundle loaders,</li>
<li>need compiled LocalizationMap swc, </li>
<li>need support runtime fonts and stylesheets</li>
<li>need mentoring and training for your staff</li>
<li>need to optimize and plan the translation processes</li>
<li>need better tools to support remote translators while protecting your source code</li>
<li>need to minimize your application footprint size</li>
<li>need to optimize your application download speeds</li>
</ol>
</li>
</ul>
<p>Thanks for reading my blogs. Don&#8217;t forget to rate this blog please!<br/> And <a rel="lightbox;height=652;width=556" href="http://www.gridlinked.info/images/2008/05/bizcardsnapshot.png"><span style="text-decoration: underline; color:#900">contact me</span></a> to discuss IT resources and assistance we can provide to help you with internet solutions, architecture, mentoring, training, or product delivery.
</p>
<p>
Be sure to read Part 2: <a href="http://www.gridlinked.info/flex-i18n-with-localizationmaps-video-tutorial-source/"><span style="text-decoration: underline; color:#0070C0">LocalizationMaps &#8211; A Video Tutorial and Source Code</span></a></p>
<br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=9.6" /></div><div>Rating: 9.6/<strong>10</strong> (18 votes cast)</div><br /><hr />
<p><small>© Thomas Burleson for <a href="http://www.gridlinked.info">GridLinked to RUX</a>, 2009.   
&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;  
<a href="http://feedburner.google.com/fb/a/mailverify?uri=GridlinkedToRux&amp;loc=en_US"><span style="color:#900">Subscribe by Email</span></a> |
<a href="mailto:ThomasBurleson@GMail.com">Contact Author</a> 	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;
<a href="http://www.gridlinked.info/amazing-i18n-solutions-for-flex-3-4/">Permalink</a> |    
<a href="http://www.gridlinked.info/amazing-i18n-solutions-for-flex-3-4/#comments">29 comments</a>
<br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.gridlinked.info/amazing-i18n-solutions-for-flex-3-4/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>RSA Encryption for Flex 4 RSLs</title>
		<link>http://www.gridlinked.info/how-to-encrypt-flex-rsls/</link>
		<comments>http://www.gridlinked.info/how-to-encrypt-flex-rsls/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 20:27:43 +0000</pubDate>
		<dc:creator>thomasb</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[event dispatching]]></category>
		<category><![CDATA[Nitro-LM]]></category>
		<category><![CDATA[Preloader]]></category>
		<category><![CDATA[RSA Encryption]]></category>
		<category><![CDATA[RSL]]></category>
		<category><![CDATA[SystemManager]]></category>

		<guid isPermaLink="false">http://www.gridlinked.info/?p=394</guid>
		<description><![CDATA[Do you know how ridiculously easy it is to reverse-engineer/decompile a Flex 3 or Flex 4 application and its AVM byte code?  If you are developing an online Flex product, then you had better worry about protecting your source code.  I present an attractive solution for source-code protection of your intellectual property using Nitro-LM and "encryption of Flex RSLs". SimplifiedLogic's Nitro-LM already provides solutions and samples for encrypting your Flex application or encrypting a Flex "module", but nothing is available for encrypting a Flex RSL (aka shared library). So I created that solution, released it as open-source to SimplifiedLogic, and now present it to all readers. <br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=10.0" /></div><div>Rating: 10.0/<strong>10</strong> (5 votes cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p>I have been working on a new <strong><em>ThunderBay SaaS </em></strong> product for months now. And two of the myriad issues I have had to consider is that of <span style="color: #0070C0;">user management and licensing</span> and <span style="color: #0070C0;">intellectual property protection</span> (IPP). Now many people will argue that one should not protect source code as IP, but rather business processes as IP. When it comes to online Flex products, however, I could not disagree more!</p>
<p>Do you know how ridiculously easy it is to reverse-engineer/decompile a Flex 3 application and its AVM byte code? <br/><br/>Try it: simply use <span style="text-decoration: underline;"><a href="http://www.sothink.com">SWFDecompiler</a></span> to open any SWF. Even if that .swf file has been optimized for production release, you can still see the classes, methods, and logic. If you are developing an online Flex solution, then you had better worry about protecting your source code. Why lose your invest of time and effort and let competitors steal your ideas and solutions? Patents and trademarks are not the issue here. Those are ex post facto protection mechanisms. At the very least, using source-code IPP will present an immediate &#8220;barrier-to-entry&#8221; to your competitors. </p>
<p>Now, do not misunderstand the intent of this blog. I am a huge proponent of mentoring, open-source, and the community-driven evolution of software. Google and blog entries have been radical saviors to many technical roadblocks and bugs that I have encountered. In return, I reciprocate by blogging solutions and contributing to open-source (Cairngorm Extensions/CGX, Mate Localizations, Flex Behaviour Injection, etc.) I do not, however, open source ALL my software or solutions. <br/></p>
<div id="pullquote-con">Do you deserve to be <span style="color: #990000;">bitch slapped</span>? </div>
<p>As a consultant or developer working on a disruptive solution you would be have to be an <span style="text-decoration: underline;">idiot</span> to not protect your core IP and your core source. </p>
<div class="img aligncenter" style="width:301px;">
	<a rel="lightbox;height=525;width=670" href="http://www.youtube.com/watch?v=3BRw_ihZRJI#t=0m20s"><img src="/images/2009/11/developerSlap.jpg" alt="Consequences of Not Encrypting" width="301" height="204" /></a>
	<div>Figure 1: Consequences... if you do not protect!!</div>
</div>
<p>So how do you protect your source code? Really only two (2) viable solutions exist for Flash/Flex solutions: <span style="color: #0070C0">code obfuscation</span> or <span style="color: #0070C0">encryption</span>. Source or byte code obfuscation works well for some purposes; but may present real problems with non-trivial Flex architectures. Encryption, however, is more secure and also provides opportunities for you to track customer usage and authorize access.</p>
<p>You can &quot;grow-your-own&quot; encryption mechanism and embed the decryption key in your code. Or you can use a client-cloud model to request your decryption key from a cloud-based service. <span style="text-decoration: underline;"><a href="http://www.simplifiedlogic.com" target="_blank">Nitro-LM</a></span> is a hosted, commercial technology platform that provides user management, product licenses, and software protection (encryption) for Java, .NET, Adobe Flex/AIR, C/C++ software. Nitro-LM administration, user authorization, and key creation/access is all managed online as a hosted software-as-a-service (SaaS). And while the license services are offered as an annual subscription, the yearly cost to provide RSA encryption for my software product IPP is trivial. Granted, if you have a free product, then a subscription-based licensing model may not work for you. If you have a free product, I would contend that you probably do not have a viable revenue model in the first place&#8230; so why protect it?</p>
<div id="pullquote-con">You say: &#8220;I can implement <span style="color: #990000;">my own</span> encryption scheme!&#8221; </div>
<p>Anyone who has ever tried to write user management or user license modules recalls that those features and the associated issues of maintenance &amp; availability quickly become a &quot;full-time job&quot;. The broad suite of features and functionality offered by Nitro-LM is amazing and the support is excellent (shout out to Andrew Westberg). So sign-up for a webinar and check it out for yourself; and no I do NOT get any compensation for my promotion.<br />
<br/> For the purpose of this blog, I will be presenting a solution for IP source-code protection using Nitro-LM and &quot;<u>encryption of Flex RSLs</u>&quot;. Nitro-LM already publishes solutions for encrypting your Flex application or a Flex &quot;module&quot;. But nothing was available for encrypting a Flex RSL (aka shared library). So I created that solution, released it as open-source to SimplifiedLogic, and now present it to you. Shown below is a live demo of a Flex app using a custom preloader [display] and dynamic RSL decryption:</p>
<div class="img aligncenter" style="width:311px;">
	<a rel="lightbox;height=402;width=554" href="http://www.gridlinked.info/flash/encryptedRSLs/Demo_3_LoadEncryptedRSL.html"><img src="/images/2009/11/launchDemo3.jpg" alt="Custom Preloader with Dynamic RSL Decryption" width="311" height="178" /></a>
	<div>Figure 2: Custom Preloader with Dynamic RSL Decryption (click to launch)</div>
</div>
<p><br/></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
</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>Application layout=<span style="color: #990000;">&quot;absolute&quot;</span> 
				minWidth=<span style="color: #990000;">&quot;1024&quot;</span> minHeight=<span style="color: #990000;">&quot;768&quot;</span> 
				<span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;#777777&quot;</span>  backgroundGradientColors=<span style="color: #990000;">&quot;[#777777,#BABABA]&quot;</span>
<span style="display:block;background-color: #ffc;">				preloader=<span style="color: #990000;">&quot;tb.preloader.ThunderPreloader&quot;</span></span>				creationComplete=<span style="color: #990000;">&quot;onAppReady();&quot;</span>
				xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
				xmlns<span style="color: #000000; font-weight: bold;">:</span>adobe=<span style="color: #990000;">&quot;http://www.adobe.com/2006/cairngorm&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">&lt;!--</span>
	Note the ThunderBay loading indicator <span style="color: #0033ff; font-weight: bold;">is</span> shown because
    of the preloader reference to ThunderPreloader; which <span style="color: #0033ff; font-weight: bold;">is</span> NOT
    a preloader but a subclass of DownloadProgressBar
 <span style="color: #000000; font-weight: bold;">--&gt;</span>
&nbsp;
 <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> mx.controls.Alert;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">import</span> tb.utils.DelayedCall;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onAppReady<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>
			DelayedCall.schedule<span style="color: #000000;">&#40;</span> showStatus,<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span>,<span style="color: #000000; font-weight:bold;">600</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #339966; font-weight: bold;">function</span> showStatus<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: #6699cc; font-weight: bold;">var</span> msg <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">'Finished: CGX encrypted RSL was decrypted &amp; loaded using Nitro-LM!'</span>;
				mx.controls.Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span>msg,<span style="color: #990000;">'Encrypted RSLs Loaded'</span><span style="color: #000000;">&#41;</span>;	
			<span style="color: #000000;">&#125;</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>
&nbsp;
 <span style="color: #000000; font-weight: bold;">&lt;!--</span> A <span style="color: #9900cc; font-weight: bold;">class</span> from the encrypted RSL CairngormExtensions.swf <span style="color: #000000; font-weight: bold;">--&gt;</span>
 <span style="color: #000000; font-weight: bold;">&lt;</span>adobe<span style="color: #000000; font-weight: bold;">:</span>FrontController id=<span style="color: #990000;">&quot;myController&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Application<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>This demo loads an encrytped CaignormExtension RSL. Download this <a href="http://www.gridlinked.info/flash/encryptedRSLs/CairngormExtensions.swf" target="_blank">encrypted RSL</a> directly and try to decompile it! Now download and decompile the <a href="http://www.gridlinked.info/flash/encryptedRSLs/CairngormExtensions_notEncrypted.swf"  target="_blank">standard version</a> that is NOT encrypted. The latter version you can get access to class code and logic. The former is completely locked and unreadable. I love this feature; encryption is awesome! </p>
<p><div id="pullquote-con">Why should I use RSLs with my Flex/AIR application?</div>
</p>
<p>Flex RSLs act as shared libraries (similar to DLLs on Windows), require only a single download [to the browser/flashplayer] and can be shared among multiple Flex applications. These RSLs can be optimized for small footprint sizes to achieve faster download times. And best of all, you can update an RSL with patches, upgrades, etc&#8230; without requiring new downloads of any other RSLs. This power comes with a small price to start-up time and complexities to builds and source-code organization. For a SaaS solutions, especially, I think RSLs are critical requirements. For deeper learning, check out</p>
<ol>
<li>Adobe LiveDocs &quot;<a href="http://livedocs.adobe.com/flex/3/html/help.html?content=rsl_01.html">Introduction to RSLs</a>&quot;</li>
<li>Adobe Labs     &quot;<a href="http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:Flex_3_RSLs#Introduction">Flex 3 RSLs</a>&quot;
  </li>
</ol>
<p></p>
<div id="pullquote-con">You need to know <span style="color: #990000;">how RSLs are loaded</span>. </div>
</p>
<p>To understand the process of RSL encryption/decryption, you must first be familiar with how RSLs are loaded. First, do you need to know an interesting secret about a Flex application! <strong><em> A Flex application is constructed as a 2-frame movie.</em></strong> The first frame of a Flex application movie contains on the very critical classes including the SystemManager, the Preloader, the DownloadProgressBar and some glue helper classes. The second frame of a Flex SWF contains the rest of the Flex framework code, your application code and all of your application assets like embedded fonts, images, etc. This means it takes a lot longer to get all of the frame 2 downloaded than the small stuff in frame 1.</p>
<p><div id="pullquote-con">The .swf format is a <span style="color: #990000;">progressive download format</span>&#8230; </div>
<p>Which means that the Flash player can access content on downloaded frames without having to wait for subsequent frames/the entire file to download. By creating a 2-frame movie, Flex applications can take advantage of the streaming support built into the Flash Player and a preloader can appear before all of the Flex framework code and your application code are downloaded. The visible benefit of this whole idea is the loading bar. Even on a large app, Flex quickly shows that it is loading (Frame1 downloaded) and gives continual feedback to the user while the rest of the app downloads (Frame 2).
</p>
<p>So here are the steps involved in the startup of a Flex application:</p>
<ol>
<li>First, enough bytes for frame 1 are streamed down to the Flash Player.</li>
<li>The Flash Player executes those bytes by creating a SystemManager instance.</li>
<li>SystemManager instruct the Flash Player to stop at the end of frame 1.</li>
<li>SystemManager then goes on to create the Preloader which creates the DownloadProgressBar control and pops that up on the client screen.</li>
<li>The Preloader then starts tracking the rest of the bytes streaming in from the Flex SWF (or from external SWFs).<br />
  Once all the bytes for the Flex framework and application code are in, the System Manager goes on to frame 2 and instantiates the Application instance.</p>
<ul>
<li>All RSLs and their associated classes are now loaded [into the ApplicationDomain]; note that the load order is in the order defined during app compile time.</li>
<li>All class definitions used by the application (views, logic, etc) must be loaded prior to Frame 2. It is here, in Frame1, that your preloader code can even install patches to the Flex framework BEFORE the framework classes themselves are loaded. </li>
<li>This technique is called &quot;<span style="color: #0070C0;">monkey-patching</span>&quot; and will be used later <br />
        when we are discussing the decryption process.</li>
</ul>
</li>
<li>Once the Application instance has been created, the SystemManager sets Application.systemManager to itself. This is how you, the application developer, can access the SystemManager at a later time.
  </li>
<li>The Application dispatches the preinitialize event at the beginning of the initialization process.</li>
<li>Application goes on to create its children. The method createChildren() is called on the application. At this point each of the application’s components is being constructed, and each component’s createChildren() will be also called. For detail, look at component lifecycle section.</li>
<li>The Application dispatches the initialize event, which indicates that all application’s components have been initialized. However, at this state, all the components are not yet laid out.</li>
<li>Eventually, once all the Application child controls and containers have been created, sized and positioned, the Application dispatches the creationComplete event.</li>
<li>Once the creationComplete event has been dispatched, the Preloader removes the DownloadProgressBar control and the SystemManager adds the Application instance to the Flash Player display list. (The Flash Player display list is basically the tree of visible or potentially visible objects that make up your application. When you add and remove child components to your application, your basically just adding and removing them from the display list).</li>
<li>Once the Application is added to the Flash Player display list, the Application dispatches its applicationComplete event</li>
<li>The Application has been created and is up on the screen ready to be interacted with.
  </li>
</ol>
<div id="pullquote-con">Better RUX using <span style="color: #990000;">custom preloaders</span>. </div>
<p>A well-known technique for displaying your own startup splash screen is to subclass the DownloadProgressBar control [or implement the IPreloaderDisplay interface]. Your custom display class can be used during the startup and that class can listen for 6 types of events:</p>
<ul>
<li>ProgressEvent.PROGRESS</li>
<li>Event.COMPLETE</li>
<li>FlexEvent.INIT_PROGRESS</li>
<li>FlexEvent.INIT_COMPLETE</li>
<li><span style="color: #990000;">RSLEvent.RSL_PROGRESS</span></li>
<li><span style="color: #990000;">RSLEvent.RSL_ERROR</span></li>
</ul>
<p>The last two are the interesting part&#8230; with those you can listen to events for RSL loading and errors. And, it is <span style="color: #0070C0;">during the preloader event dispatching phase</span> that you will manage/decrypt 1 or more encrypted RSLs. Here are the steps involved:</p>
<ol>
<li>The FlashPlayer loads an encrypted RSL/swf and dispatches an RSLError event; normally this kills the preload process and your application &quot;hangs&quot;.</li>
<li>Intercept that event and kill all event propogation to any other listeners; which effectively pauses all subsequent loading of other RSL still in the pending queue.</li>
<li>Using Nitro-LM, asynchronously request a RSA decryption key</li>
<li>Reload the encrypted RSL (in order to get clear access to the swf bytecode array)</li>
<li>Decrypt the byte array</li>
<li>Load the decrypted bytecode into the AVM</li>
<li>Notify the Preloader to resume loading all remaining pending RSLs</li>
</ol>
<p>So let&#8217;s look at the AS3 code for the custom display class that also supports RSL decryption:<br />
</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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">package</span> tb.<span style="color: #660066;">preloader</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">display</span>.<span style="color: #660066;">Sprite</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #660066;">Event</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #660066;">ProgressEvent</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">import</span> mx.<span style="color: #660066;">core</span>.<span style="color: #660066;">RSLItem</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> mx.<span style="color: #660066;">core</span>.<span style="color: #660066;">RSLListLoader</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> mx.<span style="color: #660066;">core</span>.<span style="color: #660066;">mx_internal</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> mx.<span style="color: #660066;">events</span>.<span style="color: #660066;">RSLEvent</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">import</span> mx.<span style="color: #660066;">preloaders</span>.<span style="color: #660066;">Preloader</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">import</span> tb.<span style="color: #660066;">preloader</span>.<span style="color: #660066;">nitrolm</span>.<span style="color: #660066;">NitroDecryptor</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">use</span> <span style="color: #003366; font-weight: bold;">namespace</span> mx_internal<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">class</span> ThunderPreloader <span style="color: #003366; font-weight: bold;">extends</span> SplashDisplay
<span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">/**</span>
<span style="color: #006600; font-style: italic;">&nbsp;* Constructor for a Preloader subclass that supports on-demand RSL decryption</span>
<span style="color: #006600; font-style: italic;">&nbsp;* </span>
<span style="color: #006600; font-style: italic;">&nbsp;*/</span>
<span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> ThunderPreloader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #006600; font-style: italic;">/**</span>
<span style="color: #006600; font-style: italic;">&nbsp;* The code in the preloader setter below uses listeners to intercept RSLErrors and </span>
<span style="color: #006600; font-style: italic;">&nbsp;* handles the loading and decryptiong of encrypted RSLs. </span>
<span style="color: #006600; font-style: italic;">&nbsp;* </span>
<span style="color: #006600; font-style: italic;">&nbsp;* 		Note: The parent class is responsibile for the </span>
<span style="color: #006600; font-style: italic;">&nbsp;* 			  PROGRESS, COMPLETE, INIT_PROGRESS, INIT_COMPLETE events and handlers</span>
<span style="color: #006600; font-style: italic;">&nbsp;* </span>
<span style="color: #006600; font-style: italic;">&nbsp;* @param value IPreloaderDisplay subclasses used as interface to startup processes; that have been initiated by SystemManager. </span>
<span style="color: #006600; font-style: italic;">&nbsp;*/</span>
override <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> set preloader<span style="color: #009900;">&#40;</span>value<span style="color: #339933;">:</span>Sprite<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">super</span>.<span style="color: #660066;">preloader</span> <span style="color: #339933;">=</span> value<span style="color: #339933;">;</span>
&nbsp;
	_preloader <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>value <span style="color: #000066; font-weight: bold;">as</span> Preloader<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	_preloader.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>RSLEvent.<span style="color: #660066;">RSL_PROGRESS</span><span style="color: #339933;">,</span> 	onRSLDownloadProgress <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	_preloader.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>RSLEvent.<span style="color: #660066;">RSL_ERROR</span><span style="color: #339933;">,</span> 	onRSLEncryptionDetected<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">999</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// **************************************************************</span>
<span style="color: #006600; font-style: italic;">//  RSL Event Handlers</span>
<span style="color: #006600; font-style: italic;">// **************************************************************</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**</span>
<span style="color: #006600; font-style: italic;">&nbsp;* Called during initial RSLEvent.RSL_ERROR; in our case</span>
<span style="color: #006600; font-style: italic;">&nbsp;* this is expected because the RSL is encrypted and cannot be properly loaded.</span>
<span style="color: #006600; font-style: italic;">&nbsp;* Kill the event propogation and invoke the NitroLM decryptor to reload a decrypted version </span>
<span style="color: #006600; font-style: italic;">&nbsp;* of the RSL.</span>
<span style="color: #006600; font-style: italic;">&nbsp;* </span>
<span style="color: #006600; font-style: italic;">&nbsp;* @param event  Initial RSLEvent.RSL_ERROR</span>
<span style="color: #006600; font-style: italic;">&nbsp;* </span>
<span style="color: #006600; font-style: italic;">&nbsp;*/</span>
<span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> onRSLEncryptionDetected<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>RSLEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// Could be encrypted so reload it and check.</span>
	event.<span style="color: #660066;">stopImmediatePropagation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="display:block;background-color: #ffc;">	_decryptor.<span style="color: #660066;">loadAndDecrypt</span><span style="color: #009900;">&#40;</span>event.<span style="color: #660066;">url</span><span style="color: #339933;">,</span> onRSLDecryptedAndLoaded<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></span><span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**</span>
<span style="color: #006600; font-style: italic;">&nbsp;* Method invoked when the encrypted RSL has been decrypted and loaded into the AVM.</span>
<span style="color: #006600; font-style: italic;">&nbsp;* This causes the next RSL to start loading (if any available). </span>
<span style="color: #006600; font-style: italic;">&nbsp;* @param event</span>
<span style="color: #006600; font-style: italic;">&nbsp;* </span>
<span style="color: #006600; font-style: italic;">&nbsp;*/</span>
<span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> onRSLDecryptedAndLoaded<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>Event<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// We must manually force the Preloader to continue load all subsequent RSLs</span>
	<span style="color: #006600; font-style: italic;">// that are in the queue (after the current RSL has processed/loaded).</span>
	Preloader<span style="color: #009900;">&#40;</span>_preloader<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mx_internal</span><span style="color: #339933;">::</span>resume<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**</span>
<span style="color: #006600; font-style: italic;">&nbsp;* Show the progress of the current RSL download relative to the total percentage </span>
<span style="color: #006600; font-style: italic;">&nbsp;* Not relevant to </span>
<span style="color: #006600; font-style: italic;">&nbsp;* @param event RSLEvent to update progress of load each RSL</span>
<span style="color: #006600; font-style: italic;">&nbsp;* </span>
<span style="color: #006600; font-style: italic;">&nbsp;*/</span>
<span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> onRSLDownloadProgress<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>RSLEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// Now that are tracking on RSL loads, remove generic listener...</span>
	_preloader.<span style="color: #660066;">removeEventListener</span><span style="color: #009900;">&#40;</span>ProgressEvent.<span style="color: #660066;">PROGRESS</span><span style="color: #339933;">,</span> 	onDownload_Progress<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	centerOnScreen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	progressBar.<span style="color: #660066;">progress</span> <span style="color: #339933;">=</span> calculatePercentDone<span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>progressBar.<span style="color: #660066;">visible</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>isReady<span style="color: #009900;">&#41;</span> progressBar.<span style="color: #660066;">visible</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// **************************************************************</span>
<span style="color: #006600; font-style: italic;">//  Private Attributes</span>
<span style="color: #006600; font-style: italic;">// **************************************************************</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> calculatePercentDone<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>RSLEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>Number <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> amountPerRSL   <span style="color: #339933;">:</span> Number <span style="color: #339933;">=</span> DOWNLOAD_PERCENTAGE <span style="color: #339933;">/</span> event.<span style="color: #660066;">rslTotal</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> alreadyLoaded  <span style="color: #339933;">:</span> Number <span style="color: #339933;">=</span> amountPerRSL <span style="color: #339933;">*</span> event.<span style="color: #660066;">rslIndex</span><span style="color: #339933;">;</span> 
	<span style="color: #003366; font-weight: bold;">var</span> currentLoading <span style="color: #339933;">:</span> Number <span style="color: #339933;">=</span> amountPerRSL <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>event.<span style="color: #660066;">bytesLoaded</span> <span style="color: #339933;">/</span> event.<span style="color: #660066;">bytesTotal</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">return</span>  alreadyLoaded <span style="color: #339933;">+</span> currentLoading<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #006600; font-style: italic;">/**</span>
<span style="color: #006600; font-style: italic;">&nbsp;* Decryptor facade class that hides complexities of asynchronous decryption </span>
<span style="color: #006600; font-style: italic;">&nbsp;* of encrtyped RSL.</span>
<span style="color: #006600; font-style: italic;">&nbsp;* </span>
<span style="color: #006600; font-style: italic;">&nbsp;* @private </span>
<span style="color: #006600; font-style: italic;">&nbsp;*/</span>
<span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> _decryptor      <span style="color: #339933;">:</span> NitroDecryptor <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> NitroDecryptor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// **************************************************************</span>
<span style="color: #006600; font-style: italic;">//  Monkey-Patch Attributes (to force linker to load the patched classes)</span>
<span style="color: #006600; font-style: italic;">// **************************************************************</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> _preloader     <span style="color: #339933;">:</span> Preloader<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> _unused4       <span style="color: #339933;">:</span> RSLListLoader<span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p></br></p>
<p>Because the Flex 3 &amp; 4 mx framework never planned for the use of encrypted RSLs, any RSLError event immediately stops the current and all other RSL load processes. In our situation, however, we do not consider an &quot;encryption error&quot; to be a real error&#8230; so we have to &quot;fix&quot; or monkey-patch the Flex codebase to support new &quot;resume()&quot; functionality. </p>
<p>Don&#8217;t worry, I have provided all that &quot;patch&quot; code in source code for this blog! In order to employ RSL encryption within your own Flex application(s), you will need:</p>
<ul>
<li>A Nitro-LM account and product encryption keyset</li>
<li>An application configured to load 1 or more RSLs during startup</li>
<li>A custom DownloadProgressBar display with support for RSL decryption </li>
<li>An Ant script to encrypt your RSL/swf (shown below) </li>
</ul>
<p>Below is a sample ANT script that you can use to encrypt a target Flex library using a Nitro-LM RSA private key:</p>
<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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
</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>project <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;Deploy EncryptedRSL Demo&quot;</span> basedir=<span style="color: #990000;">&quot;.&quot;</span> <span style="color: #0033ff; font-weight: bold;">default</span>=<span style="color: #990000;">&quot;encrypt.compiled.swc&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>property <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;library.name&quot;</span> 	<span style="color: #004993;">value</span>=<span style="color: #990000;">&quot;CairngormExtensions&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>property <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;flexsdk.dir&quot;</span> 	<span style="color: #004993;">value</span>=<span style="color: #990000;">&quot;/Users/thomasburleson/Documents/dev/flexSDK&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>property <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;bin.dir&quot;</span> 		<span style="color: #004993;">value</span>=<span style="color: #990000;">&quot;/Users/thomasburleson/Documents/dev/frameworks/CGX/build&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>property <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;deploy.dir&quot;</span> 	<span style="color: #004993;">value</span>=<span style="color: #990000;">&quot;/Users/thomasburleson/Documents/dev/samples/nitroLM/Flex4_encryptedRSL/bin-debug&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>property <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;build.dev&quot;</span> 		<span style="color: #004993;">value</span>=<span style="color: #990000;">&quot;/Users/thomasburleson/Documents/dev/samples/nitroLM/Flex4_encryptedRSL/build&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>property <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;tools.dir&quot;</span> 		<span style="color: #004993;">value</span>=<span style="color: #990000;">&quot;${build.dev}/tools/build&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>target <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;encrypt.compiled.swc&quot;</span> depends=<span style="color: #990000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="display:block;background-color: #ffc;">		<span style="color: #000000; font-weight: bold;">&lt;</span>encryptSWC rsl<span style="color: #000000; font-weight: bold;">-</span>dir=<span style="color: #990000;">&quot;${bin.dir}/rsl&quot;</span> swc<span style="color: #000000; font-weight: bold;">-</span>dir=<span style="color: #990000;">&quot;${bin.dir}&quot;</span> swc<span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;${library.name}&quot;</span> deploy<span style="color: #000000; font-weight: bold;">-</span>dir=<span style="color: #990000;">&quot;${deploy.dir}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>		<span style="color: #000000; font-weight: bold;">&lt;</span>delete dir=<span style="color: #990000;">&quot;${bin.dir}/rsl&quot;</span> quiet=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">&lt;</span>echo <span style="color: #004993;">message</span>=<span style="color: #990000;">&quot;Finished build and encryption of: ${deploy.dir}/${library.name}.swf &quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>target<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
&nbsp;
		<span style="color: #000000; font-weight: bold;">&lt;!--</span>
			Ant Definitions and Macros
		<span style="color: #000000; font-weight: bold;">--&gt;</span>	
&nbsp;
		<span style="color: #000000; font-weight: bold;">&lt;</span>taskdef <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;nitrolm-encrypt&quot;</span> classname=<span style="color: #990000;">&quot;com.simplifiedlogic.nitrolm.LMEncryptAsset&quot;</span> classpath=<span style="color: #990000;">&quot;${tools.dir}/jars/AssetEncrypterX.jar&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">&lt;</span>macrodef <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;encryptSWC&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>attribute <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;rsl-dir&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>attribute <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;swc-dir&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>attribute <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;swc-name&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>attribute <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;version-stamp&quot;</span> <span style="color: #0033ff; font-weight: bold;">default</span>=<span style="color: #990000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;</span>attribute <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;deploy-dir&quot;</span>       <span style="color: #0033ff; font-weight: bold;">default</span>=<span style="color: #990000;">&quot;${deploy.dir}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
			<span style="color: #000000; font-weight: bold;">&lt;</span>attribute <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;encrypt-keys-dir&quot;</span> <span style="color: #0033ff; font-weight: bold;">default</span>=<span style="color: #990000;">&quot;${tools.dir}/nitro_lm/keys&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;</span>sequential<span style="color: #000000; font-weight: bold;">&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;!--</span>   Process
&nbsp;
					<span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Extract the SWF from the SWC <span style="color: #000000;">&#40;</span>RSL that should be encrypted<span style="color: #000000;">&#41;</span>
				    <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> Optimize the RSL <span style="color: #000000;">&#40;</span>remove debug <span style="color: #004993;">info</span> and <span style="color: #004993;">compress</span><span style="color: #000000;">&#41;</span>
				    <span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span> Encrypt the SWF<span style="color: #000000; font-weight: bold;">/</span>RSL <span style="color: #0033ff; font-weight: bold;">with</span> Nitro<span style="color: #000000; font-weight: bold;">-</span>LM tools and keys
				    <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span> Deploy the encrypted RSL
				    <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span> Update the <span style="color: #004993;">target</span> SWC digest <span style="color: #0033ff; font-weight: bold;">with</span> the encrypted RSL checksum 
				       <span style="color: #000000; font-weight: bold;">-</span> The <span style="color: #990000;">&quot;parent&quot;</span> app that loads the RSL uses the SWC<span style="color: #000000; font-weight: bold;">/</span>updated digest <span style="color: #004993;">value</span> to
				       <span style="color: #000000; font-weight: bold;">-</span> insure that the RSL <span style="color: #0033ff; font-weight: bold;">is</span> the <span style="color: #990000;">&quot;expected&quot;</span> RSL and not a pirated one<span style="color: #000000; font-weight: bold;">!</span>
				<span style="color: #000000; font-weight: bold;">--&gt;</span>
&nbsp;
				<span style="color: #000000; font-weight: bold;">&lt;</span>unzip src=<span style="color: #990000;">&quot;@{swc-dir}/@{swc-name}.swc&quot;</span>
					dest=<span style="color: #990000;">&quot;@{rsl-dir}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
					<span style="color: #000000; font-weight: bold;">&lt;</span>patternset<span style="color: #000000; font-weight: bold;">&gt;</span>
	                   <span style="color: #000000; font-weight: bold;">&lt;</span>include <span style="color: #004993;">name</span>=<span style="color: #990000;">&quot;library.swf&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
					<span style="color: #000000; font-weight: bold;">&lt;/</span>patternset<span style="color: #000000; font-weight: bold;">&gt;</span> 
				<span style="color: #000000; font-weight: bold;">&lt;/</span>unzip<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
				<span style="color: #000000; font-weight: bold;">&lt;</span>java jar=<span style="color: #990000;">&quot;${flexsdk.dir}/lib/optimizer.jar&quot;</span> fork=<span style="color: #990000;">&quot;true&quot;</span> failonerror=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
					<span style="color: #000000; font-weight: bold;">&lt;</span>jvmarg line=<span style="color: #990000;">&quot;-ea -DAS3 -DAVMPLUS -Dflexlib=${flexsdk.dir}/frameworks -Xms32m -Xmx384m -Dsun.io.useCanonCaches=false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
					<span style="color: #000000; font-weight: bold;">&lt;</span>arg line=<span style="color: #990000;">&quot;'@{rsl-dir}/library.swf' --output '@{rsl-dir}/library.swf' --keep-as3-metadata='Bindable,Managed,ChangeEvent,NonCommittingChangeEvent,Transient' &quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;/</span>java<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
				<span style="color: #000000; font-weight: bold;">&lt;!--</span> encrypt the swf to protect 
					 Here, I am using my <span style="color: #0033ff; font-weight: bold;">private</span> key downloaded from my Nitro<span style="color: #000000; font-weight: bold;">-</span>LM account
					 @ https<span style="color: #000000; font-weight: bold;">:</span><span style="color: #009900;">//license.nitromation.com/NitroAdminLite/index.html</span>
				<span style="color: #000000; font-weight: bold;">--&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;</span>nitrolm<span style="color: #000000; font-weight: bold;">-</span>encrypt
					filename=<span style="color: #990000;">&quot;@{rsl-dir}/library.swf&quot;</span>
					product=<span style="color: #990000;">&quot;6LMLulqf9VN9AmbFzKky&quot;</span>
					library=<span style="color: #990000;">&quot;6LMLulqf9VN9AmbFzKky&quot;</span>
					keydir=<span style="color: #990000;">&quot;@{encrypt-keys-dir}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
&nbsp;
				<span style="color: #000000; font-weight: bold;">&lt;</span>delete file=<span style="color: #990000;">&quot;@{deploy-dir}/@{swc-name}.swf&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;</span>copy file=<span style="color: #990000;">&quot;@{rsl-dir}/library.swf&quot;</span> tofile=<span style="color: #990000;">&quot;@{deploy-dir}/@{swc-name}@{version-stamp}.swf&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
				<span style="color: #000000; font-weight: bold;">&lt;!--</span> Update the digest <span style="color: #004993;">value</span> <span style="color: #0033ff; font-weight: bold;">in</span> the .swc so linking applications will use the updated digest <span style="color: #004993;">value</span> 
				     Do not worry about the library.swf inside the SWC being the original <span style="color: #004993;">version</span>...
				<span style="color: #000000; font-weight: bold;">--&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;</span>java jar=<span style="color: #990000;">&quot;${flexsdk.dir}/lib/digest.jar&quot;</span> fork=<span style="color: #990000;">&quot;true&quot;</span> failonerror=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
					<span style="color: #000000; font-weight: bold;">&lt;</span>jvmarg line=<span style="color: #990000;">&quot;-ea -DAS3 -DAVMPLUS -Dflexlib=${flexsdk.dir}/frameworks -Xms32m -Xmx384m -Dsun.io.useCanonCaches=false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
					<span style="color: #000000; font-weight: bold;">&lt;</span>arg line=<span style="color: #990000;">&quot;--digest.rsl-file  @{rsl-dir}/library.swf --digest.swc-path  @{swc-dir}/@{swc-name}.swc&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;/</span>java<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;/</span>sequential<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;/</span>macrodef<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>project<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

</p>
<p>Click here to download the <a href="http://www.gridlinked.info/slides/demoEncryptedRSLs.zip" target="_parent">FlashBuilder 4 Demo project </a>(and ant build script) used for the demo above. You can even use the Custom Preloader display solutions to rapidly create your own. </p>
<p>So what is next? Well, if you have non-trivial flex applications you may want to deliver some of the following support:</p>
<ul>
<li>want to partition your code into multiple RSLs ?  </li>
<li>need to provide on-demand compiles and encryption of multiple RSLs ? </li>
<li>want to version stamp those RSLs based on tags in SVN, CVS, or GIT ?</li>
<li>want to optimize filesizes for all deployed, production components ?</li>
<li>want to auto-deploy components with version-stamps ?</li>
<li>want to configure CruiseControl for automated builds and deploys ?</li>
</ul>
<p><br/>If you need help with these, contact me. My professional life is as an RIA Flex/Flash consultant, entrepreneur, developer, architect, and mentor. So give me a shout out at <span style="color: #800000">Thomas dot Burleson at ThunderbaySoft dot com</span>.</p>
<br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=10.0" /></div><div>Rating: 10.0/<strong>10</strong> (5 votes cast)</div><br /><hr />
<p><small>© Thomas Burleson for <a href="http://www.gridlinked.info">GridLinked to RUX</a>, 2009.   
&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;  
<a href="http://feedburner.google.com/fb/a/mailverify?uri=GridlinkedToRux&amp;loc=en_US"><span style="color:#900">Subscribe by Email</span></a> |
<a href="mailto:ThomasBurleson@GMail.com">Contact Author</a> 	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;
<a href="http://www.gridlinked.info/how-to-encrypt-flex-rsls/">Permalink</a> |    
<a href="http://www.gridlinked.info/how-to-encrypt-flex-rsls/#comments">7 comments</a>
<br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.gridlinked.info/how-to-encrypt-flex-rsls/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Cairngorm Secret Tip #3: Responders for View Notifications</title>
		<link>http://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/</link>
		<comments>http://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 21:57:50 +0000</pubDate>
		<dc:creator>thomasb</dc:creator>
				<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[Fireworks]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[event dispatching]]></category>
		<category><![CDATA[mvc]]></category>

		<guid isPermaLink="false">http://www.gridlinked.info/?p=287</guid>
		<description><![CDATA[In the real-world appliations, the data binding solutions espoused by Cairngorm MVC are not always sufficient. Sometimes Views dispatch business events to request data that should be available only to that specific instance of the calling view. So how does a Cairngorm presentation layer view "subscribe" for post event-processing notifications from the Command? The remarkably easy solution is to use Responders as notification mechanisms to allow Commands to notify Views… just like the way Delegates notify Commands in the control layers.<br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=9.5" /></div><div>Rating: 9.5/<strong>10</strong> (42 votes cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p>As Flex continues to grow as the choice RIA technology, many developers start investigating and apply Java design patterns to Flex implementations. Similar to Java Struts, Cairngorm is a  MVC (Model-View-Controller)  framework &#8211; endorsed by Adobe &#8211; that is widely popular within the community.  </p>
<p>One of issues that frequently confuses, blocks, or complicates Cairngorm implementations is the issue of &#8220;view notifications&#8221;. Every Cairngorm developer ask the following question at some point: <span style="color:#AB0000;font-size:1.1em;">How should the Cairngorm business layer best communicate with the Presentation layer?</span> </p>
<p><br/>Review Figure 1 which illustrates the recommended relationships between the view and control layers:</p>
<p><img src="http://www.gridlinked.info/images/2009/04/figure1_mvc.png" alt="Flex Cairngorm MVC " width="642" height="280" class="alignleft size-full wp-image-317" /></p>
<ul>
<li>Model is a repository for data</li>
<li>Views support user interactions and announce user gestures as dispatched events to Controllers</li>
<li>Controllers employ commands to process dispatched events</li>
<li>Commands are responsible for using Delegates to talk to the server, and updating model data (client side)</li>
<li>Views use data binding to &#8220;watch&#8221; Model data changes and self-update to dipslay formatted data. </li>
</ul>
<div class="qa"><span class="question">This sounds great. So what is the problem?</span></div>
<p>Commands are supposed to use the Model layer as the mediator between business and presentation layers. In Flex, data bindings and change watchers allow views to <em>watch</em> data models. When data is modified, hidden propertyChange events are dispatched from Models to Views and the View uses event listeners to self-update.  This is the basic premise of the Flex Cairngorm MVC framework. </p>
<p>In real-world applications, data binding solutions espoused by Cairngorm MVC are not always sufficient; since such solutions require views to watch for data changes. Some times, however, watching for data changes is complicated&#8230; perhaps the data is not globally available. Sometimes the view [that dispatches the business event] is requesting data that should  be available <em>only</em> to that specific instance of the calling view; and should not be stored in global repositories. Sometimes, we do not care so much about the data&#8230; but instead we want to execute custom code when the event succeeds and finishes.</p>
<p>PureMVC and traditional Cairngorm solutions require complex code and design patterns to solve these situations. </p>
<ul>
<li> ViewLocators could be used to try to <em>lookup</em> an instance of a view. (Requires coupling to specific view classes from the business layer&#8230;. BAD!)
<li> Views could employ/register private view controllers with the front controller, </li>
<li> Command could dispatch new &#8220;notify view&#8221; events thru the front Controller to the view controller </li>
</ul>
<p>The above approaches create a proliferation of view controllers and is useful ONLY when multiple views want to listen to the same event and be notified simultaneously. Please note that in such rare situtations, a custom event-bridge or a traditional data binding approach would be more practical [but that is another article]. In fact, in most scenarios, the view simply wants the notification directly and exclusively (only to its instance). For these situations, there is a simpler &#8211; and better &#8211; solution to the ViewController complexity. </p>
<ul>
<li>What if we cannot easily use global data models and view data binding?</li>
<li>What if we do not want to create an hierarchy of bindable properties simply to deliver data to deeply nested child views?
<li>How can we deliver data directly to a view instance without storing that data in the ModelLocator hierarchy?</li>
<li>And&#8230; if the View invokes a Command [via event dispatching] and Command/Delegate pairs process server data, how can the Command deliver the processed results back to the View only?</li>
</ul>
<p>The remarkably easy solution is to use Responders as notification mechanisms to allow Commands to <em>notify</em>  Views&#8230; just like the way Delegates notify Commands [See Cairngorm Secret Tip #2: Data Transformations within Delegates]. To understand the proposed solution, consider the Cairngorm approach where a Command instance employs a Delegate class as &#8220;API facade&#8221; to remote data services. </p>
<p>The command instance <em>submits</em> itself [or a proxy to itself] as a responder to the delegate. The delegate, in turn, simply uses the specified responder to direct dataservice responses directly to back to the command.  This allows the Command to receive <em>callbacks</em> from the Delegate or the Server. In fact, advance this same approach is used at the Delegate level to allow Delegate instances to intercept server responses, transform data, and <em>then</em> notify/pass the modified data back to the Command.</p>
<div class="qa">
With Responders, post-command notifications can be delivered agnostically to any caller [View] that has provided a ResultEvent handler and a FaultEvent handler.
</div>
<p>Using Responders, a Command can submit itself as a callback to specific Delegate calls. Views can effectively do the same with Commands. Figure 2 below illustrates this process or queueing of responses. The queue builds with (1) View waits for a response from the Command, (2) the Commands waits on the Delegate, and (3) the Delegate waits on the Server. The queue unwinds after (4) the server responds, (5) Delegate notifies the command, (6) the Command notifies the view.  Using a Responder proxy, the view is notified after the actual dataservice request/response and after Command processing; see Step (6) in Figure 2. </p>
<p><img src="http://www.gridlinked.info/images/2009/04/figure2_viewnotifications.png" alt="View Notifications using Responders" width="642" height="269" class="alignleft size-full wp-image-318" /></p>
<p><br/> &nbsp;</p>
<div class="qa"><span class="question">How exactly does the view provide a Responder to the Command  ?</span></div>
<p>Well, when we dispatch business events to commands, we create custom events. So we simply need to transport a Responder instance along with the normal event information that is dispatched to the Cairngorm control layer. If all custom events have constructors with optional responder arguments then we have a built-in mechanism to support callbacks from Commands.</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> mx.rpc
<span style="color: #000000;">&#123;</span>
<span style="color: #3f5fbf;">/**</span>
<span style="color: #3f5fbf;">&nbsp;*  This interface provides the contract for any service</span>
<span style="color: #3f5fbf;">&nbsp;*  that needs to respond to remote or asynchronous calls.</span>
<span style="color: #3f5fbf;">&nbsp;*/</span>
<span style="color: #0033ff; font-weight: bold;">public</span> interface IResponder
<span style="color: #000000;">&#123;</span>
	<span style="color: #3f5fbf;">/**</span>
<span style="color: #3f5fbf;">	 *  This method is called by a service when the return value</span>
<span style="color: #3f5fbf;">	 *  has been received. </span>
<span style="color: #3f5fbf;">	 *  While &lt;code&gt;data&lt;/code&gt; is typed as Object, it is often</span>
<span style="color: #3f5fbf;">	 *  (but not always) an mx.rpc.events.ResultEvent.</span>
<span style="color: #3f5fbf;">	 */</span>
<span style="display:block;background-color: #ffc;">	<span style="color: #339966; font-weight: bold;">function</span> result<span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</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>&nbsp;
	<span style="color: #3f5fbf;">/**</span>
<span style="color: #3f5fbf;">	 *  This method is called by a service when an error has been received.</span>
<span style="color: #3f5fbf;">	 *  While &lt;code&gt;info&lt;/code&gt; is typed as Object it is often</span>
<span style="color: #3f5fbf;">	 *  (but not always) an mx.rpc.events.FaultEvent.</span>
<span style="color: #3f5fbf;">	 */</span>
	<span style="color: #339966; font-weight: bold;">function</span> fault<span style="color: #000000;">&#40;</span><span style="color: #004993;">info</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</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;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.grdlinked.samples.control.events <span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
    <span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.IResponder;
    <span style="color: #0033ff; font-weight: bold;">import</span> com.universalmind.cairngorm.events.UMEvent;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> LoadUserDetails extends UMEvent <span style="color: #000000;">&#123;</span>
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> EVENT_ID <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;loadUserDetailsBySSN&quot;</span>;
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> ssn      <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;&quot;</span>;
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> password <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;&quot;</span>; 
&nbsp;
        <span style="color: #009900;">// Constructor </span>
<span style="display:block;background-color: #ffc;">        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> LoadUserDetails<span style="color: #000000;">&#40;</span> ssn<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>,</span>                                    password<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>,
                                    callbacks<span style="color: #000000; font-weight: bold;">:</span>IResponder=<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>EVENT_ID, callbacks, <span style="color: #0033ff; font-weight: bold;">true</span>, <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>;
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">this</span>.ssn      = ssn;
            <span style="color: #0033ff; font-weight: bold;">this</span>.password = password;
&nbsp;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>For the examples in the post, we use a custom event <CairngormEvent> <em>LoadUserDetailsEvent</em> class that accepts an optional &#8220;responder&#8221; parameter.  Using a SSN and password the view requests user details from the control layer. The control/business layer may elect to lookup the user in a client-side cache or call the server. The business layer is responsible for all these details and the presentation/UI layer need not worry. And the view does NOT know anything about who handles the event or how the event is processed. This &#8220;separation of concerns&#8221; is what MVC is all about.  </p>
<p>When the event is processed by the command, the command can temporarily cache the view responder or callback. Sometime later &#8211; after the asynchronous data service call responds &#8211; the following can happen:</p>
<ol>
<li> the command can use the dataservice response to update the ModelLocator directly, trigger databindings to update, and</li>
<li>  the command can forward the dataservice response or any OTHER data to the cached responder. Command::notifyCaller() is the method used to provide view notifications.</li>
</ol>
<div class="qa">
<span class="question">Do all my views have to implement the IResponder interface or &#8211; even worse &#8211; extend a custom parent class?&#8221;</span>
</div>
<p>If your views want to implement the IResponder interface, each one of your views would need to include public result() and fault() functions:</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
</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 	<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;400&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;300&quot;</span> 
		implements=<span style="color: #990000;">&quot;mx.rpc.IResponder&quot;</span>
		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: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	<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> mx.rpc.IResponder;
		<span style="color: #0033ff; font-weight: bold;">import</span> mx.controls.Alert;
&nbsp;
     <span style="color: #009900;">// Methods required by the IResponder interface		</span>
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> result<span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</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>
            btnLoad.<span style="color: #004993;">enabled</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
      <span style="color: #000000;">&#125;</span>
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> fault<span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</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>
            Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span>event.<span style="color: #004993;">message</span><span style="color: #000000;">&#41;</span>;
            btnLoad.<span style="color: #004993;">enabled</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
      <span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #009900;">// Private methods invoked by child controls		</span>
      <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> loadUserDetails<span style="color: #000000;">&#40;</span>ssn<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>
            btnLoad.<span style="color: #004993;">enabled</span> = <span style="color: #0033ff; font-weight: bold;">false</span>;	<span style="color: #009900;">// disable button while waiting for a response.</span>
&nbsp;
            <span style="color: #009900;">// Load the user details for the specified user</span>
            <span style="color: #009900;">//NOTE how this view will be the responder...</span>
<span style="display:block;background-color: #ffc;">            <span style="color: #6699cc; font-weight: bold;">var</span> callbacks <span style="color: #000000; font-weight: bold;">:</span> IResponder = <span style="color: #0033ff; font-weight: bold;">this</span> <span style="color: #0033ff; font-weight: bold;">as</span> IResponder;</span>            <span style="color: #6699cc; font-weight: bold;">var</span> event <span style="color: #000000; font-weight: bold;">:</span> LoadUserDetailsEvent = <span style="color: #0033ff; font-weight: bold;">new</span> LoadUserDetailsEvent<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;435-34-1283&quot;</span>, <span style="color: #990000;">&quot;anonymous&quot;</span>, callbacks<span style="color: #000000;">&#41;</span>;
		  event.<span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span>  <span style="color: #000000;">&#41;</span>;   <span style="color: #009900;">// Cairngorm events self-dispatch directly to the business layer; </span>
      <span style="color: #000000;">&#125;</span>
&nbsp;
	<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>
&nbsp;
	<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;btnLoad&quot;</span> label=<span style="color: #990000;">&quot;Load User&quot;</span> textAlign=<span style="color: #990000;">&quot;center&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;145&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;149&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;loadUserDetails()&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;147&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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>In our example the view needs to know when the results are available; since the load button is disabled until the business layer [and server] responds .</p>
<p>The above code sample shows, unfortunately, how each of your custom views would need to be modified to work as view responders. When the command finishes, it would call something like caller.result(). Unfortunately, the signature of the result() function is ambiguous and does not document which event triggered the result. In contrast a method like onResult_loadUserDetails() explicit documents its purpose.</p>
<div id="pullquote-con">If you see any code like that show above, then please slap the developer immediately! </div>
<p>After a thorough slapping, ask that developer this question: <span style="color:#AB0000"><br />
&#8220;What if I had two buttons that each dispatched separate business events and each needed separate response handlers? How could the result() function be the common event handler for both events? Would I have to somehow detect &#8211; inside the result() method &#8211; which event is responding?&#8221;<br />
</span></p>
<p>As you can see, this solution rapidly creates nasty code and rapidly produces nasty, convoluted, unmanageable code.</p>
<p>So instead of requiring an abomination of view interfaces or view inheritance (which is even worse), the view will instead create an instance of a Responder class that will serve as a proxy responder class. The Responder class will <em>redirect</em> result() and fault() calls to methods that we specify.   Let us look at some code for clarity. Below we see an example of custom view component created to load and display user details.</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
50
51
52
53
54
55
56
57
</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 	<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;400&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;300&quot;</span> 
		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: #000000; font-weight: bold;">&gt;</span>
&nbsp;
    <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> mx.rpc.IResponder;
		<span style="color: #0033ff; font-weight: bold;">import</span> mx.controls.Alert;
		<span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.events.FaultEvent;
		<span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.<span style="color: #004993;">Responder</span>;
&nbsp;
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> loadUserDetails<span style="color: #000000;">&#40;</span>ssn<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>
          <span style="color: #009900;">// Load the user details for the specified user</span>
<span style="display:block;background-color: #ffc;">          <span style="color: #6699cc; font-weight: bold;">var</span> callbacks <span style="color: #000000; font-weight: bold;">:</span> IResponder           = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Responder</span><span style="color: #000000;">&#40;</span>onResults_loadUserDetails, onFault_loadUserDetails<span style="color: #000000;">&#41;</span>;</span>          <span style="color: #6699cc; font-weight: bold;">var</span> event     <span style="color: #000000; font-weight: bold;">:</span> LoadUserDetailsEvent = <span style="color: #0033ff; font-weight: bold;">new</span> LoadUserDetailsEvent<span style="color: #000000;">&#40;</span>user.ssn, user.password, callbacks<span style="color: #000000;">&#41;</span>;
&nbsp;
          btnLoad.<span style="color: #004993;">enabled</span> = <span style="color: #0033ff; font-weight: bold;">false</span>;	<span style="color: #009900;">// disable button while waiting for a response.</span>
          event.<span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span>  <span style="color: #000000;">&#41;</span>;	<span style="color: #009900;">// Cairngorm events can self-dispatch to the business layer.	  </span>
     <span style="color: #000000;">&#125;</span>
&nbsp;
     <span style="color: #009900;">// ***************************************************</span>
     <span style="color: #009900;">// Private EventHandlers for the loadUserDetails()</span>
     <span style="color: #009900;">// ***************************************************</span>
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onResuls_loadUserDetails<span style="color: #000000;">&#40;</span>user<span style="color: #000000; font-weight: bold;">:</span>UserVO<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;">// The SSN and password were authenticated; here are user details</span>
          _user = <span style="color: #000000; font-weight: bold;">!</span>user <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #0033ff; font-weight: bold;">new</span> UserVO<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> user;
          btnLoad.<span style="color: #004993;">enabled</span> = <span style="color: #0033ff; font-weight: bold;">true</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> onFault_loadUserDetails<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>FaultEvent<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>
          Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span>event.<span style="color: #004993;">message</span><span style="color: #000000;">&#41;</span>;
          btnLoad.<span style="color: #004993;">enabled</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
     <span style="color: #000000;">&#125;</span>
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _user <span style="color: #000000; font-weight: bold;">:</span> UserVO = <span style="color: #0033ff; font-weight: bold;">new</span> UserVO<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;			
&nbsp;
    <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>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Text <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Please enter your credentials to edit your account:&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;16&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;30&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>FormItem label=<span style="color: #990000;">&quot;FullName:&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;23&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;208&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>Label <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_user.fullName}&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>FormItem<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>FormItem label=<span style="color: #990000;">&quot;SSN:&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;54&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;104&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>TextInput id=<span style="color: #990000;">&quot;txtSSN&quot;</span>  <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{_user.ssn}&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;129&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>FormItem<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>FormItem label=<span style="color: #990000;">&quot;Password:&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;23&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;70&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>TextInput id=<span style="color: #990000;">&quot;txtPassword&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>FormItem<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	<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;btnLoad&quot;</span> label=<span style="color: #990000;">&quot;Load User&quot;</span> textAlign=<span style="color: #990000;">&quot;center&quot;</span> <span style="color: #004993;">x</span>=<span style="color: #990000;">&quot;145&quot;</span> <span style="color: #004993;">y</span>=<span style="color: #990000;">&quot;149&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;loadUserDetails()&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;147&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
<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>

<div class="qa">
<span class="question">Question: And how is the view notified of the response from the server (after the command finishes)? </span>
</div>
<p>Commands &#8211; after the processing is finished &#8211; will trigger any cached IResponders::result() methods to notify the sender [View] of the event. </p>
<p>In the code example above, look at line 15  where we use a Responder instance to act as a proxy for the functions that we want to call. The Responder class does NOT know any details about the view itself. It simply has functions that may be called upon an event response. For a successful response, the view wants <span style="color:#0070C0;">onResults_loadUserDetails()</span> to be called. Likewise for failures, the view wants <span style="color:#0070C0;">onFault_loadUserDetails()</span> to be called. With responders, the view essentially provides event handlers for Command post-processing. </p>
<p>To summarize the above code snippet as psuedo-code, you (a) use a responder proxy wrapper class, (b) package the responder instance inside the event, and (c) extend the command base class to support the caching of the callback/view responder. And voila&#8217; you are done!</p>
<p>This is VERY clean:</p>
<ol>
<li> your views are still standard mxml or as classes with aggregates and composite controls,</li>
<li>  event dispatching is the same [with an optional callback] and</li>
<li>  you do NOT have to create crude view controllers to handle view notifications</li>
<li>  each view instance can have its OWN, separate callback</li>
<li>  views can then support  modal operations, undos, reverts, commits, etc&#8230; completely independent of each other.</li>
<li>  you can dispatch as many business events as desired; each with their own event/response handler methods.
</ol>
<p>Better yet, this functionality is built into the Cairngorm Extensions (CGX) using both the Callback and the mx.rpc.Responder classes.  CGX is an open-source extension to cairngorm. If you are interested in this and other Cairngorm extensions provide comments to this blog or or visit <a href="http://code.google.com/p/flexcairngorm/">Google Cairngorm Extensions</a>. </p>
<br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=9.5" /></div><div>Rating: 9.5/<strong>10</strong> (42 votes cast)</div><br /><hr />
<p><small>© Thomas Burleson for <a href="http://www.gridlinked.info">GridLinked to RUX</a>, 2009.   
&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;  
<a href="http://feedburner.google.com/fb/a/mailverify?uri=GridlinkedToRux&amp;loc=en_US"><span style="color:#900">Subscribe by Email</span></a> |
<a href="mailto:ThomasBurleson@GMail.com">Contact Author</a> 	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;
<a href="http://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/">Permalink</a> |    
<a href="http://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comments">41 comments</a>
<br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Automation with Fireworks CS4 Commands &#8211; Reflections</title>
		<link>http://www.gridlinked.info/reflections-made-easy-with-fireworks-cs4-commands/</link>
		<comments>http://www.gridlinked.info/reflections-made-easy-with-fireworks-cs4-commands/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 01:08:44 +0000</pubDate>
		<dc:creator>thomasb</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Fireworks]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[designer]]></category>
		<category><![CDATA[prototyping]]></category>
		<category><![CDATA[reflections]]></category>
		<category><![CDATA[storyboarding]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://www.gridlinked.info/?p=163</guid>
		<description><![CDATA[Fireworks CS4 is an amazing web design and storyboarding tool. Learn how to use Commands for automation of complex features such as Lighting and Reflections. With the Create Reflection command, you can easily add RUX concepts to your designs. Includes commented source code and introduces the Ustrive2 Sellit ShopBOT widget.  <br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=10.0" /></div><div>Rating: 10.0/<strong>10</strong> (6 votes cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p>While working at <a href="http://www.sellit.com/pages/for_partners" target="_blank"><span style="text-decoration: underline;">Ustrive2, Inc.</span></a> I initiated some redesign efforts for the <a href="http://www.sellit.com/pages/for_merchants" target="_blank"><span style="text-decoration: underline;">Sellit Administrator</span></a> tools. Focused on creating a fantastic, rich user experience, The dev team [DanM, JesseF, MichaelF, and MikeC] used Fireworks CS4 to quickly iterate through several design prototypes and deliver designs that satisfied many complex feature requirements. </p>
<p>One aspect of those designs was to create a sense of depth [and engage the user] by judiciously highlighting key components with lighting and <span style="color: #0070C0">reflections</span>. Many of the resulting storyboard pages contained 2 or more components with reflections. </p>
<p>Manually creating a reflection requires 20 or more steps and about 60 seconds to complete&#8230; for <span style="text-decoration: italic;">each</span> component. I will not bother listing each step&#8230; it is non-trivial and tedious [and the code at the bottom of this blog shows you the details]. There had to be a way to <span style="color: #0070C0;">automate</span> the process. I realized that a Fireworks Command was the solution! </p>
<div style="margin: 1px 0pt;" id="pullquote-con">Fireworks CS4 is an amazing <a href="http://tv.adobe.com/?promoid=DRHYB#vi+f15383v1022" target="_blank"><span style="text-decoration: underline;">web design</span></a> and <a href="http://odeo.com/episodes/22108974-Storyboarding-in-Production-Premium-CS3" target="_blank"><span style="text-decoration: underline;">storyboarding</span></a> tool. If you are not leveraging its power within your own design processes you are crazy.</div>
<p>With a Fireworks command and associated hot-key, I could automate 20+ steps and many mouse movements to a single command. And I could easily invoke that command using a hotkey. Wow! But how would I create the command if I did not know the Fireworks API?  Before we solve the automation issue, let&#8217;s first see what the <span style="color: #0070C0">Reflection</span> command actually does. Then we will learn how to create such a command. </p>
<p><span style="font-weight:bold;font-size:1.1em;">Click</span> on any of the thumbnails below to see the examples of using a &#8216;Create Reflection&#8217; command.</p>
<div class="gallery">
<dl class="gallery-item">
<dt class="gallery-icon"> <div class="img size-thumbnail wp-image-165" style="width:125px;">
	<a href="http://www.gridlinked.info/images/2009/03/reflect_1.jpg" rel="shadowbox[fireworks_reflection];options={resizeDuration:.05,fadeDuration:.05}"><img src="http://www.gridlinked.info/images/2009/03/reflect_1-150x150.jpg" alt="Sellit ShopBOT " width="125" height="125" /></a>
	<div>Sellit ShopBOT</div>
</div> </dt>
</dl>
<dl class="gallery-item">
<dt class="gallery-icon"><div class="img size-thumbnail wp-image-166" style="width:125px;">
	<a href="http://www.gridlinked.info/images/2009/03/reflect_2.jpg" rel="shadowbox[fireworks_reflection];options={resizeDuration:.05,fadeDuration:.05}"><img src="http://www.gridlinked.info/images/2009/03/reflect_2-150x150.jpg" alt="ShopBOT w/ Reflection" width="125" height="125" /></a>
	<div>ShopBOT w/ Reflection</div>
</div> </dt>
</dl>
<dl class="gallery-item">
<dt class="gallery-icon"> <div class="img size-thumbnail wp-image-169" style="width:125px;">
	<a href="http://www.gridlinked.info/images/2009/03/reflect_4.jpg" rel="shadowbox[fireworks_reflection];options={resizeDuration:.05,fadeDuration:.05}"><img src="http://www.gridlinked.info/images/2009/03/reflect_4-150x150.jpg" alt="Reflections on many ShopBOTs" width="125" height="125" /></a>
	<div>Reflections on many ShopBOTs</div>
</div> </dt>
</dl>
<dl class="gallery-item">
<dt class="gallery-icon">
<div class="img size-thumbnail wp-image-249" style="width:125px;">
	<a href="http://www.gridlinked.info/images/2009/03/4shopbots.jpg" rel="shadowbox[fireworks_reflection];options={resizeDuration:.05,fadeDuration:.05}"><img src="http://www.gridlinked.info/images/2009/03/4shopbots-150x150.jpg" alt="More Reflections on ShopBOTs" width="125" height="125" /></a>
	<div>More Reflections on ShopBOTs</div>
</div>
 </dt>
</dl>
</div>
<p><br/></p>
<p>Below is an outline of the process you can use to create your own reflection command. Let Fireworks record all your steps and save those steps as javascript code. Then you can fine-tune that code as desired:</p>
<ol>
<li>Open the History panel and make sure the history is clear,</li>
<li>Manually create a reflection with the 20 or more steps (painful details not included),</li>
<li>In the History palette, select the steps that match the process to create the reflection,</li>
<li>Using the History Menu, select the &#8216;Save as Command&#8230;&#8217; menu option,</li>
<li>Specify the name &#8216;Create Reflection&#8217; and click OK</li>
<li>Edit the javascript command code to perform as desired:
<ol>
<li>Use a text or code editor to open the &#8216;Create Reflection.jsf&#8217; file (directory location below),</li>
<li>Modify the code to programmatically support clip height, opacity, offsets, etc.</li>
<li>Save modified command file,</li>
<li>Return to Fireworks, select a object, and invoke the &#8216;Create Reflection&#8217; command</li>
</ol>
</li>
<li>Did your changes work? If not go to Step (6) make more coding changes and iterate&#8230;</li>
</ol>
<div id="pullquote-con" style="font-size:1.3em;">Did you know about the <a href="http://www.adobe.dougwinnie.com/?p=45" target="_blank"><span style="text-decoration:underline;color:0x00D000">Export Pages as PDF</span></a> feature and its click support to jump between pages. Your PDFs can be used for storyboarding, collaborating, sharing prototypes, and walkthrus.</div>
<div id='conclusion' style="vertical-align:top;">
<div id="attachment_164" class="wp-caption alignright" style="width: 160px"><a href="http://www.gridlinked.info/images/2009/03/command_loc.jpg" rel="shadowbox;options={resizeDuration:.05,fadeDuration:.05}""><img src="http://www.gridlinked.info/images/2009/03/command_loc-150x150.jpg" alt="Commands Directory (Mac OS X)" width="150" height="150" class="size-medium wp-image-164" /></a><p class="wp-caption-text">Fireworks Commands Directory (Mac OS X)</p></div><br />
But where [which directory] should you open/edit/save the &#8216;Create Reflection.jsf&#8217; command file?  Click the thumbnail on the right to zoom for details.</p>
<p>After the challenging [and fun] time invested to create my own working command, my &#8216;Create Reflection&#8217; works great. The Ustrive2 developers loved using it for their own design efforts.  </p>
<p>With the code [shown below] and a copy of the &#8216;Create Reflection.jsf&#8217; command file, it is my hope that you will also enjoy using this command.<br />
<br/>
</div>
<p>Below is the javascript code contained in the link for your own <span style="text-decoration:underline;color:0x00D000"><a href="http://www.gridlinked.info/data/CreateReflection.zip">Create Reflection.jsf</a></span> command (click to download):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/*</span>
<span style="color: #006600; font-style: italic;">&nbsp;* CreateReflection is a Fireworks Command that creates a vertical reflection [of the currently selected items].</span>
<span style="color: #006600; font-style: italic;">&nbsp;*</span>
<span style="color: #006600; font-style: italic;">&nbsp;* This is an incredible timesaver and allows the designer to quickly create reflections for anything.</span>
<span style="color: #006600; font-style: italic;">&nbsp;* When 1 or more items are selected in the current canvas area, those items are:</span>
<span style="color: #006600; font-style: italic;">&nbsp;*   1) Duplicated, flipped vertically, and flatten (original items are unchanged and deselected)</span>
<span style="color: #006600; font-style: italic;">&nbsp;*   2) The flattened copy is cropped to the top 40 pixels</span>
<span style="color: #006600; font-style: italic;">&nbsp;*   3) A gradient alpha mask is applied to the cropped image</span>
<span style="color: #006600; font-style: italic;">&nbsp;*   4) Both the mask and image are flattened and opacity set to 20%</span>
<span style="color: #006600; font-style: italic;">&nbsp;*</span>
<span style="color: #006600; font-style: italic;">&nbsp;* TODOs:</span>
<span style="color: #006600; font-style: italic;">&nbsp;*    1) Add support to skew/distort the selected images and reflection (for 3D perspective effect)</span>
<span style="color: #006600; font-style: italic;">&nbsp;*    2) Create runtime UI dialog to request clip height, offset, opacity, and skew parameters</span>
<span style="color: #006600; font-style: italic;">&nbsp;*    3) Check for no items currently selected and posting feedback to designer</span>
<span style="color: #006600; font-style: italic;">&nbsp;*</span>
<span style="color: #006600; font-style: italic;">&nbsp;* Author:  Thomas Burleson, Flex/Groovy Consultant</span>
<span style="color: #006600; font-style: italic;">&nbsp;*</span>
<span style="color: #006600; font-style: italic;">&nbsp;*          Blog    @ http://www.gridlinked.info</span>
<span style="color: #006600; font-style: italic;">&nbsp;*          Profile @ http://www.LinkedIn.com/in/ThomasBurleson</span>
<span style="color: #006600; font-style: italic;">&nbsp;*          eMail   @ ThomasBurleson@gmail.com</span>
<span style="color: #006600; font-style: italic;">&nbsp;*</span>
<span style="color: #006600; font-style: italic;">&nbsp;*</span>
<span style="color: #006600; font-style: italic;">&nbsp;* Date:  Feb 24, 2009</span>
<span style="color: #006600; font-style: italic;">&nbsp;*/</span> 
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> OFFSET         <span style="color: #339933;">=</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> REFLECT_HEIGHT <span style="color: #339933;">=</span> <span style="color: #CC0000;">40</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> dom            <span style="color: #339933;">=</span> fw.<span style="color: #660066;">getDocumentDOM</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> reflections    <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Copy and flip selection, move to OFFSET below the original, and flatten to bitmap </span>
dom.<span style="color: #660066;">clipCopy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dom.<span style="color: #660066;">clipPaste</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
dom.<span style="color: #660066;">group</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dom.<span style="color: #660066;">reflectSelection</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;autoTrimImages transformAttributes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dom.<span style="color: #660066;">flattenSelection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> bounds <span style="color: #339933;">=</span> dom.<span style="color: #660066;">getSelectionBounds</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dom.<span style="color: #660066;">moveSelectionBy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> y<span style="color: #339933;">:</span>bounds.<span style="color: #660066;">bottom</span><span style="color: #339933;">-</span>bounds.<span style="color: #660066;">top</span><span style="color: #339933;">+</span>OFFSET<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Clip image to REFLECT_HEIGHT,</span>
bounds <span style="color: #339933;">=</span> dom.<span style="color: #660066;">getSelectionBounds</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
bounds.<span style="color: #660066;">bottom</span> <span style="color: #339933;">=</span> bounds.<span style="color: #660066;">top</span> <span style="color: #339933;">+</span> REFLECT_HEIGHT<span style="color: #339933;">;</span>
dom.<span style="color: #660066;">setSelectionMask</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#123;</span>  maskBounds<span style="color: #339933;">:</span>bounds<span style="color: #339933;">,</span> 
                                       maskKind<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;rectangle&quot;</span><span style="color: #339933;">,</span> 
                                       maskEdgeMode<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;hard edge&quot;</span><span style="color: #339933;">,</span> 
                                       featherAmount<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> 
                                       maskData<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
                                    <span style="color: #3366CC;">&quot;replace&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dom.<span style="color: #660066;">exitPaintMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dom.<span style="color: #660066;">cropSelection</span><span style="color: #009900;">&#40;</span>bounds<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Cache the reflection...</span>
reflections.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>fw.<span style="color: #660066;">selection</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Build an alpha clip mask and set transparency to 20%</span>
dom.<span style="color: #660066;">addNewRectanglePrimitive</span><span style="color: #009900;">&#40;</span>bounds<span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dom.<span style="color: #660066;">setBrushNColor</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;#ffffff00&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dom.<span style="color: #660066;">setFillVectorStart</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span>bounds.<span style="color: #660066;">left</span><span style="color: #339933;">,</span> y<span style="color: #339933;">:</span>bounds.<span style="color: #660066;">top</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dom.<span style="color: #660066;">setFill</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#123;</span> category     <span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;fc_Linear&quot;</span><span style="color: #339933;">,</span> 
			   ditherColors <span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span> <span style="color: #3366CC;">&quot;#000000&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;#000000&quot;</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			   edgeType     <span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;antialiased&quot;</span><span style="color: #339933;">,</span> 
			   feather      <span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> 
			   gradient     <span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;cn_Custom&quot;</span><span style="color: #339933;">,</span> nodes<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#123;</span> color<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#ffffff&quot;</span><span style="color: #339933;">,</span>  isOpacityNode<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> position<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> color<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#ffffff&quot;</span><span style="color: #339933;">,</span>  isOpacityNode<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> position<span style="color: #339933;">:</span><span style="color: #CC0000;">1</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> opacityNodes<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#123;</span> color<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#000000&quot;</span><span style="color: #339933;">,</span>  isOpacityNode<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>  position<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> color<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#00000000&quot;</span><span style="color: #339933;">,</span>isOpacityNode<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>  position<span style="color: #339933;">:</span><span style="color: #CC0000;">1</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
			   <span style="color: #000066;">name</span>         <span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;fn_Linear&quot;</span><span style="color: #339933;">,</span> 
			   pattern      <span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> 
			   shape        <span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;linear&quot;</span><span style="color: #339933;">,</span> 
			   stampingMode <span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;blend opaque&quot;</span><span style="color: #339933;">,</span> 
			   textureBlend <span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> 
			   webDitherTransparent<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Cache the alpha mask</span>
reflections.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>fw.<span style="color: #660066;">selection</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Select the reflection and alpha mask, then group and set opacity...</span>
<span style="display:block;background-color: #ffc;">fw.<span style="color: #660066;">selection</span> <span style="color: #339933;">=</span> reflections<span style="color: #339933;">;</span></span>&nbsp;
dom.<span style="color: #660066;">group</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mask to image&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dom.<span style="color: #660066;">flattenSelection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dom.<span style="color: #660066;">setOpacity</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// DONE!</span></pre></div></div>

<p>After this tutorial, you should explore more solutions and start creating your own cool Fireworks commands. I will let you figure out how to assign a hotkey sequence to a command. <span style="color:0x00D000;">With commands and hotkeys, your design life becomes FUN!</span></p>
<p>If you extend or enhance &#8216;Create Reflection&#8217;, please send me a copy <img src='http://www.gridlinked.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   And don&#8217;t forget, please comment and rate this article (rate by select the star levels) below.<br />
<br/></p>
<br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=10.0" /></div><div>Rating: 10.0/<strong>10</strong> (6 votes cast)</div><br /><hr />
<p><small>© Thomas Burleson for <a href="http://www.gridlinked.info">GridLinked to RUX</a>, 2009.   
&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;  
<a href="http://feedburner.google.com/fb/a/mailverify?uri=GridlinkedToRux&amp;loc=en_US"><span style="color:#900">Subscribe by Email</span></a> |
<a href="mailto:ThomasBurleson@GMail.com">Contact Author</a> 	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;
<a href="http://www.gridlinked.info/reflections-made-easy-with-fireworks-cs4-commands/">Permalink</a> |    
<a href="http://www.gridlinked.info/reflections-made-easy-with-fireworks-cs4-commands/#comments">3 comments</a>
<br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.gridlinked.info/reflections-made-easy-with-fireworks-cs4-commands/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flex Behavior Injection (like jQuery)</title>
		<link>http://www.gridlinked.info/flex-behavior-injection/</link>
		<comments>http://www.gridlinked.info/flex-behavior-injection/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 23:29:52 +0000</pubDate>
		<dc:creator>thomasb</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[chart]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[flexCamp]]></category>
		<category><![CDATA[interactions]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[zoom]]></category>

		<guid isPermaLink="false">http://gridlinked.info/wordpress/?p=20</guid>
		<description><![CDATA[The "Flex Behavior Injection" approach to component development and architectures will change your perspective on Flex software development.<br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=9.2" /></div><div>Rating: 9.2/<strong>10</strong> (5 votes cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p><strong><em>This approach</em></strong> to component development and architectures will change your perspective on Flex software development! Consider the myriad situations when you want to add sophisticated functionality like <span style="color: #0070C0;">zoom</span>, <span style="color: #0070C0; ">drag-n-drop</span>, <span style="color: #0070C0; ">swapping</span>, <span style="color: #0070C0;">MDI window minimizing</span>, etc. Instead of designing subclasses or building complex compositions of nested components, developers can create distinct <span style="color: #800000">behavior components</span>. These behavior components are then dynamically attached to target components and <span style="color: #800000;">inject functionality</span>.</p>
<p>I must admit that this software concept is not new. Consider the very popular <a href="http://docs.jquery.com/UI/Resizable" target="_blank"><span style="text-decoration: underline;">JQuery UI Interactions</span></a>. The JQuery UI Resizable code provides functionality to allow 1 or more HTML components to be dynamically resized. Other functionality exists for dragging, dropping, selecting, etc.</p>
<div id="pullquote-con">Using Flex technologies, can we have this same sort of functionality where behaviors are <span style="color: #800000">injected or attached</span> to target components upon demand ?</div>
<p>During Jan &#8216;09 &#8211; at FlexCamp OC in Irvine, CA &#8211; I presented a new topic called <a href="http://www.flexcampoc.com/" target="_blank"><span style="text-decoration: underline;">Flex Behavior Injection</span></a>.  Below is an improved version of the slide deck that I presented at that conference. These slides are interactive; simply click to go to the next or previous slide. You can also zoom the slides using the slide control bar&#8230;</p>
<p><center><br />
<object width="425" height="348"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=flexbehaviourinjection-090303105114-phpapp02"/><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=flexbehaviourinjection-090303105114-phpapp02"  type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="348"></embed></object><!-- ysttest:Array
(
    [id] => 1095693&amp;doc=flexbehaviourinjection-090303105114-phpapp02&amp;w=425
)
--><br />
</center></p>
<p>Of course, what good is a slide deck without a live application and code samples? Below is a live version of a well-known Adobe application that demonstrates a charting dashboard solution with multi-chart interactions. Selecting a data point on a chart triggers filters and auto-updates dependent charts. With two (2) lines of code, I have enhanced that application to use injected behaviors for <span style="color: #0070C0;">swapping</span> and <span style="color: #0070C0; ">zooming</span>. Click the picture below to play with the live Flex application. </p>
<p>Here are some helpful tips: To zoom, use the toolbar to select which chart you want to zoom, then click the Zoom button.<br/><br />
To swap a chart:</p>
<ol>
<li>Select the &#8216;Enable Swap&#8217; checkbox,</li>
<li>Then move your mouse over the bottom area of any of the chart panels,</li>
<li>The cursor will change to a hand-cursor,</li>
<li>Click and drag a chart to see how dynamic swapping works</li>
</ol>
<div id="pullquote-con">Snap-to, animation, dragging, <span style="color: #800000">real-time swapping</span>, and constraints are all handled by the Swapper behavior! You can drag a chart, drop anywhere, and the current chart will <span style="color: #800000">snap</span> into place&#8230;</div>
<p>As you drag a chart around, watch how the other charts will swap positions dynamically, on-the-fly as you drag. Even better, with view states, your chart could be coded to change reconfig its states after resizing&#8230; so swapping could also change the layouts of each chart. For example, if placed in an narrow vertical area, the panel could change state to display a datagrid instead of a chart&#8230; you can imagine the sensation and rich user experience that you could offer to users.</p>
<div class="img aligncenter" style="width:403px;">
	<a style="color: #ffffff;" rel="lightbox" href="http://www.gridlinked.info/flash/dashboard4/dashboard4.html"><img src="/flash/dashboard4/dashboard4_proxy.jpg" alt="Chart Dashboard with Behaviors" width="403" height="309" /></a>
	<div>Figure 1: Chart Dashboard with Behaviors (click to launch)</div>
</div>
<p>Below is the main code for the sample application. Notice the Zoomer component tag that is highlighted on line 14. When activated (click event on line 26), the Zoomer handles all nesting and constraint issues for the target component when it zooms. And &#8211; best of all &#8211; the Zoomer handles details of un-zooming the component back to its original settings/location. You can easily imagine the enormous pain of trying to manually cache and restore settings and anchors&#8230;<br />
<br/></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
</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>Application 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: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	<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: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span> <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _target <span style="color: #000000; font-weight: bold;">:</span> UIComponent = <span style="color: #0033ff; font-weight: bold;">null</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>
&nbsp;
   <span style="color: #000000; font-weight: bold;">&lt;!--</span> RPC Dataservice component <span style="color: #0033ff; font-weight: bold;">for</span> the chart <span style="color: #004993;">XML</span> <span style="color: #004993;">data</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>HTTPService id=<span style="color: #990000;">&quot;srv&quot;</span> <span style="color: #004993;">url</span>=<span style="color: #990000;">&quot;/data/dashboard4.xml&quot;</span> useProxy=<span style="color: #990000;">&quot;false&quot;</span> result=<span style="color: #990000;">&quot;resultHandler(event)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">&lt;!--</span> Behavior components <span style="color: #000000; font-weight: bold;">--&gt;</span>
<span style="display:block;background-color: #ffc;">    <span style="color: #000000; font-weight: bold;">&lt;</span>behaviour<span style="color: #000000; font-weight: bold;">:</span>Zoomer	id=<span style="color: #990000;">&quot;zoomer&quot;</span> <span style="color: #004993;">target</span>=<span style="color: #990000;">&quot;{_target}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>   <span style="color: #000000; font-weight: bold;">&lt;</span>swap<span style="color: #000000; font-weight: bold;">:</span>Swapper 	id=<span style="color: #990000;">&quot;swapper&quot;</span> 
			allowedDrops=<span style="color: #990000;">&quot;{[allRegions,regionBreakdown,regionDetail]}&quot;</span> 
			<span style="color: #004993;">active</span>=<span style="color: #990000;">&quot;{_canSwap}&quot;</span> 	<span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>ApplicationControlBar <span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;10&quot;</span> <span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;10&quot;</span> <span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;5&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>Label <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Chart to Zoom:&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>RadioButton label=<span style="color: #990000;">&quot;All Regions&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;_target = allRegions;&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>RadioButton label=<span style="color: #990000;">&quot;Breakdown&quot;</span>   <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;_target = regionBreakdown;&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>RadioButton label=<span style="color: #990000;">&quot;Details&quot;</span>     <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;_target = regionDetail;&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;{zoomer.isZoomed ? 'UnZoom' : 'Zoom'}&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;zoomer.play();&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>Spacer <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;10&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>CheckBox label=<span style="color: #990000;">&quot;Swap Enabled&quot;</span> selected=<span style="color: #990000;">&quot;false&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;_canSwap = (event.target as CheckBox).selected;&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>ApplicationControlBar<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Canvas id=<span style="color: #990000;">&quot;content&quot;</span> <span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;50&quot;</span> <span style="color: #004993;">bottom</span>=<span style="color: #990000;">&quot;10&quot;</span> label=<span style="color: #990000;">&quot;10&quot;</span> <span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;10&quot;</span> <span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;10&quot;</span> horizontalScrollPolicy=<span style="color: #990000;">&quot;off&quot;</span> verticalScrollPolicy=<span style="color: #990000;">&quot;off&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>views<span style="color: #000000; font-weight: bold;">:</span>AllRegions   id=<span style="color: #990000;">&quot;allRegions&quot;</span>	
	    		 <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;{content.width/2 - 10}&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span>  <span style="color: #004993;">left</span>=<span style="color: #990000;">&quot;0&quot;</span>
	    		 revenueData=<span style="color: #990000;">&quot;{slicedMonthData.source}&quot;</span> 
			 monthChange=<span style="color: #990000;">&quot;monthChange()&quot;</span>   	<span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">&lt;</span>views<span style="color: #000000; font-weight: bold;">:</span>RegionBreakdown id=<span style="color: #990000;">&quot;regionBreakdown&quot;</span> 
			<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;{content.width/2}&quot;</span> <span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;0&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;{content.height/2 - 10}&quot;</span> <span style="color: #004993;">top</span>=<span style="color: #990000;">&quot;0&quot;</span> 
			regionChange=<span style="color: #990000;">&quot;regionChange()&quot;</span>   <span style="color: #000000; font-weight: bold;">/&gt;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">&lt;</span>views<span style="color: #000000; font-weight: bold;">:</span>RegionDetail id=<span style="color: #990000;">&quot;regionDetail&quot;</span> 	 
			<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;{content.width/2}&quot;</span> <span style="color: #004993;">right</span>=<span style="color: #990000;">&quot;0&quot;</span>   <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;{content.height/2 - 10}&quot;</span> <span style="color: #004993;">bottom</span>=<span style="color: #990000;">&quot;0&quot;</span> 
			revenueData=<span style="color: #990000;">&quot;{slicedRegionData.source}&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>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Application<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>This concept is very powerful. Your view components are not required to know about zooming or swapping (etc.) nor are you &#8211; the developer &#8211; required to configure special view hierarchies or plan for other considerations. Your coding style remains unchanged and your framework(s) [e.g. Cairngorm, CGX, Mate, etc.] remains unchanged.</p>
<p>Many people have asked for the source code to these components. This code will be open-sourced soon and the release is planned within the near future. Please consider rating this blog post and submitting some comments. You may subscribe to my blog RSS for auto-notifications when the <span style="color: #800000">Flex Behavior library</span> is released. <img src='http://www.gridlinked.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
<br/></p>
<br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=9.2" /></div><div>Rating: 9.2/<strong>10</strong> (5 votes cast)</div><br /><hr />
<p><small>© Thomas Burleson for <a href="http://www.gridlinked.info">GridLinked to RUX</a>, 2009.   
&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;  
<a href="http://feedburner.google.com/fb/a/mailverify?uri=GridlinkedToRux&amp;loc=en_US"><span style="color:#900">Subscribe by Email</span></a> |
<a href="mailto:ThomasBurleson@GMail.com">Contact Author</a> 	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;
<a href="http://www.gridlinked.info/flex-behavior-injection/">Permalink</a> |    
<a href="http://www.gridlinked.info/flex-behavior-injection/#comments">5 comments</a>
<br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.gridlinked.info/flex-behavior-injection/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Porting Flash to Flex &#8211; Elastic Cords</title>
		<link>http://www.gridlinked.info/elastic-cords-porting-flash-to-flex/</link>
		<comments>http://www.gridlinked.info/elastic-cords-porting-flash-to-flex/#comments</comments>
		<pubDate>Sun, 19 Mar 2006 05:00:53 +0000</pubDate>
		<dc:creator>thomasb</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[designer]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[interactions]]></category>
		<category><![CDATA[migrate]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[timeline]]></category>

		<guid isPermaLink="false">http://www.gridlinked.info/?p=116</guid>
		<description><![CDATA[Porting such RIA applications from Flash 8 to Flex 2 - where the concepts of timelines are deprecated - presents challenges. When you consider that most Flex projects are business-oriented applications...<br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=8.5" /></div><div>Rating: 8.5/<strong>10</strong> (2 votes cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p>Recently, <a href="http://www.ericd.net/new_css/">Eric Dolecki</a> published a Flash 8 version of a very cool Elastic Cords flash application. I am sure he was &#8211; as I am &#8211; inspired by the works of <a href="http://void.andre-michelle.com/">Andre Michelle</a>. This application, of course, does nothing commercially practical but does demonstrate great features of the FP8 API. I, of course, decided to continue that tradition. I wanted to create a Flex, object-oriented, component version&#8230;</p>
<p>All too often I find great visual applications with great experiences&#8230; are more often created in Flash not Flex. And unfortunately, their code (if published) is usually <span style="color: #0070C0; ">procedural</span> and <span style="color: #0070C0; ">timeline-based</span> instead of the <span style="color: #0070C0; ">component-based</span> approaches that come so easily in Flex.</p>
<div id="pullquote-con">Flash 8/CS3/CS4 is a tool intended primarily for designers.<br />
While Flex is a tool focused primarily on <span style="color: #800000">developer teams</span> &amp; object-oriented, coding techniques.</div>
<p>Porting such RIA applications from Flash 8 to Flex 2 &#8211; where the concepts of timelines are deprecated &#8211; presents challenges. When you consider that most Flex projects are business-oriented applications that do not require dynamic stage-drawing interactions (like the Elastic Cords), then this project was the perfect impetus for me to explore and understand some <strong>major</strong> conceptual differences between Flash and Flex; differences such <span style="color: #0070C0; ">UI interactions</span>, <span style="color: #0070C0; ">tweenings</span>, <span style="color: #0070C0; ">component coupling</span>, etc..</p>
<div class="img aligncenter" style="width:386px;">
	<a rel="lightbox;height=550;width=700" href="http://www.gridlinked.info/flash/elasticCords/cords.html"><img src="/flash/elasticCords/cords.jpg" alt="Elastic Cords Demo" width="386" height="280" /></a>
	<div>Figure 1: Elastic Cords Demo (click to launch)</div>
</div>
<p>I knew the effort would prove to be quite fun and challenging. In fact, I first became obsessed with the development efforts and solutions. Then I became obsessed the playing with the demo and dragging those ridiculous cords around.[So be forewarned <img src='http://www.gridlinked.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ]</p>
<p>Click on the sockets on the left to create new cords. Watch the new cords elastically bounced out and fall to the ground in a simulation of elasticity and gravity. You can click and drag the loose end(s) of the cords around. Watch the cords bounce and sway as you move the endpoint. Then you can release the end-point near the &#8220;drop&#8221; sockets and watch them snap into the dock sockets.</p>
<p>The source code is available! Simply right-click on the running application and <span style="color: #800000">View Source</span>.</p>
<p>Enjoy.</p>
<br /><div><img src="http://www.gridlinked.info/wp-content/plugins/gd-star-rating/gfx.php?value=8.5" /></div><div>Rating: 8.5/<strong>10</strong> (2 votes cast)</div><br /><hr />
<p><small>© Thomas Burleson for <a href="http://www.gridlinked.info">GridLinked to RUX</a>, 2006.   
&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;  
<a href="http://feedburner.google.com/fb/a/mailverify?uri=GridlinkedToRux&amp;loc=en_US"><span style="color:#900">Subscribe by Email</span></a> |
<a href="mailto:ThomasBurleson@GMail.com">Contact Author</a> 	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;	&nbsp;
<a href="http://www.gridlinked.info/elastic-cords-porting-flash-to-flex/">Permalink</a> |    
<a href="http://www.gridlinked.info/elastic-cords-porting-flash-to-flex/#comments">2 comments</a>
<br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.gridlinked.info/elastic-cords-porting-flash-to-flex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
