<?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>Thanks, Mister! &#187; Adobe AIR</title>
	<atom:link href="http://www.thanksmister.com/index.php/archive/tag/adobe-air/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thanksmister.com</link>
	<description>Adobe Flex &#38; AIR Development</description>
	<lastBuildDate>Mon, 19 Jul 2010 17:28:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Screen Capture with AIR 2 NativeProcess</title>
		<link>http://www.thanksmister.com/index.php/archive/screen-capture-with-air-2-nativeprocess/</link>
		<comments>http://www.thanksmister.com/index.php/archive/screen-capture-with-air-2-nativeprocess/#comments</comments>
		<pubDate>Tue, 25 May 2010 01:20:57 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Command-line interface]]></category>
		<category><![CDATA[Screenshot]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=807</guid>
		<description><![CDATA[Prior to AIR 2 the only way to capture the screen was to use something like Marapi Java Bridge that acts as a conduit between your application and the native system. However, AIR 2 now lets us call With AIR 2 Beta and the upcoming AIR 2 release, you can now use the command-line tool [...]]]></description>
			<content:encoded><![CDATA[<p>Prior to AIR 2 the only way to capture the screen was to use something like <a href="http://blog.everythingflex.com/2008/04/24/do-a-screen-capture-with-adobe-air/">Marapi Java Bridge</a> that acts as a conduit between your application and the native system.  However, AIR 2 now lets us call</p>
<p>With AIR 2 Beta and the upcoming AIR 2 release, you can now use the command-line tool &#8220;screencapture&#8221; that comes with Mac OS.   Nothing extra needs to be bundled with the application for this to work on a Mac, but on Windows, you need an additional piece of code to execute the screen capture process.</p>
<p>The process of doing a screen capture is pretty easy.   You first create a File object that points to the location of the &#8220;screencapture&#8221; command line on the Mac:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> file:File = File.<span style="color: #006600;">applicationDirectory</span>;<br />
file = file.<span style="color: #006600;">resolvePath</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;usr/sbin/screencapture&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>Then create a <a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/desktop/NativeProcessStartupInfo.html">NativeProcessStartupInfo</a> object that will be used when we start the <a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/desktop/NativeProcess.html">NativeProcess</a>.The arguments property of the NativeProcessStartupInfo takes a list of arguments that will be passed to the command line tool when its started.  For a complete list of arguments used by the screencapture command line tool, type &#8220;screencapture &#8211;help&#8221; in the terminal window.  For this example I wanted to push out a file named &#8220;screencap.png&#8221; to the desktop from a selection of the screen.  Optionally, you could capture the image to the clipboard and paste it directly.</p>
<p><span id="more-807"></span></p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> nativeProcessStartupInfo:NativeProcessStartupInfo = <span style="color: #000000; font-weight: bold;">new</span> NativeProcessStartupInfo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> args:Vector. = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;-i&quot;</span>;<br />
args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;screencapture.png&quot;</span>;<br />
<br />
nativeProcessStartupInfo.<span style="color: #0066CC;">arguments</span> = args;<br />
nativeProcessStartupInfo.<span style="color: #006600;">executable</span> = file;</div></td></tr></tbody></table></div>
<p>Now we can start the native process:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">process = <span style="color: #000000; font-weight: bold;">new</span> NativeProcess<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
process.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span>nativeProcessStartupInfo<span style="color: #66cc66;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>The screencapture command tool will be launched and you will see the selection cursor on your screen.  After you make a selection, the file will automatically be saved to the desktop as &#8220;screencapture.png&#8221;.</p>
<p>Here is the complete project code:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><br />
xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span><span style="color: #66cc66;">&amp;</span>gt;<br />
<br />
<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> process:NativeProcess;<br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
launchNativeProcess<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> launchNativeProcess<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>NativeProcess.<span style="color: #006600;">isSupported</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> file:File = File.<span style="color: #006600;">applicationDirectory</span>;<br />
<br />
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Capabilities</span>.<span style="color: #0066CC;">os</span>.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;win&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #808080; font-style: italic;">//file = file.resolvePath(&quot;bin/mylocalexe.exe&quot;);</span><br />
<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Capabilities</span>.<span style="color: #0066CC;">os</span>.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;mac&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
file = file.<span style="color: #006600;">resolvePath</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/usr/sbin/screencapture&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> args:Vector.<span style="color: #66cc66;">&lt;</span>String<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>String<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;-i&quot;</span>;<br />
args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;screencapture.png&quot;</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> nativeProcessStartupInfo:NativeProcessStartupInfo = <span style="color: #000000; font-weight: bold;">new</span> NativeProcessStartupInfo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
nativeProcessStartupInfo.<span style="color: #0066CC;">arguments</span> = args;<br />
nativeProcessStartupInfo.<span style="color: #006600;">executable</span> = file;<br />
nativeProcessStartupInfo.<span style="color: #006600;">workingDirectory</span> = File.<span style="color: #006600;">desktopDirectory</span>;<br />
<br />
process = <span style="color: #000000; font-weight: bold;">new</span> NativeProcess<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
process.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span>nativeProcessStartupInfo<span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span></div></td></tr></tbody></table></div>
<p>To get something like this to work on Windows, you need to know a little bit of C or C# so you can call your own service and launch the screen print functionality on Windows. For more about using the NativeProcess in AIR 2 for both Windows and Mac, you check out this <a href="http://www.adobe.com/devnet/air/flex/quickstart/interacting_with_native_process.html">Adobe article</a>.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/ea2c0ce1-6d29-4a27-b680-848f9c046997/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=ea2c0ce1-6d29-4a27-b680-848f9c046997" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<p><map name='google_ad_map_807_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/807?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_807_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=807&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fscreen-capture-with-air-2-nativeprocess%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/screen-capture-with-air-2-nativeprocess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preventing scrolling and mouse events on out of focus AIR application</title>
		<link>http://www.thanksmister.com/index.php/archive/preventing-scrolling-mouse-events-out-of-focus-air-application/</link>
		<comments>http://www.thanksmister.com/index.php/archive/preventing-scrolling-mouse-events-out-of-focus-air-application/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 23:28:44 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Event.ACTIVATE]]></category>
		<category><![CDATA[Event.DEACTIVATE]]></category>
		<category><![CDATA[mouseChildren]]></category>
		<category><![CDATA[mouseEnabled]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=746</guid>
		<description><![CDATA[This has been a little bit of annoyance for me for some time. When an AIR application (like any Twitter application) is out of focus and you click on the application activate it, you inadvertently click a link or button within the application. You are also able to scroll the application when the application has [...]]]></description>
			<content:encoded><![CDATA[<p>This has been a little bit of annoyance for me for some time.  When an AIR application (like any Twitter application) is out of focus and you click on the application activate it, you inadvertently click a link or button within the application.   You are also able to scroll the application when the application has no focus, which may or may not be your desired behavior.  I wanted a way to prevent mouse events and scrolling until the application has focus.   I tried to find away around this annoyance by capturing if the application has focus by listening for Event.ACTIVATE or Event.DEACTIVATE events on the NativeApplication.nativeApplication:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ACTIVATE</span>, handleAppActivate<span style="color: #66cc66;">&#41;</span>;<br />
NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">DEACTIVATE</span>, handleAppDiactivate<span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAppActivate<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set a flag that application has focus so now links and buttons work</span><br />
<span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAppDiactivate<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// set some flag to let the application has no focus so disable links and buttons</span><br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>This solution has a couple of problems.  First the application has focus the instance you click on any link within the application window.  So fine, the way around that is to use some kind of timer so that your flag that says application is now active is not set until some time after the application receives focus.     This leads to the second problem, at least for larger scale applications.   You have to pipe the flag that says the application has no focus to every button and link through the entire application, this is a huge pain.   </p>
<p><span id="more-746"></span></p>
<p>Today I just happened to be playing with the new <a href="http://www.gskinner.com/blog/archives/2009/05/idle_cpu_usage.html">FramerateThrottler</a> class created by Grant Skinner to reduce CPU usage for AIR applications running on Mac (this is yet another gripe of mine).    So on his bog there are some comments about using mouseChildren and mouseEnabled on all open AIR windows to reduce CPU.    Anyways, when I was messing around with this suggestion, I happened to notice my application no longer scrolled when the application was in the background, but mouse events were still active.   </p>
<p>So I then thought of combining my previous attempt at preventing links and buttons from being clicked on with mouseChildren and mouseEnabled.  I ended up only setting mouseChildren and mouseEnabled to true if the application has focus, and after a small timer dalay of 500 miliseconds.   That gives me just enough time to click on the application any where without also clicking on a link or button and activating it.   So now I can click on the application to give it focus any place I like without firing off click events:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ACTIVATE</span>, handleAppActivate<span style="color: #66cc66;">&#41;</span>;<br />
NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">DEACTIVATE</span>, handleAppDiactivate<span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> timer:Timer;<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAppActivate<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set timer to enable mouse events after short delay on app activation</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; timer = <span style="color: #000000; font-weight: bold;">new</span> Timer<span style="color: #66cc66;">&#40;</span>500<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; timer.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">COMPLETE</span>, enableAppEvents<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; timer.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAppDiactivate<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">this</span>.<span style="color: #006600;">mouseChildren</span> = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">this</span>.<span style="color: #006600;">mouseEnabled</span> = <span style="color: #000000; font-weight: bold;">false</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> enableAppEvents<span style="color: #66cc66;">&#40;</span>event:TimerEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;timer.<span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp;timer.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">COMPLETE</span>, enableAppEvents<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// now scrolling and mouse events work</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">this</span>.<span style="color: #006600;">mouseChildren</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">this</span>.<span style="color: #006600;">mouseEnabled</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>That&#8217;s it, a simple solution that was probably sitting under my nose the whole time but I never thought of it.</p>
<p><strong>UPDATE</strong></p>
<p>Jonnie Hallman from Adobe posted a great article that expands the idea of handling throttling and events (mouse wheel for example).   </p>
<p><a href="http://www.adobe.com/devnet/air/flex/articles/framerate_throttling.html">http://www.adobe.com/devnet/air/flex/articles/framerate_throttling.html</a></p>
<p>- Mister</p>
<p><map name='google_ad_map_746_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/746?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_746_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=746&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fpreventing-scrolling-mouse-events-out-of-focus-air-application%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/preventing-scrolling-mouse-events-out-of-focus-air-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Spark TextFlow LinkElement Rollover in Flex 4</title>
		<link>http://www.thanksmister.com/index.php/archive/spark-textflow-linkelement-rollover-in-flex-4/</link>
		<comments>http://www.thanksmister.com/index.php/archive/spark-textflow-linkelement-rollover-in-flex-4/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 02:42:50 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash Builder 4]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Spark Skins]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[linkActiveFormat]]></category>
		<category><![CDATA[linkHoverFormat]]></category>
		<category><![CDATA[linkNormalFormat]]></category>
		<category><![CDATA[RichEditableText]]></category>
		<category><![CDATA[SkinnableContainer]]></category>
		<category><![CDATA[TextFlow]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=689</guid>
		<description><![CDATA[This is a little example of how to create a skinned rollover popup on a LinkElement object in Flash Builder 4 (Flex 4) within a TextFlow object. This is something I have been waiting for since 2001. The old way to create a rollover action on an HTML link was to create an invisible MovieClip [...]]]></description>
			<content:encoded><![CDATA[<p>This is a little example of how to create a skinned rollover popup on a <a href="http://livedocs.adobe.com/flex/gumbo/langref/flashx/textLayout/elements/LinkElement.html">LinkElement</a> object in Flash Builder 4 (Flex 4) within a <a href="http://livedocs.adobe.com/flex/gumbo/langref/flashx/textLayout/elements/TextFlow.html">TextFlow</a> object.  This is something I have been waiting for since 2001.  The old way to create a rollover action on an HTML link was to create an invisible MovieClip that floats over your hyperlink.  Flex Builder 4 greatly simplifies this by adding rollover, mouse, and click events to all hyperlinks within the TextFlow object.  This is a HUGE plus</p>
<p>I borrowed the click event action from an <a href="http://blog.flexexamples.com/2009/06/28/styling-hyperlinks-in-a-textflow-object-in-flex-4/#more-1220">example</a> by Peter deHaan posted on his blog <a href="http://blog.flexexamples.com">Flex Examples</a>. You will need the latest build of the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4">Flex Builder 4 SDK</a> and some helpful instructions on how to install the latest <a href="http://blog.flexexamples.com/2009/07/13/downloading-and-installing-flex-4-sdk-builds-from-opensource-adobe-com-flash-builder-4-beta-edition/">Flex Builder 4 SDK</a>.</p>
<p><strong>Example AIR Application Output</strong></p>
<p><img src="http://www.thanksmister.com/examples/linkelementrollover/LinkRollover2.png" alt="LinkElement Rollover Example" /></p>
<p><span id="more-689"></span></p>
<p><strong>Main.mxml</strong></p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;</span>s:WindowedApplication title=<span style="color: #ff0000;">&quot;Spark RichEditableText LinkElement Rollover&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>fx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> flashx.<span style="color: #006600;">textLayout</span>.<span style="color: #006600;">formats</span>.<span style="color: #006600;">TextDecoration</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">managers</span>.<span style="color: #006600;">PopUpManager</span>;<br />
&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> flashx.<span style="color: #006600;">textLayout</span>.<span style="color: #006600;">elements</span>.<span style="color: #006600;">LinkElement</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> flashx.<span style="color: #006600;">textLayout</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">FlowElementMouseEvent</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> customToolTip:CustomToolTip;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> clickHandler<span style="color: #66cc66;">&#40;</span>evt:FlowElementMouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> linkEl:LinkElement = evt.<span style="color: #006600;">flowElement</span> as LinkElement;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;The '&quot;</span> + linkEl.<span style="color: #006600;">getFirstLeaf</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">&quot;' link would have gone to &quot;</span> + linkEl.<span style="color: #006600;">href</span> + <span style="color: #ff0000;">&quot; in a &quot;</span> + linkEl.<span style="color: #0066CC;">target</span> + <span style="color: #ff0000;">&quot; window, but it was cancelled.&quot;</span>, <span style="color: #ff0000;">&quot;Fun with hyperlinks&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; evt.<span style="color: #006600;">stopImmediatePropagation</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; evt.<span style="color: #006600;">preventDefault</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> rollOverHandler<span style="color: #66cc66;">&#40;</span>evt:FlowElementMouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>customToolTip<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; customToolTip = <span style="color: #000000; font-weight: bold;">new</span> CustomToolTip<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; customToolTip.<span style="color: #006600;">x</span> = <span style="color: #0066CC;">this</span>.<span style="color: #006600;">mouseX</span> - customToolTip.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; customToolTip.<span style="color: #006600;">y</span> = <span style="color: #0066CC;">this</span>.<span style="color: #006600;">mouseY</span> - <span style="color: #cc66cc;">40</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PopUpManager.<span style="color: #006600;">addPopUp</span><span style="color: #66cc66;">&#40;</span>customToolTip, <span style="color: #0066CC;">this</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; customToolTip.<span style="color: #0066CC;">text</span> = &nbsp;LinkElement<span style="color: #66cc66;">&#40;</span>evt.<span style="color: #006600;">flowElement</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">href</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> rollOutHandler<span style="color: #66cc66;">&#40;</span>evt:FlowElementMouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PopUpManager.<span style="color: #006600;">removePopUp</span><span style="color: #66cc66;">&#40;</span>customToolTip<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;customToolTip = <span style="color: #000000; font-weight: bold;">null</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>fx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:RichEditableText id=<span style="color: #ff0000;">&quot;richEdTxt&quot;</span> &nbsp;editable=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #0066CC;">selectable</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #0066CC;">focusEnabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:textFlow<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:TextFlow<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;!</span>--<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:linkNormalFormat &nbsp;textDecoration=<span style="color: #ff0000;">&quot;{TextDecoration.NONE}&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:linkHoverFormat textDecoration=<span style="color: #ff0000;">&quot;{TextDecoration.UNDERLINE}&quot;</span> <span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:linkActiveFormat &nbsp;textDecoration=<span style="color: #ff0000;">&quot;{TextDecoration.UNDERLINE}&quot;</span> <span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:p<span style="color: #66cc66;">&gt;</span>Text that includes a link to <span style="color: #66cc66;">&lt;</span>s:a href=<span style="color: #ff0000;">&quot;http://adobe.com/&quot;</span> <span style="color: #0066CC;">target</span>=<span style="color: #ff0000;">&quot;_blank&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rollOver=<span style="color: #ff0000;">&quot;rollOverHandler(event);&quot;</span> rollOut=<span style="color: #ff0000;">&quot;rollOutHandler(event);&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; click=<span style="color: #ff0000;">&quot;clickHandler(event);&quot;</span><span style="color: #66cc66;">&gt;</span>Adobe<span style="color: #66cc66;">&lt;/</span>s:a<span style="color: #66cc66;">&gt;</span>.<span style="color: #66cc66;">&lt;/</span>s:p<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:TextFlow<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:textFlow<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:RichEditableText<span style="color: #66cc66;">&gt;</span><br />
&nbsp;<br />
<span style="color: #66cc66;">&lt;/</span>s:WindowedApplication<span style="color: #66cc66;">&gt;</span></div></td></tr></tbody></table></div>
<p><strong>CustomToolTip</strong></p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;</span>s:SkinnableContainer xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> <br />
&nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><br />
&nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>fx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> spark.<span style="color: #006600;">skins</span>.<span style="color: #006600;">spark</span>.<span style="color: #006600;">BorderSkin</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _text:<span style="color: #0066CC;">String</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _text = value;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>fx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:Skin minHeight=<span style="color: #ff0000;">&quot;25&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:Rect id=<span style="color: #ff0000;">&quot;upFill&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top=<span style="color: #ff0000;">&quot;1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">&quot;1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">&quot;1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bottom=<span style="color: #ff0000;">&quot;1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; radiusX=<span style="color: #ff0000;">&quot;10&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; radiusY=<span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:fill<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:LinearGradient rotation=<span style="color: #ff0000;">&quot;90&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:GradientEntry <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">&quot;#222222&quot;</span> &nbsp;ratio=<span style="color: #ff0000;">&quot;0&quot;</span> alpha=<span style="color: #ff0000;">&quot;0.45&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:GradientEntry <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">&quot;#222222&quot;</span> &nbsp;ratio=<span style="color: #ff0000;">&quot;0.45&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:GradientEntry <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">&quot;#222222&quot;</span> &nbsp;ratio=<span style="color: #ff0000;">&quot;0.65&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:GradientEntry <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">&quot;#222222&quot;</span> ratio=<span style="color: #ff0000;">&quot;.8&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:LinearGradient<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:fill<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:stroke<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:SolidColorStroke <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">&quot;#222222&quot;</span> weight=<span style="color: #ff0000;">&quot;0.5&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:stroke<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:Rect<span style="color: #66cc66;">&gt;</span><br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:Rect id=<span style="color: #ff0000;">&quot;highlightFill&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top=<span style="color: #ff0000;">&quot;2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">&quot;2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">&quot;2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bottom=<span style="color: #ff0000;">&quot;2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; radiusX=<span style="color: #ff0000;">&quot;10&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; radiusY=<span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:stroke<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:LinearGradientStroke rotation=<span style="color: #ff0000;">&quot;90&quot;</span> weight=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:GradientEntry <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">&quot;#FDFDFD&quot;</span> ratio=<span style="color: #ff0000;">&quot;0&quot;</span> alpha=<span style="color: #ff0000;">&quot;0.6&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:GradientEntry <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">&quot;#FDFDFD&quot;</span> ratio=<span style="color: #ff0000;">&quot;0.2&quot;</span> alpha=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:LinearGradientStroke<span style="color: #66cc66;">&gt;</span><br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:stroke<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:Rect<span style="color: #66cc66;">&gt;</span><br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:SimpleText id=<span style="color: #ff0000;">&quot;labelElement&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;{_text}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">&quot;#FFFFFF&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">&quot;20&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">&quot;20&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; verticalCenter=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:filters<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>s:DropShadowFilter <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">&quot;#999999&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blurX=<span style="color: #ff0000;">&quot;5&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blurY=<span style="color: #ff0000;">&quot;5&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; angle=<span style="color: #ff0000;">&quot;90&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; distance=<span style="color: #ff0000;">&quot;2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alpha=<span style="color: #ff0000;">&quot;0.8&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:filters<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>s:Skin<span style="color: #66cc66;">&gt;</span><br />
<br />
<span style="color: #66cc66;">&lt;/</span>s:SkinnableContainer<span style="color: #66cc66;">&gt;</span></div></td></tr></tbody></table></div>
<p>The only think I couldn&#8217;t get working for this example (the commented out section) was changing the format of the hyperlinks within the TextFlow object.  </p>
<p><a href="http://www.thanksmister.com/examples/linkelementrollover/LinkElementRollover.zip">Source File</a></p>
<p><strong>Additional Resources</strong></p>
<p><a href="http://labs.adobe.com/technologies/flashbuilder4/">http://labs.adobe.com/technologies/flashbuilder4/</a><br />
<a href="http://livedocs.adobe.com/flex/gumbo/langref/spark/primitives/RichEditableText.html">http://livedocs.adobe.com/flex/gumbo/langref/spark/primitives/RichEditableText.html</a><br />
<a href="http://blog.flexexamples.com/2009/08/27/creating-a-linkelement-in-a-spark-richeditabletext-control-in-flex-4/">http://blog.flexexamples.com/2009/08/27/creating-a-linkelement-in-a-spark-richeditabletext-control-in-flex-4/</a><br />
<a href="http://blog.flexexamples.com/2009/07/13/downloading-and-installing-flex-4-sdk-builds-from-opensource-adobe-com-flash-builder-4-beta-edition/">http://blog.flexexamples.com/2009/07/13/downloading-and-installing-flex-4-sdk-builds-from-opensource-adobe-com-flash-builder-4-beta-edition/</a></p>
<p>-Mister</p>
<p><map name='google_ad_map_689_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/689?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_689_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=689&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fspark-textflow-linkelement-rollover-in-flex-4%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/spark-textflow-linkelement-rollover-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AIR:: Adding Application Menu Bar Items</title>
		<link>http://www.thanksmister.com/index.php/archive/air-adding-application-menu-bar-items/</link>
		<comments>http://www.thanksmister.com/index.php/archive/air-adding-application-menu-bar-items/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 18:55:57 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex 3]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[garbage collection]]></category>
		<category><![CDATA[NativeApplication]]></category>
		<category><![CDATA[NativeMenuItem]]></category>
		<category><![CDATA[WindowedApplication]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=669</guid>
		<description><![CDATA[Just a quick how-to post on adding application menu bar items to your Adobe AIR application when running. Certain operating systems can support application menu bars, so this example will not be true for all systems. You can check this using &#8220;NativeApplication.supportsMenu == true&#8221;, which basically means you are on Mac OSX dude. If you [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick how-to post on adding application menu bar items to your Adobe AIR application when running.  Certain operating systems can support application menu bars, so this example will not be true for all systems.  You can check this using &#8220;NativeApplication.supportsMenu == true&#8221;, which basically means you are on Mac OSX dude.  If you were on a Windows or Linux box you would check for &#8220;NativeWindow.supportsMenu == true&#8221; and add the menu items to the NativeWindow rather than the NativeApplication.    </p>
<p>As it turns out, I ran into just a small confusing snag that initially prevented the added application menu bar item from firing a select event.   I eventually reached out to the <a href="http://groups.google.com/group/air-tight/browse_thread/thread/a719522bdb10b7a6?hl=en">Adobe AIR Tight</a> discussion group and Jesse Warden had a quick fix.   It turns out that if you do not use strong item references, they are swept away by Garbage Collection (GC) before you actually use the items.    For example instead of creating the <a href="http://">NativeMenuItem</a> within the scope of the function, I had to create it within the scope of the class or in this case, the WindowedApplication.     </p>
<p>In my application I only needed to add a single menu bar item.   So instead of blowing away the entire application menu and then creating all my own menu items (<a href="http://livedocs.adobe.com/flex/3/html/help.html?content=Menus_9.html">as many of the examples show</a>). I just wanted to add a single item to the exiting application menu bar.   On  Mac OS, you get 4 application menu items: YourAppName, File, Edit, and Window.  YourAppName would be your applications name or if you are running in the Eclipse IDE, just simply &#8220;adl&#8221;.  In my case I wanted to add a &#8220;Preferences&#8221; option under the YourAppName.    You can do this by accessing the NativeMenuItem representing the YourAppName. Something like NativeApplication.nativeApplication.menu.items[0] will return a NativeMenuItem with that reference.   Using that reference you can then add a new NativeMenuItem to the submenu of the referenced NativeMenuItem.   In addition to adding items to the submenu, you can also detect when the new item is selected.    </p>
<p>In any event, here is the complete application code example:</p>
<p><span id="more-669"></span></p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;</span>mx:WindowedApplication xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> windowComplete=<span style="color: #ff0000;">&quot;createApplicationMenu()&quot;</span> &nbsp;<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:Style source=<span style="color: #ff0000;">&quot;assets/css/whitelabel.css&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> prefItem:NativeMenuItem;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> menuItem:NativeMenuItem;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> createApplicationMenu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>NativeApplication.<span style="color: #006600;">supportsMenu</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prefItem = <span style="color: #000000; font-weight: bold;">new</span> NativeMenuItem<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Preferences...&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prefItem.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">SELECT</span>, handlePreferencesSelected<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prefItem.<span style="color: #006600;">keyEquivalent</span> = <span style="color: #ff0000;">&quot;,&quot;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; menuItem = NativeMenuItem<span style="color: #66cc66;">&#40;</span>NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #0066CC;">menu</span>.<span style="color: #006600;">items</span><span style="color: #66cc66;">&#91;</span>0<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; menuItem.<span style="color: #006600;">submenu</span>.<span style="color: #006600;">addItemAt</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> NativeMenuItem<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>, 1<span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; menuItem.<span style="color: #006600;">submenu</span>.<span style="color: #006600;">addItemAt</span><span style="color: #66cc66;">&#40;</span>prefItem, 2<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handlePreferencesSelected<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;handlePreferencesSelected&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></div></td></tr></tbody></table></div>
<p>That&#8217;s it, so now you can have a new item under your application name in the application menu bar to fire whatever function you desire.   </p>
<p>-Mister</p>
<p><map name='google_ad_map_669_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/669?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_669_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=669&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fair-adding-application-menu-bar-items%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/air-adding-application-menu-bar-items/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>AIR :: TextField bug when resetting HTML text.</title>
		<link>http://www.thanksmister.com/index.php/archive/air-textfield-bug-when-resetting-html-text/</link>
		<comments>http://www.thanksmister.com/index.php/archive/air-textfield-bug-when-resetting-html-text/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 17:29:06 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[TextField]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=625</guid>
		<description><![CDATA[I ran into a really strange issue that only occurs within AIR applications (AIR 1.5.1/1.5.2).   When I create a TextField control, set it's style, and then assign it HTML text it appears fine.  However, if I wish to reset that TextField content and the original content has links, the entire replaced content becomes one HTML link.    I think the issue can be better explained with some images and some code samples. ]]></description>
			<content:encoded><![CDATA[<p>I ran into a really strange issue that only occurs within Adobe AIR applications (<a href="http://get.adobe.com/air/">AIR 1.5.1/1.5.2</a>).   When I create a TextField control, set it&#8217;s style, and then assign it HTML text it appears fine.  However, if I wish to reset that TextField content and the original content has links, the entire replaced content becomes one HTML link.    I think the issue can be better explained with some images and some code samples. </p>
<p><strong>Issue Context</strong></p>
<p>The first image is a TextField with one HTML link.  The link fires a TextEvent which is handled by a function which replaces the text.   The original TextField out put is in the image below withe the &#8220;more&#8221; HTML link at the end:</p>
<p><img alt="" src="http://thanksmister.com/examples/htmltextfield/textfield1.png" title="TextField" class="alignnone" width="432" height="259" /></p>
<p>The second image shows the result when the &#8220;more&#8221; link is clicked and the text is replaced.   You can see that when the mouse is over the text the entire text becomes a &#8220;more&#8221; link even though the new content has no HTML links.   The rollover style on the TextField underlines the text.</p>
<p><img alt="" src="http://thanksmister.com/examples/htmltextfield/textfield2.png" title="TextField" class="alignnone" width="440" height="258" /></p>
<p><span id="more-625"></span></p>
<p>Below is the complete AIR application code that shows how I setup the application and changed the TextField content.</p>
<p><strong>Code</strong></p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;</span>mx:WindowedApplication xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> applicationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponent</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">navigateToURL</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> textMessage:<span style="color: #0066CC;">TextField</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> longtext:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque fermentum lorem in dolor facilisis aliquam dictum libero aliquet. Pellentesque scelerisque eleifend nunc nec consectetur. Pellentesque et libero lacus. Etiam condimentum diam pellentesque quam pretium ut gravida velit rutrum. Pellentesque sapien mauris, semper accumsan tristique at, hendrerit sed nunc. Quisque diam odio, dignissim quis scelerisque eu, interdum sed nibh. Sed fringilla, enim ac ultricies tristique, lacus ligula aliquet neque, et imperdiet nulla tellus in erat. In pulvinar, urna non semper congue, leo nulla vulputate dolor, et congue dui purus ac risus. Duis accumsan scelerisque consectetur. Nulla nisi justo, interdum sed porttitor a, rhoncus at lorem. Suspendisse sit amet tellus est. Maecenas vestibulum tristique sapien eu interdum. Integer a risus odio. &quot;</span> + <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;Vivamus ac placerat neque. Donec consectetur malesuada lectus, id euismod odio convallis sit amet. Integer eget purus vel neque sagittis blandit.&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> shorttext:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque fermentum lorem in dolor facilisis aliquam dictum libero aliquet. &lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>event:more<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;[more]&lt;/a&gt;.&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">object</span>:UIComponent = <span style="color: #000000; font-weight: bold;">new</span> UIComponent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">object</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage.<span style="color: #0066CC;">multiline</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage.<span style="color: #0066CC;">selectable</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TextEvent.<span style="color: #006600;">LINK</span>, handleLinkClicked<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">object</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>textMessage<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage.<span style="color: #006600;">styleSheet</span> = getTextStyle<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>body<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> + shorttext + <span style="color: #ff0000;">&quot;&lt;/span&gt;&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">400</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;">200</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getTextStyle<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : StyleSheet <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> textStyle:StyleSheet = <span style="color: #000000; font-weight: bold;">new</span> StyleSheet<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> fonts:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Arial, _sans&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textStyle = <span style="color: #000000; font-weight: bold;">new</span> StyleSheet<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textStyle.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;.body&quot;</span>, <span style="color: #66cc66;">&#123;</span>fontFamily:fonts, fontSize:<span style="color: #ff0000;">&quot;12&quot;</span>, fontWeight:<span style="color: #ff0000;">&quot;normal&quot;</span>, <span style="color: #0066CC;">color</span>:<span style="color: #ff0000;">&quot;#222222&quot;</span>, textDecoration:<span style="color: #ff0000;">&quot;none&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textStyle.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;a&quot;</span>, <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">color</span>:<span style="color: #ff0000;">&quot;#245290&quot;</span>, textDecoration:<span style="color: #ff0000;">&quot;none&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textStyle.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;a:hover&quot;</span>, <span style="color: #66cc66;">&#123;</span> textDecoration: <span style="color: #ff0000;">&quot;underline&quot;</span> <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> textStyle;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleLinkClicked<span style="color: #66cc66;">&#40;</span>event:TextEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> prefix:<span style="color: #0066CC;">String</span> = event.<span style="color: #0066CC;">text</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">split</span>:<span style="color: #0066CC;">Array</span> = prefix.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;:&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#91;</span>0<span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> id:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#91;</span>1<span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">split</span>.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&gt;</span> 2<span style="color: #66cc66;">&#41;</span> id = <span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> + <span style="color: #ff0000;">&quot;:&quot;</span> + <span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#91;</span>2<span style="color: #66cc66;">&#93;</span>; <span style="color: #808080; font-style: italic;">// recreate the http link</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span> == <span style="color: #ff0000;">&quot;more&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>body<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> + longtext + <span style="color: #ff0000;">&quot;&lt;/span&gt;&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span> == <span style="color: #ff0000;">&quot;link&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> request:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; navigateToURL<span style="color: #66cc66;">&#40;</span>request,<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></div></td></tr></tbody></table></div>
<p><strong>Workaround</strong></p>
<p>I can&#8217;t remember where in my web travels or blog reading I found this, but there seems to be a need to reset the TextField.htmlText value before setting the TextField.text value within AIR applications to clear the previous content.  I couldn&#8217;t find any official bug that reported this issue.    However, doing this will eliminate the bug and reset the TextField content properly.  So in the event handler for TextEvent, just before setting the content of the TextField, do the <strong>textMessage.htmlText = &#8220;&#8221;</strong>:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleLinkClicked<span style="color: #66cc66;">&#40;</span>event:TextEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> prefix:<span style="color: #0066CC;">String</span> = event.<span style="color: #0066CC;">text</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">split</span>:<span style="color: #0066CC;">Array</span> = prefix.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;:&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#91;</span>0<span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> id:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#91;</span>1<span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">split</span>.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&gt;</span> 2<span style="color: #66cc66;">&#41;</span> id = <span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> + <span style="color: #ff0000;">&quot;:&quot;</span> + <span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#91;</span>2<span style="color: #66cc66;">&#93;</span>; <span style="color: #808080; font-style: italic;">// recreate the http link</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span> == <span style="color: #ff0000;">&quot;more&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage.<span style="color: #0066CC;">htmlText</span> = <span style="color: #ff0000;">&quot;&quot;</span>; &nbsp;<span style="color: #808080; font-style: italic;">// reset the HTML value of the TextField</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textMessage.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>body<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> + longtext + <span style="color: #ff0000;">&quot;&lt;/span&gt;&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span> == <span style="color: #ff0000;">&quot;link&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> request:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; navigateToURL<span style="color: #66cc66;">&#40;</span>request,<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>The issue could be with setting the styles of the link tags of the TextField.  However, I could not reproduce this issue with Flex in a browser, this only occurs within an AIR application.  If anyone can explain why this works or point me to the bug report for this particular issue, please pass it on, thanks!</p>
<p>-Mister</p>
<p><map name='google_ad_map_625_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/625?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_625_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=625&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fair-textfield-bug-when-resetting-html-text%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/air-textfield-bug-when-resetting-html-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Mac OS X Close Behavior to AIR 1.5 Application</title>
		<link>http://www.thanksmister.com/index.php/archive/adding-mac-os-x-close-behavior-to-air-application/</link>
		<comments>http://www.thanksmister.com/index.php/archive/adding-mac-os-x-close-behavior-to-air-application/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 23:36:29 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=598</guid>
		<description><![CDATA[Just a quick post because I have seen this done on other sites but it no longer is valid in AIR 1.5. Most Mac OS X applications minimize to system tray on closing the application using the &#8220;x&#8221; close button on the app. To achieve this in AIR 1.5 you will need to do the [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick post because I have seen this done on other sites but it no longer is valid in AIR 1.5.   Most Mac OS X applications minimize to system tray on closing the application using the &#8220;x&#8221; close button on the app.   To achieve this in AIR 1.5 you will need to do the following on creationComplete event of the main application:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">// on application creation complete setup default Mac OS X behavior</span><br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>NativeApplication.<span style="color: #006600;">supportsMenu</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> &nbsp;<span style="color: #808080; font-style: italic;">// we are on a Mac</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">//this.nativeWindow.addEventListener(InvokeEvent.INVOKE, handleAppInvoke);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>InvokeEvent.<span style="color: #006600;">INVOKE</span>, handleAppInvoke<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">this</span>.<span style="color: #006600;">nativeWindow</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">CLOSING</span>, handleAppHide<span style="color: #66cc66;">&#41;</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">EXITING</span>, handleAppExit<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">autoExit</span> = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span> &nbsp;<span style="color: #808080; font-style: italic;">// we are on a Windows machine</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">this</span>.<span style="color: #006600;">nativeWindow</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">CLOSING</span>, handleAppClosing<span style="color: #66cc66;">&#41;</span>; <br />
&nbsp; &nbsp; NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">autoExit</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">// active that application</span><br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAppInvoke<span style="color: #66cc66;">&#40;</span>event:InvokeEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">nativeWindow</span>.<span style="color: #006600;">activate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">// close all open windows</span><br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAppClosing<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;event.<span style="color: #006600;">preventDefault</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">openedWindows</span>.<span style="color: #0066CC;">length</span> - <span style="color: #cc66cc;">1</span>; i <span style="color: #66cc66;">&gt;</span>= <span style="color: #cc66cc;">0</span>; --i<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NativeWindow<span style="color: #66cc66;">&#40;</span>NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">openedWindows</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">// hide the application instead of closing it</span><br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAppHide<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">this</span>.<span style="color: #006600;">nativeWindow</span>.<span style="color: #0066CC;">visible</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">// if the window is visible the event behaviour is canceld and the window is hidden</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; event.<span style="color: #006600;">preventDefault</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">nativeWindow</span>.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">// close all open windows, remove event listener for hiding application and close applicatin</span><br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAppExit<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">nativeWindow</span>.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">CLOSING</span>, handleAppHide<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">openedWindows</span>.<span style="color: #0066CC;">length</span> - <span style="color: #cc66cc;">1</span>; i <span style="color: #66cc66;">&gt;</span>= <span style="color: #cc66cc;">0</span>; --i<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NativeWindow<span style="color: #66cc66;">&#40;</span>NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">openedWindows</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>- Mister</p>
<p><map name='google_ad_map_598_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/598?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_598_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=598&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fadding-mac-os-x-close-behavior-to-air-application%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/adding-mac-os-x-close-behavior-to-air-application/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PhoneSeek :: Adobe AIR application</title>
		<link>http://www.thanksmister.com/index.php/archive/phoneseek-adobe-air-application/</link>
		<comments>http://www.thanksmister.com/index.php/archive/phoneseek-adobe-air-application/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 05:12:20 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Mate]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[PureMVC]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=301</guid>
		<description><![CDATA[PhoneSeek is an application to track any device that uses InstaMapper. InstaMapper is free real-time GPS tracking service. To use InstaMapper you need a GPS enabled device with the free InstaMapper tracking software installed along with a API Key from InstaMapper&#8217;s web site for each device you own. You can track mobile phones (iPhone, G1, [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="http://farm4.static.flickr.com/3626/3339950794_0e9ba8fc72_o.jpg" class="alignnone" width="231" height="59" border=0 /></p>
<p>PhoneSeek is an application to track any device that uses <a href="http://www.instamapper.com/">InstaMapper</a>. InstaMapper is free real-time GPS tracking service.   To use InstaMapper you need a GPS enabled device with the free InstaMapper tracking software installed along with a API Key from InstaMapper&#8217;s web site for each device you own.   You can track mobile phones (iPhone, G1, Blackberry) or even automobiles.  </p>
<p><strong>Use Case</strong></p>
<p>With PhoneSeek I can add my InstaMapper API Key for my phone and track it from the desktop.   I can also add and track multiple devices.  On my G1 phone, I installed the <a href="http://www.instamapper.com/android">Android</a> version of the InstaMapper tracking software.   This software allows me to send my phone&#8217;s GPS data to InstaMapper service where I can view it either on their website or consume the data through InstaMapper&#8217;s web service.   In PhoneSeek I just add the API Key to begin tracking the advice as soon as your phone starts to transmit GPS data.</p>
<p><strong>Get PhoneSeek</strong></p>
<p><a href="http://thanksmister.com/?page_id=477">Download the latest version from this location.</a></p>
<p><strong>Development Background</strong></p>
<p>PhoneSeek might be used to track devices from your family members, or maybe track down a lost or stolen phone. However, Phoneseek was basically created as a test project to learn <a href="puremvc.org">PureMVC</a> and also experiment with the new <a href="http://code.google.com/apis/maps/documentation/flash/tutorial-flexbuilder.html#AIRDevelopment">Google Maps API SWC</a> for Adobe AIR.  Previous versions of the Google Maps API SWC only worked for web-based applications.</p>
<p>Coming from <a href="http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm">Cairngorm</a> to PureMVC was quite an experience.  At first it was really painful because I had a tendency to over think things, or try to structure things more the Cairngorm ways (like dude, where are my delegates and commands).  </p>
<p>I really had a hard time understanding where to put certain code, like update code, or code to set the window location on startup, and even how to pass around value objects used by more than one view. It took some time to get used to the PureMVC way, but all in all, its not a bad framework to work with.  However, I still prefer Cairngorm and have since started to investigate and really enjoy <a href="http://mate.asfusion.com/">Mate</a>. </p>
<p>Credit for some of the graphics goes to <a href="http://dragonartz.wordpress.com/">DragonArtz Designs</a>.   </p>
<p>- Mister</p>
<p><map name='google_ad_map_301_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/301?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_301_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=301&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fphoneseek-adobe-air-application%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/phoneseek-adobe-air-application/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Storing an ArrayCollection in the EncryptedLocalStore</title>
		<link>http://www.thanksmister.com/index.php/archive/storing-arraycollection-in-encryptedlocalstore/</link>
		<comments>http://www.thanksmister.com/index.php/archive/storing-arraycollection-in-encryptedlocalstore/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 00:47:08 +0000</pubDate>
		<dc:creator>Mister</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Adobe Integrated Runtime]]></category>
		<category><![CDATA[ArrayCollection]]></category>
		<category><![CDATA[describeType]]></category>
		<category><![CDATA[EncryptedLocalStore]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=213</guid>
		<description><![CDATA[On one of my side AIR projects I got the idea to store an ArrayCollection (AC) object into the EncryptedLocalStore (ELS) to have a sort of mini data structure. I thought it would be no problem since you can basically throw anything you want into the EncryptedLocalStore as long as its not over 10MB where [...]]]></description>
			<content:encoded><![CDATA[<p>On one of my side AIR projects I got the idea to store an ArrayCollection (AC) object into the EncryptedLocalStore (ELS) to have a sort of mini data structure.   I thought it would be no problem since you can basically throw anything you want into the EncryptedLocalStore as long as its not over 10MB where performance would be hampered.   I built a little sample script to test the idea by filling an AC with a bunch of value objects.   Upon retrieving the AC from the ELS, I cast it as an AC, but none of the value objects were readable.  I tried casting the value objects, but that threw a runtime error in Flex.    </p>
<p>I did some searching around and found <a href="http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&amp;postid=10563&amp;loc=en_US&amp;productid=4">one example</a> from the <a href="http://www.adobe.com/products/air/" title="Adobe Integrated Runtime" rel="homepage" class="zem_slink">Adobe AIR</a> cookbook that stores and retrieves an value object from the ELS, casting the object as a value object when retrieved.  However, I really wanted to store a whole AC of value objects and retrieve them.    So I did a little more searching and found one blog post that outlines the same issue I was having: <a href="http://corlan.org/2008/07/29/how-to-create-a-generic-function-for-parsing-an-xml-into-an-array-collection-of-objects-of-a-certain-type/">&#8220;when I read the object from disk back into my application, the type of objects from Array Collection is lost.&#8221;</a> </p>
<p>Ok, cool, so the blog post lists a generic function to solve the solution by transforming the objects stored in the AC back to a proper value object.  I wanted to make a little demo that combines the AIR cookbook example with the solution for storing/retrieving AC from the ELS with a slight modification of the generic function. </p>
<p><span id="more-213"></span></p>
<p>The first step is to create our Contact value object similar to the cookbook example:</p>
<p>Contact.as</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package com.<span style="color: #006600;">thanksmister</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Contact<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> firstName:<span style="color: #0066CC;">String</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> lastName:<span style="color: #0066CC;">String</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> phoneNumber:<span style="color: #0066CC;">String</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Contact<span style="color: #66cc66;">&#40;</span>firstName:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>, lastName:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>, phoneNumber:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">firstName</span> = firstName;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">lastName</span> = lastName;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">phoneNumber</span> = phoneNumber;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now we create a function that creates an ArrayCollection of Contact value objects and stores those in the EncryptedLocalStore:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> storeContacts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> contact:Contact = <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;Michael&quot;</span>, <span style="color: #ff0000;">&quot;Ritchie&quot;</span>, <span style="color: #ff0000;">&quot;555-555-5555&quot;</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> ac:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ac.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>contact<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> bytes:ByteArray = <span style="color: #000000; font-weight: bold;">new</span> ByteArray<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bytes.<span style="color: #006600;">writeObject</span><span style="color: #66cc66;">&#40;</span> ac <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; EncryptedLocalStore.<span style="color: #006600;">setItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;contacts&quot;</span>, bytes <span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>Ok, now we have stored out ArrayCollection of Contact VO&#8217;s in the EncryptedLocalStore, now we need to write a function that retrieves the AC and transforms all of the VO&#8217;s back to something that we can utilize within Flex:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> retrieveContacts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// retrieve AC from ELS</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> bytes:ByteArray = EncryptedLocalStore.<span style="color: #006600;">getItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;contacts&quot;</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> collection:ArrayCollection = bytes.<span style="color: #006600;">readObject</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as ArrayCollection;<br />
&nbsp; &nbsp; &nbsp;collection = serializeContacts<span style="color: #66cc66;">&#40;</span>Contact, collection<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// trace our collection value</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>Contact<span style="color: #66cc66;">&#40;</span>collection.<span style="color: #006600;">getItemAt</span><span style="color: #66cc66;">&#40;</span>0<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">firstName</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> serializeContacts<span style="color: #66cc66;">&#40;</span>valueObject:<span style="color: #000000; font-weight: bold;">Class</span>, arryCollection:ArrayCollection<span style="color: #66cc66;">&#41;</span>:ArrayCollection<br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// use the the flash.utils.describeType to create an XML of the property names within the object</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">xml</span>:<span style="color: #0066CC;">XML</span> = describeType<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> valueObject<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> properties:XMLList = <span style="color: #0066CC;">xml</span>..<span style="color: #006600;">accessor</span>.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">name</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> tempac:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// iterate through the collection passed into the function and reassign the types to it's objects</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">object</span>:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> arryCollection<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> tempvo:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> valueObject<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> properties<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempvo<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #0066CC;">object</span><span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tempac.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>tempvo<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//add the item to collection</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// return an ArrayCollection of the Class file passed into the function</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> tempac;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>The above serializeContacts function takes a Class file (VO) and an ArrayCollection pulled from the EncryptedLocalStore using the retrieveContacts function.  The VO is our Contact VO that we want to use to transform our ArrayCollection of objects. This generic function is pretty much what Mihai Corlan used on his blog post, but I changed&#8221; xml..value.@name;&#8221; from the example he posted to &#8220;xml..accessor.@name;&#8221; in my example in this post because the dump using the describeType() utility method the node we want is &#8220;accessor&#8221;.   (The describeType() method returns an xml dump of the details about the object that is passed into the method.  This is a pretty cool function that I previously didn&#8217;t know about.)  Here is the dump of our Contact value object when I trace out the &#8220;xml&#8221; value from the above serializeContacts function:</p>
<p>xml:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>type <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;com.thanksmister::Contact&quot;</span> base=<span style="color: #ff0000;">&quot;Object&quot;</span> isdynamic=<span style="color: #ff0000;">&quot;false&quot;</span> isfinal=<span style="color: #ff0000;">&quot;false&quot;</span> isstatic=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;</span>extendsclass <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;Object&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;</span>implementsinterface <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;flash.events::IEventDispatcher&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;</span>constructor<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> optional=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> optional=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> optional=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;/</span>parameter<span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;</span>accessor <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;lastName&quot;</span> access=<span style="color: #ff0000;">&quot;readwrite&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> declaredby=<span style="color: #ff0000;">&quot;com.thanksmister::Contact&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>metadata <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;Bindable&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>arg <span style="color: #0066CC;">key</span>=<span style="color: #ff0000;">&quot;event&quot;</span> value=<span style="color: #ff0000;">&quot;propertyChange&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>arg<span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;/</span>metadata<span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;</span>method <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;dispatchEvent&quot;</span> declaredby=<span style="color: #ff0000;">&quot;com.thanksmister::Contact&quot;</span> returntype=<span style="color: #ff0000;">&quot;Boolean&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;flash.events::Event&quot;</span> optional=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;/</span>parameter<span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;</span>method <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;hasEventListener&quot;</span> declaredby=<span style="color: #ff0000;">&quot;com.thanksmister::Contact&quot;</span> returntype=<span style="color: #ff0000;">&quot;Boolean&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> optional=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;/</span>parameter<span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;</span>accessor <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;phoneNumber&quot;</span> access=<span style="color: #ff0000;">&quot;readwrite&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> declaredby=<span style="color: #ff0000;">&quot;com.thanksmister::Contact&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>metadata <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;Bindable&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>arg <span style="color: #0066CC;">key</span>=<span style="color: #ff0000;">&quot;event&quot;</span> value=<span style="color: #ff0000;">&quot;propertyChange&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>arg<span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;/</span>metadata<span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;</span>method <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;willTrigger&quot;</span> declaredby=<span style="color: #ff0000;">&quot;com.thanksmister::Contact&quot;</span> returntype=<span style="color: #ff0000;">&quot;Boolean&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> optional=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;/</span>parameter<span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;</span>method <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;removeEventListener&quot;</span> declaredby=<span style="color: #ff0000;">&quot;com.thanksmister::Contact&quot;</span> returntype=<span style="color: #ff0000;">&quot;void&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> optional=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;Function&quot;</span> optional=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;Boolean&quot;</span> optional=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;/</span>parameter<span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;</span>accessor <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;firstName&quot;</span> access=<span style="color: #ff0000;">&quot;readwrite&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> declaredby=<span style="color: #ff0000;">&quot;com.thanksmister::Contact&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>metadata <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;Bindable&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>arg <span style="color: #0066CC;">key</span>=<span style="color: #ff0000;">&quot;event&quot;</span> value=<span style="color: #ff0000;">&quot;propertyChange&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>arg<span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;/</span>metadata<span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;</span>method <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;addEventListener&quot;</span> declaredby=<span style="color: #ff0000;">&quot;com.thanksmister::Contact&quot;</span> returntype=<span style="color: #ff0000;">&quot;void&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span> optional=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;Function&quot;</span> optional=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;Boolean&quot;</span> optional=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;int&quot;</span> optional=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>parameter <span style="color: #0066CC;">index</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;Boolean&quot;</span> optional=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; <span style="color: #66cc66;">&lt;/</span>parameter<span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;/</span>parameter<span style="color: #66cc66;">&gt;</span></div></td></tr></tbody></table></div>
<p>We are interested in the name property of accessor node, and we store those names in an XMLList called &#8220;properties&#8221;.  This XMLList will be used later to assign the values of the Contact properties within the serializeContacts function.    So this gives us a legitimate Contact value objects stored in the ArrayCollection, which we can then use in our application without any errors or null values. </p>
<p>Here is the complete sample application code that can be copied and used in an AIR application:</p>
<p>Main.mxml:</p>
<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:640px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>mx:windowedapplication xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;435&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;277&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;!</span>--<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">thanksmister</span>.<span style="color: #006600;">Contact</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">describeType</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">ByteArray</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> storeContacts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> contact:Contact = <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;Michael&quot;</span>, <span style="color: #ff0000;">&quot;Ritchie&quot;</span>, <span style="color: #ff0000;">&quot;555-555-5555&quot;</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> ac:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ac.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>contact<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> bytes:ByteArray = <span style="color: #000000; font-weight: bold;">new</span> ByteArray<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bytes.<span style="color: #006600;">writeObject</span><span style="color: #66cc66;">&#40;</span> ac <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EncryptedLocalStore.<span style="color: #006600;">setItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;contacts&quot;</span>, bytes <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outPutText.<span style="color: #0066CC;">text</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Contact Stored<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> retrieveContacts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// retrieve AC from ELS</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> bytes:ByteArray = EncryptedLocalStore.<span style="color: #006600;">getItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;contacts&quot;</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> collection:ArrayCollection = bytes.<span style="color: #006600;">readObject</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as ArrayCollection;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; collection = serializeContacts<span style="color: #66cc66;">&#40;</span>Contact, collection<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// trace our collection value</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outPutText.<span style="color: #0066CC;">text</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;First Name: &quot;</span> + Contact<span style="color: #66cc66;">&#40;</span>collection.<span style="color: #006600;">getItemAt</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">firstName</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outPutText.<span style="color: #0066CC;">text</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Last Name: &quot;</span> + Contact<span style="color: #66cc66;">&#40;</span>collection.<span style="color: #006600;">getItemAt</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">lastName</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outPutText.<span style="color: #0066CC;">text</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Phone: &quot;</span> + Contact<span style="color: #66cc66;">&#40;</span>collection.<span style="color: #006600;">getItemAt</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">phoneNumber</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> serializeContacts<span style="color: #66cc66;">&#40;</span>valueObject:<span style="color: #000000; font-weight: bold;">Class</span>, arryCollection:ArrayCollection<span style="color: #66cc66;">&#41;</span>:ArrayCollection<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// use the the flash.utils.describeType to create an XML of the property names within the object</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">xml</span>:<span style="color: #0066CC;">XML</span> = describeType<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> valueObject<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">//trace(xml.toString());</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> properties:XMLList = <span style="color: #0066CC;">xml</span>..<span style="color: #006600;">accessor</span>.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">name</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> tempac:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// iterate through the collection passed into the function and reassign the types to it's objects</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">object</span>:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> arryCollection<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> tempvo:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> valueObject<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> properties<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempvo<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #0066CC;">object</span><span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tempac.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>tempvo<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//add the item to collection</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// return an ArrayCollection of the Class file passed into the function</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> tempac;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>mx:script<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:hbox <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;300&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">button</span> label=<span style="color: #ff0000;">&quot;Store Contacts&quot;</span> click=<span style="color: #ff0000;">&quot;storeContacts()&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">button</span> label=<span style="color: #ff0000;">&quot;Retrieve Contants&quot;</span> click=<span style="color: #ff0000;">&quot;retrieveContacts()&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;/</span>mx:button<span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:textarea id=<span style="color: #ff0000;">&quot;outPutText&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;400&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;200&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;40&quot;</span><span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&lt;/</span>mx:textarea<span style="color: #66cc66;">&gt;</span></div></td></tr></tbody></table></div>
<p>Now we can store and retrieve ArrayCollections from the EncryptedLocalStore without dealing with the hosed object in our application.  Many thanks to Daniel Dura and Mihai Corlan who helped tackle this problem in their contributions to the community.  Sweet!</p>
<p>Update</p>
<p>I recently read a way to persist typed objects when storing them to the ELS, method outlined on <a href="http://soenkerohde.com/2009/04/encryptedlocalstore-file-variable-with-gettersetter/">Sönke Rohde&#8217;s blog</a>.</p>
<p>-Mister</p>
<p><map name='google_ad_map_213_1452acacd61817fb'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/213?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_213_1452acacd61817fb' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=213&amp;url= http%3A%2F%2Fwww.thanksmister.com%2Findex.php%2Farchive%2Fstoring-arraycollection-in-encryptedlocalstore%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.thanksmister.com/index.php/archive/storing-arraycollection-in-encryptedlocalstore/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
