<?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>Gaurav&#039;s Blog &#187; Gaurav</title>
	<atom:link href="http://gauravj.com/blog/author/Gaurav/feed/" rel="self" type="application/rss+xml" />
	<link>http://gauravj.com/blog</link>
	<description>Tips and Tools of Flex</description>
	<lastBuildDate>Wed, 28 Mar 2012 17:55:42 +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>Alchemy pre-release</title>
		<link>http://gauravj.com/blog/2012/03/alchemy-pre-release/</link>
		<comments>http://gauravj.com/blog/2012/03/alchemy-pre-release/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 17:28:27 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[Gaming]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://gauravj.com/blog/?p=981</guid>
		<description><![CDATA[<p>Developers, you can now apply to join the pre-release program of Alchemy.</p> <p>Alchemy is a cross-compiler that compiles C/C++ code to ActionScript. You can use Alchemy to compile C/C++ code to run in Flash Player with high performance across browsers. ActionScript developers will be able to leverage high performance C/C++ libraries in their ActionScript <span style="color:#777"> . . . &#8594; Read More: <a href="http://gauravj.com/blog/2012/03/alchemy-pre-release/">Alchemy pre-release</a></span>]]></description>
			<content:encoded><![CDATA[<p>Developers, you can now apply to join the pre-release program of Alchemy.</p>
<p>Alchemy is a cross-compiler that compiles C/C++ code to ActionScript. You can use Alchemy to compile C/C++ code to run in Flash Player with high performance across browsers. ActionScript developers will be able to leverage high performance C/C++ libraries in their ActionScript code and C/C++ developers can easily deliver sophisticated, immersive C/C++ games across browsers to over 1.3 billion computers on the web. </p>
<p>The link for applying to the pre-release is <a href="https://adobeformscentral.com/?f=FYonhPd8lGDTb13YuB-5rg" title="here" target="_blank">here</a>.</p>
<p>For a sample of what can be compiled using Alchemy see <a href="http://www.unrealengine.com/flash/" title="epic citadel running in flash">epic citadel running in flash</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gauravj.com/blog/2012/03/alchemy-pre-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using spark datagrid to capture multiple rows of data</title>
		<link>http://gauravj.com/blog/2011/04/using-spark-datagrid-to-capture-multiple-rows-of-data/</link>
		<comments>http://gauravj.com/blog/2011/04/using-spark-datagrid-to-capture-multiple-rows-of-data/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 20:05:59 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[Flex Framework]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[Editor]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[Item Renderer]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[Skins]]></category>
		<category><![CDATA[Spark]]></category>

		<guid isPermaLink="false">http://gauravj.com/blog/?p=948</guid>
		<description><![CDATA[<p>Sometimes you need forms to capture entries for multiple rows of data. In such forms each row is a sub object (with multiple associated parameters), like sales report for a particular item or a particular expense in an expense report. The tricky part with such forms is that you can&#8217;t predict how many sub <span style="color:#777"> . . . &#8594; Read More: <a href="http://gauravj.com/blog/2011/04/using-spark-datagrid-to-capture-multiple-rows-of-data/">Using spark datagrid to capture multiple rows of data</a></span>]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need forms to capture entries for multiple rows of data. In such forms each row is a sub object (with multiple associated parameters), like sales report for a particular item or a particular expense in an expense report. The tricky part with such forms is that you can&#8217;t predict how many sub objects will be captured, so you need to dynamically add controls to capture data. </p>
<p>To achieve this why not use the spark data grid instead of a form? This way you add a new row to the data grid instead of adding controls for each parameter of sub object.</p>
<p>Lets take a look at an app that captures data for an expense report:<br />
<center><br />
<iframe src ="http://gauravj.com/blog/examples/SparkDataGrid/DataGridFormExample.html" width="900" height="500"></p>
<p>Your browser does not support iframes.</p>
<p></iframe><br />
</center><br />
You can download the fxp file for this project from <a href="http://gauravj.com/blog/examples/SparkDataGrid/DataGridFormExample.fxp">DataGridFormExample.fxp</a></p>
<p>You can click on the trash icon to delete a row. And if you want to add blank rows, then you can either click on the new icon in the top left of the grid or click the <em>TAB</em> key in the comments field of the last row.</p>
<p>I primarily did the following customization to change the look of the datagrid:</p>
<ul>
<li>Custom skin for the datagrid (EntryDGSkin.mxml) to hide all the row and column separators. </li>
<li>Used custom item renderers and marked rendererIsEditable as true so the controls are always visible when the rows are present in the datagrid</li>
</ul>
<p>There are validators defined inside the item renderer and when the validation fails the item renderer changes a boolean property (invalidValue) on the parent document. So before saving, the document checks the boolean value to decide whether to proceed with save or not. If you don&#8217;t like the approach to set a boolean flag, then you can also access each validator via the itemRenderer for a particular cell. To access the itemRender use the getItemRendererAt() method present on grid property inside the spark data grid.</p>
<p>Also you should pay attention to the <strong>prepare()</strong>and <strong>discard()</strong>methods inside the data grid itemRenderers. The <strong>prepare()</strong> method is called for every visual update and it sets the data to the sub component of item renderer. I am using a boolean flag (pendingEdits &#8211; set to false when there are unsaved changes) inside the itemRenderers to decide whether to update the sub component or not.</p>
<p>Spark datagrid is a new feature in Flex SDK 4.5 and to import the fxp file you would need Flash Builder 4.5.<br />
Both Flex SDK 4.5 and Flash Builder 4.5 were announced recently. See <a href="http://blogs.adobe.com/flex/2011/04/announcing-flex-sdk-4-5-flash-builder-4-5-and-flash-catalyst-cs-5-5.html">the flex team blog</a></p>
<p>Feedback is welcome <img src='http://gauravj.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://gauravj.com/blog/2011/04/using-spark-datagrid-to-capture-multiple-rows-of-data/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Troubleshooting ActionScript Code Coverage</title>
		<link>http://gauravj.com/blog/2011/02/troubleshooting-actionscript-code-coverage/</link>
		<comments>http://gauravj.com/blog/2011/02/troubleshooting-actionscript-code-coverage/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 23:12:07 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[Flex Tools]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Code Coverage]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://gauravj.com/blog/?p=896</guid>
		<description><![CDATA[<p>Sometimes folks run into situation with ActionScript code coverage plugin-in where the SWF files doesn&#8217;t make a connection. When this happens the plug-in stays in the &#8220;Listening..&#8221; status after the SWF is launched in Flash Player or AIR. Usually this happens because one the prerequisites for the tool is not being fulfilled. Before we <span style="color:#777"> . . . &#8594; Read More: <a href="http://gauravj.com/blog/2011/02/troubleshooting-actionscript-code-coverage/">Troubleshooting ActionScript Code Coverage</a></span>]]></description>
			<content:encoded><![CDATA[<p>Sometimes folks run into situation with ActionScript code coverage plugin-in where the SWF files doesn&#8217;t make a connection. When this happens the plug-in stays in the &#8220;Listening..&#8221; status after the SWF is launched in Flash Player or AIR. Usually this happens because one the prerequisites for the tool is not being fulfilled. Before we jump into the diagnosis, lets recap the prerequisites (which are listed in the <a href="http://labs.adobe.com/wiki/index.php/ActionScript_Code_Coverage:Using">docs</a>). </p>
<p><strong>Prerequisites:</strong></p>
<ul>
<li>Debug version of Flash Player</li>
<li>SWF file that has been compiled in debug mode </li>
<li>The preloaded SWF must be local trusted.</li>
</ul>
<p>Following is how you can ensure that the prerequisites are being met and possible resolutions:</p>
<p><strong>I.</strong> To ensure that you are using the debug version of flash player, you can simply compile and run the following mxml code and it should list the version and also if it supports debugging or not:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><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;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;horizontal&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;application1_creationCompleteHandler(event)&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">		&lt;![CDATA[</span>
<span style="color: #339933;">			import mx.events.FlexEvent;</span>
<span style="color: #339933;">			protected function application1_creationCompleteHandler(event:FlexEvent):void</span>
<span style="color: #339933;">			{</span>
<span style="color: #339933;">				playerVersion.text = Capabilities.version;</span>
<span style="color: #339933;">				isDebugger.text = String(Capabilities.isDebugger);</span>
<span style="color: #339933;">			}</span>
<span style="color: #339933;">		]]&gt;</span>
<span style="color: #339933;">	&lt;/mx:Script&gt;</span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> text=<span style="color: #ff0000;">&quot;Version&quot;</span><span style="color: #7400FF;">/&gt;</span><span style="color: #7400FF;">&lt;mx:Label</span> id=<span style="color: #ff0000;">&quot;playerVersion&quot;</span><span style="color: #7400FF;">/&gt;</span><span style="color: #7400FF;">&lt;mx:Label</span> text=<span style="color: #ff0000;">&quot;Supports Debugging? &quot;</span><span style="color: #7400FF;">/&gt;</span><span style="color: #7400FF;">&lt;mx:Label</span> id=<span style="color: #ff0000;">&quot;isDebugger&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

</blockquote>
<p><strong>Resolution:</strong> Reinstall debug version of flash player.</p>
<p><strong>II.</strong> To ensure that you are using the debug version of the SWF, you can run swfdump on the swf file. The swfdump generates an XML report. Look for tags like <strong>EnableDebugger2</strong> and <strong>DebugID</strong> in the report. If these tags are missing then you are probably running a release mode swf.</p>
<p><strong>Resolution:</strong> Recompile SWF with debug info. To do this from command line add -debug=true to mxmlc command. To do this from Flash builder, make sure debug is not set to false in additional compiler arguments or a local config file. </p>
<p><strong>III.</strong> To ensure that PreloadSwf is local trusted, you can follow the following steps:</p>
<ol>
<li>Run tail -f command on the mm.cfg file and then click the start button in code coverage plug-in.<br />
The mm.cfg file is present at the following location:</p>
<p><strong>XP:</strong> C:\Documents and Settings\<em>username</em><br />
<strong>Vista/Win7:</strong> C:\Users\<em>username</em><br />
<strong>Mac:</strong> /home/<em>username</em>  or if that doesn&#8217;t exist: /Library/Application Support/Macromedia</p>
<p>After you click the start button, the plugin should add a PreloadSwf entry to the mm.cfg file. <em>If it doesn&#8217;t then you should <strong>make sure that mm.cfg is writable and that the user has permissions</strong>.</em></p>
<p>An example of PreloadSwf entry:<br />
PreloadSwf=/Users/<em>username</em>/Documents/Adobe Flash Builder 4/.metadata/.plugins/com.adobe.flash.codecoverage/CodeCoverageAgent.swf?host=localhost&#038;port=9900&#038;level=0</p>
<p>Note down the absolute path of folder containing CodeCoverageAgent.swf. It should be in your FB workspace at <em>&lt;workspace&gt;/.metadata/.plugins/com.adobe.flash.codecoverage</em></p>
<p>Also the plug-in removes the PreloadSwf entry when you click the stop button</li>
<li>Inspect at the trust files.<br />
Location of trust file (per-user):<br />
<strong>XP</strong> C:\Documents and Settings\<em>username</em>\Application Data\Macromedia\Flash Player\#Security\FlashPlayerTrust<br />
<strong>Vista/Win7</strong>: C:\Users\<em>username</em>\AppData\Roaming\Macromedia\Flash Player\#Security\FlashPlayerTrust<br />
<strong>Mac:</strong> /Users/<em>username</em>/Library/Preferences/Macromedia/Flash Player/#Security/FlashPlayerTrust</p>
<p>Location of trust file (global):<br />
<strong>XP/Vista/Win7</strong> C:\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust<br />
<strong>Mac</strong> /Library/Application Support/Macromedia/FlashPlayerTrust</p>
<p>The trust file is usually called flashbuilder.cfg. Make sure that the path of folder containing CodeCoverageAgent.swf is present in the trust file.
</li>
</ol>
<p><strong>Resolution:</strong> Add parent folder of CodeCoverageAgent.swf to the trust file. If the trust file is not present create a new trust file. Also it is important to restart your browser/AIR after changes to the trust file.</p>
<p>If all the prerequisites are being satisfied then make sure that the port number (9900) is free for use by code coverage plug-in. In case 9900 is not available then you should update the port number in the code coverage preferences.</p>
]]></content:encoded>
			<wfw:commentRss>http://gauravj.com/blog/2011/02/troubleshooting-actionscript-code-coverage/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Setting icon on spark button</title>
		<link>http://gauravj.com/blog/2011/01/setting-icon-on-spark-button/</link>
		<comments>http://gauravj.com/blog/2011/01/setting-icon-on-spark-button/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 23:45:02 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[Flex Framework]]></category>
		<category><![CDATA[Button]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[Styles]]></category>

		<guid isPermaLink="false">http://gauravj.com/blog/?p=883</guid>
		<description><![CDATA[<p>A friend asked why the spark button doesn&#8217;t support icons like the mx button? Well now it does with the upcoming hero release. </p> <p>Here a quick example:</p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;s:Application xmlns:fx=&#34;http://ns.adobe.com/mxml/2009&#34; xmlns:s=&#34;library://ns.adobe.com/flex/spark&#34; xmlns:mx=&#34;library://ns.adobe.com/flex/mx&#34; minWidth=&#34;955&#34; minHeight=&#34;600&#34;&#62; &#60;fx:Declarations&#62; &#60;s:RadioButtonGroup id=&#34;rbg&#34;/&#62; &#60;/fx:Declarations&#62; &#60;s:layout&#62; &#60;s:VerticalLayout paddingLeft=&#34;5&#34; paddingRight=&#34;5&#34; /&#62; &#60;/s:layout&#62; &#60;s:HGroup&#62; &#60;s:RadioButton label=&#34;left&#34; value=&#34;left&#34; group=&#34;{rbg}&#34; selected=&#34;true&#34;/&#62; &#60;s:RadioButton <span style="color:#777"> . . . &#8594; Read More: <a href="http://gauravj.com/blog/2011/01/setting-icon-on-spark-button/">Setting icon on spark button</a></span>]]></description>
			<content:encoded><![CDATA[<p>A friend asked why the spark button doesn&#8217;t support icons like the mx button?<br />
Well now it does with the upcoming <a href="http://opensource.adobe.com/wiki/display/flexsdk/Hero">hero</a> release. </p>
<p>Here a quick example:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><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> xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </span>
<span style="color: #000000;">               xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span> minWidth=<span style="color: #ff0000;">&quot;955&quot;</span> minHeight=<span style="color: #ff0000;">&quot;600&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <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: #7400FF;">&lt;s:RadioButtonGroup</span> id=<span style="color: #ff0000;">&quot;rbg&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <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: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> paddingLeft=<span style="color: #ff0000;">&quot;5&quot;</span> paddingRight=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HGroup</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RadioButton</span> label=<span style="color: #ff0000;">&quot;left&quot;</span> value=<span style="color: #ff0000;">&quot;left&quot;</span> group=<span style="color: #ff0000;">&quot;{rbg}&quot;</span> selected=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RadioButton</span> label=<span style="color: #ff0000;">&quot;right&quot;</span> value=<span style="color: #ff0000;">&quot;right&quot;</span> group=<span style="color: #ff0000;">&quot;{rbg}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RadioButton</span> label=<span style="color: #ff0000;">&quot;top&quot;</span> value=<span style="color: #ff0000;">&quot;top&quot;</span> group=<span style="color: #ff0000;">&quot;{rbg}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RadioButton</span> label=<span style="color: #ff0000;">&quot;bottom&quot;</span> value=<span style="color: #ff0000;">&quot;bottom&quot;</span> group=<span style="color: #ff0000;">&quot;{rbg}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>    
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:HGroup</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> id=<span style="color: #ff0000;">&quot;myButton&quot;</span> label=<span style="color: #ff0000;">&quot;Button with Icon&quot;</span> icon=<span style="color: #ff0000;">&quot;@Embed(source='Fx.png')&quot;</span> iconPlacement=<span style="color: #ff0000;">&quot;{rbg.selectedValue}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

</blockquote>
<p><center><br />
<iframe src ="http://gauravj.com/blog/examples/Styles/ButtonIcon/ButtonIconExample.html" width="250" height="100"></p>
<p>Your browser does not support iframes.</p>
<p></iframe><br />
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://gauravj.com/blog/2011/01/setting-icon-on-spark-button/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>RSL enhancements in Hero</title>
		<link>http://gauravj.com/blog/2011/01/rsl-enhancement-in-hero/</link>
		<comments>http://gauravj.com/blog/2011/01/rsl-enhancement-in-hero/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 17:04:13 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[Flex Framework]]></category>
		<category><![CDATA[Flex Tools]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[RSL]]></category>

		<guid isPermaLink="false">http://gauravj.com/blog/?p=830</guid>
		<description><![CDATA[<p>While RSLs help to reduce the size for your Flex applications, they can sometimes be tricky to use. So to simplify the usage of RSLs, we made some enhancements in the upcoming Flex SDK release (code-named Hero).</p> <p>These enhancements should provide the following benefits:</p> Applications will only load RSLs that are required Modules (and <span style="color:#777"> . . . &#8594; Read More: <a href="http://gauravj.com/blog/2011/01/rsl-enhancement-in-hero/">RSL enhancements in Hero</a></span>]]></description>
			<content:encoded><![CDATA[<p>While RSLs help to reduce the size for your Flex applications, they can sometimes be tricky to use. So to simplify the usage of RSLs, we made some enhancements in the upcoming Flex SDK release (code-named <a href="http://opensource.adobe.com/wiki/display/flexsdk/Hero">Hero</a>).</p>
<p>These enhancements should provide the following benefits:</p>
<ul>
<li>Applications will only load RSLs that are required</li>
<li>Modules (and sub applications) will use RSLs which are already loaded by the parent application (or module)</li>
<li>Enable sharing of RSLs between modules (and sub applications)</li>
<li>Simply usage of Monkey Patch with Flex RSLs</li>
</ul>
<h3>Only load what&#8217;s needed</h3>
<p>In Flex 4, all RSLs that were listed in the flex-config.xml (at compile time) were loaded by the app when it was launched. But with the Hero release the compiler will remove any RSLs which are not needed by your application. This means that the load time for your app should improve because it won&#8217;t load any extra RSL. The RSLs removed by the compiler will be the placeholder RSLs. This feature is controlled by a new compiler switch called <strong>-remove-unused-rsls</strong> which defaults to true.</p>
<p>Also if you compile your app using the command line compiler, then it will print the names of the RSLs that are needed by your application. The following is an example of compiler output where the app uses 3 out of the 10 RSLs listed in flex-config.xml<br />
<img alt="" src="http://www.gauravj.com/blog/examples/RSLs/RSL_feedback.png" title="RSL_feedback.png" class="aligncenter" width="803" height="72" /></p>
<p>There could be cases where the compiler may remove RSL which is needed by your app (say if you used soft-linking to load classes from a swc). If you run into such a situation then you can override the compiler&#8217;s decision, to remove the RSL, by using the <strong>-force-rsls</strong> compiler switch. This option takes the path of the swcs for which the RSLs should be force loaded.</p>
<h3>Use what&#8217;s already loaded</h3>
<p>Starting with Hero, modules and sub-applications will use the RSLs loaded by the parent app instead of loading a duplicate copy. </p>
<p>When a module or sub-application loads a new RSL, the RSL will be loaded into the default application domain and if this was the placeholder RSL for the parent app then it will be loaded into the parent&#8217;s application domain. Now if the parent app loads another module or sub-app which needs the same RSL then it will be able to use the RSL loaded by previous module or sub app.</p>
<p>The image below is an example of application where the OSMF RSL is removed by the compiler and so it becomes the placeholder RSL for the main app.<br />
<img alt="" src="http://www.gauravj.com/blog/examples/RSLs/placeholder.png" title="placeholder" class="aligncenter" width="269" height="228" /></p>
<p>In the following image, the main app loads a module that uses spark video player. The module needs OSMF RSL so it loads it into the app domain of the parent application because OSMF RSL is a placeholder RSL. The module does not load the Framework or Spark RSLs because those were already loaded by the parent app.<br />
<img alt="" src="http://www.gauravj.com/blog/examples/RSLs/moduleLoadsRSL.png" title="module loads RSL" class="aligncenter" width="269" height="230" /></p>
<p>Now if the main app loads another sub app which needs OSMF RSL, then the sub-app will simply be able to use the OSMF RSL loaded by the module. </p>
<p>You can also specify the application domain where the module should load the RSL. The <strong>-application-domain</strong> compiler option takes the path of the swc and then the name of the application domain. The valid values for application domain  are &#8216;current&#8217;, &#8216;default&#8217;, &#8216;parent&#8217;, or &#8216;top-level&#8217;</p>
<h3>Smaller Framework RSL</h3>
<p>In Hero, we also reduced the size of the framework RSL. This was done by removing all mx components from framework.swc and moving them to a separate swc called mx.swc. So if you are creating pure spark apps then you don&#8217;t need to load any mx classes. </p>
<h3>Monkey Patch RSL</h3>
<p>The only way to use monkey patches with Flex RSLs is to load monkey patched file as RSL itself. But again it was quite tedious to create a monkey patched RSL, so to simplify that a new compiler option (called <strong>-include-inheritance-dependencies-only</strong>) was added. This option can be used when compiling the monkey patched library. This options works with -include-classes flag and it only pulls dependencies which are of type inheritance. An example for usage of this option: </p>
<p><code>bin/compc -include-classes=spark.components.Button -sp=frameworks/projects/spark/src/ -include-inheritance-dependencies-only=true -output=patch.swc</code></p>
<p>In the above example, the output swc will contain spark.components.Button and only it&#8217;s inheritance dependencies. And the library.swf contained in the output swc can be used as an RSL if you were to monkey patch the spark button component.</p>
<p>Most of these changes (except for the -application-domain compiler option) are already available in the latest <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+Hero">Hero preview build</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://gauravj.com/blog/2011/01/rsl-enhancement-in-hero/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

