<?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>The Space For App Developers &#187; Articles</title>
	<atom:link href="http://www.riaspace.com/category/articles/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.riaspace.com</link>
	<description>Beyond Plain Old HTML Objects</description>
	<lastBuildDate>Mon, 30 Jan 2012 10:51:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Bundling AIR 3 runtime in AIR desktop applications</title>
		<link>http://www.riaspace.com/2011/08/bundling-air-3-runtime-in-air-desktop-applications/</link>
		<comments>http://www.riaspace.com/2011/08/bundling-air-3-runtime-in-air-desktop-applications/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 15:49:35 +0000</pubDate>
		<dc:creator>Piotr Walczyszyn</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[AIR]]></category>

		<guid isPermaLink="false">http://www.riaspace.com/?p=3290</guid>
		<description><![CDATA[At the beginning of this week a beta 2 version of the AIR 3 SDK was released. The AIR 3 SDK and AIR 3 runtime will be a major release that will bring a lot of really cool features. One of the features that I’m really excited about is Captive Runtime, which lets you package your [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F08%2Fbundling-air-3-runtime-in-air-desktop-applications%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F08%2Fbundling-air-3-runtime-in-air-desktop-applications%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p><a href="http://www.riaspace.com/wp-content/uploads/2011/08/air_165x165.jpg"><img class="alignleft size-full wp-image-3300" style="border-style: initial; border-color: initial; margin-left: 10px; margin-right: 10px; border-width: 0px;" title="air_165x165" src="http://www.riaspace.com/wp-content/uploads/2011/08/air_165x165.jpg" alt="" width="165" height="165" /></a>At the beginning of this week a <strong>beta 2</strong> version of the <a href="http://labs.adobe.com/downloads/air3.html" target="_blank">AIR 3 SDK</a> was released. The AIR 3 SDK and AIR 3 runtime will be a major release that will bring a lot of really cool features. One of the features that I’m really excited about is <strong>Captive Runtime</strong>, which lets you package your applications with a bundled AIR runtime. This is something that was available for the iOS platform from day one, and now it is also supported for both Android devices and desktops.</p>
<p>I think this is a really important feature for AIR. I heard many times from our customers and the community that we need a solution that enables users to install AIR applications without administrator rights. This is a common scenario especially in the enterprise environments where users don’t have full privileges. Also in some other cases it may improve user experience as there is no need to ask the user to install an additional runtime. It will also help when you need to distribute your application on a CD or other media that doesn’t let you use the browser-based badge installer.</p>
<p>Now how do you package your app for both Windows and Mac? It&#8217;s really simple. First thing what you need to do is to download and unzip the new SDK from <a href="http://labs.adobe.com" target="_blank">Adobe Labs</a>. Next compile your application either with the command line mxmlc compiler or using Flash Builder. To do it in Flash Builder, right-click your AIR application project, select Export&#8230; -&gt; Flash Builder -&gt; Release Build, and complete just the first step of this wizard without finishing it. This will create a bin-release-temp folder under your project directory with a compiled SWF and app descriptor file. Now go to the command line and invoke following adt command from your project/bin-release-temp folder.</p>
<h4>On Windows:</h4>
<p><code>c:\path\to\air3sdk\bin\adt.bat -package -storetype pkcs12 -keystore c:\path\to\certificate.p12 -target bundle myapp.exe myapp-app.xml -C . myapp.swf<br />
</code></p>
<h4>On Mac:</h4>
<p><code>/path/to/air3sdk/bin/adt -package -storetype pkcs12 -keystore /path/to/certificate.p12 -target bundle myapp.app myapp-app.xml -C . myapp.swf<br />
</code></p>
<p>You will receive slightly different results depending on your platform. On Mac your application is packaged into myapp.app, which is a single Mac package file. You can just double-click it to run the app. Also if you want to introspect its content you can right-click it and select the Show Package Contents option. On Windows you will get myapp.exe folder that has all the runtime files and the executable myapp.exe file in it. Now you can use your favorite installer builder to build a setup package for your application.</p>
<h4>Generated folders structure on Windows:</h4>
<p><a href="http://www.riaspace.com/wp-content/uploads/2011/08/captive-win.png"><img class="size-full wp-image-3312 alignnone" style="border-style: initial; border-color: initial; border-width: 0px;" title="captive-win" src="http://www.riaspace.com/wp-content/uploads/2011/08/captive-win.png" alt="" width="334" height="180" /></a></p>
<h4>Generated package structure on Mac:</h4>
<p><a href="http://www.riaspace.com/wp-content/uploads/2011/08/captive-mac.png"><img class="size-full wp-image-3313 alignnone" style="border-style: initial; border-color: initial; border-width: 0px;" title="captive-mac" src="http://www.riaspace.com/wp-content/uploads/2011/08/captive-mac.png" alt="" width="327" height="229" /></a></p>
<p>For Android options check out this blog <a href="http://www.tricedesigns.com/2011/08/10/air-3-0-captive-runtime/" target="_blank">post</a> by my new fellow evangelist Andy Trice.</p>
<div class="shr-publisher-3290"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F08%2Fbundling-air-3-runtime-in-air-desktop-applications%2F' data-shr_title='Bundling+AIR+3+runtime+in+AIR+desktop+applications'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F08%2Fbundling-air-3-runtime-in-air-desktop-applications%2F' data-shr_title='Bundling+AIR+3+runtime+in+AIR+desktop+applications'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.riaspace.com/2011/08/bundling-air-3-runtime-in-air-desktop-applications/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Defining custom URL schemes for your AIR mobile applications</title>
		<link>http://www.riaspace.com/2011/08/defining-custom-url-schemes-for-your-air-mobile-applications/</link>
		<comments>http://www.riaspace.com/2011/08/defining-custom-url-schemes-for-your-air-mobile-applications/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 15:15:44 +0000</pubDate>
		<dc:creator>Piotr Walczyszyn</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[OAuth]]></category>

		<guid isPermaLink="false">http://www.riaspace.com/?p=3182</guid>
		<description><![CDATA[If you&#8217;ve ever wondered if you can register your own URL schemes for your AIR mobile applications running on iOS or Android platforms the answer is yes! Actually it is very simple and you can do it by adding few extra lines in the *-app.xml document. Once you do your application can be invoked directly [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F08%2Fdefining-custom-url-schemes-for-your-air-mobile-applications%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F08%2Fdefining-custom-url-schemes-for-your-air-mobile-applications%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p>If you&#8217;ve ever wondered if you can register your own URL schemes for your AIR mobile applications running on iOS or Android platforms the answer is yes! Actually it is very simple and you can do it by adding few extra lines in the *-app.xml document. Once you do your application can be invoked directly from other applications or browser with a simple <code>&lt;a href="my-scheme:"&gt;open app&lt;/a&gt;</code> link click. </p>
<p>(Custom URL schemes are especially useful if you are doing OAuth authentication in your app and you want to redirect the user back to your application after the authorization in the browser. You can find out more about OAuth in AS3/Flex applications in my <a href="http://www.riaspace.com/2011/05/oauth-authorization-with-flash-and-flex-apps/" target="_blank">ADC tutorials</a>.)</p>
<p>To register a custom URL scheme like <code>my-scheme:</code> you simply add the following code in your *-app.xml.</p>
<h4>Android settings:</h4>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;android<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;manifestAdditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">        &lt;manifest android:installLocation=&quot;auto&quot;&gt;</span>
<span style="color: #339933;">            &lt;application&gt; </span>
<span style="color: #339933;">                &lt;activity&gt; </span>
<span style="color: #339933;">                    &lt;intent-filter&gt; </span>
<span style="color: #339933;">                        &lt;action android:name=&quot;android.intent.action.VIEW&quot;/&gt; </span>
<span style="color: #339933;">                        &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot;/&gt; </span>
<span style="color: #339933;">                        &lt;category android:name=&quot;android.intent.category.DEFAULT&quot;/&gt; </span>
<span style="color: #339933;">                        &lt;data android:scheme=&quot;my-scheme&quot;/&gt; </span>
<span style="color: #339933;">                    &lt;/intent-filter&gt; </span>
<span style="color: #339933;">                &lt;/activity&gt; </span>
<span style="color: #339933;">            &lt;/application&gt; </span>
&nbsp;
<span style="color: #339933;">            &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;</span>
&nbsp;
<span style="color: #339933;">        &lt;/manifest&gt;</span>
<span style="color: #339933;">    ]]&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/manifestAdditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/android<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h4>iOS settings:</h4>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;iPhone<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;InfoAdditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">		&lt;key&gt;UIDeviceFamily&lt;/key&gt;</span>
<span style="color: #339933;">		&lt;array&gt;</span>
<span style="color: #339933;">			&lt;string&gt;1&lt;/string&gt;</span>
<span style="color: #339933;">			&lt;string&gt;2&lt;/string&gt;</span>
<span style="color: #339933;">		&lt;/array&gt;</span>
&nbsp;
<span style="color: #339933;">		&lt;key&gt;CFBundleURLTypes&lt;/key&gt;</span>
<span style="color: #339933;">		&lt;array&gt;</span>
<span style="color: #339933;">			&lt;dict&gt;</span>
<span style="color: #339933;">				&lt;key&gt;CFBundleURLSchemes&lt;/key&gt;</span>
<span style="color: #339933;">				&lt;array&gt;</span>
<span style="color: #339933;">					&lt;string&gt;my-scheme&lt;/string&gt;</span>
<span style="color: #339933;">				&lt;/array&gt;</span>
<span style="color: #339933;">				&lt;key&gt;CFBundleURLName&lt;/key&gt;</span>
<span style="color: #339933;">				&lt;string&gt;com.myapp&lt;/string&gt;</span>
<span style="color: #339933;">			&lt;/dict&gt;</span>
<span style="color: #339933;">		&lt;/array&gt;</span>
&nbsp;
<span style="color: #339933;">	]]&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/InfoAdditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;requestedDisplayResolution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>high<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/requestedDisplayResolution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/iPhone<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Also you can pass additional arguments to your app from the invoking source. Arguments can be passed in the URL scheme after the colon; for example: <code>my-scheme:myparam</code>. Then in your application you can listen for <code>InvokeEvent.INVOKE</code> event on the <code>NativeApplication.nativeApplication</code> instance. The received event object contains an <code>arguments</code> property that returns an Array with the invoking scheme and parameters in the first item, so it would be <code>my-scheme:myparam</code> value. Next you can parse the value of your argument, and take some action in the application based on its value.</p>
<p>In a Flex Mobile app you can register an <code>InvokeEvent.INVOKE</code> event listener in the <code>preinitialize</code> phase as in following snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;">&nbsp;
<span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </span>
<span style="color: #000000;">			   xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">			   preinitialize=<span style="color: #ff0000;">&quot;application_preinitializeHandler(event)&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">			import mx.events.FlexEvent;</span>
&nbsp;
<span style="color: #000000;">			protected function application_preinitializeHandler<span style="color: #66cc66;">&#40;</span>event:FlexEvent<span style="color: #66cc66;">&#41;</span>:void</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">				NativeApplication.nativeApplication.addEventListener<span style="color: #66cc66;">&#40;</span></span>
<span style="color: #000000;">					InvokeEvent.INVOKE, onInvoke<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">			private function onInvoke<span style="color: #66cc66;">&#40;</span>event:InvokeEvent<span style="color: #66cc66;">&#41;</span>:void</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">				// You can parse argument value from event.arguments property</span>
<span style="color: #000000;">				lblArguments.text = <span style="color: #ff0000;">&quot;Arguments: &quot;</span> + event.arguments;</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> id=<span style="color: #ff0000;">&quot;lblArguments&quot;</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>One caveat is that invoking other apps with the custom URL schemes from AIR apps is not possible. The AIR security model is more restrictive and it limits schemes to: <code>http:, https:, sms:, tel:, mailto:, file:, app:, app-storage:, vipaccess: and connectpro:</code>. You can find more about it <a href="http://help.adobe.com/en_US/air/html/dev/WS5b3ccc516d4fbf351e63e3d118666ade46-7cba.html" target="_blank">here</a> and <a href="http://help.adobe.com/en_US/air/reference/html/flash/net/package.html" target="_blank">here</a>.</p>
<div class="shr-publisher-3182"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F08%2Fdefining-custom-url-schemes-for-your-air-mobile-applications%2F' data-shr_title='Defining+custom+URL+schemes+for+your+AIR+mobile+applications'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F08%2Fdefining-custom-url-schemes-for-your-air-mobile-applications%2F' data-shr_title='Defining+custom+URL+schemes+for+your+AIR+mobile+applications'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.riaspace.com/2011/08/defining-custom-url-schemes-for-your-air-mobile-applications/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Creating SkinnableContainer skins for Flex mobile apps</title>
		<link>http://www.riaspace.com/2011/07/creating-skinnablecontainer-skins-for-flex-mobile-apps/</link>
		<comments>http://www.riaspace.com/2011/07/creating-skinnablecontainer-skins-for-flex-mobile-apps/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 14:03:41 +0000</pubDate>
		<dc:creator>Piotr Walczyszyn</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://www.riaspace.com/?p=3123</guid>
		<description><![CDATA[Recently I was looking for an example on how to create a skin that would work with the SkinnableContainer component class in a Flex mobile application. It turned out I couldn&#8217;t find any examples available in the wild so I had to dig it out myself. So below is the approach I took, which can also work [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F07%2Fcreating-skinnablecontainer-skins-for-flex-mobile-apps%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F07%2Fcreating-skinnablecontainer-skins-for-flex-mobile-apps%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p>Recently I was looking for an example on how to create a skin that would work with the <code>SkinnableContainer</code> component class in a Flex mobile application. It turned out I couldn&#8217;t find any examples available in the wild so I had to dig it out myself. So below is the approach I took, which can also work for others.</p>
<p>The first thing I found out is that there is a <code>SkinnableContainerSkin</code> class in the <code>spark.skins.mobile</code> package that extends <code>MobileSkin</code> class. This is a basic implementation that works out-of-the-box when you use <code>SkinnableContainer</code> in mobile projects. Its only behavior is setting a <code>contentGroup</code> property with a new instance of the <code>Group</code> class and drawing a background rectangle filled with color based on the <code>backgroundColor</code> style.</p>
<p>Now my goal, instead of drawing the background with AS3, was to use a custom FXG file with some rounded corners, simple stroke and gradient. The screenshot below demonstrates what I was looking for:</p>
<p style="text-align: center;"><a href="http://www.riaspace.com/wp-content/uploads/2011/07/skinnablecontainerskin.png"><img class="size-medium wp-image-3128 aligncenter" style="border-style: initial; border-color: initial; border-width: 0px;" title="skinnablecontainerskin" src="http://www.riaspace.com/wp-content/uploads/2011/07/skinnablecontainerskin-180x300.png" alt="" width="180" height="300" /></a></p>
<p>In order to achieve the example above I extended <code>SkinnableContainerSkin</code> as in the following snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> spark.<span style="color: #006600;">core</span>.<span style="color: #006600;">SpriteVisualElement</span>;
	<span style="color: #0066CC;">import</span> spark.<span style="color: #006600;">skins</span>.<span style="color: #006600;">mobile</span>.<span style="color: #006600;">SkinnableContainerSkin</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MySkinnableContainerSkin <span style="color: #0066CC;">extends</span> SkinnableContainerSkin
	<span style="color: #66cc66;">&#123;</span>
		protected <span style="color: #000000; font-weight: bold;">var</span> backgroundClass:<span style="color: #000000; font-weight: bold;">Class</span>;
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">background</span>:SpriteVisualElement;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MySkinnableContainerSkin<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">// Here could be a DPI dependent logic, for demo purposes it is not necessary</span>
			backgroundClass = MySkinnableContainerBackground;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> createChildren<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// Adding container background</span>
			<span style="color: #0066CC;">background</span> = <span style="color: #000000; font-weight: bold;">new</span> backgroundClass;
			addChild<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">background</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">// Creating content group instance</span>
			<span style="color: #0066CC;">super</span>.<span style="color: #006600;">createChildren</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> layoutContents<span style="color: #66cc66;">&#40;</span>unscaledWidth:<span style="color: #0066CC;">Number</span>, unscaledHeight:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span>.<span style="color: #006600;">layoutContents</span><span style="color: #66cc66;">&#40;</span>unscaledWidth, unscaledHeight<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">// Setting size of background container</span>
			setElementSize<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">background</span>, unscaledWidth, unscaledHeight<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> drawBackground<span style="color: #66cc66;">&#40;</span>unscaledWidth:<span style="color: #0066CC;">Number</span>, unscaledHeight:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// By default SkinnableContainerSkin draws Rect with backgroundColor but this is not</span>
			<span style="color: #808080; font-style: italic;">// required in this case since background is constructed of MySkinnableContainerBackground fxg</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>My FXG file content looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">'1.0'</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">'UTF-8'</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Graphic</span> <span style="color: #000066;">xmlns:fc</span>=<span style="color: #ff0000;">&quot;http://ns.adobe.com/flashcatalyst/2009&quot;</span> <span style="color: #000066;">xmlns:d</span>=<span style="color: #ff0000;">&quot;http://ns.adobe.com/fxg/2008/dt&quot;</span> </span>
<span style="color: #009900;">		 <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://ns.adobe.com/fxg/2008&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span></span>
<span style="color: #009900;">		 <span style="color: #000066;">scaleGridLeft</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">scaleGridTop</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">scaleGridRight</span>=<span style="color: #ff0000;">&quot;90&quot;</span> <span style="color: #000066;">scaleGridBottom</span>=<span style="color: #ff0000;">&quot;90&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Rect</span> <span style="color: #000066;">radiusX</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;100&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fill<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LinearGradient</span> <span style="color: #000066;">rotation</span>=<span style="color: #ff0000;">&quot;90&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;GradientEntry</span> <span style="color: #000066;">alpha</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">color</span>=<span style="color: #ff0000;">&quot;#CCCCCC&quot;</span> <span style="color: #000066;">ratio</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;GradientEntry</span> <span style="color: #000066;">alpha</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">color</span>=<span style="color: #ff0000;">&quot;#666666&quot;</span> <span style="color: #000066;">ratio</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LinearGradient<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fill<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stroke<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SolidColorStroke</span> <span style="color: #000066;">color</span>=<span style="color: #ff0000;">&quot;#FF0000&quot;</span> <span style="color: #000066;">weight</span>=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stroke<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Rect<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Graphic<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And the way I can use it now in my Flex mobile projects is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:SkinnableContainer</span> <span style="color: #000066;">left</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">top</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">right</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">bottom</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">skinClass</span>=<span style="color: #ff0000;">&quot;MySkinnableContainerSkin&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:Label</span> <span style="color: #000066;">left</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">top</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">right</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">bottom</span>=<span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eget arcu et nibh vehicula pulvinar sit amet sit amet ligula. Duis a orci at nisi faucibus luctus. Quisque congue vulputate porttitor. Curabitur ac turpis nulla, a malesuada diam. Sed ullamcorper massa ac libero tincidunt vel ultrices odio cursus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce pharetra varius tortor id rutrum. Duis tempor, nisl sit amet scelerisque dignissim, lorem nisl vehicula leo, in auctor dolor turpis at nisl. Quisque bibendum faucibus turpis vitae pulvinar. Sed mollis risus eget turpis molestie laoreet. Aenean metus nulla, vestibulum at egestas quis, aliquet tempus lectus.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:Label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:SkinnableContainer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<div class="shr-publisher-3123"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F07%2Fcreating-skinnablecontainer-skins-for-flex-mobile-apps%2F' data-shr_title='Creating+SkinnableContainer+skins+for+Flex+mobile+apps'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F07%2Fcreating-skinnablecontainer-skins-for-flex-mobile-apps%2F' data-shr_title='Creating+SkinnableContainer+skins+for+Flex+mobile+apps'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.riaspace.com/2011/07/creating-skinnablecontainer-skins-for-flex-mobile-apps/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Running LCDS/BlazeDS in the cloud with AWS Elastic Beanstalk</title>
		<link>http://www.riaspace.com/2011/07/running-lcds-blazeds-in-the-cloud-with-aws-elastic-beanstalk/</link>
		<comments>http://www.riaspace.com/2011/07/running-lcds-blazeds-in-the-cloud-with-aws-elastic-beanstalk/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 12:47:36 +0000</pubDate>
		<dc:creator>Piotr Walczyszyn</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex Mobile]]></category>
		<category><![CDATA[LCDS]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://www.riaspace.com/?p=3034</guid>
		<description><![CDATA[Very recently I was looking for a simple and affordable solution to host Java-based services for the mobile version of my LCDS Samples application. Unfortunately, with the Java development, life is not as easy as with PHP where you can get affordable hosting that is managed and secured by your hosting provider. The reality is that with [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F07%2Frunning-lcds-blazeds-in-the-cloud-with-aws-elastic-beanstalk%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F07%2Frunning-lcds-blazeds-in-the-cloud-with-aws-elastic-beanstalk%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p style="text-align: justify;">Very recently I was looking for a simple and affordable solution to host Java-based services for the <a href="http://www.riaspace.com/2011/06/ported-lcds-samples-in-android-market/" target="_blank">mobile version of my LCDS Samples application</a>. Unfortunately, with the Java development, life is not as easy as with PHP where you can get affordable hosting that is managed and secured by your hosting provider. The reality is that with Java you usually end up having a VPS or an instance of a dedicated Linux server (of course Windows would work also). This is certainly a very good solution that gives you a lot of flexibility but you have to remember that the tasks of administering and securing your box are usually on your shoulders. Although I have some knowledge of Unix-type systems, to be honest I wouldn&#8217;t feel comfortable doing the whole administration on my own.</p>
<p style="text-align: justify;">So after some research and trying out different options I ended up with an <a href="http://aws.amazon.com/elasticbeanstalk/" target="_blank">AWS Elastic Beanstalk</a> service provided by Amazon (you can see it in action running <a href="http://lcds.riaspace.com" target="_blank">here</a>). I&#8217;m really excited about this service because it provides an instance of Tomcat (both 6.x and 7.x versions are available) hosted and managed on Amazon&#8217;s cloud infrastructure. On top of that and out-of-the-box, it provides a load balancer that will automatically launch additional instances if your application encounters the increased load. Also you have full access to your Tomcat logs and you can receive email notifications with the status and health of your running services.  Another important thing is that it is extremely easy to use, especially when you install the AWS Eclipse plugin that can also work well with Eclipse/Flash Builder.</p>
<p style="text-align: justify;">The good thing is that the cost of all this is not really high, the entry level service is just about <strong>$35.27</strong> a month, more details about pricing are available <a href="http://aws.amazon.com/elasticbeanstalk/#pricing" target="_blank">here</a>.</p>
<h3 style="text-align: justify;">Getting started</h3>
<p style="text-align: justify;">Follow these steps to get up and running:</p>
<ol style="text-align: justify;">
<li><strong>Get an account (if  you don&#8217;t already have one) with <a href="http://aws.amazon.com/" target="_blank">AWS (Amazon Web Services)</a>.</strong> Once you get an account you can sign up for Elastic Beanstalk via the &#8220;Manage Your Account&#8221; section.</li>
<li><strong>Configure your IDE environment.</strong> By default Flash Builder comes with a standard version of Eclipse that has only the JDT available. I suggest downloading the Eclipse IDE for Java EE Developers and to configure FB with this environment. It will give you additional tools to handle Tomcat instances and Java Web Projects, which you can use when developing for Elastic Beanstalk. Configuring FB with a custom installation of Eclipse is really straightforward. Once you download Eclipse from <a href="http://eclipse.org/downloads/" target="_blank">here</a> and you extract it somewhere to your hard drive, you can go to the folder where you have FB installed and find the <strong>Adobe Flash Builder 4.5 Plug-in Utility</strong> application located in the utilities folder. In my case it is here &#8220;/Applications/Adobe Flash Builder 4.5/utilities/Adobe Flash Builder 4.5 Plug-in Utility.app&#8221; but it all depends where you have your FB installation and also on what OS you are on. Run this application and it will guide you with a few simple steps through the whole Flash Builder &#8211; Eclipse integration process.</li>
<li><strong>Install the AWS Eclipse plugin. </strong>This can be done directly from Eclipse. Just go to the Help -&gt; Install New Software menu and enter the following update site URL: <a href="http://aws.amazon.com/eclipse">http://aws.amazon.com/eclipse</a><br />
<img class="aligncenter size-medium wp-image-3058" style="border-style: initial; border-color: initial; border-width: 0px;" title="AWS Eclipse update site" src="http://www.riaspace.com/wp-content/uploads/2011/07/aws-eclipse-udapte-site-300x232.png" alt="" width="300" height="232" /></li>
<li><strong>Create a new AWS Java Web Project. </strong>After a successful install of the AWS plugin you will have an option to create new AWS projects. Use the wizard available from the top bar of Eclipse (with an AWS icon on it) to create a New AWS Java Web Project. First you will need to enter a project name, and credentials like Access Key ID and Secret Access Key. These values are generated when you sign up for an AWS account and you can copy them from the Security Credentials section of your AWS account.<a href="http://www.riaspace.com/wp-content/uploads/2011/07/aws-wizard.png"><img class="aligncenter size-medium wp-image-3062" style="border-style: initial; border-color: initial; border-width: 0px;" title="AWS wizard" src="http://www.riaspace.com/wp-content/uploads/2011/07/aws-wizard-261x300.png" alt="" width="261" height="300" /></a><br />
You can select the Basic Java Web Application option (see the screenshot above), this will be enough for the LCDS/BlazeDS scenario. More info about other options is available through this <a href="http://aws.amazon.com/eclipse" target="_blank">site</a>, with an in-depth video tutorial.</li>
<li><strong>Configure the LCDS/BlazeDS  environment.</strong> In order to do that you need to, copy all necessary jars into the WebContent/WEB-INF/lib folder of the newly created project. In my case I used a turnkey installation of LCDS and I just copied jars from the lcds-samples application and also jars from tomcat/lib/activemq4.1.1, tomcat/lib/jotm2.0.10 and tomcat/lib/lcds (this wouldn&#8217;t be necessary for BlazeDS but for LCDS it was required to make the DataServices and Messaging work properly). Next you will also need to copy all configuration files from the WEB-INF/flex folder and the web.xml that has all necessary LCDS/BlazeDS servlets/listeners configured. The important thing to note here is that by default the AWS Elastic Beanstalk service enables only port 80 and HTTP channels; in order to enable other ports that could be required for RTMP channels you can modify the AWS EC2 Security group settings (but that is a topic for another blog post and I will not cover it here). Another solution you have is to stick to the default settings and to configure LCDS services to use only HTTP channels; this is actually what I did for my <a href="http://lcds.riaspace.com">lcds.riaspace.com</a>service.    One last thing I had to do to make the LCDS function properly was to create a WebContent/META-INF/context.xml file in which I defined the transaction configuration as in the following snippet:

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Context</span> <span style="color: #000066;">reloadable</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Transaction</span> <span style="color: #000066;">factory</span>=<span style="color: #ff0000;">&quot;org.objectweb.jotm.UserTransactionFactory&quot;</span> <span style="color: #000066;">jotm.timeout</span>=<span style="color: #ff0000;">&quot;60&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Context<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

</li>
<li><strong>Deploy your application to the cloud. </strong>Once you have the configuration completed and all the services built you can deploy your application directly from Eclipse. Just right-click on the project and select the Amazon Web Services -&gt; Deploy to AWS Elastic Beanstalk&#8230; option. Another wizard will pop up that will ask you to specify names for your application and environment.<a href="http://www.riaspace.com/wp-content/uploads/2011/07/app-environment-name.png"><img class="size-medium wp-image-3077 aligncenter" style="border-style: initial; border-color: initial; border-width: 0px;" title="app-environment-name" src="http://www.riaspace.com/wp-content/uploads/2011/07/app-environment-name-252x300.png" alt="" width="252" height="300" /></a>Next you will need to select the server type, which would be AWS Elastic Beanstalk for Tomcat 6 (you also have the option to deploy to Tomcat 7 instances).<br />
<a href="http://www.riaspace.com/wp-content/uploads/2011/07/server-type.png"><img class="size-medium wp-image-3078 aligncenter" style="border-style: initial; border-color: initial; border-width: 0px;" title="server-type" src="http://www.riaspace.com/wp-content/uploads/2011/07/server-type-252x300.png" alt="" width="252" height="300" /></a>At last you will be able to specify the CNAME of your server (you can assign your own domain name in the DNS configuration, that is actually what I used to get the default lcds-samples.elasticbeanstalk.com configured as lcds.riaspace.com). Another valuable option here is to enter your email address, which will receive notifications of any changes to the service&#8217;s state and health.</p>
<p style="text-align: center;"><a href="http://www.riaspace.com/wp-content/uploads/2011/07/aws-cname.png"><img class="aligncenter size-medium wp-image-3081" style="border-style: initial; border-color: initial; border-width: 0px;" title="aws-cname" src="http://www.riaspace.com/wp-content/uploads/2011/07/aws-cname-252x300.png" alt="" width="252" height="300" /></a></p>
<p>Now you are ready to click the Finish button and it will start uploading and configuring your application in the cloud. Be aware that this process may take several minutes the first time. Once it is done you will be able to access your services via the following URL: http://yourcname.elasticbeanstalk.com. To redeploy any changes made to your services you just need to follow this last step all over again.</li>
</ol>
<div class="shr-publisher-3034"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F07%2Frunning-lcds-blazeds-in-the-cloud-with-aws-elastic-beanstalk%2F' data-shr_title='Running+LCDS%2FBlazeDS+in+the+cloud+with+AWS+Elastic+Beanstalk'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F07%2Frunning-lcds-blazeds-in-the-cloud-with-aws-elastic-beanstalk%2F' data-shr_title='Running+LCDS%2FBlazeDS+in+the+cloud+with+AWS+Elastic+Beanstalk'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.riaspace.com/2011/07/running-lcds-blazeds-in-the-cloud-with-aws-elastic-beanstalk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OAuth authorization with Flash and Flex apps</title>
		<link>http://www.riaspace.com/2011/05/oauth-authorization-with-flash-and-flex-apps/</link>
		<comments>http://www.riaspace.com/2011/05/oauth-authorization-with-flash-and-flex-apps/#comments</comments>
		<pubDate>Mon, 16 May 2011 10:03:23 +0000</pubDate>
		<dc:creator>Piotr Walczyszyn</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Recording]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[OAuth]]></category>

		<guid isPermaLink="false">http://www.riaspace.com/?p=2866</guid>
		<description><![CDATA[Below you will find links to my two video tutorials about OAuth authorization with Flash and Flex apps: 1) Introduction to OAuth for secure user and application authorization 2) OAuth in Adobe AIR applications built with Flash or Flex You can also download example code from here.]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F05%2Foauth-authorization-with-flash-and-flex-apps%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F05%2Foauth-authorization-with-flash-and-flex-apps%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p>Below you will find links to my two video tutorials about OAuth authorization with Flash and Flex apps:</p>
<p>1) <a href="http://tv.adobe.com/watch/adc-presents/introduction-to-oauth-for-secure-user-and-application-authorization/" target="_blank">Introduction to OAuth for secure user and application authorization</a></p>
<p><object width="425" height="256"><param name="movie" value="http://images.tv.adobe.com/swf/player.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="FlashVars" value="fileID=9719&amp;context=64&amp;embeded=true&amp;environment=production"></param><embed src="http://images.tv.adobe.com/swf/player.swf" flashvars="fileID=9719&amp;context=64&amp;embeded=true&amp;environment=production" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="256"></embed></object></p>
<p>2) <a href="http://tv.adobe.com/watch/adc-presents/oauth-in-adobe-air-applications-built-with-flash-or-flex/" target="_blank">OAuth in Adobe AIR applications built with Flash or Flex</a></p>
<p><object width="425" height="256"><param name="movie" value="http://images.tv.adobe.com/swf/player.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="FlashVars" value="fileID=9721&amp;context=64&amp;embeded=true&amp;environment=production"></param><embed src="http://images.tv.adobe.com/swf/player.swf" flashvars="fileID=9721&amp;context=64&amp;embeded=true&amp;environment=production" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="256"></embed></object></p>
<p>You can also download example code from <a href="https://github.com/downloads/pwalczyszyn/examples/adc-oauth-example.zip" target="_blank">here</a>.</p>
<div class="shr-publisher-2866"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F05%2Foauth-authorization-with-flash-and-flex-apps%2F' data-shr_title='OAuth+authorization+with+Flash+and+Flex+apps'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F05%2Foauth-authorization-with-flash-and-flex-apps%2F' data-shr_title='OAuth+authorization+with+Flash+and+Flex+apps'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.riaspace.com/2011/05/oauth-authorization-with-flash-and-flex-apps/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>ADC tutorial: Updating Adobe AIR applications packaged with a native installer</title>
		<link>http://www.riaspace.com/2011/03/adc-tutorial-updating-adobe-air-applications-packaged-with-a-native-installer/</link>
		<comments>http://www.riaspace.com/2011/03/adc-tutorial-updating-adobe-air-applications-packaged-with-a-native-installer/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 12:38:13 +0000</pubDate>
		<dc:creator>Piotr Walczyszyn</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[NAU]]></category>

		<guid isPermaLink="false">http://www.riaspace.com/?p=2576</guid>
		<description><![CDATA[My tutorial about updating AIR apps packaged with a native installer was published on Adobe Developer Connection &#8211; it is available here. It goes step-by-step through how a custom updater can be built for Windows; it also explains how a similar process could be applied for the Mac OS X platform. This tutorial is also a [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F03%2Fadc-tutorial-updating-adobe-air-applications-packaged-with-a-native-installer%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F03%2Fadc-tutorial-updating-adobe-air-applications-packaged-with-a-native-installer%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p>My tutorial about updating AIR apps packaged with a native installer was published on <strong>Adobe Developer Connection</strong> &#8211; it is available <a href="http://www.adobe.com/devnet/air/articles/updating-air-apps-native-installer.html" target="_blank">here</a>.</p>
<p>It goes step-by-step through how a custom updater can be built for Windows; it also explains how a similar process could be applied for the Mac OS X platform.</p>
<p>This tutorial is also a good starting point to understand how my <a href="nativeapplicationupdater.googlecode.com" target="_blank">NativeApplicationUpdater</a> library works.</p>
<div class="shr-publisher-2576"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F03%2Fadc-tutorial-updating-adobe-air-applications-packaged-with-a-native-installer%2F' data-shr_title='ADC+tutorial%3A+Updating+Adobe+AIR+applications+packaged+with+a+native+installer'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F03%2Fadc-tutorial-updating-adobe-air-applications-packaged-with-a-native-installer%2F' data-shr_title='ADC+tutorial%3A+Updating+Adobe+AIR+applications+packaged+with+a+native+installer'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.riaspace.com/2011/03/adc-tutorial-updating-adobe-air-applications-packaged-with-a-native-installer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe InMarket experience</title>
		<link>http://www.riaspace.com/2011/01/adobe-inmarket-experience/</link>
		<comments>http://www.riaspace.com/2011/01/adobe-inmarket-experience/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 15:26:28 +0000</pubDate>
		<dc:creator>Piotr Walczyszyn</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[InMarket]]></category>
		<category><![CDATA[Resicon]]></category>

		<guid isPermaLink="false">http://www.riaspace.com/?p=2479</guid>
		<description><![CDATA[Today I published my Resicon application to Adobe InMarket. At the moment Adobe InMarket is just a front end for online application stores like Adobe Marketplace or Intel AppUp. It&#8217;s goal is to make distribution and monetization of AIR based applications as simple as possible. Adobe is also working to integrate it with other online application [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F01%2Fadobe-inmarket-experience%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.riaspace.com%2F2011%2F01%2Fadobe-inmarket-experience%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p>Today I published my <a href="http://www.riaspace.com/2011/01/resicon-icons-batch-resizing-tool/" target="_blank">Resicon</a> application to <strong><a href="http://www.adobe.com/devnet/inmarket.html" target="_blank">Adobe InMarket</a></strong>. At the moment Adobe InMarket is just a front end for online application stores like <a href="http://marketplace.adobe.com" target="_blank">Adobe Marketplace</a> or <a href="http://www.appup.com/" target="_blank">Intel AppUp</a>. It&#8217;s goal is to make distribution and monetization of AIR based applications as simple as possible. Adobe is also working to integrate it with other online application stores as well.</p>
<p>The process of publishing my application was really straightforward. The first thing I had to do was to sign up to the InMarket service with my Adobe ID. Next I applied for the free code signing certificate (this is a really great promotional offer from Adobe because you get a trusted certificate completely for free). To get myself validated I had to fill in a form and have it faxed to the US phone number with my signature on it and a scan of my personal ID. I know it can be tricky to find the fax machine these days, but hey it is worth the effort <img src='http://www.riaspace.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>After I got the certificate I was ready to do some additional steps on my application side. It only required me to copy and paste few lines of code that enable the <code>LicenseManager</code> API that comes with the InMarket SDK and its licensing.swc. In addition to the distribution and licensing, InMarket also provides the functionality for application updates. To enable it I only had to create a <code>config</code> folder with an <code>updateConfig.xml</code> file in my application directory structure. The updateConfig.xml is exactly the same file as you would use for standard AIR Update Framework.</p>
<p>Once all of the above steps were done I was ready to compile and sign my application. Next using <a href="http://www.adobe.com/go/inmarketportal/" target="_blank">InMarket portal</a> I uploaded my *.air file and provided additional information like: an application description, screenshots, a and 495&#215;250 px promotional image that will be displayed in the Adobe Marketplace.</p>
<p>After that done I was able to publish Resicon targeting both Adobe Markeplace and Intel AppUp stores with just a single click from a single place!</p>
<p>In my case the application is free but still I find it worth publishing it via InMarket since hopefully I will get wider distribution, place for hosting my application binaries and also nice reports with downloads stats etc. Those of you that will publish paid applications you can also see reports with numbers of: Trails, Purchases, Revenue, Activations and Trial to Purchase Histogram.</p>
<p>Really great resource with more in-depth information about InMarket is this <a href="http://learn.adobe.com/wiki/display/InMarket/0.0+About+Adobe+InMarket" target="_blank">wiki</a>. You can also find links to the InMarket video tutorials on this <a href="http://www.adobe.com/devnet/inmarket.html" target="_blank">page</a>.</p>
<div class="shr-publisher-2479"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F01%2Fadobe-inmarket-experience%2F' data-shr_title='Adobe+InMarket+experience'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2011%2F01%2Fadobe-inmarket-experience%2F' data-shr_title='Adobe+InMarket+experience'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.riaspace.com/2011/01/adobe-inmarket-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Video with an un-framework overview</title>
		<link>http://www.riaspace.com/2010/11/video-with-an-un-framework-overview/</link>
		<comments>http://www.riaspace.com/2010/11/video-with-an-un-framework-overview/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 15:36:30 +0000</pubDate>
		<dc:creator>Piotr Walczyszyn</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex Mobile]]></category>
		<category><![CDATA[un-framework]]></category>

		<guid isPermaLink="false">http://www.riaspace.com/?p=2140</guid>
		<description><![CDATA[I wanted to share a video recording with an un-framework overview. This simple library has evolved a little bit from my previous post but I expect it will stay in this form for good I don&#8217;t think it can evolve to anything more sophisticated but I hope that it will serve as an inspiration to [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.riaspace.com%2F2010%2F11%2Fvideo-with-an-un-framework-overview%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.riaspace.com%2F2010%2F11%2Fvideo-with-an-un-framework-overview%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p>I wanted to share a video recording with an <a href="https://github.com/pwalczyszyn/un-framework">un-framework</a> overview. This simple library has evolved a little bit from my <a href="http://www.riaspace.com/2010/11/unframework-so-how-to-getaway-without-any-framework/">previous post</a> but I expect it will stay in this form for good <img src='http://www.riaspace.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  I don&#8217;t think it can evolve to anything more sophisticated but I hope that it will serve as an inspiration to others when building their own sets of helpers. I plan to use it solely as a substitue for my favorite DI frameworks when doing mobile Flex development.</p>
<p style="text-align: center;"><iframe src="http://player.vimeo.com/video/16999000" width="580" height="362" frameborder="0"></iframe></p>
<div class="shr-publisher-2140"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2010%2F11%2Fvideo-with-an-un-framework-overview%2F' data-shr_title='Video+with+an+un-framework+overview'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2010%2F11%2Fvideo-with-an-un-framework-overview%2F' data-shr_title='Video+with+an+un-framework+overview'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.riaspace.com/2010/11/video-with-an-un-framework-overview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>UnFramework &#8211; or how to work without any frameworks</title>
		<link>http://www.riaspace.com/2010/11/unframework-so-how-to-getaway-without-any-framework/</link>
		<comments>http://www.riaspace.com/2010/11/unframework-so-how-to-getaway-without-any-framework/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 15:45:12 +0000</pubDate>
		<dc:creator>Piotr Walczyszyn</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[un-framework]]></category>

		<guid isPermaLink="false">http://www.riaspace.com/?p=2013</guid>
		<description><![CDATA[Those who know me or at least subscribe to my blog know that I&#8217;m a big fan of Flex/AS3 frameworks. At this year&#8217;s Adobe MAX conference I even had my own session where I covered five major DI frameworks. Usually these frameworks provide a lot of productivity features and helpers like: IoC/DI, Event/Messaging bus, implementation [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.riaspace.com%2F2010%2F11%2Funframework-so-how-to-getaway-without-any-framework%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.riaspace.com%2F2010%2F11%2Funframework-so-how-to-getaway-without-any-framework%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p>Those who know me or at least subscribe to my blog know that I&#8217;m a big fan of Flex/AS3 frameworks. At this year&#8217;s Adobe MAX conference I even had my own session where I covered five major DI frameworks. Usually these frameworks provide a lot of productivity features and helpers like: IoC/DI, Event/Messaging bus, implementation of some architectural or design patterns (MVC, Command&#8230;), and many others. But what happens if we can&#8217;t or don&#8217;t want to use any of these frameworks? </p>
<p><span id="more-2013"></span>Well, we fall back to pure Flex and we start missing things&#8230; </p>
<p>This is something that happened to me very recently when I started to play with <a href="http://opensource.adobe.com/wiki/display/flexsdk/Hero">Flex Hero</a> and I wanted to build my first Flex mobile application. As the targeted runtimes are rather constrained in processing power I knew I would have to make certain sacrifices in order to make things as light as possible. </p>
<p>First I started to wonder what general architectural pattern I should follow. After looking at <a href="http://www.adobe.com/devnet/flex/articles/mobile_development_hero_burrito.html">Flex Hero</a> and its new <code>MobileApplication</code>, <code>ViewNavigator</code> and <code>View</code> concepts, I knew that I was still okay with using the Presentation Model pattern. </p>
<p>Next I took a look at DI frameworks &#8211; well here I really didn&#8217;t find a suitable candidate. Most of these rely heavily on reflection, metadata processing, or stage events capturing for view wiring, and these unfortunately are not really very lightweight. That is why at the end of the day I made a decision not to use any of these, and instead decided to substitute some of their features with simple helpers or pure Flex functionality. </p>
<p><strong>Global Event Dispatcher</strong></p>
<p>The thing I missed most thing was a global dispatcher that I could use to dispatch events from my Presentation Model or any other pure AS3 classes. The approach I took was as simple as creating a global eventDispatcher property in the default package in a eventDispatcher.as file, as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// eventDispatcher.as script file</span>
&nbsp;
package 
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">IEventDispatcher</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> eventDispatcher<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:IEventDispatcher
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> _eventDispatcher;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">EventDispatcher</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">IEventDispatcher</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> _eventDispatcher:IEventDispatcher = <span style="color: #000000; font-weight: bold;">new</span> EventDispatcher<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>That step gave me access to <code>eventDispatcher</code> object anywhere in my code:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyViewPM
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> btn_clickHandler<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
    <span style="color: #66cc66;">&#123;</span>
        eventDispatcher.<span style="color: #006600;">dispatchEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> MyEvent<span style="color: #66cc66;">&#40;</span>MyEvent.<span style="color: #006600;">EVENT_TYPE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>RemoteObject&#8217;s handling</strong></p>
<p>The next thing I wanted was a clean and simple way of handling <code>RemoteObject</code> calls and configuration. What I really missed here was the approach from the <a href="http://swizframework.org">Swiz Framework</a> with its <code>ServiceHelper.executeServiceCall</code> function where you can pass an <code>AsyncToken</code> object returned from the <code>RemoteObject</code> call together with the <code>ResultEvent</code> and <code>FaultEvent</code> handlers as the other two parameters. </p>
<p>Another thing I really wanted was a declarative (MXML based) configuration of my RemoteObjects and to have a services registry without the use of <code>ServiceLocator</code> pattern. That is why the following code is a bit more complex but I think it&#8217;s still worth it and of course very light:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// remoteService.as script file</span>
&nbsp;
package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">riaspace</span>.<span style="color: #006600;">un</span>.<span style="color: #006600;">IRemoteService</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> remoteService<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:IRemoteService
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> _remoteService;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> _remoteService:IRemoteService = <span style="color: #000000; font-weight: bold;">new</span> RemoteService<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">riaspace</span>.<span style="color: #006600;">un</span>.<span style="color: #006600;">IRemoteService</span>;
&nbsp;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">AsyncToken</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">Responder</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">remoting</span>.<span style="color: #006600;">Operation</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">remoting</span>.<span style="color: #006600;">RemoteObject</span>;
&nbsp;
internal <span style="color: #000000; font-weight: bold;">class</span> RemoteService <span style="color: #0066CC;">implements</span> IRemoteService
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> configObj:<span style="color: #0066CC;">Object</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> config<span style="color: #66cc66;">&#40;</span>value:<span style="color: #000000; font-weight: bold;">Class</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		configObj = <span style="color: #000000; font-weight: bold;">new</span> value<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getRemoteObject<span style="color: #66cc66;">&#40;</span>remoteObjectId:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:RemoteObject
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>configObj<span style="color: #66cc66;">&#41;</span>
			<span style="color: #b1b100;">return</span> configObj<span style="color: #66cc66;">&#91;</span>remoteObjectId<span style="color: #66cc66;">&#93;</span>;
		<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">null</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> callDirectly<span style="color: #66cc66;">&#40;</span>token:AsyncToken, resultHandler:<span style="color: #000000; font-weight: bold;">Function</span>, faultHandler:<span style="color: #000000; font-weight: bold;">Function</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		token.<span style="color: #006600;">addResponder</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>resultHandler, faultHandler<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span>remoteObjectId:<span style="color: #0066CC;">String</span>, methodName:<span style="color: #0066CC;">String</span>, args:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">null</span>, resultHandler:<span style="color: #000000; font-weight: bold;">Function</span> = <span style="color: #000000; font-weight: bold;">null</span>, faultHandler:<span style="color: #000000; font-weight: bold;">Function</span> = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> remoteObject:RemoteObject = getRemoteObject<span style="color: #66cc66;">&#40;</span>remoteObjectId<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>remoteObject<span style="color: #66cc66;">&#41;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#40;</span>remoteObjectId + <span style="color: #ff0000;">&quot; not configured!&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> method:Operation = remoteObject<span style="color: #66cc66;">&#91;</span>methodName<span style="color: #66cc66;">&#93;</span>;
		method.<span style="color: #0066CC;">arguments</span> = args;
		callDirectly<span style="color: #66cc66;">&#40;</span>method.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, resultHandler, faultHandler<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>As you can see you can use the above code in multiple ways. The first one requires no additional configuration and uses only <code>remoteService.callDirectly</code> function:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// some AS3 class</span>
&nbsp;
...
<span style="color: #006600;">remoteService</span>.<span style="color: #006600;">callDirectly</span><span style="color: #66cc66;">&#40;</span>myRemoteObject.<span style="color: #006600;">remoteMethod</span><span style="color: #66cc66;">&#40;</span>param<span style="color: #66cc66;">&#41;</span>, remoteMethod_resultHandler, 
    remoteMethod_faultHandler<span style="color: #66cc66;">&#41;</span>;
...
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> remoteMethod_resultHandler<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// Handle remote method call result</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> remoteMethod_faultHandler<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// Handle remote method call fault</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The next option requires defining a config class that should extend simple Object; the best way is to do it in MXML like this:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;">// RemoteServiceConfig.mxml file
&nbsp;
<span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ChannelSet</span> id=<span style="color: #ff0000;">&quot;channels&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:AMFChannel</span> url=<span style="color: #ff0000;">&quot;http://yourhost.tld/services/amf&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:ChannelSet</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RemoteObject</span> id=<span style="color: #ff0000;">&quot;myRemoteObject&quot;</span> destination=<span style="color: #ff0000;">&quot;someDestination&quot;</span> channelSet=<span style="color: #ff0000;">&quot;{channels}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Object</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>After you have your configuration class defined you can set it to the <code>remoteService.config</code> property, most probably somewhere at the very beginning of your application lifecycle:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Main.mxml file</span>
...
&nbsp;
<span style="color: #006600;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> mobileapplication_creationCompleteHandler<span style="color: #66cc66;">&#40;</span>event:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    remoteService.<span style="color: #006600;">config</span> = RemoteServiceConfig;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
...</pre></div></div>

<p>So now you are ready to call the <code>RemoteObject</code> methods, and you can do that like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// some AS3 class</span>
&nbsp;
...
<span style="color: #006600;">remoteService</span>.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;myRemoteObject&quot;</span>, <span style="color: #ff0000;">&quot;remoteMethod&quot;</span>, <span style="color: #66cc66;">&#91;</span>param<span style="color: #66cc66;">&#93;</span>, remoteMethod_resultHandler, 
    remoteMethod_faultHandler<span style="color: #66cc66;">&#41;</span>;
...
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> remoteMethod_resultHandler<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// Handle remote method call result</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> remoteMethod_faultHandler<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// Handle remote method call fault</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>Application context</strong></p>
<p>The last thing I was really missing was some type of global application context/registry where I could read or write application objects. The approach I took goes beyond a simple singleton dynamic object. It is actually a bindable (event dispatching) singleton dynamic object <img src='http://www.riaspace.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  You can see it&#8217;s implementation below:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// applicationContext.as file</span>
&nbsp;
package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> applicationContext<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:ApplicationContext
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> _applicationContext;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> _applicationContext:ApplicationContext = <span style="color: #000000; font-weight: bold;">new</span> ApplicationContext<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">EventDispatcher</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">IEventDispatcher</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">Proxy</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">flash_proxy</span>;
&nbsp;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">PropertyChangeEvent</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">PropertyChangeEventKind</span>;
&nbsp;
use namespace flash_proxy;
&nbsp;
internal <span style="color: #0066CC;">dynamic</span> <span style="color: #000000; font-weight: bold;">class</span> ApplicationContext <span style="color: #0066CC;">extends</span> Proxy <span style="color: #0066CC;">implements</span> IEventDispatcher
<span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> values:<span style="color: #0066CC;">Object</span>;
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> contextEventHandler:IEventDispatcher;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ApplicationContext<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		contextEventHandler = <span style="color: #000000; font-weight: bold;">new</span> EventDispatcher<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
		values = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	flash_proxy override <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">getProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>:<span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #66cc66;">*</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> values<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#93;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	flash_proxy override <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">setProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>:<span style="color: #66cc66;">*</span>, value:<span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> oldValue:<span style="color: #66cc66;">*</span> = values<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#93;</span>;
		values<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#93;</span> = value;
		<span style="color: #000000; font-weight: bold;">var</span> kind:<span style="color: #0066CC;">String</span> = PropertyChangeEventKind.<span style="color: #006600;">UPDATE</span>;
		dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> PropertyChangeEvent<span style="color: #66cc66;">&#40;</span>PropertyChangeEvent.<span style="color: #006600;">PROPERTY_CHANGE</span>, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #000000; font-weight: bold;">false</span>, kind, <span style="color: #0066CC;">name</span>, oldValue, value, <span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> hasEventListener<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> contextEventHandler.<span style="color: #006600;">hasEventListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> willTrigger<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> contextEventHandler.<span style="color: #006600;">willTrigger</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> addEventListener<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>, listener:<span style="color: #000000; font-weight: bold;">Function</span>, useCapture:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">false</span>, priority:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0.0</span>, useWeakReference:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		contextEventHandler.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>, listener, useCapture, priority, useWeakReference<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> removeEventListener<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>, listener:<span style="color: #000000; font-weight: bold;">Function</span>, useCapture:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		contextEventHandler.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>, listener, useCapture<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> dispatchEvent<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> contextEventHandler.<span style="color: #006600;">dispatchEvent</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The way to use this is, of course, very simple:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// some AS3 class</span>
...
<span style="color: #006600;">applicationContext</span>.<span style="color: #006600;">myObject</span> = <span style="color: #000000; font-weight: bold;">new</span> MyObject<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
...
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">// another AS3 class</span>
...
<span style="color: #000000; font-weight: bold;">var</span> myObject:MyObject = applicationContext.<span style="color: #006600;">myObject</span>;
...</pre></div></div>

<p>The cool thing about this approach is that you can actually bind to your <code>applicationContext.myObject</code> without getting this nasty warning: <code>unable to bind to property 'foo' on class 'Object' (class is not an IEventDispatcher).</code></p>
<p>Also if you would like to listen for changes done to applicationContext properties you can do it like this (in order to make code completion work you need to cast <code>applicationContext</code> to <code>IEventDispatcher</code>):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// some AS3 class</span>
...
<span style="color: #006600;">IEventDispatcher</span><span style="color: #66cc66;">&#40;</span>applicationContext<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>
    PropertyChangeEvent.<span style="color: #006600;">PROPERTY_CHANGE</span>, applicationContext_changeHandler<span style="color: #66cc66;">&#41;</span>;
...</pre></div></div>

<p><strong>My UnFramework approach summary</strong></p>
<p>So in the end you can see there is actually life <img src='http://www.riaspace.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  without frameworks, especially when you are building not very complex applications that don&#8217;t require module support (in that case the singleton approach used here would fail).</p>
<p>Now please don&#8217;t accuse me of building yet another framework (we already have plenty of really great ones available) but I have packaged all these helper functions into a Flex Library project and pushed it into a GitHub repository. As I said this is not a framework so its called <strong>un-framework</strong> and it is available for download from <a href="https://github.com/pwalczyszyn/un-framework" target="_blank">here</a> and as a swc from <a href="https://github.com/downloads/pwalczyszyn/un-framework/un-framework-1.0.0.swc" target="_blank">here</a>.</p>
<p>Stay tuned for my upcoming posts where you will see these functions in action on some of my Flex Mobile apps.</p>
<div class="shr-publisher-2013"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2010%2F11%2Funframework-so-how-to-getaway-without-any-framework%2F' data-shr_title='UnFramework+-+or+how+to+work+without+any+frameworks'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2010%2F11%2Funframework-so-how-to-getaway-without-any-framework%2F' data-shr_title='UnFramework+-+or+how+to+work+without+any+frameworks'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.riaspace.com/2010/11/unframework-so-how-to-getaway-without-any-framework/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>AMF Playground with public services, Flash/Flex client-server communication</title>
		<link>http://www.riaspace.com/2010/07/amf-playground-with-public-services-flashflex-client-server-communication/</link>
		<comments>http://www.riaspace.com/2010/07/amf-playground-with-public-services-flashflex-client-server-communication/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 08:58:25 +0000</pubDate>
		<dc:creator>Piotr Walczyszyn</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Zend_Amf]]></category>

		<guid isPermaLink="false">http://www.riaspace.com/?p=1335</guid>
		<description><![CDATA[Today I published a microsite (http://amf.riaspace.com/) on my blog dedicated to AMF communication. The goal of it is to gather necessary information needed for quick start with AMF. You will find there: Publicly available AMF services for the start without setting up your own server environment Code snippets demonstrating how to utilize AMF services Video tutorials on [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.riaspace.com%2F2010%2F07%2Famf-playground-with-public-services-flashflex-client-server-communication%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.riaspace.com%2F2010%2F07%2Famf-playground-with-public-services-flashflex-client-server-communication%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p>Today I published a microsite (<a href="http://amf.riaspace.com/" target="_blank">http://amf.riaspace.com/</a>) on my blog dedicated to AMF communication. The goal of it is to gather necessary information needed for quick start with AMF.</p>
<p>You will find there:</p>
<ul>
<li>Publicly available AMF services for the start without setting up your own server environment</li>
<li>Code snippets demonstrating how to utilize AMF services</li>
<li>Video tutorials on how to setup your own Flex/Zend_Amf projects</li>
<li>Demo applications with a source code</li>
</ul>
<p>At the moment I&#8217;m hosting only PHP based services but I&#8217;m also thinking about Java based backend to be able to play with messaging.</p>
<div class="shr-publisher-1335"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2010%2F07%2Famf-playground-with-public-services-flashflex-client-server-communication%2F' data-shr_title='AMF+Playground+with+public+services%2C+Flash%2FFlex+client-server+communication'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.riaspace.com%2F2010%2F07%2Famf-playground-with-public-services-flashflex-client-server-communication%2F' data-shr_title='AMF+Playground+with+public+services%2C+Flash%2FFlex+client-server+communication'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.riaspace.com/2010/07/amf-playground-with-public-services-flashflex-client-server-communication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

