<?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 &#187; debug</title>
	<atom:link href="http://www.rialvalue.com/blog/tag/debug/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>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>Debugging production ready AIR applications</title>
		<link>http://www.rialvalue.com/blog/2009/08/16/debugging-production-ready-air-applications/</link>
		<comments>http://www.rialvalue.com/blog/2009/08/16/debugging-production-ready-air-applications/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 02:19:49 +0000</pubDate>
		<dc:creator>Xavi Beumala</dc:creator>
				<category><![CDATA[air]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[error handling]]></category>

		<guid isPermaLink="false">http://www.rialvalue.com/blog/?p=62</guid>
		<description><![CDATA[One of the biggest problems around testing installed AIR applications is that testers can&#8217;t see when a runtime exception is triggered. Lots of times the symptom of a problem will be something completely different to the real cause and developers will have to spend much more time trying to figure out what was the root [...]]]></description>
			<content:encoded><![CDATA[<p>One of the biggest problems around testing installed AIR applications is that testers can&#8217;t see when a runtime exception is triggered. Lots of times the symptom of a problem will be something completely different to the real cause and developers will have to spend much more time trying to figure out what was the root cause of the problem. Even though you have a good logging policy if there&#8217;s an uncaught exception there&#8217;s not too much you can do.</p>
<p>Here are some techniques I&#8217;ve came across to make testing less painful for everybody.</p>
<h4>The debug flag way</h4>
<p>One thing I&#8217;ve been thinking for a while is that there are not two different versions of the AIR runtime; one with debugging enabled and the other without it (the way Flash Player has). This means that there might be a way to enable and disable debugging in the same runtime.  This would allow, at least in some controlled environments, to see Runtime Exceptions and make everybody&#8217;s life easier. At least until we have global error handling implemented directly on AIR or Flash Player. Yes, I agree, It&#8217;s unbelievable that on its 10th version we still are not able to capture global exceptions: <a href="http://bugs.adobe.com/jira/browse/FP-444">FP-444</a> and  <a href="http://bugs.adobe.com/jira/browse/FP-1499">FP-1499</a></p>
<p>Using <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx">Procmon</a> I realized that when an AIR application is launched it tries to read a file in {INSTALLATION_FOLDER}/META-INF/AIR/debug. See the screenshot. What surprised me was the result &#8220;NAME NOT FOUND&#8221;. Basically the file didn&#8217;t exist in the app I was playing with. After some more trial / error, yes, you&#8217;re right, this is the flag that switches on and off debugging capabilities.</p>
<p><a class="lightbox"  title ="procmon" href="http://www.rialvalue.com/blog/files/picture-3.png"><img src="http://www.rialvalue.com/blog/files/picture-3-300x126.png" alt="" title="procmon" width="300" height="126" class="aligncenter size-medium wp-image-63" /></a></p>
<p>If an AIR application is launched and an empty file with name debug is found in {INSTALLATION_FOLDER}/META-INF/AIR/debug then, any runtime exception will be displayed in a system modal window! In OS the path for this file will be {APPLICATION_FOLDER}.app/Contents/Resources/META-INF/AIR/debug</p>
<p><a class="lightbox"  title ="picture-4" href="http://www.rialvalue.com/blog/files/picture-4.png"><img src="http://www.rialvalue.com/blog/files/picture-4-300x203.png" alt="" title="picture-4" width="300" height="203" class="aligncenter size-medium wp-image-64" /></a></p>
<p>So if testers (or users during the earlier versions of your app) are using your application, make sure they create the debug file and attach any stack trace they see to their bug reports.</p>
<h4>The adl way</h4>
<p>This is not as easy as the previous solution but it gives the testers more options.</p>
<p>Once installed, an AIR application, is not more than the swf file produced from FB, its application descriptor and a native launcher. Given that we have access to the main application swf file and its corresponding descriptor we can use ADL to launch the installed application instead of the native launcher.</p>
<p>Here&#8217;s how:</p>
<p>1. Installed the SDK you want to use from http://opensource.adobe.com/wiki/display/flexsdk/Downloads<br />
2. Uncompress the zip in the location you prefer. I&#8217;ll refer to this folder as {FLEX_HOME}</p>
<p><b>In Windows</b><br />
3. Right click on &#8220;My Computer&#8221; &gt; Properties<br />
4. Go to &#8220;Advanced&#8221; tab<br />
5. Click in the option &#8220;Environment Variables&#8221;<br />
6. In the &#8220;System variables&#8221; find the &#8220;Path&#8221; definition and add this to it (double clicking on it): &#8220;;{FLEX_HOME}/bin&#8221;<br />
7. Make sure your replace {FLEX_HOME} with the path to the folder where you&#8217;ve uncompressed the SDK</p>
<p><b>In OS X</b><br />
3. Open a terminal<br />
4. Execute this command: open ~/.bash_profile<br />
5. Add the following line to the opened file:<br />
PATH=${PATH}:{FLEX_HOME}/bin<br />
6. Make sure your replace {FLEX_HOME} with the path to the folder where you&#8217;ve uncompressed the SDK</p>
<p><b>In Linux</b><br />
3. Open a terminal<br />
4. Edit your profile file ~/.profile<br />
5. Add the line: export PATH=$PATH:$FLEX_HOME</p>
<p>Then to launch the application you will have to:</p>
<p><b>In Windows</b><br />
1. Open a command line window. Start &gt; &#8220;Run &#8230;&#8221; &gt; cmd<br />
2. Navigate to the folder where the application is installed: cd &#8220;Program Files&#8221;/MyApp<br />
3. Execute this command: adl META-INF/AIR/application.xml .<br />
4. Don&#8217;t forget the dot at the end of the command</p>
<p><b>In OS X and Linux</b><br />
1. Open a terminal<br />
2. Navigate to the folder where the application is installed: cd /soft/testAirApp.app/Contents/Resources where testAirApp is the name of your application<br />
3. Execute the following command: adl META-INF/AIR/application.xml .<br />
4. Don&#8217;t forget the dot at the end of the command</p>
<p>If during the execution process there&#8217;s an exception, ADL will show it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rialvalue.com/blog/2009/08/16/debugging-production-ready-air-applications/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

