<?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>blog.betabong.com &#187; Flex</title>
	<atom:link href="http://blog.betabong.com/category/tech/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.betabong.com</link>
	<description></description>
	<lastBuildDate>Thu, 13 May 2010 09:49:40 +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>Flash Debug Speed</title>
		<link>http://blog.betabong.com/2009/04/05/flash-debug-speed/</link>
		<comments>http://blog.betabong.com/2009/04/05/flash-debug-speed/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 00:49:46 +0000</pubDate>
		<dc:creator>betabong</dc:creator>
				<category><![CDATA[Flash & more]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Flash Player]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=225</guid>
		<description><![CDATA[I did some speed tests today, comparing two string parsing methods. And I&#8217;ve made some very interesting discoveries: The execution speed between SWF compiled for debugging and those compiled without differs.
Ha! Okay, that&#8217;s not that much of news (even for me). But what astonishes me is how much this speed gap can be, especially when [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2009/04/27/switch-flash-browser-plugin-mac/' rel='bookmark' title='Permanent Link: Switch Flash Browser Plugin on Mac OS X'>Switch Flash Browser Plugin on Mac OS X</a></li><li><a href='http://blog.betabong.com/2008/08/22/flash-player-10-i-love-speed/' rel='bookmark' title='Permanent Link: Flash Player 10 – I love speed'>Flash Player 10 – I love speed</a></li><li><a href='http://blog.betabong.com/2008/12/06/test-flex-throttled-simulate-download/' rel='bookmark' title='Permanent Link: Test Flex/Flash throttled (aka Simulate Download)'>Test Flex/Flash throttled (aka Simulate Download)</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I did some speed tests today, comparing two string parsing methods. And I&#8217;ve made some very interesting discoveries: The execution speed between SWF compiled for debugging and those compiled without differs.</p>
<p>Ha! Okay, that&#8217;s not that much of news (even for me). But what astonishes me is how much this speed gap can be, especially when it comes to massive data calculations. I somehow always had a somewhat 20 percent speed decrease in mind (I was just presuming, me dumb). But for a 3d particle test we&#8217;re talking factor 8!!</p>
<p>Now this made me curious&#8230; so I&#8217;ve tested with Debug and Release Player both debug and release SWFs:</p>
<p><strong>Debug Player running Debug SWF</strong></p>
<p><strong><a href="http://blog.betabong.com/wp-content/uploads/2009/04/picture-11.png" rel="lightbox[225]"><img class="alignnone size-full wp-image-226" title="Flash Debug in Debug" src="http://blog.betabong.com/wp-content/uploads/2009/04/picture-11.png" alt="Flash Debug in Debug" width="428" height="185" /></a></strong></p>
<p><strong>Debug Player running Release SWF</strong></p>
<p><strong><a href="http://blog.betabong.com/wp-content/uploads/2009/04/picture-9.png" rel="lightbox[225]"><img class="alignnone size-full wp-image-227" title="Release in Debug" src="http://blog.betabong.com/wp-content/uploads/2009/04/picture-9.png" alt="Release in Debug" width="428" height="185" /></a></strong></p>
<p><strong>Release Player running Debug SWF</strong></p>
<p><strong><a href="http://blog.betabong.com/wp-content/uploads/2009/04/picture-12.png" rel="lightbox[225]"><img class="alignnone size-full wp-image-228" title="Debug in Release" src="http://blog.betabong.com/wp-content/uploads/2009/04/picture-12.png" alt="Debug in Release" width="427" height="181" /></a></strong></p>
<p><strong>Release Player running Release SWF</strong></p>
<p><strong><a href="http://blog.betabong.com/wp-content/uploads/2009/04/picture-13.png" rel="lightbox[225]"><img class="alignnone size-full wp-image-229" title="Release in Release" src="http://blog.betabong.com/wp-content/uploads/2009/04/picture-13.png" alt="Release in Release" width="427" height="185" /></a></strong></p>
<p><strong>A few conclusions:</strong></p>
<ul>
<li><strong>Never release a SWF file with debug code</strong> (or otherwise said: put only stuff online from bin-release, never bin-debug). Though common users won&#8217;t notice the speed decrease, your friendly flash developers may, at least if you&#8217;re app is somewhat cpu intensive. And of course: debug SWF are much bigger in size (just in case you give a fuck about flash devs ;-)</li>
<li><strong>Speed tests should be played in the release player.</strong> Why? After all, I wouldn&#8217;t care if the relation would stay the same. Usually you just need to know how much faster one thing is compared to the other one, so that would do it. But unfortunately the ratio won&#8217;t always be the same. In the above example the ration is 3.66 for debug and 2.92 for release. And it can differ muuuuch more.</li>
</ul>
<p>The last one bugs me quite a bit. It&#8217;s just a pain in the ass to export a release build each time you wanna compare performance. And it also means you can&#8217;t do quick&#8217;n'dirty trace outputs for the time result (not a biggy if you&#8217;re testing within a Flex project though).</p>
<p>So here we go with <strong>two wishes for Adobe</strong>:</p>
<ul>
<li>Let us quickly test release builds within Flex Builder (a simple command would do it – I thought it might be «Run Testapp» (instead of «Debug Testapp»), but that just doesn&#8217;t bring up the Debugger (and same speed)</li>
<li>An option to turn off debugging mode in Debug Player!!! That would solve almost all problems, and we could also use our Plugin for normal browsing without performance penalties (is this why Youtube eats so much cpu here?</li>
</ul>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2009/04/27/switch-flash-browser-plugin-mac/' rel='bookmark' title='Permanent Link: Switch Flash Browser Plugin on Mac OS X'>Switch Flash Browser Plugin on Mac OS X</a></li><li><a href='http://blog.betabong.com/2008/08/22/flash-player-10-i-love-speed/' rel='bookmark' title='Permanent Link: Flash Player 10 – I love speed'>Flash Player 10 – I love speed</a></li><li><a href='http://blog.betabong.com/2008/12/06/test-flex-throttled-simulate-download/' rel='bookmark' title='Permanent Link: Test Flex/Flash throttled (aka Simulate Download)'>Test Flex/Flash throttled (aka Simulate Download)</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2009/04/05/flash-debug-speed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embed Assets in Flash Project</title>
		<link>http://blog.betabong.com/2009/02/13/embed-assets-in-flash-project/</link>
		<comments>http://blog.betabong.com/2009/02/13/embed-assets-in-flash-project/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 13:00:18 +0000</pubDate>
		<dc:creator>betabong</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flash IDE]]></category>
		<category><![CDATA[Flex Builder]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=190</guid>
		<description><![CDATA[There&#8217;s still quite a gap between Flash and Flex – while Flash is great for creating animations, vector symbols and just keeping little assets within one place, Flex Builder is so very much better for anything code. So how to link those two together?
Though I&#8217;ve written some posts about how to code within Flex Builder [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/' rel='bookmark' title='Permanent Link: Test Movie from Flex to Flash (easy way)'>Test Movie from Flex to Flash (easy way)</a></li><li><a href='http://blog.betabong.com/2008/12/06/test-flex-throttled-simulate-download/' rel='bookmark' title='Permanent Link: Test Flex/Flash throttled (aka Simulate Download)'>Test Flex/Flash throttled (aka Simulate Download)</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s still quite a gap between Flash and Flex – while Flash is great for creating animations, vector symbols and just keeping little assets within one place, Flex Builder is so very much better for anything code. So how to link those two together?</p>
<p>Though I&#8217;ve written some posts about how to code within Flex Builder and <a href="/2008/12/03/test-movie-from-flex-to-flash-easy-way/">compile from there using Flash IDE</a>, I personally don&#8217;t like that at all and only use it for some few older AS3 projects. There are better methods, ways to compile from within Flex Builder while still being able to make use of Flash comfort.</p>
<p>There&#8217;s a neat way to <strong>embed a library</strong> without loosing any functionality (like little scripts). I&#8217;ve first seen it at <a href="http://www.gskinner.com/blog/archives/2007/03/using_flash_sym.html">Grant Skinner</a> (who&#8217;s doing great stuff, one of my favorites in the flash community really). Let&#8217;s say, you have a assets.fla and a published assets.swf. Now here we go:<span id="more-190"></span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;750&quot;</span>, <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;500&quot;</span>, frameRate=<span style="color: #ff0000;">&quot;30&quot;</span>, <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">&quot;#111111&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">dynamic</span> <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyApplication <span style="color: #0066CC;">extends</span> Sprite
<span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">&quot;assets/assets.swf&quot;</span>, mimeType=<span style="color: #ff0000;">&quot;application/octet-stream&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> StageAssets:<span style="color: #000000; font-weight: bold;">Class</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> GlobusFlow<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		loadEmbedded<span style="color: #66cc66;">&#40;</span> StageAssets <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> loadEmbedded<span style="color: #66cc66;">&#40;</span> cls : <span style="color: #000000; font-weight: bold;">Class</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;[Preloader] Loading embedded&quot;</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> loader : Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		loader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">COMPLETE</span> , <span style="color: #0066CC;">this</span>.<span style="color: #006600;">handleComplete</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> context : LoaderContext = <span style="color: #000000; font-weight: bold;">new</span> LoaderContext<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">false</span> , ApplicationDomain.<span style="color: #006600;">currentDomain</span> <span style="color: #66cc66;">&#41;</span>;
		loader.<span style="color: #006600;">loadBytes</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> cls<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> , context <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> handleComplete<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span> : Event <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> app : Sprite = Sprite<span style="color: #66cc66;">&#40;</span> LoaderInfo<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span> <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">content</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">loaded</span><span style="color: #66cc66;">&#40;</span> app <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">loaded</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">target</span>:Sprite<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">background</span> : <span style="color: #0066CC;">MovieClip</span> = <span style="color: #0066CC;">target</span> as <span style="color: #0066CC;">MovieClip</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> mainChildren : <span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
		<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> = <span style="color: #cc66cc;">0</span> ; i<span style="color: #66cc66;">&lt;</span>background.<span style="color: #006600;">numChildren</span> ; i++ <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			mainChildren.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">background</span>.<span style="color: #006600;">getChildAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> child : DisplayObject <span style="color: #b1b100;">in</span> mainChildren <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> child.<span style="color: #0066CC;">name</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#91;</span> child.<span style="color: #0066CC;">name</span> <span style="color: #66cc66;">&#93;</span> = child;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> child <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span> = <span style="color: #0066CC;">background</span>.<span style="color: #0066CC;">width</span>;
		<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span> = <span style="color: #0066CC;">background</span>.<span style="color: #0066CC;">height</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>This does a bit more than just make the library available. In loaded() we&#8217;ll loop through all assets that are «on stage» in the loaded/embedded movieclip (assets.swf), and add each of them to our stage. That leads to a state that&#8217;s quite similar to as if we&#8217;d code within assets.fla itself. Hmm&#8230; well, really, that sounds more complicated than it is :-) It mainly gives you the feeling of being able to code within a SWF file. You can visually do your stuff in assets.fla, you can add a background and whatever to its stage, keep a nice library with graphics, animations, sounds and fonts.. and schwupps, here you go!</p>
<p>If you have Fonts embedded in your library, there&#8217;s a tiny little more to do:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">protected <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">loaded</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">target</span>:Sprite<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// ... (all the other stuff, see above)</span>
	registerFont<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'BoldFont'</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> registerFont<span style="color: #66cc66;">&#40;</span> fontLinkageId : <span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> fontClass : <span style="color: #000000; font-weight: bold;">Class</span> = getDefinitionByName<span style="color: #66cc66;">&#40;</span> fontLinkageId <span style="color: #66cc66;">&#41;</span> as <span style="color: #000000; font-weight: bold;">Class</span>;
	<span style="color: #0066CC;">Font</span>.<span style="color: #006600;">registerFont</span><span style="color: #66cc66;">&#40;</span> fontClass <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>If you just wanna embed fonts without any registering, you can also go like that:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">'assets/fonts.swf'</span> , symbol=<span style="color: #ff0000;">'BoldFont'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> BoldFont : <span style="color: #000000; font-weight: bold;">Class</span>;</pre></div></div>

<p>Of course, instead of embedding everything, you can also load this dynamically (I mean, after all we have the Loader ready, don&#8217;t we? :) The advantage of that is that you can give your assets to some dumb Flasher and he can mess around with it without you having to recompile the app.</p>
<p>I know, this is all snippets and frickets, I&#8217;m just too lazy right now to build an example Flex project. Still I hope it&#8217;s of some use for one or the other.</p>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/' rel='bookmark' title='Permanent Link: Test Movie from Flex to Flash (easy way)'>Test Movie from Flex to Flash (easy way)</a></li><li><a href='http://blog.betabong.com/2008/12/06/test-flex-throttled-simulate-download/' rel='bookmark' title='Permanent Link: Test Flex/Flash throttled (aka Simulate Download)'>Test Flex/Flash throttled (aka Simulate Download)</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2009/02/13/embed-assets-in-flash-project/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Test Flex/Flash throttled (aka Simulate Download)</title>
		<link>http://blog.betabong.com/2008/12/06/test-flex-throttled-simulate-download/</link>
		<comments>http://blog.betabong.com/2008/12/06/test-flex-throttled-simulate-download/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 15:52:55 +0000</pubDate>
		<dc:creator>betabong</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Browser]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flex Builder]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=161</guid>
		<description><![CDATA[Most of the Flash application deal with server side data like images, xml files etc. We tend to forget about that because the default Run or Debug commands in Flex will open a local html file (and also because we developers often have quite a nice internet connection when testing remotely). Thus all data is [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/' rel='bookmark' title='Permanent Link: Test Movie from Flex to Flash (easy way)'>Test Movie from Flex to Flash (easy way)</a></li><li><a href='http://blog.betabong.com/2008/11/29/flex-builder-t-flash-ide/' rel='bookmark' title='Permanent Link: Develop in Flex Builder, publish in Flash IDE (Mac OS X)'>Develop in Flex Builder, publish in Flash IDE (Mac OS X)</a></li><li><a href='http://blog.betabong.com/2009/04/05/flash-debug-speed/' rel='bookmark' title='Permanent Link: Flash Debug Speed'>Flash Debug Speed</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Most of the Flash application deal with server side data like images, xml files etc. We tend to forget about that because the default Run or Debug commands in Flex will open a local html file (and also because we developers often have quite a nice internet connection when testing remotely). Thus all data is loaded nearly instantely.</p>
<p>In Flash we have a menu command called <strong>«Simulate Download»</strong> to see how things run at different bandwidth situations. <strong>But how to achieve this in Flex?</strong></p>
<p>I&#8217;ve been using Sloppy for a long time. It&#8217;s little java app that can be started via a simple web click. It&#8217;s really easy to use and does very well what it does. For debugging your app (your flash website) throttled in Flex Builder simply follow these steps:</p>
<p> </p>
<ol>
<li><a href="http://www.dallaway.com/sloppy/">Open the <strong>Sloppy website</strong></a></li>
<li>Click the little <strong>Sloppy icon</strong>:<br />
<a href="http://blog.betabong.com/wp-content/uploads/2008/12/picture-10.png" rel="lightbox[161]"><img class="alignnone size-full wp-image-162" title="picture-10" src="http://blog.betabong.com/wp-content/uploads/2008/12/picture-10.png" alt="" width="233" height="41" /><br />
</a></li>
<li>A «sloppy.jnlp» file is downloaded. <strong>Open it</strong> if doesn&#8217;t open automatically.</li>
<li>The actual application will be downloaded and started. If it asks you to trust: <strong>trust!</strong> :-)</li>
<li><strong>Enter the address</strong> of your html file in the bin-debug or bin-release folder. It should be a webserver address. I usually create a <a href="http://www.macupdate.com/info.php/id/10433/symboliclinker">symbolic link</a> of my project directory and put it into my local webserver directory.<br />
<a href="http://blog.betabong.com/wp-content/uploads/2008/12/picture-11.png" rel="lightbox[161]"></a><a href="http://blog.betabong.com/wp-content/uploads/2008/12/picture-11.png" rel="lightbox[161]"><img class="alignnone size-full wp-image-163" title="picture-11" src="http://blog.betabong.com/wp-content/uploads/2008/12/picture-11.png" alt="" width="501" height="453" /></a></li>
<li><strong>Click «Go»</strong> – this will start the Sloppy proxy and open the page in your default browser. </li>
<li><strong>Copy the address</strong> from the browser window (usually http://127.0.0.1:7569/your/path)<br />
<a href="http://blog.betabong.com/wp-content/uploads/2008/12/picture-12.png" rel="lightbox[161]"><img class="alignnone size-full wp-image-164" title="picture-12" src="http://blog.betabong.com/wp-content/uploads/2008/12/picture-12.png" alt="" width="375" height="34" /></a></li>
<li>You may close the window. Go to Flex Builder and <strong>open the project properties</strong> (right click on project folder, last item). In an Actionscript Project, switch to ActionScript Build Path.<br />
<a href="http://blog.betabong.com/wp-content/uploads/2008/12/picture-14.png" rel="lightbox[161]"><img class="alignnone size-medium wp-image-165" title="picture-14" src="http://blog.betabong.com/wp-content/uploads/2008/12/picture-14-300x289.png" alt="" width="300" height="289" /></a> </li>
<li>Enter the copied address into <strong>«Output folder URL»</strong>, clear the html name (e.g. App.html).<br />
<a href="http://blog.betabong.com/wp-content/uploads/2008/12/picture-15.png" rel="lightbox[161]"><img class="alignnone size-full wp-image-166" title="picture-15" src="http://blog.betabong.com/wp-content/uploads/2008/12/picture-15.png" alt="" width="423" height="40" /></a></li>
<li>Click «OK» and <strong>you&#8217;re done</strong>. You can now Run and Debug as if your website was hosted on some server and you had a 256K ADSL connection (instead of your T1).</li>
</ol>
<p>Note: I tried to automate the whole thing (with Ant of course) and succeeded to a certain limit. What I did was download <a href="http://code.google.com/p/sloppy/">Sloopy&#8217;s source code</a> (java), modify it so it can handle more terminal attributes and build the  .jar file. This can be run on command line, which will start the sloopy server. So I created an ant file that does all that for me, but this ant file would only be cool, if it could also trigger the run or debug commands and modify the output folder url. I haven&#8217;t found a way (at least not a satisfying one) to do this, so I might just follow the manual street for once ;)</p>
<p>Another note: If you are windows user, you might wanna try this Firefox plugin: <a href="https://addons.mozilla.org/en-US/firefox/addon/5917">Firefox Throttle</a></p>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/' rel='bookmark' title='Permanent Link: Test Movie from Flex to Flash (easy way)'>Test Movie from Flex to Flash (easy way)</a></li><li><a href='http://blog.betabong.com/2008/11/29/flex-builder-t-flash-ide/' rel='bookmark' title='Permanent Link: Develop in Flex Builder, publish in Flash IDE (Mac OS X)'>Develop in Flex Builder, publish in Flash IDE (Mac OS X)</a></li><li><a href='http://blog.betabong.com/2009/04/05/flash-debug-speed/' rel='bookmark' title='Permanent Link: Flash Debug Speed'>Flash Debug Speed</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2008/12/06/test-flex-throttled-simulate-download/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Test Movie from Flex to Flash (easy way)</title>
		<link>http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/</link>
		<comments>http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 11:23:33 +0000</pubDate>
		<dc:creator>betabong</dc:creator>
				<category><![CDATA[Flash & more]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Ant]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flex Builder]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=154</guid>
		<description><![CDATA[I figured a much much easier (compared to this) way to trigger Test Movie in Flash IDE from within Flex. What you&#8217;ll still need is Ant (here&#8217;s how to install), but that&#8217;s all you gonna need apart from Flex Builder and Flash. That&#8217;s the simplest ant build file to achieve this:

&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;
&#60;project name=&#34;Publish&#34; default=&#34;Publish&#34; [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2008/12/06/test-flex-throttled-simulate-download/' rel='bookmark' title='Permanent Link: Test Flex/Flash throttled (aka Simulate Download)'>Test Flex/Flash throttled (aka Simulate Download)</a></li><li><a href='http://blog.betabong.com/2008/11/29/flex-builder-t-flash-ide/' rel='bookmark' title='Permanent Link: Develop in Flex Builder, publish in Flash IDE (Mac OS X)'>Develop in Flex Builder, publish in Flash IDE (Mac OS X)</a></li><li><a href='http://blog.betabong.com/2008/07/16/flex-project-svn-strategy/' rel='bookmark' title='Permanent Link: Flex Project &#8211; SVN Strategy'>Flex Project &#8211; SVN Strategy</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I figured a much much easier (<a href="http://blog.betabong.com/2008/11/29/flex-builder-t-flash-ide">compared to this</a>) way to trigger Test Movie in Flash IDE from within Flex. What you&#8217;ll still need is Ant (<a href="http://blog.jodybrewster.net/2008/04/09/installing-ant-in-flex-builder-3/">here&#8217;s how to install</a>), but that&#8217;s all you gonna need apart from Flex Builder and Flash. That&#8217;s the simplest ant build file to achieve this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Publish&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;Publish&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;./&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #808080; font-style: italic;">&lt;!-- project specifics --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Publish&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;concat</span> <span style="color: #000066;">destfile</span>=<span style="color: #ff0000;">&quot;build.jsfl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			fl.getDocumentDOM().testMovie();
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/concat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;open&quot;</span> <span style="color: #000066;">failonerror</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">logerror</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;build.jsfl&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;delete</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;build.jsfl&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This tests the frontmost document in Flash IDE. (basically what does <a href="http://theflashblog.com/?p=482">this plugin</a>). Tested on Mac OS X 10.5.5 with Flex Builder Pro 3.0.2 and Flash CS4.</p>
<p>No need for <a href="http://www.mikechambers.com/blog/2008/05/02/flashcommand-for-os-x-updated-to-work-with-flash-cs3/">FlashCommand</a>. No need to alter the file for other projects. Just a super easy file for people with not too many requirements. </p>
<p>You can still go more advanced with something like that:<br />
<span id="more-154"></span></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Build Project&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;Publish and Test&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;../&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #808080; font-style: italic;">&lt;!-- common --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;browser&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Safari&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;log.path&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${user.home}/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- project specifics --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;fla.path&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${basedir}/main.fla&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;swf.path&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${basedir}/result.swf&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;test.path&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;http://localhost/projects/test/index.html&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Publish and Test&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;antcall</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;Publish&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;antcall</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;Clear Log&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;antcall</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;Open in Browser&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- publish swf --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Publish&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;concat</span> <span style="color: #000066;">destfile</span>=<span style="color: #ff0000;">&quot;build.jsfl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			var sourceFile = &quot;#FLA#&quot;;
			var outputFile = &quot;#SWF#&quot;;
			var doc = fl.getDocumentDOM();
			if ( !doc || sourceFile.indexOf( doc.path ) <span style="color: #ddbb00;">&amp;lt;</span> 0 ) {
				doc = fl.openDocument(sourceFile);
			}
			doc.exportSWF(outputFile, true);
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filterchain<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;replacetokens</span> <span style="color: #000066;">begintoken</span>=<span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">endtoken</span>=<span style="color: #ff0000;">&quot;#&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;token</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;FLA&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;file:///${fla.path}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;token</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;SWF&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;file:///${swf.path}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/replacetokens<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filterchain<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/concat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;open&quot;</span> <span style="color: #000066;">failonerror</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">logerror</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;build.jsfl&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;delete</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;build.jsfl&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- Open in local browser --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Open in Browser&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;open&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-a ${browser} ${test.path}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- Clear Debug Log --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Clear Log&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;concat</span> <span style="color: #000066;">destfile</span>=<span style="color: #ff0000;">&quot;${log.path}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>                                                                                                            
		.: Sev Log File :.
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/concat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;open&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-a console '${log.path}'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This has pretty much the same results as <a href="http://blog.betabong.com/2008/11/29/flex-builder-t-flash-ide/">posted here</a>.</p>
<p>I have created a Flex Project that contains all necessary files (fla, main class, build file). Just download and import into Flex:</p>
<p><a class="download" href='http://blog.betabong.com/wp-content/uploads/2008/12/flaproject.zip'> Download Flex Project</a></p>
<p><strong>Update: </strong>Mirko Sablijic sent me a Hello World project for Windows (he runs Vista):</p>
<p><a class="download" href='http://blog.betabong.com/wp-content/uploads/2008/12/helloworld.zip'>Download Flex Project (Windows)</a></p>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2008/12/06/test-flex-throttled-simulate-download/' rel='bookmark' title='Permanent Link: Test Flex/Flash throttled (aka Simulate Download)'>Test Flex/Flash throttled (aka Simulate Download)</a></li><li><a href='http://blog.betabong.com/2008/11/29/flex-builder-t-flash-ide/' rel='bookmark' title='Permanent Link: Develop in Flex Builder, publish in Flash IDE (Mac OS X)'>Develop in Flex Builder, publish in Flash IDE (Mac OS X)</a></li><li><a href='http://blog.betabong.com/2008/07/16/flex-project-svn-strategy/' rel='bookmark' title='Permanent Link: Flex Project &#8211; SVN Strategy'>Flex Project &#8211; SVN Strategy</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Develop in Flex Builder, publish in Flash IDE (Mac OS X)</title>
		<link>http://blog.betabong.com/2008/11/29/flex-builder-t-flash-ide/</link>
		<comments>http://blog.betabong.com/2008/11/29/flex-builder-t-flash-ide/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 12:12:43 +0000</pubDate>
		<dc:creator>betabong</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[CS4]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Install]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=144</guid>
		<description><![CDATA[Update: I&#8217;ve found an easier way without FlashCommand
Once you got used to developing for Flash in Flex Builder, you hate to do any programming in Flash IDE. Still you sometimes might have to: Flex Builder won&#8217;t allow to publish into a FLA file. (There are of course many other reasons, like supporting older AS1/AS2 projects, [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/' rel='bookmark' title='Permanent Link: Test Movie from Flex to Flash (easy way)'>Test Movie from Flex to Flash (easy way)</a></li><li><a href='http://blog.betabong.com/2008/12/06/test-flex-throttled-simulate-download/' rel='bookmark' title='Permanent Link: Test Flex/Flash throttled (aka Simulate Download)'>Test Flex/Flash throttled (aka Simulate Download)</a></li><li><a href='http://blog.betabong.com/2008/07/16/flex-project-svn-strategy/' rel='bookmark' title='Permanent Link: Flex Project &#8211; SVN Strategy'>Flex Project &#8211; SVN Strategy</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p><span class="update"><strong>Update:</strong> <a href="http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/">I&#8217;ve found an easier way without FlashCommand</a></span></p>
<p>Once you got used to developing for Flash in Flex Builder, you hate to do any programming in Flash IDE. Still you sometimes might have to: Flex Builder won&#8217;t allow to publish into a FLA file. (There are of course many other reasons, like supporting older AS1/AS2 projects, we don&#8217;t go into that here.) Thanks to Eclipse&#8217;s ability to be customized, there are ways to make things at least a little easier. I give here a little overview of how I&#8217;ve set up my environment, based on several helpful resources I&#8217;ve found in the web.</p>
<ol>
<li>Install FlashCommand</li>
<li>Install Ant</li>
</ol>
<p>And for each project:</p>
<ol>
<li>Create/modify Ant file</li>
<li>Create Actionscript project</li>
<li>Set up project and FLA file</li>
</ol>
<p><span id="more-144"></span></p>
<h3>What you need</h3>
<ul>
<li><a href="http://www.adobe.com/products/flex/">Flex Builder</a></li>
<li><a href="http://www.adobe.com/products/flash/">Flash IDE (CS3 or CS4)</a></li>
</ul>
<h3>Install FlashCommand</h3>
<p><a href="http://www.mikechambers.com/blog/2008/05/02/flashcommand-for-os-x-updated-to-work-with-flash-cs3/">flashcommand</a> is a python script by <a href="http://www.mikechambers.com/blog/">Mike Chambers</a> that lets you compile FLA files from the command line using Flash IDE. <a href="http://code.google.com/p/flashcommand/downloads/list">Download it</a> and put it wherever you want.</p>
<h3>Install ANT</h3>
<p>If you&#8217;re used to FDT (or Eclipse in any way) you may well know Ant. <a href="http://en.wikipedia.org/wiki/Apache_Ant">Ant</a> is the premier build tool for any developers working in <a href="http://www.eclipse.org/">Eclipse</a>, with many many cool possibilites to automate your workflow. Here&#8217;s how you <a href="http://blog.jodybrewster.net/2008/04/09/installing-ant-in-flex-builder-3/">install Ant in Flex Builder 3 Standalone</a>:</p>
<ol>
<li>Go to Help &gt; Software Updates &gt; Find and Install</li>
<li>Search for new features to install, click next</li>
<li>Select «The Eclipse Project Updates», click finish<br />
Note: If you do not have the option above click «New Remote Site» and enter «The Eclipse Project Updates» as the name and «http://update.eclipse.org/updates/3.3» as the url.</li>
<li>In Eclipse project updates look for «Eclipse Java Development Tools &#8230;» – it might be in «Eclipse SDK Eclipse 3.3.2» but this depends on what version you have installed and what version is currently available. Select it and click next.</li>
<li>Accept licence agreement, click next. Then click «Finish» to start download.</li>
<li>Once downloaded, click «Install all»</li>
<li>Restart Eclipse (you&#8217;ll be asked to)</li>
</ol>
<h3>Create Project</h3>
<ol>
<li>Create a new Actionscript Project in Flex Builder</li>
<li>Add a new «build» directory in the project root</li>
<li>Add your FLA file(s) and assets to the build folder and your source files to the src folder<br />
(I also strongly recommend adding external libraries to and «externals» directory and use svn:externals property on it, but that&#8217;s another story) </li>
<li>Add build paths. You have to do this at least twice:
<ul>
<li>In the Flash IDE for the FLA: Publish Settings &gt; Actionscript 3 «Settings&#8230;». Don&#8217;t forget to add the src folder at least.<br />
Test your FLA once done. It should compile just fine.</li>
<li>In Flex Builder: Project &gt; Properties &gt; ActionScript Build Path. Add your external libraries here. This is used so Flex knows where to lookup your classes, it won&#8217;t actually be needed for compiling, because that&#8217;s what Flash IDE&#8217;s gonna do.</li>
</ul>
</li>
<li>Now you&#8217;re almost done: you can edit your classes in Flex Builder and switch to Flash IDE to publish and/or test your movie. We&#8217;re gonna make this a little more comfortable with Ant and flashcommand.</li>
</ol>
<h3>Add Ant build file</h3>
<ol>
<li>Create a new file build.xml in the root folder and open it with Ant Editor (in Flex Builder aka Eclipse)</li>
<li>Edit the build.xml according your setup (see below for example)</li>
<li>Add build.xml to Ant View (Window &gt; Other Views&#8230;)</li>
<li>Run an action by double clicking it in Ant View: there you go!! It will compile in Flash IDE and open in your browser for testing!</li>
</ol>
<h3>Sample Ant build.xml</h3>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
	<span style="color: #808080; font-style: italic;">&lt;!-- ====================================================================== </span>
<span style="color: #808080; font-style: italic;">	     Nov 28, 2008 1:37:54 AM                                                        </span>
&nbsp;
<span style="color: #808080; font-style: italic;">	     MyProject    </span>
<span style="color: #808080; font-style: italic;">	     Compile in Flash IDE</span>
&nbsp;
<span style="color: #808080; font-style: italic;">	     sev                                                                </span>
<span style="color: #808080; font-style: italic;">	     ====================================================================== --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;MyProject&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;Compile and Run&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;./&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	        <span style="color: #808080; font-style: italic;">&lt;!-- project specifics --&gt;</span>
	        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;browser&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Safari&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;swf.filename&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;MyProject&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;html.filename&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;fla/index.html&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	        <span style="color: #808080; font-style: italic;">&lt;!-- Flash IDE Commandline compiler --&gt;</span>
	        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;python&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/usr/bin/python&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;flash.command&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/path/to/flashcommand&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	        <span style="color: #808080; font-style: italic;">&lt;!-- directories --&gt;</span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;user.path&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/Users/yourname&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;build.dir&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${basedir}/build&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;main.fla&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${build.dir}/${swf.filename}.fla&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	        <span style="color: #808080; font-style: italic;">&lt;!-- paths --&gt;</span>
	        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;output.path&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${build.dir}/${swf.filename}.swf&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
			<span style="color: #808080; font-style: italic;">&lt;!-- you can also point to the file:///path/to/index.html --&gt;</span>
	        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;local.path&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;http://localhost/projects/MyProject/${html.filename}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;log.path&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${user.path}/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	        <span style="color: #808080; font-style: italic;">&lt;!-- Compile python flashcommand -e  -s build/MyProject.fla -o build/MyProject.swf </span>
&nbsp;
<span style="color: #808080; font-style: italic;">	        usage: flashcommand -e | -c | -p [-v] [-x] (-s &lt;sourcefile&gt;) ([-o] &lt;exportpath&gt;) ([-t] &lt;timeout&gt;)([-d] &lt;tempdir&gt;) [-j]</span>
&nbsp;
<span style="color: #808080; font-style: italic;">	        Options and arguments:</span>
&nbsp;
<span style="color: #808080; font-style: italic;">	        -a : Prints version and about information.</span>
<span style="color: #808080; font-style: italic;">	        -c : Specifies save and compact action. </span>
<span style="color: #808080; font-style: italic;">	        -d : Specifies temp directory that will be used for temporary files. Optional.</span>
<span style="color: #808080; font-style: italic;">	        -e : Specifies export action.</span>
<span style="color: #808080; font-style: italic;">	        -h : Prints usage information.</span>
<span style="color: #808080; font-style: italic;">	        -j : Specifies that the generated JSFL file should be printed. If this option is specified, Flash will not be executed.</span>
<span style="color: #808080; font-style: italic;">	        -o : Specifies the output file if -e flag is also set. Optional. If not specified, file will be output to same directory as source.</span>
<span style="color: #808080; font-style: italic;">	        -p : Specifies publish action.</span>
<span style="color: #808080; font-style: italic;">	        -s : Specifies source file. Required.</span>
<span style="color: #808080; font-style: italic;">	        -t : Specifies timeout value. Optional.</span>
<span style="color: #808080; font-style: italic;">	        -v : Specifies verbose mode. Optional.</span>
<span style="color: #808080; font-style: italic;">	        -f : Specifies that the Flash authoring version installed is a version other than Flash CS3</span>
<span style="color: #808080; font-style: italic;">	        -x : Specifies whether Flash should be closed after it is done processing. Optional.    </span>
&nbsp;
<span style="color: #808080; font-style: italic;">	        --&gt;</span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Compile and Run&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;antcall</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;Compile in IDE&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;antcall</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;Clear Log&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;antcall</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;Open in Browser&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Compile in IDE&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${flash.command} -e -c -s ${main.fla} -o ${output.path}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;${python}&quot;</span> <span style="color: #000066;">failonerror</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">logError</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;${flash.command}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-e &quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-s ${main.fla} &quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-o ${output.path}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
        <span style="color: #808080; font-style: italic;">&lt;!-- Open in local browser --&gt;</span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Open in Browser&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;open&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-a ${browser} ${local.path}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #808080; font-style: italic;">&lt;!-- Clear Debug Log --&gt;</span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Clear Log&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
        	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;concat</span> <span style="color: #000066;">destfile</span>=<span style="color: #ff0000;">&quot;${log.path}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>                                                                                                            
.: Sev Log File :.
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/concat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;open&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;-a console '${log.path}'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>Update:</strong> <a href="http://www.leebrimelow.com/">Lee Brimelov</a> just released a <a href="http://theflashblog.com/?p=482">plugin for Eclipse</a>, that provides this functionality (more or less) with a single click of an icon. It&#8217;s an alpha version, and you won&#8217;t have all the Ant flexibility (well, you could still install Ant), but you can avoid most of the installation hazzle, and that&#8217;s pretty cool. Unfortunately I couldn&#8217;t get it to work so far. </p>
<p><strong>Update 2:</strong> It bugged me that every time I execute this action Flash would pop up. To work around that I slightly modified the FlashCommand script (it actually checks wether the FLA file is already open, and if so won&#8217;t call the open command). Also I had to leave away the -c option (save and compact), something I don&#8217;t need anyway. So now when you execute the command from Flex the following happens:</p>
<ol>
<li>The little publish dialog pops up (Fla is exported to SWF)</li>
<li>The HTML file is opened in the browser (which comes to front), as well as the Console displaying the trace output</li>
</ol>
<p>Also I have bound the «Launch last external tool» command in Flex Builder to a key combo. Now things run pretty smooth and as much satisfying as compiling via Flash can be. Btw, I also looked into this Eclipse plugin – as it seems the only thing it does is to tell Flash to «Test Movie» with the frontmost open document. That&#8217;s absolutely okay for most people, but I&#8217;m glad for the extra functionality I get with this solution (at the cost of more initial effort of course). Download here the modified FlashCommand: <a class="download" href='http://blog.betabong.com/wp-content/uploads/2008/12/flashcommand.zip'>flashcommand.zip</a></p>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/' rel='bookmark' title='Permanent Link: Test Movie from Flex to Flash (easy way)'>Test Movie from Flex to Flash (easy way)</a></li><li><a href='http://blog.betabong.com/2008/12/06/test-flex-throttled-simulate-download/' rel='bookmark' title='Permanent Link: Test Flex/Flash throttled (aka Simulate Download)'>Test Flex/Flash throttled (aka Simulate Download)</a></li><li><a href='http://blog.betabong.com/2008/07/16/flex-project-svn-strategy/' rel='bookmark' title='Permanent Link: Flex Project &#8211; SVN Strategy'>Flex Project &#8211; SVN Strategy</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2008/11/29/flex-builder-t-flash-ide/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>E4X String Parser</title>
		<link>http://blog.betabong.com/2008/09/23/e4x-string-parser/</link>
		<comments>http://blog.betabong.com/2008/09/23/e4x-string-parser/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 11:13:00 +0000</pubDate>
		<dc:creator>betabong</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[e4x]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[os]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=111</guid>
		<description><![CDATA[I did a lot of string parsing in the recent time: CSS Selectors, XML Display Objects, Stylesheets, &#8230; I also need XML selection from String expressions – I formerly (AS2) used the great XPath4AS2 from XFactorStudio which did it&#8217;s job well (though a bit slow, it&#8217;s AS2 after all).
There&#8217;s also one for Actionscript 3 (xpath-as3). [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2008/09/01/speed-parsing-string-in-as3/' rel='bookmark' title='Permanent Link: Simplicity follows Performance – parsing Strings in Actionscript 3'>Simplicity follows Performance – parsing Strings in Actionscript 3</a></li><li><a href='http://blog.betabong.com/2008/11/19/alchemy-release/' rel='bookmark' title='Permanent Link: Alchemy – THE cool new flash feature!'>Alchemy – THE cool new flash feature!</a></li><li><a href='http://blog.betabong.com/2008/07/21/nested-inner-functions-can-be-evil/' rel='bookmark' title='Permanent Link: Nested inner functions can be evil'>Nested inner functions can be evil</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I did a lot of string parsing in the recent time: CSS Selectors, XML Display Objects, Stylesheets, &#8230; I also need XML selection from String expressions – I formerly (AS2) used the great <a href="http://www.xfactorstudio.com/">XPath4AS2 from XFactorStudio</a> which did it&#8217;s job well (though a bit slow, it&#8217;s AS2 after all).</p>
<p>There&#8217;s also one for Actionscript 3 (<a href="http://code.google.com/p/xpath-as3/">xpath-as3</a>). But.. well&#8230; I wanted to go for some real speed! I like XPath a lot, but we now have native E4X selection in Actionscript 3, quite a different concept of node selection, and the conversion of XPath to E4X obviously results in quite a compromise in performance.</p>
<p>So all I need is a decent E4X parser. And hey, I found one! E<a href="http://www.adobe.com/devnet/flex/articles/e4x_print.html">4XParser from Digital Primates</a>. It does its job really well, especially considering the very compact code it consists of. Thanks to some preparsing and caching, it&#8217;s also quite fast.</p>
<p><strong>Still I thought I can do better :-)</strong> So I planted myself for a day (and a night) in front of my displays and hacked the hell out of it. The result is a little library which does pretty much the same thing as E4XParser, though pretty much more and a little faster too (15% to 50%). It&#8217;s about half as fast as the native E4X selection (once parsed). You can do nearly anything you can do with E4X. Use it like this:</p>
<p> </p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">betabong</span>.<span style="color: #0066CC;">xml</span>.<span style="color: #006600;">e4x</span>.<span style="color: #006600;">E4X</span>;
<span style="color: #000000; font-weight: bold;">var</span> result : XMLList = E4X.<span style="color: #006600;">evaluate</span><span style="color: #66cc66;">&#40;</span> xmllist , <span style="color: #ff0000;">&quot;author.( name.@last == 'Jobs' )&quot;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// E4X.evaluate( source : XMLList , expression : String ) : XMLList</span></pre></div></div>

<p> <br />
If your source is XML, just do XMLList( xml ), if your result should be xml, do xml = result[0]</p>
<p><a href="/showcase/e4x/E4X_Parse_Test.html">Test it here</a></p>
<p><a href="http://blog.betabong.com/showcase/e4x/E4X_Parse_Test.html" target="_blank"><img class="alignnone size-full wp-image-113" title="e4x" src="http://blog.betabong.com/wp-content/uploads/2008/09/e4x.png" alt="" width="512" height="405" /></a></p>
<p><strong>Restrictions:</strong> You can&#8217;t use AND/OR in comparisions. So, this won&#8217;t go: author.( name.@first == &#8216;Steve&#8217; &amp;&amp; name.@last == &#8216;Jobs&#8217; ) – though this is only a real limitations for OR. do this for AND: author.( name.@first == &#8216;Steve&#8217; ).( name.@last == &#8216;Jobs&#8217; ).</p>
<p><strong>What you can do:</strong> Yes, you can do quite advanced stuff like author.( name.@first == name.@last ) or car.@rating.average() (one of the few proprietary functions I added). Or even</p>
<pre>*..car.( @brand.toLowerCase() == 'volvo' ).( parent().( localName() == 'group' ).@rating &gt; @rating )</pre>
<p>– a weird example, I admit, but fancy, ain&#8217;t it? :-)</p>
<p>This is the first time ever I&#8217;m releasing part of my library as Open Source (MIT licence). As soon as I&#8217;ll find some time (and if I see any interest), I&#8217;m gonna put this into Google Code, so everybody can easily checkout and participate. Until then download it from here:</p>
<p><a class="download" href="/showcase/e4x/betabong-e4x.zip">Download</a> (zip 13kb)</p>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2008/09/01/speed-parsing-string-in-as3/' rel='bookmark' title='Permanent Link: Simplicity follows Performance – parsing Strings in Actionscript 3'>Simplicity follows Performance – parsing Strings in Actionscript 3</a></li><li><a href='http://blog.betabong.com/2008/11/19/alchemy-release/' rel='bookmark' title='Permanent Link: Alchemy – THE cool new flash feature!'>Alchemy – THE cool new flash feature!</a></li><li><a href='http://blog.betabong.com/2008/07/21/nested-inner-functions-can-be-evil/' rel='bookmark' title='Permanent Link: Nested inner functions can be evil'>Nested inner functions can be evil</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2008/09/23/e4x-string-parser/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Nested inner functions can be evil</title>
		<link>http://blog.betabong.com/2008/07/21/nested-inner-functions-can-be-evil/</link>
		<comments>http://blog.betabong.com/2008/07/21/nested-inner-functions-can-be-evil/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 07:53:29 +0000</pubDate>
		<dc:creator>betabong</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash & more]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[EventDispatcher]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=39</guid>
		<description><![CDATA[Sometimes it would be quite comfortable (from a programmer&#8217;s perspective) to use nested inner functions. But they are a potential source for nasty problems. Let&#8217;s take the following simple scenario:

&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;mx:Application xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;absolute&#34; creationComplete=&#34;create()&#34; click=&#34;destroy()&#34;&#62;
	&#60;mx:Script&#62;
		&#60;![CDATA[
			private var dispatcher : Sprite;
&#160;
			private function create() : void {
				dispatcher = new Sprite();
				// listen to inner function
				dispatcher.addEventListener( Event.ENTER_FRAME , function( [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2008/09/26/weak-method-closure/' rel='bookmark' title='Permanent Link: Weak Method Closure'>Weak Method Closure</a></li><li><a href='http://blog.betabong.com/2008/07/18/garbage-collector-and-dictionary/' rel='bookmark' title='Permanent Link: Garbage Collector and Dictionary'>Garbage Collector and Dictionary</a></li><li><a href='http://blog.betabong.com/2009/04/13/metatunnel-1k-demo-as-vs-js/' rel='bookmark' title='Permanent Link: Metatunnel 1k Demo: AS vs. JS'>Metatunnel 1k Demo: AS vs. JS</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Sometimes it would be quite comfortable (from a programmer&#8217;s perspective) to use nested inner functions. But they are a potential source for nasty problems. Let&#8217;s take the following simple scenario:<span id="more-39"></span></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;create()&quot;</span> click=<span style="color: #ff0000;">&quot;destroy()&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">		&lt;![CDATA[</span>
<span style="color: #339933;">			private var dispatcher : Sprite;</span>
&nbsp;
<span style="color: #339933;">			private function create() : void {</span>
<span style="color: #339933;">				dispatcher = new Sprite();</span>
<span style="color: #339933;">				// listen to inner function</span>
<span style="color: #339933;">				dispatcher.addEventListener( Event.ENTER_FRAME , function( e : Event ) : void { trace( e.type ); } );</span>
<span style="color: #339933;">			}</span>
&nbsp;
<span style="color: #339933;">			private function destroy() : void {</span>
<span style="color: #339933;">				// this should free created dispatcher from memory</span>
<span style="color: #339933;">				dispatcher = null;</span>
<span style="color: #339933;">				// what we would need is:</span>
<span style="color: #339933;">				// dispatcher.destroy() or dispatcher.removeEventListener( Event.ENTER_FRAME )</span>
<span style="color: #339933;">				// or dispatcher.removeAllEventListeners()</span>
<span style="color: #339933;">			}</span>
<span style="color: #339933;">		]]&gt;</span>
<span style="color: #339933;">	&lt;/mx:Script&gt;</span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>The dispatcher will just live on. The mean thing is that in method «destroy» we don&#8217;t even have a chance to get rid of the sprite anymore – it just lives on and on (and dispatches its event every time it enters a frame to the listener function.) So 3 objects will just not be freed in memory because of our inner function listener: 1. the dispatcher object, 2. the listener function (the inner function) and 3. the creating object, because the listener function (or its method closure) is bound to the creating method create() scope.</p>
<p>We also can&#8217;t use the addEventListener&#8217;s flag to use weak references, because the listener method wouldn&#8217;t have any other references and would «dye» instantely. So what you should do right now is something like that:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;create()&quot;</span> click=<span style="color: #ff0000;">&quot;destroy()&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">		&lt;![CDATA[</span>
<span style="color: #339933;">			private var dispatcher : Sprite;</span>
&nbsp;
<span style="color: #339933;">			private function create() : void {</span>
<span style="color: #339933;">				dispatcher = new Sprite();</span>
<span style="color: #339933;">				dispatcher.addEventListener( Event.ENTER_FRAME , handler );</span>
<span style="color: #339933;">			}</span>
&nbsp;
<span style="color: #339933;">			private function destroy() : void {</span>
<span style="color: #339933;">				dispatcher.removeEventListener( Event.ENTER_FRAME , handler );</span>
<span style="color: #339933;">				dispatcher = null;</span>
<span style="color: #339933;">			}</span>
&nbsp;
<span style="color: #339933;">			private function handler( event : Event ) : void {</span>
<span style="color: #339933;">				trace( e.type );</span>
<span style="color: #339933;">			}</span>
<span style="color: #339933;">		]]&gt;</span>
<span style="color: #339933;">	&lt;/mx:Script&gt;</span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>That&#8217;s clean code. Good bye dispatcher, good bye sprite! But sometimes it can be quite difficult to maintain this. I personally would wish that actionscript objects, especially the EventDispatcher class, would provide a destroy() method. Calling it gets rid of all event listeners and also would unlisten to everything it has listened to. And for DisplayObjects it would also perform other operations like removing itself from its parent and destroying all children.</p>
<p>I&#8217;d also like to see the following method like this in EventDispatcher:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">EventDispatcher.<span style="color: #0066CC;">removeListener</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">type</span> : <span style="color: #0066CC;">String</span> = <span style="color: #000000; font-weight: bold;">null</span> , listener : <span style="color: #000000; font-weight: bold;">Function</span> = <span style="color: #000000; font-weight: bold;">null</span> , useCapture : <span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// so this would remove all listeners</span>
EventDispatcher.<span style="color: #0066CC;">removeListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// and this all listeners to enter frame</span>
EventDispatcher.<span style="color: #0066CC;">removeListener</span><span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">ENTER_FRAME</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>I get around many issues by implementing something like a IEventListener interface:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">interface</span> IEventListener <span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">function</span> listenTo<span style="color: #66cc66;">&#40;</span> dispatcher : IEventDispatcher , <span style="color: #0066CC;">type</span> : <span style="color: #0066CC;">String</span> , listener : <span style="color: #000000; font-weight: bold;">Function</span> , useCapture : <span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>;
functon unlistenTo<span style="color: #66cc66;">&#40;</span> dispatcher : IEventDispatcher , <span style="color: #0066CC;">type</span> : <span style="color: #0066CC;">String</span> , listener : <span style="color: #000000; font-weight: bold;">Function</span> , useCapture : <span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>;
<span style="color: #000000; font-weight: bold;">function</span> destroy<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>; <span style="color: #808080; font-style: italic;">// will remove myself as event listener from all registered dispatchers</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Way to go :-)</p>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2008/09/26/weak-method-closure/' rel='bookmark' title='Permanent Link: Weak Method Closure'>Weak Method Closure</a></li><li><a href='http://blog.betabong.com/2008/07/18/garbage-collector-and-dictionary/' rel='bookmark' title='Permanent Link: Garbage Collector and Dictionary'>Garbage Collector and Dictionary</a></li><li><a href='http://blog.betabong.com/2009/04/13/metatunnel-1k-demo-as-vs-js/' rel='bookmark' title='Permanent Link: Metatunnel 1k Demo: AS vs. JS'>Metatunnel 1k Demo: AS vs. JS</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2008/07/21/nested-inner-functions-can-be-evil/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flex Project &#8211; SVN Strategy</title>
		<link>http://blog.betabong.com/2008/07/16/flex-project-svn-strategy/</link>
		<comments>http://blog.betabong.com/2008/07/16/flex-project-svn-strategy/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 10:35:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash & more]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=13</guid>
		<description><![CDATA[I like to keep all my projects on a svn server. So far this was just for myself and I didn&#8217;t care much about the simplicity of checking out and in – a little chaos is acceptable if you&#8217;re up to handle it ;)
Finally I was forced to rethink this strategy because I wanted to [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2008/11/29/flex-builder-t-flash-ide/' rel='bookmark' title='Permanent Link: Develop in Flex Builder, publish in Flash IDE (Mac OS X)'>Develop in Flex Builder, publish in Flash IDE (Mac OS X)</a></li><li><a href='http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/' rel='bookmark' title='Permanent Link: Test Movie from Flex to Flash (easy way)'>Test Movie from Flex to Flash (easy way)</a></li><li><a href='http://blog.betabong.com/2008/08/14/svn-hook-%e2%80%93-auto-upload-to-ftp/' rel='bookmark' title='Permanent Link: SVN Hook – auto-upload to FTP'>SVN Hook – auto-upload to FTP</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I like to keep all my projects on a svn server. So far this was just for myself and I didn&#8217;t care much about the simplicity of checking out and in – a little chaos is acceptable if you&#8217;re up to handle it ;)</p>
<p>Finally I was forced to rethink this strategy because I wanted to let other people work on a project. As many actionscript projects, this one also heavily relies on external libraries, most of them hosted by Google Code, another one being my own (closed) lib. So should I tell people: «hey, just svn checkout from here and there and then relink the libs in the project properties but don&#8217;t check in the updated settings for christ&#8217;s sake!»No. Too shaky, really.</p>
<p>Fortunately, SVN provides a fucking cool way to solve this issue: svn:externals. <span id="more-13"></span>Ha! This is so awesome, you won&#8217;t believe it ;-) Okay, here are the steps to follow (on a mac at least):</p>
<p>Create a flex project:</p>
<ul>
<li>project
<ul>
<li>html-template</li>
<li>src</li>
</ul>
</li>
</ul>
<p>Add a new directory:</p>
<ul>
<li>project
<ul>
<li>html-template</li>
<li>src</li>
<li>externals</li>
</ul>
</li>
</ul>
<p>Now put this on your svn, either by svn add or by putting in the repos and checking out again (well.. just as you did). If you&#8217;ve already got bin-debug or bin-release directories, just remove them on the repos and svn update (they are created with each publish in flex).</p>
<p>Now let&#8217;s say our project resides in ~/Documents/projects/project (path to project). Do the following in Terminal:</p>
<pre>cd ~/Documents/projects/project/externals
svn svn propedit svn:externals .</pre>
<p>This should open an editor (in my case I&#8217;ve defined textmate as my editor by doing:)</p>
<pre>export EDITOR='mate -w'</pre>
<p>Enter the following (example libraries):</p>
<pre>caurinatweener http://tweener.googlecode.com/svn/trunk/as3/
as3corelib http://as3corelib.googlecode.com/svn/</pre>
<p>You can also add a specific release:</p>
<pre>caurinatweener -r23 http://tweener.googlecode.com/svn/trunk/as3/</pre>
<p>(in TextMate save and close, if you use vim you know what to do anyway)</p>
<p>Now comes the magic part:</p>
<pre>svn up</pre>
<p>This will checkout all defined libraries into externals/xyz!! you do <code>svn commit</code> and now every time somebody checks out your project (or your externals directory) all the libs will be checked out automatically! I think this is just fucking awesome! :-)</p>
<p>Now in Eclipse all paths to your external libraries will be relative to the project (of course you have to add the libs there or change the paths – you should know how to do that ;))</p>
<p>Now all we need to is ignoring bin-release and bin-debug. We don&#8217;t want these directories to be in our svn repos:</p>
<pre>cd ~/Documents/projects/project
svn svn propedit svn:ignore .</pre>
<p>enter a list of directories or files to be ignored. in our case:</p>
<pre>bin-debug
bin-release</pre>
<p>That&#8217;s it! Thanks, svn!</p>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2008/11/29/flex-builder-t-flash-ide/' rel='bookmark' title='Permanent Link: Develop in Flex Builder, publish in Flash IDE (Mac OS X)'>Develop in Flex Builder, publish in Flash IDE (Mac OS X)</a></li><li><a href='http://blog.betabong.com/2008/12/03/test-movie-from-flex-to-flash-easy-way/' rel='bookmark' title='Permanent Link: Test Movie from Flex to Flash (easy way)'>Test Movie from Flex to Flash (easy way)</a></li><li><a href='http://blog.betabong.com/2008/08/14/svn-hook-%e2%80%93-auto-upload-to-ftp/' rel='bookmark' title='Permanent Link: SVN Hook – auto-upload to FTP'>SVN Hook – auto-upload to FTP</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2008/07/16/flex-project-svn-strategy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
