<?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>Daniel Eneström &#187; AS3</title>
	<atom:link href="http://enestrom.com/tag/as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://enestrom.com</link>
	<description>Keep It Simply Stupid</description>
	<lastBuildDate>Fri, 23 Dec 2011 00:50:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Flash trace app for Mac OS X</title>
		<link>http://enestrom.com/20110108/flash-trace-app-for-mac-os-x/</link>
		<comments>http://enestrom.com/20110108/flash-trace-app-for-mac-os-x/#comments</comments>
		<pubDate>Sat, 08 Jan 2011 19:36:49 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://blog.enestrom.com/?p=135</guid>
		<description><![CDATA[The other day my FlashTracer (Firefox add-on) and my FBTracer (FireBug extension for Firefox) stopped working (again!). I&#8217;m so tired of these flash tracing tools doing this to me all the time and as an addition I&#8217;ve wanted a stand-alone &#8230; <a href="http://enestrom.com/20110108/flash-trace-app-for-mac-os-x/">Continue reading <span class="meta-nav">&#8594;</span></a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://enestrom.com/20110108/flash-trace-app-for-mac-os-x/' addthis:title='Flash trace app for Mac OS X ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p><a href="http://enestrom.enkelbutik.se/wp-content/uploads/2011/01/FlashTrace.zip"><img class="alignright size-full wp-image-137" title="Download FlashTrace" src="http://enestrom.enkelbutik.se/wp-content/uploads/2011/01/Skärmavbild-2011-01-08-kl.-20.05.02.jpeg" alt="Download FlashTrace" width="138" height="139" /></a>The other day my FlashTracer (Firefox add-on) and my FBTracer (FireBug extension for Firefox) stopped working (again!). I&#8217;m so tired of these flash tracing tools doing this to me all the time and as an addition I&#8217;ve wanted a stand-alone tool for my flash trace for a while, so I can have the Flash trace and Safari windows visible at the same time, without the need for Firefox (or a massive debugging tool &#8211; I just want a simple trace output). That&#8217;s why this time I wrapped up a small Mac OS app that simply opens Terminal and shows the user the Flash trace output in a Terminal window.</p>
<p>This is no magical app, it still demands that the user has the <a href="http://www.adobe.com/support/flashplayer/downloads.html" target="_blank">DEBUG version of Flash player</a> installed and that your flash trace text file is in this directory:<br />
~/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt<br />
(the ~ meaning your home directory in unix talk)</p>
<p>The app is downloadable below and is free for you to use. Note that I release the app with a <a href="http://sv.wikipedia.org/wiki/GNU_General_Public_License" target="_blank">GPL license</a> and your are welcome to use, distribute and change it. You can open the app using the AppleScript Editor. I would love to hear if you make any useful additions to it but cannot provide any support, sorry.</p>
<p>Enjoy!</p>
<p><a href="http://enestrom.enkelbutik.se/wp-content/uploads/2011/01/FlashTrace.zip">Download FlashTrace.app here</a></p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://enestrom.com/20110108/flash-trace-app-for-mac-os-x/' addthis:title='Flash trace app for Mac OS X ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://enestrom.com/20110108/flash-trace-app-for-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create iPhone apps using Flash</title>
		<link>http://enestrom.com/20091021/create-iphone-apps-using-flash/</link>
		<comments>http://enestrom.com/20091021/create-iphone-apps-using-flash/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 04:43:24 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://blog.enestrom.com/?p=109</guid>
		<description><![CDATA[I&#8217;m so excited about the upcoming Flash Pro CS5. It will let you create native iPhone applications by exporting your ActionScript 3 movie from Flash. The app will, when it&#8217;s been exported, behave as any other app and can be &#8230; <a href="http://enestrom.com/20091021/create-iphone-apps-using-flash/">Continue reading <span class="meta-nav">&#8594;</span></a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://enestrom.com/20091021/create-iphone-apps-using-flash/' addthis:title='Create iPhone apps using Flash ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m so excited about the upcoming Flash Pro CS5. It will let you create native iPhone applications by exporting your ActionScript 3 movie from Flash. The app will, when it&#8217;s been exported, behave as any other app and can be uploaded to the AppStore etc.<br />
<a href="http://labs.adobe.com/technologies/flashcs5/appsfor_iphone/">Read more on Adobe Labs</a></p>
<p><a href="http://www.youtube.com/watch?v=M7SK5ZKAaio">www.youtube.com/watch?v=M7SK5ZKAaio</a></p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://enestrom.com/20091021/create-iphone-apps-using-flash/' addthis:title='Create iPhone apps using Flash ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://enestrom.com/20091021/create-iphone-apps-using-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maintaining state on Tree Component while updating remote data</title>
		<link>http://enestrom.com/20090312/maintaining-state-on-tree-component-while-updating-remote-data/</link>
		<comments>http://enestrom.com/20090312/maintaining-state-on-tree-component-while-updating-remote-data/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 15:29:01 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[AMFPHP]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Remoting]]></category>

		<guid isPermaLink="false">http://blog.enestrom.com/?p=80</guid>
		<description><![CDATA[I suppose I&#8217;m not the only one who&#8217;s had problems with maintaining the state of a flex tree component upon updating the data. Recently I encountered the problem again and decided to crack this nut once and for all. As &#8230; <a href="http://enestrom.com/20090312/maintaining-state-on-tree-component-while-updating-remote-data/">Continue reading <span class="meta-nav">&#8594;</span></a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://enestrom.com/20090312/maintaining-state-on-tree-component-while-updating-remote-data/' addthis:title='Maintaining state on Tree Component while updating remote data ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>I suppose I&#8217;m not the only one who&#8217;s had problems with maintaining the state of a flex tree component upon updating the data. Recently I encountered the problem again and decided to crack this nut once and for all. As it turned out it was a lot easier than I had anticipated.</p>
<p><strong>The Scenario<br />
</strong>In this particular case I had a tree component displaying a hierarchical view of the pages of a web site. Upon making some certain changes, like dragging and dropping pages to reorder them I felt the need to change the order server-side and reload the data, rather than changing the order inside the dataProvider. I just like it that way better.</p>
<p><strong>The Problem<br />
</strong>So before I reloaded the data I saved the tree&#8217;s open items in a variable called openTreeItems and when I received the new data I tried to reset it by using <em>tree.openItems = openTreeItems</em>.<br />
Nothing happened.</p>
<p><strong>The Research<br />
</strong>So I started doing some research and quickly discovered that to make this work the component uses the <strong>uid</strong> property and on updating the data for the dataProvider Flex reassigns new uid&#8217;s to the items in the collection. So, in short, Flex doesn&#8217;t recognize the items as the same items after the reload, because of the new uid values.</p>
<p>I encountered <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=about_dataproviders_6.html" target="_blank">this article in the Flex 3 Help pages</a> and started experimenting with creating custom classes that implemented the IUID interface and soon discovered that this was way to complicated for the (actually) quite simple problem I had. The pages in my database had unique ID&#8217;s! Why the h*ll couldn&#8217;t I use these values as the uid values instead of the built-in values?</p>
<p><strong>The Solution</strong><br />
I suddenly had an idea: what if I simply add the uid property to my data serverside by using the id value I already had? This could be done in many ways but I chose to alter my SQL query like so: <em><br />
&#8220;SELECT pages.id, <strong>pages.id uid</strong>, &#8230; FROM pages&#8230;&#8221;</em>. This way the value would be passed on into Flex the same way as all the other values.</p>
<p>And, voilà, it worked!<br />
After this tiny alteration of my SQL query Flex recognized my items as the ones saved in the openTreeItems variable and when using <em>tree.invalidateList()</em> before the update and <em>tree.validateNow()</em> after the update there isn&#8217;t even a flicker upon updating the data. Sweetness!</p>
<p>Hope this helps anyone that has had the same problem.</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://enestrom.com/20090312/maintaining-state-on-tree-component-while-updating-remote-data/' addthis:title='Maintaining state on Tree Component while updating remote data ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://enestrom.com/20090312/maintaining-state-on-tree-component-while-updating-remote-data/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google Analytics and Flex using ExternalInterface</title>
		<link>http://enestrom.com/20081114/google-analytics-and-flex-using-externalinterface/</link>
		<comments>http://enestrom.com/20081114/google-analytics-and-flex-using-externalinterface/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 10:17:09 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Google Analytics]]></category>

		<guid isPermaLink="false">http://blog.enestrom.com/?p=64</guid>
		<description><![CDATA[A big issue for people creating flash sites is getting the site to work well with Google Analytics. &#8220;The page doesn&#8217;t refresh. How can I track the clicks?&#8221; Well, it is actually very easy. If you look at the trace &#8230; <a href="http://enestrom.com/20081114/google-analytics-and-flex-using-externalinterface/">Continue reading <span class="meta-nav">&#8594;</span></a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://enestrom.com/20081114/google-analytics-and-flex-using-externalinterface/' addthis:title='Google Analytics and Flex using ExternalInterface ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>A big issue for people creating flash sites is getting the site to work well with Google Analytics. &#8220;The page doesn&#8217;t refresh. How can I track the clicks?&#8221;</p>
<p>Well, it is actually very easy. If you look at the trace script Google Analytics gives you to add to your HTML code you can find a call to a method that actually records the event. This method is simple to call using JavaScript.</p>
<p>I have solved it like this in my latest Flex App (which is a public site). NOTE: This is for the new trace code version.</p>
<p><strong>1. Paste the Google Analytics trace code as usual just before the &lt;/BODY&gt; tag.</strong><br />
Check your Google Analytics account for the correct code.</p>
<p><strong>2. See to it that your embedded flash works with ExternalInterface.</strong><br />
This can be a bit tricky, but in my experience the things that do the trick are to change <em>allowScriptAccess</em> to <em>always</em> and inside the Flex App call a custom JavaScript function on <em>creationComplete</em> like so: <em>ExternalInterface.call(&#8216;initFlash&#8217;)</em>. In my html this initFlash function creates a variable reference to the embedded flash. This sort of &#8220;creates the connection&#8221; between them. I&#8217;m not sure why this is so, but for me it works, so I&#8217;m happy with that. If there is a need I would be glad to create a more thorough tutorial on the use of ExternalInterface. Just let me know.</p>
<p><strong>3. Create a custom JavaScript that passes the URL you want to register to the Google Analytics script.</strong><br />
This is not necessary, but I have found it easier to work with, as you don&#8217;t need to edit you call from inside of Flex if something changes in the Google code or such.</p>
<pre lang="javascript">function trackURL(url)
{
    pageTracker._trackPageview(url);
}</pre>
<p><strong>4. Call your custom javascript from within Flex.</strong><br />
I created a static class for this. (I love static classes). I named it <em>Analytics.as</em> and placed it in the root source folder in the Flex App. It looks like this. All it does really is call the JavaScript using ExternalInterface, but putting it within a static class lets you call it from anywhere in your application without having to pass on references to this or that object or function.</p>
<pre lang="actionscript">package
{
   public class Analytics
   {
      import flash.external.ExternalInterface;

      public static function track(url:String) : void
      {
         ExternalInterface.call("trackURL", url);
      }
   }
}</pre>
<p>And anywhere in your app write:</p>
<pre lang="actionscript">
Analytics.track('/path_to_tha_page_you_want_to_track/');
</pre>
<p>(NOTE: You have to start your path with a slash).</p>
<p><strong>There you go.</strong> It now should track the URL:s you want and give you nice statistics.</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://enestrom.com/20081114/google-analytics-and-flex-using-externalinterface/' addthis:title='Google Analytics and Flex using ExternalInterface ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://enestrom.com/20081114/google-analytics-and-flex-using-externalinterface/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Passing on optional arguments in ActionScript 3</title>
		<link>http://enestrom.com/20080811/passing-on-optional-arguments-in-actionscript-3/</link>
		<comments>http://enestrom.com/20080811/passing-on-optional-arguments-in-actionscript-3/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 10:28:32 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.enestrom.com/?p=25</guid>
		<description><![CDATA[The other day I ran into a small problem with optional arguments in Flex. While writing my tutorial on AMFPHP and Flex I decided to create a small static class that would take care of all the boring stuff with &#8230; <a href="http://enestrom.com/20080811/passing-on-optional-arguments-in-actionscript-3/">Continue reading <span class="meta-nav">&#8594;</span></a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://enestrom.com/20080811/passing-on-optional-arguments-in-actionscript-3/' addthis:title='Passing on optional arguments in ActionScript 3 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>The other day I ran into a small problem with optional arguments in Flex. While writing my tutorial on <a href="http://blog.enestrom.com/20080808/amfphp-and-flex/">AMFPHP and Flex</a> I decided to create a small static class that would take care of all the boring stuff with calling AMFPHP. This class enables me to simply use AMFPHP.send(&#8220;ServiceName&#8221;, and so on).</p>
<p>However, writing the class I realized I wouldn&#8217;t be able to pass on the optional parameters. If I would use:</p>
<pre lang="actionscript">
function send(anArgument:Object, ...args)
</pre>
<p>&#8230;I wouldn&#8217;t be able to send the args argument to the NetConnection.call method, because actionscript would send a &#8220;bunched up&#8221; array with all the arguments as ONE parameter to the call method, as opposed to a series of parameters, which was what I wanted.</p>
<p>The solution to this is using the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Function.html#apply()" target="_blank">Function.apply()</a> method. What I did was to create an empty array and add a series of arguments I wanted to pass on to a function, create a reference to the function and then use the apply method. This is what my finished static method looks like:</p>
<pre lang="actionscript">public static function send(serviceFunction:String, resultHandler:Function, faultHandler:Function, ... args:*) : void
{
	trace("AMFPHP("+serviceFunction+")");
	// Create responder
	var responder:Responder = new Responder(resultHandler, faultHandler);
	// Create an array that will temporarily store all the arguments
	var collectArgs:Array = new Array;
	// Add the fixed arguments
	collectArgs.push(serviceFunction);
	collectArgs.push(responder);
	// Loop through the optional arguments and add them too
	for (var i:uint=0; i<args.length; i++)
	{
		collectArgs.push(args[i]);
	}
	// Create a reference to the function we will call
	var callFunction:Function = connection.call;
	// Call the function using the arguments
	callFunction.apply(connection,collectArgs);
}
</pre>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://enestrom.com/20080811/passing-on-optional-arguments-in-actionscript-3/' addthis:title='Passing on optional arguments in ActionScript 3 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://enestrom.com/20080811/passing-on-optional-arguments-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

