<?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>rialvalue.com</title>
	<atom:link href="http://www.rialvalue.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rialvalue.com/blog</link>
	<description>No Flex No Fun</description>
	<lastBuildDate>Fri, 04 Feb 2011 08:09:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Documenting functions and named parameters</title>
		<link>http://www.rialvalue.com/blog/2011/02/04/documenting-functions-and-named-parameters/</link>
		<comments>http://www.rialvalue.com/blog/2011/02/04/documenting-functions-and-named-parameters/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 08:03:09 +0000</pubDate>
		<dc:creator>Xavi Beumala</dc:creator>
				<category><![CDATA[best practice]]></category>
		<category><![CDATA[best_practice]]></category>
		<category><![CDATA[clean code]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[flexunit]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.rialvalue.com/blog/?p=299</guid>
		<description><![CDATA[Sometime ago someone asked me how I&#8217;d pass custom paramaters to event listeners. I don&#8217;t remember the exact use case neither who asked me but basically he was asking for something like:
mc.addEventListener&#40;MouseEvent.CLICK, myListener, &#34;myCustomParam&#34;, 2&#41;;
functoin myListener&#40;event: MouseEvent, custom :String, custom2 : int&#41; : void;
While the exact syntax above would not be possible, closures are in [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime ago someone asked me how I&#8217;d pass custom paramaters to event listeners. I don&#8217;t remember the exact use case neither who asked me but basically he was asking for something like:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> myListener<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;myCustomParam&quot;</span><span style="color: #000066; font-weight: bold;">,</span> 2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
functoin myListener<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">,</span> custom <span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">,</span> custom2 <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000066; font-weight: bold;">;</span></div></div>
<p>While the exact syntax above would not be possible, closures are in any case the way to go. I explained him how I&#8217;d do it and I forgot about the topic until today.</p>
<p>Today while waiting for a long compilation process to complete I&#8217;ve came up with an idea on how to improve code readability on cases similar to this. Here&#8217;s the cleaneast syntax I&#8217;ve came up with (ideas are more than welcome to improve it):</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> createListenerAdapterBasedOn<span style="color: #000000;">&#40;</span>myListener<span style="color: #000066; font-weight: bold;">,</span> withParameters<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;myCustomParam&quot;</span><span style="color: #000066; font-weight: bold;">,</span> 2<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></div>
<p>Does it look too verbose? I guess it will highly depend on the exact use case where this is used. But under some circumstances I think the readability can be substantially improved.</p>
<p><b>createListenerAdapterBasedOn</b> is a <a href="http://www.rialvalue.com/blog/2011/01/25/as3-package-level-functions-and-java-static-imports/">package level method</a>. I could have used a utility static method like FunctionUtils.createListenerAdapter. But instead I&#8217;ve used a package function because I can reduce the length of the Class + method name (or use the same number of characters to add verbosity and clarity). On the other hand it&#8217;s unlikely that this utility class would have more methods.</p>
<h2>Documenting functions</h2>
<p>This is a concept I&#8217;ve never read about or used before, but I think I&#8217;ll start using in different places. <i>withParameters</i> method is a completely dummy method that simply returns the parameters it gets but <b>giving them a semantic and contextual meaning</b>. The solely purpose of this method is to improve the readability by converting the method invocation in a Fluent API that can be read as natural language. The method is simply documenting the usage of the call. Putting this together with the <a href="http://www.rialvalue.com/blog/2010/03/30/some-thoughts-on-method-parameters/">Builder pattern and named parameters I discussed a while ago</a> it gives us an incredible weapon to create self-documented code that doesn&#8217;t need most-of-the-times useless, needless and confusing ASDoc or inline comments.</p>
<p>If necessary when you have a method accepting several parameters of the same type and that can be confusing to read you could used Documenting functions to create kind of named-parameters:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">myMethod<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;John&quot;</span><span style="color: #66cc66;">&#41;</span>, surname<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Green&quot;</span><span style="color: #66cc66;">&#41;</span>, age<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">33</span><span style="color: #66cc66;">&#41;</span>, weight<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">70</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div></div>
<p>Here are the details of the implementation in case you are interested in seeing the internal details and some of the tests.</p>
<h3>createListenerAdapterBasedOn.as</h3>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>rialvalue<span style="color: #000066; font-weight: bold;">.</span>utils<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> createListenerAdapterBasedOn<span style="color: #000000;">&#40;</span>callback<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=function%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:function.html"><span style="color: #004993;">Function</span></a><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">...</span> args<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=function%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:function.html"><span style="color: #004993;">Function</span></a><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">...</span> rest<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:*</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>args<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span> == 1<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> callback<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">apply</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">,</span> rest<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">concat</span><span style="color: #000000;">&#40;</span>args<span style="color: #000000;">&#91;</span>0<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> callback<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">apply</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">,</span> rest<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">concat</span><span style="color: #000000;">&#40;</span>args<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<h3>withParameters.as</h3>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>rialvalue<span style="color: #000066; font-weight: bold;">.</span>utils<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> withParameters<span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">...</span> args<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> args<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<h3>createListenerAdapterBasedOnTest.as</h3>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;height:330px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>rialvalue<span style="color: #000066; font-weight: bold;">.</span>utils<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:movieclip.html"><span style="color: #004993;">MovieClip</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=ieventdispatcher%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:ieventdispatcher.html"><span style="color: #004993;">IEventDispatcher</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> flashx<span style="color: #000066; font-weight: bold;">.</span>textLayout<span style="color: #000066; font-weight: bold;">.</span>debug<span style="color: #000066; font-weight: bold;">.</span>assert<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flexunit<span style="color: #000066; font-weight: bold;">.</span>assertThat<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>hamcrest<span style="color: #000066; font-weight: bold;">.</span>object<span style="color: #000066; font-weight: bold;">.</span>equalTo<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ListenerUtilsTest<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> static const ORIGINAL_PARAMETER<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;originalParameter&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> static const FIRST_PARAM<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;firstParam&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> static const SECOND_PARAM<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;secondParam&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Test<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> createCallbackAdapterWithNoParameters<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> callbackAdapter<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=function%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:function.html"><span style="color: #004993;">Function</span></a> = createListenerAdapterBasedOn<span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertThat<span style="color: #000000;">&#40;</span>ORIGINAL_PARAMETER<span style="color: #000066; font-weight: bold;">,</span> equalTo<span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callbackAdapter<span style="color: #000000;">&#40;</span>ORIGINAL_PARAMETER<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Test<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> createCallbackAdapterWithIndividualParameter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> callbackAdapter<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=function%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:function.html"><span style="color: #004993;">Function</span></a> = createListenerAdapterBasedOn<span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">,</span> p1<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertThat<span style="color: #000000;">&#40;</span>ORIGINAL_PARAMETER<span style="color: #000066; font-weight: bold;">,</span> equalTo<span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertThat<span style="color: #000000;">&#40;</span>FIRST_PARAM<span style="color: #000066; font-weight: bold;">,</span> equalTo<span style="color: #000000;">&#40;</span>p1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">,</span> withParameters<span style="color: #000000;">&#40;</span>FIRST_PARAM<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callbackAdapter<span style="color: #000000;">&#40;</span>ORIGINAL_PARAMETER<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Test<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> createCallbackAdapterWithIndividualParameterNoFluent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> callbackAdapter<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=function%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:function.html"><span style="color: #004993;">Function</span></a> = createListenerAdapterBasedOn<span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">,</span> p1<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertThat<span style="color: #000000;">&#40;</span>ORIGINAL_PARAMETER<span style="color: #000066; font-weight: bold;">,</span> equalTo<span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertThat<span style="color: #000000;">&#40;</span>FIRST_PARAM<span style="color: #000066; font-weight: bold;">,</span> equalTo<span style="color: #000000;">&#40;</span>p1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">,</span> FIRST_PARAM<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callbackAdapter<span style="color: #000000;">&#40;</span>ORIGINAL_PARAMETER<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Test<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> createCallbackAdapterWithIndividualParameters<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> callbackAdapter<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=function%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:function.html"><span style="color: #004993;">Function</span></a> = createListenerAdapterBasedOn<span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">,</span> p1<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">,</span> p2<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertThat<span style="color: #000000;">&#40;</span>ORIGINAL_PARAMETER<span style="color: #000066; font-weight: bold;">,</span> equalTo<span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertThat<span style="color: #000000;">&#40;</span>FIRST_PARAM<span style="color: #000066; font-weight: bold;">,</span> equalTo<span style="color: #000000;">&#40;</span>p1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertThat<span style="color: #000000;">&#40;</span>SECOND_PARAM<span style="color: #000066; font-weight: bold;">,</span> equalTo<span style="color: #000000;">&#40;</span>p2<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">,</span> withParameters<span style="color: #000000;">&#40;</span>FIRST_PARAM<span style="color: #000066; font-weight: bold;">,</span> SECOND_PARAM<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callbackAdapter<span style="color: #000000;">&#40;</span>ORIGINAL_PARAMETER<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Test<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> createCallbackAdapterWithIndividualParametersNoFluent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> callbackAdapter<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=function%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:function.html"><span style="color: #004993;">Function</span></a> = createListenerAdapterBasedOn<span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">,</span> p1<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">,</span> p2<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertThat<span style="color: #000000;">&#40;</span>ORIGINAL_PARAMETER<span style="color: #000066; font-weight: bold;">,</span> equalTo<span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertThat<span style="color: #000000;">&#40;</span>FIRST_PARAM<span style="color: #000066; font-weight: bold;">,</span> equalTo<span style="color: #000000;">&#40;</span>p1<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertThat<span style="color: #000000;">&#40;</span>SECOND_PARAM<span style="color: #000066; font-weight: bold;">,</span> equalTo<span style="color: #000000;">&#40;</span>p2<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">,</span> FIRST_PARAM<span style="color: #000066; font-weight: bold;">,</span> SECOND_PARAM<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callbackAdapter<span style="color: #000000;">&#40;</span>ORIGINAL_PARAMETER<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.rialvalue.com/blog/2011/02/04/documenting-functions-and-named-parameters/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AS3 Package level functions and Java static imports</title>
		<link>http://www.rialvalue.com/blog/2011/01/25/as3-package-level-functions-and-java-static-imports/</link>
		<comments>http://www.rialvalue.com/blog/2011/01/25/as3-package-level-functions-and-java-static-imports/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 11:12:06 +0000</pubDate>
		<dc:creator>Xavi Beumala</dc:creator>
				<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.rialvalue.com/blog/?p=290</guid>
		<description><![CDATA[It&#8217;s a hidden treasure for lot of people but AS3 provides a mechanism to declare functions like setTimeout or setInterval called package level functions. These functions are defined inside packages like flash.utils.setInterval or flash.utils.setTimeout but can be used as if they were static functions.
This is a feature widely used in FlexUnit but that can be [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a hidden treasure for lot of people but AS3 provides a mechanism to declare functions like setTimeout or setInterval called package level functions. These functions are defined inside packages like flash.utils.setInterval or flash.utils.setTimeout but can be used as if they were static functions.</p>
<p>This is a feature widely used in FlexUnit but that can be used in lots of other circumstances to reduce the amount of code and reduce its verbosity.</p>
<p>The mechanism to create a package level function is pretty simple. Here are the steps required to create a custom package function:</p>
<ul>
<li>You create a class where the function will be defined. i.e: your/package/Assert.as</li>
<li>You declare a public function at the package level. Note that there&#8217;s no class definition.
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> my<span style="color: #000066; font-weight: bold;">.</span>pack<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> assert<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
</li>
<li>Then you can use it from every where you wish</li>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> <br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> my<span style="color: #000066; font-weight: bold;">.</span>pack<span style="color: #000066; font-weight: bold;">.</span>assert<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> testPackagefunctions<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> testPackagefunctions<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assert<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
</ul>
<p>When creating package level functions, the only restriction to bear in mind, is that the function name exposed must be the same name as the name of the file that contains it. i.e. If I expose the assert function, the filename that defines it must be assert.as. This implies that there can only be one function definition per file. If you need more you can create as many files as you need.</p>
<p>Package level functions in AS3 are directly comparable to static imports in Java. In java we can write code like:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> static my<span style="color: #000066; font-weight: bold;">.</span>pack<span style="color: #000066; font-weight: bold;">.</span>Assert<span style="color: #000066; font-weight: bold;">.*;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #0033ff; font-weight: bold;">void</span> main<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assert<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>By using an static import in Java, static methods defined in the Assert class (in the example above) are made available directly so there&#8217;s no need to write Assert.assert. Again this is a feature used a lot in <a href="http://www.junit.org">jUnit</a>, <a href="http://code.google.com/p/hamcrest/">Hamcrest</a> or <a href="http://code.google.com/p/lambdaj/">lamdaj</a> libraries.</p>
<p>Autocompletion in Java in regards to static imports is not automatic. If you want to have autocompletion with static imports you can use Preferences > Java > Editor > Favorites and add there the Types or classes you want to use static imports for.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rialvalue.com/blog/2011/01/25/as3-package-level-functions-and-java-static-imports/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Slides for &#8220;Having Fun with Layouts in Flex 4&#8243;</title>
		<link>http://www.rialvalue.com/blog/2010/11/04/slides-for-having-fun-with-layouts-in-flex-4/</link>
		<comments>http://www.rialvalue.com/blog/2010/11/04/slides-for-having-fun-with-layouts-in-flex-4/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 13:00:55 +0000</pubDate>
		<dc:creator>Xavi Beumala</dc:creator>
				<category><![CDATA[layout]]></category>
		<category><![CDATA[presentations]]></category>

		<guid isPermaLink="false">http://www.rialvalue.com/blog/?p=278</guid>
		<description><![CDATA[Here are the slides, recording and all the material Enrique Duvos and I presented during our Max presentation around Flex4 layouts.
You can find the recording here.
I&#8217;ve uploaded all the samples here, you should be able to access the source code in all the samples by right clicking in the sample applications:

Accordion3D layout. 
Swapping layouts with [...]]]></description>
			<content:encoded><![CDATA[<p>Here are the slides, recording and all the material <a href="http://www.duvos.com">Enrique Duvos</a> and I presented during <a href="http://www.rialvalue.com/blog/2010/10/17/max-2010-having-fun-with-layouts-in-flex-4/">our Max presentation around Flex4 layouts</a>.</p>
<p>You can find the recording <a href="http://2010.max.adobe.com/online/2010/MAX269_1288217914953LLLL">here</a>.</p>
<p>I&#8217;ve uploaded all the samples here, you should be able to access the source code in all the samples by right clicking in the sample applications:</p>
<ul>
<li><a href="http://www.rialvalue.com/blog/2010/11/04/flex4-accordion3d-layout/">Accordion3D layout</a>. </li>
<li><a href="http://www.rialvalue.com/components/layouts/swappingLayouts/binding">Swapping layouts with states</a>. </li>
<li><a href="http://www.rialvalue.com/components/layouts/swappingLayouts/binding">Swapping layouts with normal bindings</a>. </li>
<li><a href="http://www.rialvalue.com/components/layouts/postTransformations">Post transformations sample</a>. Nothing new here, but look at how simple the code is.</li>
<li><a href="http://www.rialvalue.com/components/layouts/columns">Columns Layout</a>. Another layout to look at, this time it sets the children in columns top to bottom, left to right.</li>
<li><a href="http://www.rialvalue.com/components/layouts/textRotation">2D Text rotation</a>. Simple layout that positions different labels rotating them 45 degrees</li>
<li><a href="http://www.rialvalue.com/components/layouts/pile3D">Dancing pile layout</a>. A 3D pile layout that dances. Thanks for the track to the <a href="http://www.phlow.es/mp3-descargar-libre/electronic/1934-musica-per-la-pau-musica-por-la-paz-music-for-peace">&#8220;Music for the peace&#8221;</a> Creative Commons initiative. The accuracy of the dancer is not quite good since for simplicity I do only take into account one of every 8 samples.</li>
<li><a href="http://www.rialvalue.com/components/layouts/imageRotation">3D Image rotation</a>. The beginning of a Coverflow</li>
<li><a href="http://www.rialvalue.com/blog/2010/03/30/flex4-coverflow-layout/">CoverFlow layout</a></li>
<li><a href="http://www.rialvalue.com/blog/2010/04/14/carroflow-another-3d-layout-for-flex4/">Carroflow Layout</a></li>
</ul>
<p>Finally, here are the slides.</p>
<div style="width:425px" id="__ss_5666185"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/xbeumala/max-2010-having-fun-flex4-layouts" title="Max 2010: Having Fun Flex4 Layouts">Max 2010: Having Fun Flex4 Layouts</a></strong><object id="__sse5666185" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=max2010havingfunflex4layoutsfinal-101104072227-phpapp02&#038;stripped_title=max-2010-having-fun-flex4-layouts&#038;userName=xbeumala" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse5666185" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=max2010havingfunflex4layoutsfinal-101104072227-phpapp02&#038;stripped_title=max-2010-having-fun-flex4-layouts&#038;userName=xbeumala" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/xbeumala">xbeumala</a>.</div>
</div>
<p>Special thanks to <a href="http://www.evtimmy.com">Evtim Georgiev</a> for his support while preparing the presentation and all the materials.<br />
I hope you enjoyed the presentation and that you found it interesting!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rialvalue.com/blog/2010/11/04/slides-for-having-fun-with-layouts-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex4 Accordion3D layout</title>
		<link>http://www.rialvalue.com/blog/2010/11/04/flex4-accordion3d-layout/</link>
		<comments>http://www.rialvalue.com/blog/2010/11/04/flex4-accordion3d-layout/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 11:52:53 +0000</pubDate>
		<dc:creator>Xavi Beumala</dc:creator>
				<category><![CDATA[layout]]></category>
		<category><![CDATA[presentations]]></category>

		<guid isPermaLink="false">http://www.rialvalue.com/blog/?p=263</guid>
		<description><![CDATA[This is one of the layouts I created for the &#8220;Having fun with Flex layouts&#8221; MAX presentation.

You can run the sample application here.
You can find the code here.
I specially like the lightening effects achived with a simple ColorTransform transformation and the really nice cover with transparency effects positioned on top of the pictures  (I [...]]]></description>
			<content:encoded><![CDATA[<p>This is one of the layouts I created for the <a href="http://www.rialvalue.com/blog/2010/10/17/max-2010-having-fun-with-layouts-in-flex-4/">&#8220;Having fun with Flex layouts&#8221;</a> MAX presentation.</p>
<p><a href="http://www.rialvalue.com/components/layouts/accordion3D"><img src="http://www.rialvalue.com/blog/files/2010-11-04-12h06_161.png" alt="" title="2010-11-04 12h06_16" width="420" height="128" class="aligncenter size-full wp-image-272" /></a></p>
<p>You can run the sample application <a href="http://rialvalue.com/components/layouts/accordion3D/">here</a>.<br />
You can find the code <a href="http://www.rialvalue.com/components/layouts/accordion3D/srcview/index.html">here</a>.</p>
<p>I specially like the lightening effects achived with a simple ColorTransform transformation and the really nice cover with transparency effects positioned on top of the pictures  (I have to give all the kudos to Alexis Hill from <a href="http://www.undefined.es">Undefined</a> for his nice touch of design!)</p>
<p>Things I&#8217;d highlight from the implementation:</p>
<ul>
<li>There&#8217;s lot of room for improvement in the positioning function. This was written as a learning sample resource.</li>
<li>There&#8217;s a &#8220;random&#8221; glitch that misspositions some elements. This normally happens only with the second variation of the layout. I&#8217;ll have a look when I have some time</li>
<li>At the moment item selection doesn&#8217;t work by clicking items. Instead use the slider</a>
</ul>
<p>As always feel free to use it wherever you want at your own risk. The code is provided with no warranties at all.</p>
<p>If you want to learn more on Flex4 layouts you might be interested in <a href="http://www.rialvalue.com/blog/2010/11/04/slides-for-having-fun-with-layouts-in-flex-4/">reading this</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rialvalue.com/blog/2010/11/04/flex4-accordion3d-layout/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Slides for &#8220;FlexPMD, Your Canary in a Coal Mine&#8221;</title>
		<link>http://www.rialvalue.com/blog/2010/10/28/slides-for-flexpmd-your-canary-in-a-coal-mine/</link>
		<comments>http://www.rialvalue.com/blog/2010/10/28/slides-for-flexpmd-your-canary-in-a-coal-mine/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 16:45:15 +0000</pubDate>
		<dc:creator>Xavi Beumala</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[best practice]]></category>
		<category><![CDATA[flexpmd]]></category>
		<category><![CDATA[presentations]]></category>

		<guid isPermaLink="false">http://www.rialvalue.com/blog/?p=254</guid>
		<description><![CDATA[Here are the slides and the recording of the presentation Xavier and I presented at MAX this year on FlexPMD and code quality. I hope you enjoyed the presentation!
Watch the recording.
Max  flash based code quality  is there a canary in your coal mine-
View more presentations from Xavier Agnetti.

]]></description>
			<content:encoded><![CDATA[<p>Here are the slides and the recording of the presentation <a href="http://blogs.adobe.com/xagnetti/">Xavier</a> and I presented at MAX this year on FlexPMD and code quality. I hope you enjoyed the presentation!</p>
<p><a href="http://2010.max.adobe.com/online/2010/MAX267_1288282798346JWEW">Watch the recording.</a></p>
<div style="width:425px" id="__ss_5597259"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/xagnetti/max-flash-based-code-quality-is-there-a-canary-in-your-coal-mine" title="Max  flash based code quality  is there a canary in your coal mine-">Max  flash based code quality  is there a canary in your coal mine-</a></strong><object id="__sse5597259" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=max-flashbasedcodequalityisthereacanaryinyourcoalmine-101028111053-phpapp01&#038;stripped_title=max-flash-based-code-quality-is-there-a-canary-in-your-coal-mine&#038;userName=xagnetti" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse5597259" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=max-flashbasedcodequalityisthereacanaryinyourcoalmine-101028111053-phpapp01&#038;stripped_title=max-flash-based-code-quality-is-there-a-canary-in-your-coal-mine&#038;userName=xagnetti" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/xagnetti">Xavier Agnetti</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.rialvalue.com/blog/2010/10/28/slides-for-flexpmd-your-canary-in-a-coal-mine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MAX 2010: FlexPMD, Your Canary in a Coal Mine</title>
		<link>http://www.rialvalue.com/blog/2010/10/17/max-2010-flexpmd-your-canary-in-a-coal-mine/</link>
		<comments>http://www.rialvalue.com/blog/2010/10/17/max-2010-flexpmd-your-canary-in-a-coal-mine/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 18:34:45 +0000</pubDate>
		<dc:creator>Xavi Beumala</dc:creator>
				<category><![CDATA[flexpmd]]></category>

		<guid isPermaLink="false">http://www.rialvalue.com/blog/?p=241</guid>
		<description><![CDATA[This year I&#8217;m presenting at MAX next to Xavier Agnetti on FlexPMD.
Xavier has done an amazing job preparing this presentation in a very funny and engaging way! I&#8217;m pretty sure you´ll enjoy it.
During this session we&#8217;ll present you the benefits of reinforcing development and team best-practices from a tooling perspective and how FlexPMD can help [...]]]></description>
			<content:encoded><![CDATA[<p>This year I&#8217;m presenting at MAX next to <a href="http://blogs.adobe.com/xagnetti/">Xavier Agnetti</a> on <a href="http://opensource.adobe.com/wiki/display/flexpmd">FlexPMD</a>.</p>
<p>Xavier has done an amazing job preparing this presentation in a very funny and engaging way! I&#8217;m pretty sure you´ll enjoy it.</p>
<p>During this session we&#8217;ll present you the benefits of reinforcing development and team best-practices from a tooling perspective and how FlexPMD can help you on your daily developments.</p>
<p>We&#8217;ll present you not only the basis of how to use FlexPMD but also we&#8217;ll present:</p>
<ul>
<li>Streamline your development using FlexPMD eclipse plugin</li>
<li>Create a ruleset that best matches your personal and team needs</li>
<li>Extend FlexPMD creating custom rules to reinforce your team specific best-practices</li>
</ul>
<p>Last but not least we plan to release a new version of the Eclipse plugin that will fix most of the issues that the beta version has, improving the performance substantially and easing the configuration process.</p>
<p>If you can&#8217;t wait to use this upcoming version you can give it a quick try <a href="http://www.rialvalue.com/flexPmd/updateSite">using this update site</a> (let us know if you find any issue. Also note that the wrapped PMD CLI is 1.1 instead of 1.2, the final version will wrap 1.2).</p>
<p><a href="https://max.adobe.com/schedule/by-session/flexpmd-your-canary-in-a-coal-mine/e5bef8ba-cbc9-4594-9f49-89f42b25606f">See you at MAX, Wednesday 9.30am &#8211; 10.30am.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rialvalue.com/blog/2010/10/17/max-2010-flexpmd-your-canary-in-a-coal-mine/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MAX 2010: Having Fun with Layouts in Flex 4</title>
		<link>http://www.rialvalue.com/blog/2010/10/17/max-2010-having-fun-with-layouts-in-flex-4/</link>
		<comments>http://www.rialvalue.com/blog/2010/10/17/max-2010-having-fun-with-layouts-in-flex-4/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 18:30:31 +0000</pubDate>
		<dc:creator>Xavi Beumala</dc:creator>
				<category><![CDATA[layout]]></category>

		<guid isPermaLink="false">http://www.rialvalue.com/blog/?p=244</guid>
		<description><![CDATA[Join Enrique and myself in this deep dive on Flex4 layouts. I personally find the layout mechanism one of the most exciting and powerful features in Flex4 so I&#8217;m willing to present and discuss with you on this topic!
During this session we&#8217;ll present the basis of the new layout mechanism while trying to go into [...]]]></description>
			<content:encoded><![CDATA[<p>Join <a href="http://www.duvos.com">Enrique</a> and myself in <a href="https://max.adobe.com/schedule/by-session/having-fun-with-layouts-in-flex-4/b0f6cf25-cf34-41cb-93f5-611b351ef11c">this deep dive on Flex4 layouts</a>. I personally find the layout mechanism one of the most exciting and powerful features in Flex4 so I&#8217;m willing to present and discuss with you on this topic!</p>
<p>During this session we&#8217;ll present the basis of the new layout mechanism while trying to go into depth and clarify some more advanced and unknown capabilities. During the session you&#8217;ll see the required steps to create custom layouts, how to apply 2D and 3D transformations, the difference between layout transformation and post-layout transformations and layout virtualization.</p>
<p><a href="https://max.adobe.com/schedule/by-session/having-fun-with-layouts-in-flex-4/b0f6cf25-cf34-41cb-93f5-611b351ef11c">See you on Wednesday at 15.30</a></p>
<p><a href="http://max.adobe.com/?sdid=ERZUY"><img src="https://max2010.assets.confreg.com/images/MAX10_Color_125x125_Speaker.jpg" width="125" height="125" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rialvalue.com/blog/2010/10/17/max-2010-having-fun-with-layouts-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Streamlining your Flex project environment</title>
		<link>http://www.rialvalue.com/blog/2010/06/10/streamlining-your-flex-project-environment/</link>
		<comments>http://www.rialvalue.com/blog/2010/06/10/streamlining-your-flex-project-environment/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 07:27:31 +0000</pubDate>
		<dc:creator>Xavi Beumala</dc:creator>
				<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[best_practice]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[functional testing]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.rialvalue.com/blog/?p=236</guid>
		<description><![CDATA[In case you missed it, a couple of days ago an article I wrote a while ago went live in Adobe Devnet
The article summarizes a set of best practices to configure your projects on Flash Builder and Eclipse in general for maximum efficiency and reduced maintenance effort.
As a software engineer joining a new project, I [...]]]></description>
			<content:encoded><![CDATA[<p>In case you missed it, a couple of days ago an article I wrote a while ago went live in <a href="http://www.adobe.com/devnet/flex/articles/flex_streamline_project_environment.html?devcon=f1">Adobe Devnet</a></p>
<p>The article summarizes a set of best practices to configure your projects on Flash Builder and Eclipse in general for maximum efficiency and reduced maintenance effort.</p>
<blockquote><p>As a software engineer joining a new project, I want to be able to get the code quickly, build it, and then run the application. I don&#8217;t want to have to work through a complex set up procedure, read countless how-to documents, or learn the detailed ins-and-outs of the application to simply get started.</p></blockquote>
<p><a href="http://www.adobe.com/devnet/flex/articles/flex_streamline_project_environment.html?devcon=f1">You can read the article on Devnet.</a></p>
<p>Do you follow any other best practices? any tips?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rialvalue.com/blog/2010/06/10/streamlining-your-flex-project-environment/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>HowTo create your developer ToolBox with Mixins</title>
		<link>http://www.rialvalue.com/blog/2010/05/21/howto-create-your-developer-toolbox-with-mixins/</link>
		<comments>http://www.rialvalue.com/blog/2010/05/21/howto-create-your-developer-toolbox-with-mixins/#comments</comments>
		<pubDate>Fri, 21 May 2010 11:25:33 +0000</pubDate>
		<dc:creator>Xavi Beumala</dc:creator>
				<category><![CDATA[components]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[mixin]]></category>
		<category><![CDATA[toolbox]]></category>

		<guid isPermaLink="false">http://www.rialvalue.com/blog/?p=228</guid>
		<description><![CDATA[In this post I&#8217;ll explain how you can develop a flex library that automatically initializes itself avoiding developers the hassle of remembering how, when and where the libraries need to be initialized and hooked into the application. This can be particularly helpful for debugging libraries like fxSpy, DeMonsterDebugger, KaptInspect, mrdoob, etc. and extremely useful to [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I&#8217;ll explain how you can develop a flex library that automatically initializes itself avoiding developers the hassle of remembering how, when and where the libraries need to be initialized and hooked into the application. This can be particularly helpful for debugging libraries like <a href="http://code.google.com/p/fxspy/">fxSpy</a>, <a href="http://demonsterdebugger.com/">DeMonsterDebugger</a>, <a href="http://lab.kapit.fr/display/kapinspect/Kap+Inspect">KaptInspect</a>, <a href="code.google.com/p/mrdoob">mrdoob</a>, etc. and extremely useful to create your own Flex toolbox that simply plugs-in and can go with you on all your developments.<br />
<span id="more-228"></span><br />
First, create a class in your library project with whatever name you pick, in my case I&#8217;ll call it LibraryInitializer.as, make sure you mark this class to be included on the final swc or even better use the new FB4 option &#8220;Include all classes from all sources&#8221;. Second and key point, add a public static method named init that receives a parameter and mark the class as a Mixin:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000;">&#91;</span>Mixin<span style="color: #000000;">&#93;</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> LibraryInitializer <br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>systemManager<span style="color: #000066; font-weight: bold;">:</span>ISystemManager<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>The [Mixin] metadata tag is extensively used in the Flex automation API and it basically gives you a very interesting hook. The static init method of any class marked as a [Mixin] will be invoked at a very early point during the application initialization phase by the SystemManager class or FlexModuleFactory. The Mixins are executed before the preInitialize event is triggered on the main Application. The parameter that the init method receives is a reference to the related SystemManager so you can mark the parameter as an ISystemManager, InteractiveObject or whatever better fits your needs. You can <a href="http://www.rialvalue.com/blog/2010/05/13/global-exception-or-error-handling-in-flex/">read about another interesting use of the [Mixin] on the Global Exception Handler post</a> .</p>
<p>By adding a Mixin class in a library and linking the library to an Application what you effectively get is a hook where the library can initialize itself and release the developer from manually initializing it.</p>
<p>Let&#8217;s see some real world examples.</p>
<p>Libraries like fxSpy, deMonsterDebugger, KaptInspect or mrdoob are extremely easy to use but on each project you end up doing some repetitive steps or adding conditionally compiled code to your Main application class. </p>
<p>I&#8217;ll focus on a sample with <a href="http://code.google.com/p/fxspy/">fxSpy</a> where you can launch it from a contextual option when you right click on the application and see <a href="code.google.com/p/mrdoob">mrdoob</a> memory monitor. The only step required to integrate this will is adding the following compiler option:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">-include-libraries=libs/myToolbox.swc</div></div>
<p>And this is the library initializer, which basically adds a ContextMenuItem to the contextMenu of the systemManager. Note that we have to wait for the APPLICATION_COMPLETE event, otherwise the Flex SDK will override our contextMenu (it happens on the pre-initialize phase).</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;height:330px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>flexspy<span style="color: #000066; font-weight: bold;">.</span>FlexSpy<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=interactiveobject%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:interactiveobject.html"><span style="color: #004993;">InteractiveObject</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=contextmenuevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuevent.html"><span style="color: #004993;">ContextMenuEvent</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.ui</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=contextmenu%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenu.html"><span style="color: #004993;">ContextMenu</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.ui</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=contextmenuitem%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuitem.html"><span style="color: #004993;">ContextMenuItem</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> flashx<span style="color: #000066; font-weight: bold;">.</span>textLayout<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">elements</span><span style="color: #000066; font-weight: bold;">.</span>GlobalSettings<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>FlexGlobals<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>FlexEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>managers<span style="color: #000066; font-weight: bold;">.</span>ISystemManager<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> spark<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>SpriteVisualElement<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Mixin<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MyToolBoxInitializer<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> initializer<span style="color: #000066; font-weight: bold;">:</span>MyToolBoxInitializer<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>systemManager<span style="color: #000066; font-weight: bold;">:</span>ISystemManager<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; systemManager<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>FlexEvent<span style="color: #000066; font-weight: bold;">.</span>APPLICATION_COMPLETE<span style="color: #000066; font-weight: bold;">,</span> applicationCompleteHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #339966; font-weight: bold;">function</span> applicationCompleteHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> systemManager<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=interactiveobject%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:interactiveobject.html"><span style="color: #004993;">InteractiveObject</span></a> = event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span> <span style="color: #0033ff; font-weight: bold;">as</span> <a href="http://www.google.com/search?q=interactiveobject%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:interactiveobject.html"><span style="color: #004993;">InteractiveObject</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; systemManager<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>FlexEvent<span style="color: #000066; font-weight: bold;">.</span>APPLICATION_COMPLETE<span style="color: #000066; font-weight: bold;">,</span> applicationCompleteHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; initializer = <span style="color: #0033ff; font-weight: bold;">new</span> MyToolBoxInitializer<span style="color: #000000;">&#40;</span>systemManager<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MyToolBoxInitializer<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=interactiveobject%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:interactiveobject.html"><span style="color: #004993;">InteractiveObject</span></a><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; createContextMenu<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; createMonitor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> createContextMenu<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=interactiveobject%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:interactiveobject.html"><span style="color: #004993;">InteractiveObject</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">contextMenu</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=contextmenu%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenu.html"><span style="color: #004993;">ContextMenu</span></a> = <span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">contextMenu</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">contextMenu</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">customItems</span> = <span style="color: #000000;">&#91;</span> createContextMenuItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> createMonitor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> sve<span style="color: #000066; font-weight: bold;">:</span>SpriteVisualElement = <span style="color: #0033ff; font-weight: bold;">new</span> SpriteVisualElement<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sve<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Stats<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FlexGlobals<span style="color: #000066; font-weight: bold;">.</span>topLevelApplication<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span>sve<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> createContextMenuItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=contextmenuitem%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuitem.html"><span style="color: #004993;">ContextMenuItem</span></a><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> contextItem<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=contextmenuitem%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:contextmenuitem.html"><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"><span style="color: #004993;">ContextMenuItem</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Flex Spy&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contextItem<span style="color: #000066; font-weight: bold;">.</span><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"><span style="color: #004993;">ContextMenuEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MENU_ITEM_SELECT</span><span style="color: #000066; font-weight: bold;">,</span> handleContextMenuItemSelect<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> contextItem<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> handleContextMenuItemSelect<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FlexSpy<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>In the Initializer you could also intialize the fps and memory monitor provided by mrdoob by simply adding a new instance to the DisplayList.</p>
<p>These are the benefits I see on this approach:</p>
<ul>
<li>You won&#8217;t have to reapeat yourself in different projects initializing the same libraries always in the same way.</li>
<li>Your main file won&#8217;t be cluttered with infrastructure and glue code to configure your libraries.</li>
<li>You won&#8217;t need to use conditional compilation for this initializations. You can enable or disable all at once by removing the compiler option. Going an step further you could have diferent compiler profiles / environments on your ant tasks or maven builds or even use the -load-config compiler option to externalize your configurations to an xml file.</li>
</ul>
<p><a href="http://www.rialvalue.com/downloads/libraryInitializers.zip">You can downdload a zip with 2 sample projects</a>, one for the library and the other for the application using it.</p>
<p>Shortly I&#8217;ll blog about some of the things I have in my toolbox that could be helpful for you too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rialvalue.com/blog/2010/05/21/howto-create-your-developer-toolbox-with-mixins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Global Exception or Error Handling in Flex</title>
		<link>http://www.rialvalue.com/blog/2010/05/13/global-exception-or-error-handling-in-flex/</link>
		<comments>http://www.rialvalue.com/blog/2010/05/13/global-exception-or-error-handling-in-flex/#comments</comments>
		<pubDate>Thu, 13 May 2010 09:08:52 +0000</pubDate>
		<dc:creator>Xavi Beumala</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[error handling]]></category>
		<category><![CDATA[mixin]]></category>

		<guid isPermaLink="false">http://www.rialvalue.com/blog/?p=207</guid>
		<description><![CDATA[In this post I explain how you can catch unhandled exceptions or errors globally in a declarative mxml-based way using the [Mixin] flex-specific metadata tag.
Starting on FP 10.1 and AIR 2.0 you can capture unhandled exceptions or errors globally. Although you can use these new APIs you should always take care of the exceptions where [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I explain how you can catch unhandled exceptions or errors globally in a declarative mxml-based way using the [Mixin] flex-specific metadata tag.</p>
<p>Starting on FP 10.1 and AIR 2.0 you can capture unhandled exceptions or errors globally. Although you can use these new APIs you should <b>always</b> take care of the exceptions where they happen and use this technique only as a diagnosing or logging help or for async exceptions that you can&#8217;t really control in any other way. </p>
<p>You might also be interested in these 2 other topics:</p>
<ul>
<li><a href="http://www.rialvalue.com/blog/2009/08/25/logging-and-catching-exceptions-during-invalidation/">Logging and catching (async) exceptions during invalidation in Flex</a></li>
<li><a href="http://www.rialvalue.com/blog/2009/08/16/debugging-production-ready-air-applications/">Debugging and getting Stack-trace error dialogs with installed AIR applications</a></li>
</ul>
<p>The new API works like:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #004993;">loaderInfo</span><span style="color: #000066; font-weight: bold;">.</span>uncaughtErrorEvents<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>UncaughtErrorEvent<span style="color: #000066; font-weight: bold;">.</span>UNCAUGHT_ERROR<span style="color: #000066; font-weight: bold;">,</span> onUncaughtError<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onUncaughtError<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span>UncaughtErrorEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Do something with your error.</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p><a href="http://blogs.adobe.com/cantrell/archives/2009/10/global_error_handling_in_air_20.html">Christian Cantrell explains some more details on the APIs</a>. You can find further information <a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/events/UncaughtErrorEvent.html">in the documentation</a> as well.</p>
<p>When working with Flex, and adding the UncaughtErrorEvent.UNCAUGHT_ERROR listener to the loaderInfo object make sure you do it after FlexEvent.APPLICATION_COMPLETE event has been triggered, otherwise you&#8217;ll get an &#8220;Error #1009: Cannot access a property or method of a null object reference&#8221;</p>
<p>To prevent all this required glue code and avoid unnecessary configuration code (that ends up cluttering the main application Class) I&#8217;ve created a GlobalExceptionHandler component that abstracts developers a little bit from these sort of problems. The implementation isn&#8217;t tighted to the APPLICATION_COMPLETE event, instead it uses the [Mixin] metadata tag. On top of that you can use it declaratively:</p>
<div class="codecolorer-container xml mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><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><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:WindowedApplication</span> <span style="color: #000066;">xmlns:fx</span>=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">xmlns:s</span>=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">xmlns:logging</span>=<span style="color: #ff0000;">&quot;com.adobe.ac.logging.*&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fx:Declarations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;logging:GlobalExceptionHandler</span> <span style="color: #000066;">preventDefault</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;logging:LogHandlerAction</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;local:TraceHandlerAction</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/logging:GlobalExceptionHandler<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fx:Declarations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:WindowedApplication<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>You can <a href="http://www.rialvalue.com/downloads/globalExceptionHandler.zip">download the code along with a sample project here</a>. The code for GlobalExceptionHandler:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;height:330px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>adobe<span style="color: #000066; font-weight: bold;">.</span>ac<span style="color: #000066; font-weight: bold;">.</span>logging<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=loaderinfo%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:loaderinfo.html"><span style="color: #004993;">LoaderInfo</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span>UncaughtErrorEvent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>managers<span style="color: #000066; font-weight: bold;">.</span>ISystemManager<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Mixin<span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#91;</span>DefaultProperty<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;handlerActions&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> GlobalExceptionHandler<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loaderInfo</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=loaderinfo%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:loaderinfo.html"><span style="color: #004993;">LoaderInfo</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>ArrayElementType<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;com.adobe.ac.logging.GlobalExceptionHandlerAction&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> handlerActions<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">preventDefault</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span>sm<span style="color: #000066; font-weight: bold;">:</span>ISystemManager<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">loaderInfo</span> = sm<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">loaderInfo</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> GlobalExceptionHandler<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">loaderInfo</span><span style="color: #000066; font-weight: bold;">.</span>uncaughtErrorEvents<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>UncaughtErrorEvent<span style="color: #000066; font-weight: bold;">.</span>UNCAUGHT_ERROR<span style="color: #000066; font-weight: bold;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uncaughtErrorHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> uncaughtErrorHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span>UncaughtErrorEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> action<span style="color: #000066; font-weight: bold;">:</span>GlobalExceptionHandlerAction <span style="color: #0033ff; font-weight: bold;">in</span> handlerActions<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; action<span style="color: #000066; font-weight: bold;">.</span>handle<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">error</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">preventDefault</span> == <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">preventDefault</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>The code for LogHandlerAction:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:515px;height:330px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>adobe<span style="color: #000066; font-weight: bold;">.</span>ac<span style="color: #000066; font-weight: bold;">.</span>logging<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>logging<span style="color: #000066; font-weight: bold;">.</span>ILogger<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>logging<span style="color: #000066; font-weight: bold;">.</span>Log<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> LogHandlerAction implements GlobalExceptionHandlerAction<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> static const LOG<span style="color: #000066; font-weight: bold;">:</span>ILogger = Log<span style="color: #000066; font-weight: bold;">.</span>getLogger<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;UncaughtException&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> handle<span style="color: #000000;">&#40;</span><span style="color: #004993;">error</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">error</span> <span style="color: #0033ff; font-weight: bold;">is</span> <a href="http://www.google.com/search?q=error%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:error.html"><span style="color: #004993;">Error</span></a><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> errorObj<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=error%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:error.html"><span style="color: #004993;">Error</span></a> = <span style="color: #004993;">error</span> <span style="color: #0033ff; font-weight: bold;">as</span> <a href="http://www.google.com/search?q=error%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:error.html"><span style="color: #004993;">Error</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LOG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">error</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;{0}. {1}<span style="">\n</span> {2}&quot;</span><span style="color: #000066; font-weight: bold;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorObj<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">errorID</span><span style="color: #000066; font-weight: bold;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorObj<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">message</span><span style="color: #000066; font-weight: bold;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorObj<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getStackTrace</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.rialvalue.com/blog/2010/05/13/global-exception-or-error-handling-in-flex/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

