<?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>Johnvh.com - online home of John Van Horn &#187; Flash &amp; Actionscript</title>
	<atom:link href="http://johnvh.com/category/flash-actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnvh.com</link>
	<description>Online home of Dallas, TX based web developer John Van Horn</description>
	<lastBuildDate>Fri, 13 Nov 2009 05:42:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>E4x and as3 gotcha</title>
		<link>http://johnvh.com/2009/06/26/e4x-and-as3-gotcha/</link>
		<comments>http://johnvh.com/2009/06/26/e4x-and-as3-gotcha/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 19:07:42 +0000</pubDate>
		<dc:creator>johnvh</dc:creator>
				<category><![CDATA[Flash & Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[E4X]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://johnvh.com/?p=240</guid>
		<description><![CDATA[I love E4X in AS3. It's powerful and fairly simple. If you haven't worked with it yet, check out Roger Braunstein's excellent tutorial. But I was recently annoyed by this gotcha when doing some xml combining. Let's say you have this:
PLAIN TEXT
XML:




&#60;xml&#62;


&#160; &#160; &#60;people&#62;


&#160; &#160; &#160; &#160; &#60;person id="123"&#62;


&#160; &#160; &#160; &#160; &#160; &#160; &#60;name&#62;John&#60;/name&#62;


&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>I love <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=13_Working_with_XML_01.html">E4X</a> in AS3. It's powerful and fairly simple. If you haven't worked with it yet, check out <a href="http://dispatchevent.org/roger/as3-e4x-rundown/">Roger Braunstein's excellent tutorial.</a> But I was recently annoyed by this gotcha when doing some xml combining. Let's say you have this:</p>
<div class="igBar"><span id="lxml-4"><a href="#" onclick="javascript:showPlainTxt('xml-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-4">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xml<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;people<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;person</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"123"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;name<span style="font-weight: bold; color: black;">&gt;</span></span></span>John<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/name<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/person<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;person<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;name<span style="font-weight: bold; color: black;">&gt;</span></span></span>David<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/name<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/person<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/people<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/xml<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Let's parse with E4X:</p>
<div class="igBar"><span id="lactionscript-5"><a href="#" onclick="javascript:showPlainTxt('actionscript-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-5">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// #1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">xml</span>.<span style="color: #006600;">people</span>.<span style="color: #006600;">person</span>.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// 2</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// #2</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// no animals, but e4x still returns an XMLList</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">xml</span>.<span style="color: #006600;">people</span>.<span style="color: #006600;">animal</span>.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// 0</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// #3</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// no animals, so no further children, but still returns XMList</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">xml</span>.<span style="color: #006600;">people</span>.<span style="color: #006600;">animal</span>.<span style="color: #006600;">fur</span>.<span style="color: #0066CC;">color</span>.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// 0</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// #4</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// gotcha</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">xml</span>.<span style="color: #006600;">people</span>.<span style="color: #006600;">person</span>.<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">"123"</span> == @id <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// thows: ReferenceError: Error #1065: Variable @id is not defined. </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The first 3 examples work great. Even though there are no <code>&lt;animal&gt;</code> nodes, E4X still returns an XMLList. Even looking for more siblings under nodes that don't exist works great - it always returns an empty (but valid) XMLList. Always returning an XMLList makes it easy to work with because you can always for-each over the result. </p>
<p>What I don't understand is the 4th example. It fails because not every <code>&lt;person&gt;</code> node has an id attribute. But so what? If you look at the 2nd and 3rd examples, not every <code>&lt;people&gt;</code> node has an <code>&lt;animal&gt;</code> node. So why don't we get the same result - an empty XMLList?</p>
<p>Turns out that there is an easy solution/work-around, that Roger mentions in his tutorial:</p>
<div class="igBar"><span id="lactionscript-6"><a href="#" onclick="javascript:showPlainTxt('actionscript-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-6">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// will error if every person node does not have an id attribute</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">xml</span>.<span style="color: #006600;">people</span>.<span style="color: #006600;">person</span>.<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">"123"</span> == @id <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// use this</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">xml</span>.<span style="color: #006600;">people</span>.<span style="color: #006600;">person</span>.<span style="color: #66cc66;">&#40;</span> attribute<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">"id"</span> <span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">"123"</span> <span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// 1 </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>A bit <em>wtf</em>, but at least it works like the other examples.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnvh.com/2009/06/26/e4x-and-as3-gotcha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flash&#8217;s secret Javascript API</title>
		<link>http://johnvh.com/2009/04/27/flashs-secret-javascript-api/</link>
		<comments>http://johnvh.com/2009/04/27/flashs-secret-javascript-api/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 03:01:49 +0000</pubDate>
		<dc:creator>johnvh</dc:creator>
				<category><![CDATA[Flash & Actionscript]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://johnvh.com/?p=204</guid>
		<description><![CDATA[Is that a Yahoo! ad in a Youtube player? No. It's a Yahoo! logo in a Youtube player. How did it get there? Via Flash's secret javascript api!
Ok, so it's not really secret. More like old, surely deprecated, and forgotten. I've been working with flash for a good while now, and I had no idea [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_218" class="wp-caption alignleft" style="width: 580px"><img src="http://johnvh.com/wp-content/uploads/2009/04/yahoo-in-youtube2.jpg" alt="Yahoo! invasion" title="yahoo-in-youtube2" width="570" height="381" class="size-full wp-image-218" /><p class="wp-caption-text">Yahoo! invasion</p></div>
<p>Is that a <a href="http://www.yahoo.com">Yahoo!</a> ad in a <a href="http://www.youtube.com">Youtube</a> player? No. It's a Yahoo! logo in a Youtube player. How did it get there? <a href="http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html">Via Flash's secret javascript api!</a></p>
<p>Ok, so it's not really secret. More like old, surely deprecated, and forgotten. I've been working with flash for a good while now, and I had <strong>no idea</strong> this existed until my friend <a href="http://robertames.com/">Robert Ames</a> stumbled upon it.</p>
<p>What's cool (or not cool) about this api, is that it's part of the <em>Flash plugin</em> itself and has nothing to do with Actionscript. All you have to do to enable this api is... well... embed a swf. Try going to a youtube video page like <a href="http://www.youtube.com/watch?v=xp9Gm-aRe5A">this one</a>, and then entering this in the address bar:</p>
<div class="igBar"><span id="ljavascript-8"><a href="#" onclick="javascript:showPlainTxt('javascript-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-8">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javascript: document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">"movie_player"</span> <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">LoadMovie</span><span style="color: #66cc66;">&#40;</span> <span style="color: #CC0000;color:#800000;">98</span>, <span style="color: #3366CC;">"http://l.yimg.com/a/i/ww/beta/y3.gif"</span> <span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I want to play around with this a bit more... I wouldn't be surprised if some of these API methods bypassed some of the Flash Player's security restrictions.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnvh.com/2009/04/27/flashs-secret-javascript-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ignoring files in Flex Builder Navigator</title>
		<link>http://johnvh.com/2009/03/30/ignoring-files-in-flex-builder-navigator/</link>
		<comments>http://johnvh.com/2009/03/30/ignoring-files-in-flex-builder-navigator/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 04:08:53 +0000</pubDate>
		<dc:creator>johnvh</dc:creator>
				<category><![CDATA[Flash & Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex Builder]]></category>

		<guid isPermaLink="false">http://johnvh.com/?p=187</guid>
		<description><![CDATA[I don't like seeing .svn or CVS files in my Flex Builder/Eclipse workspace. I'll never need to edit those files directly, and if I do, I won't use Flex Builder to do it. But if they're in your project, they'll show up in the Navigator panel. Everywhere.
Fortunately, Eclipse provides a way to filter files in [...]]]></description>
			<content:encoded><![CDATA[<p>I don't like seeing .svn or CVS files in my Flex Builder/Eclipse workspace. I'll never need to edit those files directly, and if I do, I won't use Flex Builder to do it. But if they're in your project, they'll show up in the Navigator panel. Everywhere.</p>
<div id="attachment_188" class="wp-caption alignleft" style="width: 410px"><img src="http://johnvh.com/wp-content/uploads/2009/03/flex-navigator-before.png" alt="Every directory in your project will have a .svn folder." title="flex-navigator-before" width="400" height="410" class="size-full wp-image-188" /><p class="wp-caption-text">Every directory in your project will have a .svn folder.</p></div>
<p>Fortunately, Eclipse provides a way to filter files in the Navigator, but a) it's rather hidden, and b) it's not obvious how to add filters. In the Navigator panel, hit the down arrow in the top right corner and select "Filters...".</p>
<div id="attachment_192" class="wp-caption alignleft" style="width: 535px"><img src="http://johnvh.com/wp-content/uploads/2009/03/flex-navigator-dropdown.png" alt="Navigator panel options." title="flex-navigator-dropdown" width="525" height="254" class="size-full wp-image-192" /><p class="wp-caption-text">Navigator panel options.</p></div>
<p>Here's the list of filters you get by default:</p>
<div id="attachment_193" class="wp-caption alignleft" style="width: 394px"><img src="http://johnvh.com/wp-content/uploads/2009/03/flex-navigator-filters-default.png" alt="Default Filters" title="flex-navigator-filters-default" width="384" height="472" class="size-full wp-image-193" /><p class="wp-caption-text">Default Filters</p></div>
<p>What? No "add filter" option? No "edit"? I guess you could use the ".*" filter, but that would hide every file or directory whose name starts with ".". That may or may not be acceptable, depending on the type of project or files your working with. What if you had a <code>.htaccess</code> file in your project? </p>
<p>Fortunately again, there is a mechanism for adding additional filters, but it's not obvious. It involves editing the <em>plugins.xml</em> file for the Flex Builder editor plugin. You can find this plugin in the eclipse plugins folder (located in same place as <code>Flex Builder.app</code>) in your Flex Builder install. It's called <code>com.adobe.flexbuilder.standalone_3.0.194161</code>, and it's located for me at:</p>
<div class="igBar"><span id="lcode-11"><a href="#" onclick="javascript:showPlainTxt('code-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-11">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/Applications/Adobe Flex Builder <span style="color:#800000;color:#800000;">3</span>/plugins/com.<span style="">adobe</span>.<span style="">flexbuilder</span>.<span style="">standalone_3</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">194161</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>So navigate there, and edit <code>plugins.xml</code>.  You're looking for the <code>extension</code> node whose attribute point is "org.eclipse.ui.ide.resourceFilters". Under that node is where the default filters are defined. All you have to do is add another one and save the file:</p>
<div id="attachment_195" class="wp-caption alignleft" style="width: 478px"><img src="http://johnvh.com/wp-content/uploads/2009/03/flex-plugin-xml.png" alt="Flex Builder editor plugin.xml, with svn filter added." title="flex-plugin-xml" width="468" height="359" class="size-full wp-image-195" /><p class="wp-caption-text">Flex Builder editor plugin.xml, with svn filter added.</p></div>
<p>The remaining step is to restart Flex Builder, using the <code>-clean</code> option. Since the plugin.xml file is either cached or compiled in somewhere, using the <code>-clean</code> option tells the Eclipse executable to reload all plugins and configs. This requires use of the Terminal:</p>
<div class="igBar"><span id="lcode-12"><a href="#" onclick="javascript:showPlainTxt('code-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-12">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$ cd /Applications/Adobe\ Flex\ Builder\ <span style="color:#800000;color:#800000;">3</span>/Flex\ Builder.<span style="">app</span>/Contents/MacOS</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$ ./FlexBuilder -clean </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>When Flex Builder launches, you should now see the filter you just added in the filters window. Thanks to <a href="http://robertames.com/">Robert Ames</a> for telling me how to launch Flex Builder with arguments.</p>
<div id="attachment_199" class="wp-caption alignleft" style="width: 395px"><img src="http://johnvh.com/wp-content/uploads/2009/03/flex-navigator-after.png" alt="New filter added." title="flex-navigator-after" width="385" height="472" class="size-full wp-image-199" /><p class="wp-caption-text">New filter added.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://johnvh.com/2009/03/30/ignoring-files-in-flex-builder-navigator/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Are your event handlers bad?</title>
		<link>http://johnvh.com/2009/03/16/are-your-event-handlers-bad/</link>
		<comments>http://johnvh.com/2009/03/16/are-your-event-handlers-bad/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 04:42:46 +0000</pubDate>
		<dc:creator>johnvh</dc:creator>
				<category><![CDATA[Flash & Actionscript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://johnvh.com/?p=167</guid>
		<description><![CDATA[Event handlers can be bad. They're not intrinsically bad - that's how shit gets done in AS3. It's the way they often get written that can be bad. Consider the following example:
PLAIN TEXT
Actionscript:




package 


&#123;


&#160; &#160; import fl.motion.Color;


&#160; &#160; 


&#160; &#160; import flash.display.DisplayObject;


&#160; &#160; import flash.display.Sprite;


&#160; &#160; import flash.events.Event;


&#160; &#160; import flash.events.MouseEvent;


&#160;


&#160; &#160; public class Nothing [...]]]></description>
			<content:encoded><![CDATA[<p>Event handlers can be bad. They're not intrinsically bad - that's how shit gets done in AS3. It's the way they often get written that can be bad. Consider the following example:</p>
<div class="igBar"><span id="lactionscript-15"><a href="#" onclick="javascript:showPlainTxt('actionscript-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-15">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">motion</span>.<span style="color: #0066CC;">Color</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">DisplayObject</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Nothing <span style="color: #0066CC;">extends</span> Sprite</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> square:Sprite;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Nothing<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; square = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; square.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span> 0xFFFFFF, <span style="color: #cc66cc;color:#800000;">1</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; square.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;color:#800000;">0</span>, <span style="color: #cc66cc;color:#800000;">0</span> , <span style="color: #cc66cc;color:#800000;">50</span>, <span style="color: #cc66cc;color:#800000;">50</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; square.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; square.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">CLICK</span>, click <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addChild<span style="color: #66cc66;">&#40;</span> square <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> click<span style="color: #66cc66;">&#40;</span> event:MouseEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> clickedObject:DisplayObject = event.<span style="color: #0066CC;">target</span> as DisplayObject;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> tint:uint = 0xFF0000;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">color</span>:<span style="color: #0066CC;">Color</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Color</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">color</span>.<span style="color: #006600;">setTint</span><span style="color: #66cc66;">&#40;</span> tint, <span style="color: #cc66cc;color:#800000;">1</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clickedObject.<span style="color: #006600;">transform</span>.<span style="color: #006600;">colorTransform</span> = <span style="color: #0066CC;">color</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Great. So a sprite is tinted red when its clicked. But what happens when you have to tint that sprite at other times, like when the application loads? All the code that does the tinting is locked up inside the event handler - the problem there is that <strong>the event handler needs a <code>MouseEvent</code> to run.</strong></p>
<p>A better, more reusable, and more modular approach would be:</p>
<div class="igBar"><span id="lactionscript-16"><a href="#" onclick="javascript:showPlainTxt('actionscript-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-16">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> tint<span style="color: #66cc66;">&#40;</span> obj:DisplayObject <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> tint:uint = 0xFF0000; <span style="color: #808080; font-style: italic;">//or better, make this an argument</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">color</span>:<span style="color: #0066CC;">Color</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Color</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">color</span>.<span style="color: #006600;">setTint</span><span style="color: #66cc66;">&#40;</span> tint, <span style="color: #cc66cc;color:#800000;">1</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; obj.<span style="color: #006600;">transform</span>.<span style="color: #006600;">colorTransform</span> = <span style="color: #0066CC;">color</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> click<span style="color: #66cc66;">&#40;</span> event:MouseEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> clickedObject:DisplayObject = event.<span style="color: #0066CC;">target</span> as DisplayObject;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; tint<span style="color: #66cc66;">&#40;</span> clickedObject <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>You see? The event handler just notifies us that something needs to be tinted. The actual tinting happens elsewhere. Now, code that does work does not need anything other than a reference to a <code>DisplayObject</code> to run! Now, you can tint an object when the application loads. You can tint an object on a timer. Now, you can tint anything, at anytime! Now its testable and reusable! And, it's a very easy concept to master.</p>
<blockquote><p>
Get what you need from an event object, <strong>and get out.</strong>
</p></blockquote>
<p>When you write event handlers, think about what they are actually doing. What do you actually need from the event object? How would you test the event handler? Or better yet, how would you make the same thing that happens in the event handler, happen without the event?</p>
]]></content:encoded>
			<wfw:commentRss>http://johnvh.com/2009/03/16/are-your-event-handlers-bad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
