<?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>getRIAed &#187; Customization</title>
	<atom:link href="http://ravimarella.com/getriaed/category/flex/customization/feed/" rel="self" type="application/rss+xml" />
	<link>http://ravimarella.com/getriaed</link>
	<description>flex,flash,AIR</description>
	<lastBuildDate>Wed, 28 Jul 2010 19:34:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>AS3 Singleton class with parameterised constructor</title>
		<link>http://ravimarella.com/getriaed/2010/02/23/as3-singleton-class-with-parameterised-constructor/</link>
		<comments>http://ravimarella.com/getriaed/2010/02/23/as3-singleton-class-with-parameterised-constructor/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 11:10:51 +0000</pubDate>
		<dc:creator>ravi</dc:creator>
				<category><![CDATA[Customization]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[Patterns]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://ravimarella.com/getriaed/?p=128</guid>
		<description><![CDATA[As many of you already know, in AS3 there is no direct way to create singleton class i.e there is no keyword Singleton or any other equivalent keyword using which this can be accomplished. But there is a simple work around to create singleton class. The code below shows this: 1234567891011121314151617181920212223242526272829public class Services extends EventDispatcher [...]]]></description>
			<content:encoded><![CDATA[<p>As many of you already know, in AS3 there is no direct way to create singleton class i.e there is no keyword Singleton or any other equivalent keyword using which this can be accomplished. But there is a simple work around to create singleton class. The code below shows this:</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Services extends <a href="http://www.google.com/search?q=eventdispatcher%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:eventdispatcher.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">EventDispatcher</span></a><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getInstance<span style="color: #000000;">&#40;</span><span style="color: #004993;">url</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> Services<br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span> servicesLocator == <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
servicesLocator = <span style="color: #0033ff; font-weight: bold;">new</span> Services<span style="color: #000000;">&#40;</span><span style="color: #004993;">url</span><span style="color: #000000;">&#41;</span>;<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">return</span> servicesLocator;<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Services<span style="color: #000000;">&#40;</span><span style="color: #004993;">url</span><span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span> servicesLocator <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">throw</span> <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=error%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:error.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Error</span></a><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;Only one Services instance should be instantiated&quot;</span> <span style="color: #000000;">&#41;</span>;<br />
<span style="color: #000000;">&#125;</span><br />
ENDPOINT_URL=<span style="color: #004993;">url</span><br />
gateway=<span style="color: #0033ff; font-weight: bold;">new</span> HTTPService<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
gateway.resultFormat=<span style="color: #990000;">&quot;e4x&quot;</span>;<br />
gateway.<span style="color: #004993;">url</span> = ENDPOINT_URL;<br />
gateway.<span style="color: #004993;">method</span> = <span style="color: #990000;">&quot;POST&quot;</span>;<br />
gateway.useProxy = <span style="color: #0033ff; font-weight: bold;">false</span>;<br />
gateway.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>ResultEvent.RESULT, resultHandler<span style="color: #000000;">&#41;</span>;<br />
gateway.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>FaultEvent.FAULT, faultHandler<span style="color: #000000;">&#41;</span>;<br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>the way to create object now is like this:</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> servicesInstance<span style="color: #000000; font-weight: bold;">:</span>Services =Services.getInstance<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;serviceURL.php&quot;</span><span style="color: #000000;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>we&#8217;re defining here a static function called getInstance which calls the constructor <em>only</em> if servicesLocator object is null or not initialized already. A sinlgeton class is particularly of high use for HTTPService object as it allows single point of handling all the requests in this way.</p>
]]></content:encoded>
			<wfw:commentRss>http://ravimarella.com/getriaed/2010/02/23/as3-singleton-class-with-parameterised-constructor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding custom path to viewSource option of your flex application</title>
		<link>http://ravimarella.com/getriaed/2009/06/23/adding-custom-path-to-view-source-option-of-your-flex-application/</link>
		<comments>http://ravimarella.com/getriaed/2009/06/23/adding-custom-path-to-view-source-option-of-your-flex-application/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 08:59:25 +0000</pubDate>
		<dc:creator>ravi</dc:creator>
				<category><![CDATA[Application]]></category>
		<category><![CDATA[Customization]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://ravimarella.com/getriaed/?p=73</guid>
		<description><![CDATA[Ok. Today i was trying to export the release build of a simple example i've done with the View Source option enabled. But the problem is the source path can only be relative to bin-release which wont work with the perma link system that i'm using with my wordpress blog which creates virtual links.]]></description>
			<content:encoded><![CDATA[<p>Ok. Today i was trying to export the release build of a simple example i&#8217;ve done with the View Source option enabled. But the problem is the source path can only be relative to bin-release which wont work with the perma link system that i&#8217;m using with my wordpress blog which creates virtual links.</p>
<p>At first i thought of giving a custom path value to the viewSourceURL property of the Application tag like this:</p>
<p><span id="more-73"></span></p>
<div class="codecolorer-container mxml default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="mxml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">viewSourceURL=&quot;http://ravimarella.com/getriaed/flexSource/Custom_View_Source_Publishing/index.html&quot;<span style="color: #ddbb00;">&amp;gt;</span></div></td></tr></tbody></table></div>
<p>and just export the release build without selecting the view source option. But the problem with this is Flex Builder automatically deletes the viewSourceURL variable and its value once it publishes the release build. So my options are to place the above code intact and just the debug version of the swf. But the debug version contain lot of unnecessary info and adds up to the file size ultimately. So this is the solution i came up with:</p>
<p>1. Add a new Right Click Context Menu item on the application&#8217;s CreationComplete event like this:</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> viewSourceItem<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=contextmenuitem%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuitem.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuItem</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=contextmenuitem%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuitem.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuItem</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;View Source&quot;</span>, <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;<br />
<span style="color: #6699cc; font-weight: bold;">var</span> contextMenuCustomItems<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Array</span></a> = application.<span style="color: #004993;">contextMenu</span>.<span style="color: #004993;">customItems</span>;<br />
contextMenuCustomItems.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>viewSourceItem<span style="color: #000000;">&#41;</span>;<br />
viewSourceItem.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=contextmenuevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuevent.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">ContextMenuEvent</span></a>.<span style="color: #004993;">MENU_ITEM_SELECT</span>, showSource<span style="color: #000000;">&#41;</span>;<br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> showSource<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #004993;">navigateToURL</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">URLRequest</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http://ravimarella.com/getriaed/flexSource/Custom_View_Source_Publishing/index.html&quot;</span><span style="color: #000000;">&#41;</span>,<span style="color: #990000;">&quot;_blank&quot;</span><span style="color: #000000;">&#41;</span>;<br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>What this will do is add a new menuitem to the menu that appears when you Righ Click or Ctrl_+Click on Mac called &#8220;View Source&#8221; and up on clicking this menu item navigates to the URL mentioned. The menuitem name can be named ofcourse as anything you want.</p>
<p>2. Export the release build with viewsource option enabled. This step is just to gather the source files. You can skip this step and select the source files your self and place them in a single folder. I prefer the first method as flex published the index.html and uses a clean interface to navigate through and download different items of your source.</p>
<p>3. Now, you can edit the source code exported to remove the viewSourceURL option just for the sake of your users or keep it intact if you dont prefer to take the extra step and let your users see the extra ViewSource option which is not the one that you are actually using. Note that flex renames creates your mxml files as .mxml.html files&#8230;so to remove that ViewSourceURL option, just open the main application mxml file in any text editor and remove the code pertaining to the ViewSourceURL.</p>
<p>Now just upload the source code folder contents in the exactly same URL as mentioned above by you.</p>
<p>Thats it&#8230;now you are ready with a Custom and absolute path for your Source code.</p>
<p>Here is  sample that i&#8217;ve done:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_Custom_View_Source_Publishing_1295646107"
			class="flashmovie"
			width="600"
			height="300">
	<param name="movie" value="http://ravimarella.com/getriaed/wp-content/uploads/2009/06/Custom_View_Source_Publishing.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://ravimarella.com/getriaed/wp-content/uploads/2009/06/Custom_View_Source_Publishing.swf"
			name="fm_Custom_View_Source_Publishing_1295646107"
			width="600"
			height="300">
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Right Click any where on the application and click View Source option to see the source&#8230;</p>
<p><span style="text-decoration: underline;"><strong>REMEMBER</strong></span>, you&#8217;ve to export the release build twice&#8230;first time with the source code export option selected and second time without the sourcecode option so that the default viewsource option wont show up on right click&#8230;</p>
<p>Happy flexing..<img class="wpml_ico" src="http://ravimarella.com/getriaed/wp-content/plugins/wp-monalisa/icons/wpml_mail.gif" alt="" /></p>
<p>cheers,</p>
<p>ravi.</p>
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
]]></content:encoded>
			<wfw:commentRss>http://ravimarella.com/getriaed/2009/06/23/adding-custom-path-to-view-source-option-of-your-flex-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
