<?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>Barklund.org &#187; AS2</title>
	<atom:link href="http://www.barklund.org/blog/category/programming/flash-platform/as2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.barklund.org/blog</link>
	<description>work smarter when building current web trends</description>
	<lastBuildDate>Wed, 26 May 2010 09:49:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Top 6 AS3 features you miss when switching back to AS2</title>
		<link>http://www.barklund.org/blog/2009/07/19/top-6-as3-features-you-miss-when-switching-back-to-as2/</link>
		<comments>http://www.barklund.org/blog/2009/07/19/top-6-as3-features-you-miss-when-switching-back-to-as2/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 21:40:58 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Lists]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/?p=234</guid>
		<description><![CDATA[I have been doing ActionScript 3 projects for quite a while, but every now and then I (as well as many others in the trade) have to switch back to AS2 or even AS1 &#8211; the line between them is quite blurry really in retrospective. When doing AS3 projects, there are many features that really [...]


Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/07/01/minor-change-in-handling-nan-positions-in-flash-player-10-0-22/' rel='bookmark' title='Permanent Link: Minor change in handling NaN positions in Flash Player 10,0,22'>Minor change in handling NaN positions in Flash Player 10,0,22</a></li>
<li><a href='http://www.barklund.org/blog/2009/11/04/advanced-e4x-assignment-xmllists/' rel='bookmark' title='Permanent Link: Advanced E4X &#8211; Assignment to XMLLists'>Advanced E4X &#8211; Assignment to XMLLists</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I have been doing ActionScript 3 projects for quite a while, but every now and then I (as well as many others in the trade) have to switch back to AS2 or even AS1 &#8211; the line between them is quite blurry really in retrospective. When doing AS3 projects, there are many features that really come in handy, but it is only when you don&#8217;t have them available, that you really find out which are the true improvements, that you cannot live without, and which are just nice little tweaks, that make your everyday scripting easier.
<p>The latter category includes e.g. <a href="http://www.barklund.org/blog/2009/05/21/for-each-in-loops-in-actionscript-3/" title="For-each-in loops in ActionScript 3 from barklund.org">the for-each-in construct</a>, <a href="http://livedocs.adobe.com/flash/9.0/main/00000047.html" title="Data type descriptions from Adobe LiveDocs">different number types</a>, <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#describeType%28%29" title="describeType() in the flash.utils package description from Adobe LiveDocs">class introspection</a> or <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#getDefinitionByName%28%29" title="getDefinitionByName() in the flash.utils package description from Adobe LiveDocs">built-in class look-up by string</a>, but these are my top 6 AS3 features, that I find myself constantly missing when fixing or improving scripts in older versions of ActionScript:</p>
<p><span id="more-234"></span></p>
<h3 id="toc-number-6-default-values-for-parameters">Number 6: Default values for parameters</h3>
<blockquote><p>if (!scale) scale = 1;</p></blockquote>
<p>It is very simple, it doesn&#8217;t really look nice (at least the first couple of times you read/write it), but it gets the job done and it is consistent with how other languages does it. If it is the best possible choice for implementation, I cannot really say, but I wouldn&#8217;t be without it now that I have it &#8211; though I can easily think of improvements.</p>
<p>Okay, you are going to ask anyway, so here it is: It can be greatly improved by adding the ability to add parameters by name like in Python &#8211; e.g.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">ftp.<span style="color: #0066CC;">connect</span><span style="color: #66cc66;">&#40;</span>host=<span style="color: #ff0000;">&quot;www.server.com&quot;</span>,username=<span style="color: #ff0000;">&quot;administrator&quot;</span>,<span style="color: #0066CC;">password</span>=password_input.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>It looks a bit strange but it is a great improvement &#8211; just compare it to how you need to specify the third (useCapture) and fourth (priority) arguments to addEventListener whenever you need to specify, that you want it to use weak references (the fifth argument set to true) &#8211; it does not look that good and could be a lot easier to use with named arguments.</p>
<h3 id="toc-number-5-e4x">Number 5: E4X</h3>
<blockquote><p>firstChild.firstChild.childNodes[i].lastChild.firstChild.attributes.id</p></blockquote>
<p>XML-based configuration files have been around for ages. I have done banners back in Flash 5, that used external configuration files for texts, layout, flow, paths, connection properties or something similiar. Of course, back then you always loaded the ignoreWhite script (wasn&#8217;t it XMLNitro.as from Branden Hall?), but you still had to either create your own serialization schemes, load someone else&#8217;s or go through the staggering pain of navigating through the XML-node tree through simple node references without knowing their names in advance.</p>
<p>With E4X we have been equipped with XPath-like traversal schemes, that still allow for basic node traversal, but makes it infinitely much easier to reach that specific node, that you need and know the name (and maybe some of the path) of.</p>
<h3 id="toc-number-4-instantiate-movieclips-even-across-swfs">Number 4: Instantiate movieclips &#8211; even across SWF&#8217;s</h3>
<blockquote><p>No more duplicateMovieClip madness</p></blockquote>
<p>I did a large isometric chat world in the good old Flash 5 days (and it only just recently got improved &#8211; which meant doubling the version number from Flash 5 to Flash 10 &#8211; now that is rare) and split code out in several FLA-files compiled to several SWF-files. But as everything needed to be possible to lay in-between each other all graphics needed to be in the same SWF-file. Which meant they had to come from the same FLA-file (unless we used <a href="http://www.swfmill.org" title="The home of SWFMill">swfmill</a> or something similarly fancy, which were in their infancy back then). Everything had to be exportable from the library and as items in the library couldn&#8217;t really be linked to classes directly, all item script had to be placed on the timeline. Of course it was a big mess and already back then we were hoping for a better way of loading content from external files (did anyone <strong>ever</strong> find out how to utilize &#8220;shared libraries&#8221; for actual production value?).</p>
<p>And now we have this feature &#8211; it is so much better. Create a symbol in a library in any FLA-file, load the resulting SWF-file in your production and instantiate any symbol from it and attach it anywhere you like. Clean and beautiful and exactly what we needed back then &#8211; and when going back, you really get that feeling again.</p>
<h3 id="toc-number-3-error-handling-and-run-time-validation">Number 3: Error handling and run-time validation</h3>
<blockquote><p>When it doesn&#8217;t say anything, does that mean no error happened?</p></blockquote>
<p>Imagine having put your AS2 production live, have it loaded in the browser and an error happens (because you visually can see that something is wrong) &#8211; how the h¤ll do you find out what happened? There were the old debugger, but it was crap &#8211; simply crap. You could only hope that you had enough trace&#8217;s spread around to debug based on your flashlog.txt file.</p>
<p>With AS3 we got run-time validation. If something is wrong, we (most of the time) get a huge ugly error popping out. It might look bad, might give bad user experience (if so, they ought to stop using the debug player though) but to the developer it gives the necessary feedback (thank you stack trace). And not to mention all the other advantages that run-time validation gives.</p>
<h3 id="toc-number-2-function-scoping">Number 2: Function scoping</h3>
<blockquote><p>I simply <strong>hate</strong> delegate.</p></blockquote>
<p>When doing pseudo-OOP like in ActionScript 2 (or AS1 or JavaScript), you constantly need to bind your functions as methods of your class instances in order to be sure, that if passed by reference, they are invoked in the right place. In ActionScript 3, this is no longer necessary. Basically, when passing a reference to a method of a class to someone or somewhere else, the scope of the method (being the originating instance) remains intact:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> a<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">b</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Object</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">c</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">b</span>.<span style="color: #004993;">addChild</span> = a.<span style="color: #004993;">addChild</span>;
<span style="color: #004993;">b</span>.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">c</span><span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>a.<span style="color: #004993;">numChildren</span><span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// traces &quot;1&quot;</span></pre></div></div>

<p>Anyone using AS3 knows this by now, but this was just to re-iterate and give an example.</p>
<p>Actually, it is not function scoping. It is more about creating a clear distinction between functions and methods. Functions are anonymous and created inline and don&#8217;t really use a &#8220;this&#8221;-scope but a reference scope. Methods are attributes of classes and are always invoked <strong>on</strong> instances of the class.</p>
<p>It does remove some &#8220;scriptability&#8221; in ActionScript, as currying and similar tricks aren&#8217;t as useful anymore and actually you never use &#8220;normal&#8221; functions at all &#8211; only methods. But intelligent use of patterns can have the same effects as such minor tricks and though they require more typing, they produce cleaner and often more intelligent, re-usable code. But that is the target of a whole other discussion.</p>
<h3 id="toc-number-1-the-display-list-instead-of-depths">Number 1: The display-list instead of depths</h3>
<blockquote><p>myClip.getNextHighestDepthLowerThanTheDepthOfTheMenu()</p></blockquote>
<p>Depth. The most annoying part of AS2. I didn&#8217;t realize it back then, you were so accustomed to writing foo.createEmptyMovieClip(&#8220;myclip&#8221;, foo.getNextHighestDepth()) and then swapDepths&#8217;ing it all around afterwards, but now that I don&#8217;t need it anymore but have to go back to using it &#8211; it is so time consuming.</p>
<p>At first, the display list sounded a bit scary to me and the very first demos of the language explaining MXML and layout schemes gave horrible flashbacks to the script-consuming &#8220;layout engine&#8221;, that Java and SWING employs. But most of us never use any of those layout schemes, simply add items to stage on coordinates with the display list being the best tool to ensure proper depth management. Thank you!</p>
<p>&nbsp;</p>
<p>Please leave comments, if you have other features than you constantly find yourself missing, or in other ways believe you can improve this list. Oh, and if you have suggestions for other lists, then by all means add them here.</p>


<p>Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/07/01/minor-change-in-handling-nan-positions-in-flash-player-10-0-22/' rel='bookmark' title='Permanent Link: Minor change in handling NaN positions in Flash Player 10,0,22'>Minor change in handling NaN positions in Flash Player 10,0,22</a></li>
<li><a href='http://www.barklund.org/blog/2009/11/04/advanced-e4x-assignment-xmllists/' rel='bookmark' title='Permanent Link: Advanced E4X &#8211; Assignment to XMLLists'>Advanced E4X &#8211; Assignment to XMLLists</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2009/07/19/top-6-as3-features-you-miss-when-switching-back-to-as2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Minor change in handling NaN positions in Flash Player 10,0,22</title>
		<link>http://www.barklund.org/blog/2009/07/01/minor-change-in-handling-nan-positions-in-flash-player-10-0-22/</link>
		<comments>http://www.barklund.org/blog/2009/07/01/minor-change-in-handling-nan-positions-in-flash-player-10-0-22/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 12:34:38 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/?p=163</guid>
		<description><![CDATA[I&#8217;ve just discovered a &#8220;bug&#8221; in the latest Flash Player. Actually the &#8220;bug&#8221; was in a production, that only worked in the latest player and not in previous players. I&#8217;ve boiled it down to this: If the x- or y-attribute of a DisplayObject is set to NaN, in previous players this caused the attribute to [...]


Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/10/21/bitmap-fill-crash-flash-cs4/' rel='bookmark' title='Permanent Link: Weird bitmap fill crash error in Flash CS4.'>Weird bitmap fill crash error in Flash CS4.</a></li>
<li><a href='http://www.barklund.org/blog/2009/06/08/using-addthis-with-flash/' rel='bookmark' title='Permanent Link: Using AddThis with Flash'>Using AddThis with Flash</a></li>
<li><a href='http://www.barklund.org/blog/2009/07/06/flash-development-scripted-layout/' rel='bookmark' title='Permanent Link: Flash development and the practice of Scripted Layout'>Flash development and the practice of Scripted Layout</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just discovered a &#8220;bug&#8221; in the latest Flash Player. Actually the &#8220;bug&#8221; was in a production, that only worked in the latest player and not in previous players. I&#8217;ve boiled it down to this:</p>
<blockquote><p>
If the x- or y-attribute of a DisplayObject is set to NaN, in previous players this caused the attribute to be set to -107374182.4. In the latest player, the attribute is set to 0.</p></blockquote>
<p><span id="more-163"></span></p>
<p>The value -107,374,182.4 is -2,147,483,648/20. Flash uses &#8220;twixels&#8221; for positions, which is a twentieth pixel. Thus the lowest possible value x or y can hold is -(2^31)/20 which is exactly -107,374,182.4. This means, that when rendering DisplayObjects with a position in either direction with a value of NaN, the position was instead rendered with the lowest possible value for this attribute previously, but now it is rendered with this attribute set to 0 instead.</p>
<p>Thus, it is <strong>not</strong> a bug per se, but it is a change in behavior in response to an error condition &#8211; namely bad positioning.</p>
<p>My test-page can be found <a href="/examples/bughunt_undefined.html" title="Demo-page for undefined behavior">here</a>. Please try this page out and copy-paste the results in the comments, if you do not experience the same results as described above. The result in Flash Player 10,0,22(,87) on Mac is:</p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">Player version: MAC 10,0,22,87
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: 0 &lt;--
typeof sprite.x: number</pre></div></div>

<p>In the previous player 10,0,12(,36) the result was:</p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">Player version: MAC 10,0,12,36
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: -107374182.4 &lt;--
typeof sprite.x: number</pre></div></div>

<p>Note the second-to-last line &#8211; the value of x is different when &#8220;undefined&#8221; is added to the current value.</p>
<p>Some other test results from non-Mac versions as well as previous versions:</p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">Player version: MAC 10,0,2,54
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: -107374182.4
typeof sprite.x: number
&nbsp;
Player version: MAC 9,0,159,0
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: -107374182.4
typeof sprite.x: number
&nbsp;
Player version: MAC 9,0,124,0
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: -107374182.4
typeof sprite.x: number
&nbsp;
Player version: WIN 10,0,22,87
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: 0
typeof sprite.x: number</pre></div></div>

<p>My very simple source FLA file is available <a href="/examples/bughunt_undefined.fla" title="Link to FLA source file">here</a>. The xtra info in the above is simply to make sure, that no other changes in handling NaN or undefined has happened.</p>
<p>Thanks to David Wulff, Anders Krarup and Katharina Berg for help in testing.</p>
<p><strong>Update 4.07PM</strong>: It is actually mentioned in the <a href="http://www.adobe.com/support/documentation/en/flashplayer/releasenotes.html" title="Flash Player Release Notes for all versions">release notes</a> as: &#8220;Fix AS APIs&#8217; inconsistent handling of NaN parameters on different platforms. (<a href="https://bugs.adobe.com/jira/browse/FP-612">FP-612</a>,<a href="https://bugs.adobe.com/jira/browse/FP-903">FP- 903</a>, <a href="https://bugs.adobe.com/jira/browse/FP-964">FP-964</a>/2200454)&#8221;. However, all these reports are about Windows installations only and they all mention, that all players before FP10 set the attribute to 0 and setting the attribute to  -107374182.4 only happened in Flash Player 10,0,2 and 10,0,12 (and probably also the Linux-only 10,0,15). From my results however, it is clear that for Mac this issue has always been the case also in Flash Player 9, which is revealed in the comment about the fix as &#8220;inconsistent handling [...] on different platforms&#8221;.</p>
<p>It seems to be an actual desired result that this was &#8220;fixed&#8221; in order to bring the error condition handling back to the way it has always been in flash players for Windows in all previous versions before FP10.</p>


<p>Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/10/21/bitmap-fill-crash-flash-cs4/' rel='bookmark' title='Permanent Link: Weird bitmap fill crash error in Flash CS4.'>Weird bitmap fill crash error in Flash CS4.</a></li>
<li><a href='http://www.barklund.org/blog/2009/06/08/using-addthis-with-flash/' rel='bookmark' title='Permanent Link: Using AddThis with Flash'>Using AddThis with Flash</a></li>
<li><a href='http://www.barklund.org/blog/2009/07/06/flash-development-scripted-layout/' rel='bookmark' title='Permanent Link: Flash development and the practice of Scripted Layout'>Flash development and the practice of Scripted Layout</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2009/07/01/minor-change-in-handling-nan-positions-in-flash-player-10-0-22/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using ShareThis with Flash</title>
		<link>http://www.barklund.org/blog/2009/05/06/using-sharethis-with-flash/</link>
		<comments>http://www.barklund.org/blog/2009/05/06/using-sharethis-with-flash/#comments</comments>
		<pubDate>Wed, 06 May 2009 12:44:50 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/2009/05/06/using-sharethis-with-flash/</guid>
		<description><![CDATA[This feature does currently not work &#8211; see list of updates below ShareThis is a great service for adding shareability to your website in a very simple way. It even includes the &#8220;tip a friend&#8221; option, so you don&#8217;t need to code that for your own site. I will describe how to embed it from [...]


Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/06/08/using-addthis-with-flash/' rel='bookmark' title='Permanent Link: Using AddThis with Flash'>Using AddThis with Flash</a></li>
<li><a href='http://www.barklund.org/blog/2009/07/01/minor-change-in-handling-nan-positions-in-flash-player-10-0-22/' rel='bookmark' title='Permanent Link: Minor change in handling NaN positions in Flash Player 10,0,22'>Minor change in handling NaN positions in Flash Player 10,0,22</a></li>
<li><a href='http://www.barklund.org/blog/2009/09/04/mxhr4as3-multipart-mixed-file-download-flash/' rel='bookmark' title='Permanent Link: Announcing MXHR4AS3: Multipart/mixed-file download by Flash clients'>Announcing MXHR4AS3: Multipart/mixed-file download by Flash clients</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<blockquote style="background: #333; font-size: 120%; padding: 5px;"><p>This feature does currently not work &#8211; see list of updates below</p></blockquote>
<p>
<a href="http://www.sharethis.com" title="ShareThis website">ShareThis</a> is a great service for adding shareability to your website in a very simple way. It even includes the &#8220;tip a friend&#8221; option, so you don&#8217;t need to code that for your own site. I will describe how to embed it from flash.
</p>
<p><strong>Note 2009/05/19: </strong>Due to changes in the ShareThis API popup-functionality is broken currently (both in my example and in some of my live projects). I have filed a bug with ShareThis to fix this ASAP.</p>
<p><strong>Note 2009/05/21: </strong>ShareThis have now fixed the above bug but there is still a minor JavaScript error thrown. The popup works now though as it should from both JS and Flash.</p>
<p><strong>Note 2009/06/08: </strong>ShareThis now broke it again. And this time their support staff doesn&#8217;t answer. Please see <a href="http://www.barklund.org/blog/2009/06/08/using-addthis-with-flash/" title="Using AddThis with Flash from Barklund.org">an example implemented with AddThis</a> instead.</p>
<p><strong>Note 2009/06/19: </strong>ShareThis finally fixed it again. They wrote a mail on the 17th to me stating the bug was reintroduced when they implemented CDN, but would be fixed in the next release. Let&#8217;s hope it stays that way.</p>
<p><strong>Note 2009/08/14: </strong>ShareThis has recently implemented a brand new version of their service &#8211; and surprise: it is <strong>not</strong> backwards compatible. Thus my popup example is broken again. I will investigate and fix soon.</p>
<p><strong>Note 2009/08/17: </strong>ShareThis has promised to deliver a flash API within a few weeks. Let&#8217;s see what happens then&#8230;</p>
<p><span id="more-48"></span></p>
<p>
You can do that in two ways, either by using a overlay div in HTML or creating a popup (that might get blocked). The prettiest and most user friendly is of course the overlay, but in order to have HTML overlays on top of Flash elements, you need to set the Flash <a href="http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&#038;file=00000852.html" title="Adobe Livedocs: wmode attribute/parameter description">wmode to transparent</a>. This has a strange and unfortunate side-effect (which has been <a href="http://bugs.adobe.com/jira/browse/FP-479" title="Adobe bug-report - it is marked as closed, but it is not resolved">bug-reported to Adobe</a>), that the keyboard defaults to standard US layout. For US websites, this is not a big problem, but for a Danish website it matters a lot. There are many differences between US and DK keyboard layout including Danish special characters and the location of the @-sign. Thus, wmode-transparent cannot be used for Flash-objects having input fields requiring users to enter text (which could contain special characters) or an email address (which contains the @-sign). Thus we need to use the popup-solution.
</p>
<p>
First, simply go to <a href="http://sharethis.com/publishers/" title="Publisher guide to ShareThis">sharethis.com</a> publisher section and <a href="http://sharethis.com/publishers/getbutton/" title="Get the Button">customize your widget</a>. Instead of placing the widget code snippet where you want the button, put it in the &lt;head&gt;-section of your website.  The code snippet I got was:
</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://w.sharethis.com/button/sharethis.js#publisher=636e055b-a4a2-4f9c-872c-b7aa9a701bb0&amp;amp;type=website&amp;amp;send_services=email&amp;amp;post_services=facebook%2Clinkedin%2Cmyspace%2Cdigg%2Cdelicious%2Ctwitter%2Creddit%2Ctechnorati%2Cwordpress%2Cblogger%2Cgoogle_bmarks%2Cwindows_live&quot;&gt;&lt;/script&gt;</pre></div></div>

<p>
Then create a little javascript function like:
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  <span style="color: #003366; font-weight: bold;">function</span> share<span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span> title<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> s <span style="color: #339933;">=</span> SHARETHIS.<span style="color: #660066;">addEntry</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      url<span style="color: #339933;">:</span> url<span style="color: #339933;">,</span>
      title<span style="color: #339933;">:</span> title
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>button<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>popup<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    s.<span style="color: #660066;">popup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>
Finally, simple call this function from Flash using <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html" title="ExternalInterface Livedocs documentation for ActionScript 3">ExternalInterface</a>:
</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">url</span>:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;http://www.barklund.org/blog/2009/05/06/using-sharethis-with-flash/&quot;</span>;
<span style="color: #000000; font-weight: bold;">var</span> title:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Barklund.org - Using ShareThis with Flash&quot;</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">external</span>.<span style="color: #006600;">ExternalInterface</span>;
ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;share&quot;</span>, <span style="color: #0066CC;">url</span>, title<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>
See an example <a href="/examples/sharethis/" title="Examples using ShareThis with Flash">here</a> &#8211; the javascript function is invoked both from a regular HTML link and from a simple Flash file using just the above ActionScript.</p>


<p>Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/06/08/using-addthis-with-flash/' rel='bookmark' title='Permanent Link: Using AddThis with Flash'>Using AddThis with Flash</a></li>
<li><a href='http://www.barklund.org/blog/2009/07/01/minor-change-in-handling-nan-positions-in-flash-player-10-0-22/' rel='bookmark' title='Permanent Link: Minor change in handling NaN positions in Flash Player 10,0,22'>Minor change in handling NaN positions in Flash Player 10,0,22</a></li>
<li><a href='http://www.barklund.org/blog/2009/09/04/mxhr4as3-multipart-mixed-file-download-flash/' rel='bookmark' title='Permanent Link: Announcing MXHR4AS3: Multipart/mixed-file download by Flash clients'>Announcing MXHR4AS3: Multipart/mixed-file download by Flash clients</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2009/05/06/using-sharethis-with-flash/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Apollo has been launched</title>
		<link>http://www.barklund.org/blog/2006/06/09/apollo-has-been-launched/</link>
		<comments>http://www.barklund.org/blog/2006/06/09/apollo-has-been-launched/#comments</comments>
		<pubDate>Fri, 09 Jun 2006 11:02:32 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[AS2]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/2006/06/09/apollo-has-been-launched/</guid>
		<description><![CDATA[Adobe representative, Phillip Miller, recently guested Copenhagen, and during his visit he gave further insights into the upcoming client, Apollo. When first introduced at MAX 2005, Kevin Lynch talked about Apollo being a browser substitute for offline browsing of HTML and Flash. Since the merger with Adobe, Acrobat Reader has of course been introduced into [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Adobe representative, Phillip Miller, recently guested Copenhagen, and during his visit he gave further insights into the upcoming client, Apollo.</p>
<p>When first introduced at MAX 2005, Kevin Lynch talked about Apollo being a browser substitute for offline browsing of HTML and Flash. Since the merger with Adobe, Acrobat Reader has of course been introduced into this project. Philip Millers recent talk about this stated, that it would be available for all platforms (Win, Mac and *nix), and that a beta was to come within the next year.<br />
<span id="more-19"></span><br />
All in all, Apollo sounds like a promising technology, but it also sounds like, that no-one needs to worry about it for some years to come. I wonder what it will do to Central?</p>
<p>References:</p>
<ul>
<li><a href="http://mediamac.dk/index.php/news/show/id=15443">Recent article in Danish</a></li>
<li><a href="http://weblogs.macromedia.com/mesh/archives/2005/12/flash_player_an.html">Mike Chambers on plugins and Apollo</a></li>
<li><a href="http://news.com.com/Flash+to+jump+beyond+the+browser/2100-1007_3-6071005.html?tag=nefd.lede">CNet on Apollo (from May 11, 2006)</a></li>
<li><a href="http://www.adobe.com/macromedia/events/max/max2005/video/">Apollo introduction from MAX 2005 (select <em>Day One</em>, <em>Platform: Future</em>)</li>
</ul>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2006/06/09/apollo-has-been-launched/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing an URI</title>
		<link>http://www.barklund.org/blog/2006/06/06/parsing-an-uri/</link>
		<comments>http://www.barklund.org/blog/2006/06/06/parsing-an-uri/#comments</comments>
		<pubDate>Tue, 06 Jun 2006 11:29:01 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[AS2]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/2006/06/06/parsing-an-uri/</guid>
		<description><![CDATA[I recently promised, that if I couldn&#8217;t find a valid URI-parser in ActionScript 2, I would create and release my own. I&#8217;ve thus created my own built on simple string parsing functions (as opposed to using some regexp implementation, which is still not natively supported until AS3). It does not properly handle invalid chars of [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I recently promised, that if I couldn&#8217;t find a valid URI-parser in ActionScript 2, I would create and release my own.</p>
<p>I&#8217;ve thus created my own built on simple string parsing functions (as opposed to using some regexp implementation, which is still not natively supported until AS3). It does not properly handle invalid chars of an URI (like spaces, special characters and more), but assumes an URL-encoded URI of some sort.<br />
<span id="more-18"></span><br />
Well, here it is:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> org.<span style="color: #006600;">barklund</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">URI</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">/**
	 * parts of uri
	 */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> host:<span style="color: #0066CC;">String</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> scheme:<span style="color: #0066CC;">String</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> user:<span style="color: #0066CC;">String</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">password</span>:<span style="color: #0066CC;">String</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> query:<span style="color: #0066CC;">String</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> fragment:<span style="color: #0066CC;">String</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> port:<span style="color: #0066CC;">String</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> resource:<span style="color: #0066CC;">String</span>;
	<span style="color: #808080; font-style: italic;">/** 
	 * complete uri
	 */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> uri:<span style="color: #0066CC;">String</span>;
	<span style="color: #808080; font-style: italic;">/**
	 * private constructor initiating parse
	 */</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> URI<span style="color: #66cc66;">&#40;</span>u:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		uri = u;
		parse<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #808080; font-style: italic;">/**
	 * parse uri into scheme, host and resource - if these exist
	 */</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> parse<span style="color: #66cc66;">&#40;</span><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;">// if no slash - we only have resource</span>
		<span style="color: #000000; font-weight: bold;">var</span> first_slash:<span style="color: #0066CC;">Number</span> = uri.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>first_slash == -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			resource = uri;
			parseResource<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #808080; font-style: italic;">// if :// (before first slash) we have scheme first</span>
		<span style="color: #000000; font-weight: bold;">var</span> working:<span style="color: #0066CC;">String</span> = uri;
		<span style="color: #000000; font-weight: bold;">var</span> scheme_end:<span style="color: #0066CC;">Number</span> = uri.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;://&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>scheme_end <span style="color: #66cc66;">!</span>= -<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&amp;&amp;</span> scheme_end <span style="color: #66cc66;">&lt;</span> first_slash<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			scheme = uri.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, scheme_end<span style="color: #66cc66;">&#41;</span>;
			working = working.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span>scheme_end+<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #808080; font-style: italic;">// split working into host and resource</span>
		first_slash = working.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>first_slash == -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// no resource</span>
			host = working;
			parseHost<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
			host = working.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, first_slash<span style="color: #66cc66;">&#41;</span>;
			resource = working.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span>first_slash<span style="color: #66cc66;">&#41;</span>;
			parseResource<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			parseHost<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #808080; font-style: italic;">/**
	 * parse resource into resource, fragment and query if exists
	 */</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> parseResource<span style="color: #66cc66;">&#40;</span><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;">// split fragment from resource - including #</span>
		<span style="color: #000000; font-weight: bold;">var</span> fragment_part:<span style="color: #0066CC;">Number</span> = resource.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;#&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>fragment_part <span style="color: #66cc66;">!</span>= -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			fragment = resource.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span>fragment_part<span style="color: #66cc66;">&#41;</span>;
			resource = resource.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, fragment_part<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #808080; font-style: italic;">// split query from resource - including ?</span>
		<span style="color: #000000; font-weight: bold;">var</span> query_part:<span style="color: #0066CC;">Number</span> = resource.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;?&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>query_part <span style="color: #66cc66;">!</span>= -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			query = resource.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span>query_part<span style="color: #66cc66;">&#41;</span>;
			resource = resource.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, query_part<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #808080; font-style: italic;">/**
	 * parse host into host, port, user and password if exists
	 */</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> parseHost<span style="color: #66cc66;">&#40;</span><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;">// split host into user:pass and host:port over @</span>
		<span style="color: #000000; font-weight: bold;">var</span> at:<span style="color: #0066CC;">Number</span> = host.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;@&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> colon:<span style="color: #0066CC;">Number</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>at <span style="color: #66cc66;">!</span>= -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			user = host.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, at<span style="color: #66cc66;">&#41;</span>;
			host = host.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span>at + <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #808080; font-style: italic;">// split pass from user</span>
			colon = user.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;:&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>colon <span style="color: #66cc66;">!</span>= -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">password</span> = user.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span>colon + <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
				user = user.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, colon<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #808080; font-style: italic;">// split port from host</span>
		colon = host.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;:&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>colon <span style="color: #66cc66;">!</span>= -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			port = host.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span>colon + <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
			host = host.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, colon<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #808080; font-style: italic;">/**
	 * static constructor. it looks nice and adds the possibility to return null.
	 */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> parseString<span style="color: #66cc66;">&#40;</span>uri:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:URI <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>uri<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> URI<span style="color: #66cc66;">&#40;</span>uri<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">null</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>It is used via the static <em>constructor</em> like:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> org.<span style="color: #006600;">barklund</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">URI</span>;
<span style="color: #000000; font-weight: bold;">class</span> org.<span style="color: #006600;">barklund</span>.<span style="color: #006600;">somewhere</span>.<span style="color: #006600;">Something</span> <span style="color: #66cc66;">&#123;</span>
	...
	<span style="color: #000000; font-weight: bold;">var</span> my_ftp:URI = URI.<span style="color: #006600;">parseString</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ftp://myuser:mypassword@myhost:21/some/ressource&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>my_ftp.<span style="color: #006600;">scheme</span> === <span style="color: #ff0000;">&quot;ftp&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		...
<span style="color: #66cc66;">&#125;</span></pre></div></div>



<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2006/06/06/parsing-an-uri/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FlashVars and AS2</title>
		<link>http://www.barklund.org/blog/2006/06/06/flashvars-and-as2/</link>
		<comments>http://www.barklund.org/blog/2006/06/06/flashvars-and-as2/#comments</comments>
		<pubDate>Tue, 06 Jun 2006 10:00:00 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[AS2]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/2006/06/06/flashvars-and-as2/</guid>
		<description><![CDATA[When using FlashVars variables are pushed directly from the HTML-embedding of the Flash instance into the main timeline &#8211; _level0 that is. To avoid having _level0.some_flashvar spread around the code without knowing, whether they exist, where they are used and more, I normally use a dynamic singleton FlashVars-class for first parsing these in the main [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>When using FlashVars variables are pushed directly from the HTML-embedding of the Flash instance into the main timeline &ndash; <code>_level0</code> that is.</p>
<p>To avoid having <code>_level0.some_flashvar</code> spread around the code without knowing, whether they exist, where they are used and more, I normally use a dynamic singleton <code>FlashVars</code>-class for first parsing these in the main timeline, and subsequently using this singleton class when loading vars.<br />
<span id="more-17"></span><br />
The class is defined as:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">dynamic</span> <span style="color: #000000; font-weight: bold;">class</span> org.<span style="color: #006600;">barklund</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">FlashVars</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">/* vars */</span>
	<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> instance:FlashVars;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> vars:<span style="color: #0066CC;">Object</span>;
	<span style="color: #808080; font-style: italic;">/* can be overriden or cleared by inheritance */</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> prefix:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;fv_&quot;</span>;
	<span style="color: #808080; font-style: italic;">/* constructor */</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> FlashVars<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">// init hashmap</span>
		vars = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #808080; font-style: italic;">// set __resolve to use getVar-function for dynamic references</span>
		__resolve = getVar;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #808080; font-style: italic;">/* singleton */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> getInstance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:FlashVars <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> instance ? instance : instance = <span style="color: #000000; font-weight: bold;">new</span> FlashVars<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #808080; font-style: italic;">/* parse through movieclip */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> parse<span style="color: #66cc66;">&#40;</span>p:<span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Void</span> <span style="color: #66cc66;">&#123;</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;">String</span> <span style="color: #b1b100;">in</span> p<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>prefix<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>i.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span>prefix<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">!</span>== <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
					<span style="color: #b1b100;">continue</span>;
				<span style="color: #66cc66;">&#125;</span>
				setVar<span style="color: #66cc66;">&#40;</span>i.<span style="color: #0066CC;">substring</span><span style="color: #66cc66;">&#40;</span>prefix.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span>, p<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
				setVar<span style="color: #66cc66;">&#40;</span>i, p<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #808080; font-style: italic;">/* get and set */</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setVar<span style="color: #66cc66;">&#40;</span>n:<span style="color: #0066CC;">String</span>, v:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Void</span> <span style="color: #66cc66;">&#123;</span>
		vars<span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span> = v;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getVar<span style="color: #66cc66;">&#40;</span>n:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> vars<span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">!</span>== <span style="color: #0066CC;">undefined</span> ? <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>vars<span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #000000; font-weight: bold;">null</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>And it can be used as for instance on the main timeline:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> org.<span style="color: #006600;">barklund</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">FlashVars</span>;
FlashVars.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parse</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>And variables can be read like:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> org.<span style="color: #006600;">barklund</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">FlashVars</span>;
<span style="color: #000000; font-weight: bold;">class</span> org.<span style="color: #006600;">barklund</span>.<span style="color: #006600;">someproject</span>.<span style="color: #006600;">SomeClass</span> <span style="color: #66cc66;">&#123;</span>
	...
	<span style="color: #000000; font-weight: bold;">var</span> fv:FlashVars = FlashVars.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> id:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">parseInt</span><span style="color: #66cc66;">&#40;</span>fv.<span style="color: #006600;">id</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>fv.<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>It can also be extended with a non-dynamic class for strong typing (though it requires extending <em>singleton-ness</em>, which is quite strange-looking):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> org.<span style="color: #006600;">barklund</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">FlashVars</span>;
<span style="color: #000000; font-weight: bold;">class</span> org.<span style="color: #006600;">barklund</span>.<span style="color: #006600;">someproject</span>.<span style="color: #006600;">SomeSettingsClass</span> <span style="color: #0066CC;">extends</span> FlashVars <span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">/* override singleton */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> getInstance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:SomeSettingsClass <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> SomeSettingsClass<span style="color: #66cc66;">&#40;</span>instance ? instance : instance = <span style="color: #000000; font-weight: bold;">new</span> SomeSettingsClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #808080; font-style: italic;">/* public accessors */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> id<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>getVar<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;id&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>getVar<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>This class is not dynamic in order to make the user of this only use these two variables. Other variables from the FlashVars-object can be read via <code>getVar</code> though (inherited publicly), so this could also be redeclared as <code>private</code>.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2006/06/06/flashvars-and-as2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Biteboard sources</title>
		<link>http://www.barklund.org/blog/2006/05/21/biteboard-sources/</link>
		<comments>http://www.barklund.org/blog/2006/05/21/biteboard-sources/#comments</comments>
		<pubDate>Sun, 21 May 2006 18:41:50 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[AS2]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/2006/05/21/biteboard-sources/</guid>
		<description><![CDATA[The sources are now available for download. It would have uploaded it yesterday, but Tom and Audrey starred in a nice film, I had to see. Below are the complete sources of AS-classes, FLA-file and presentation. The presentation is in Danish, but all classes are written and documented in English, and the software itself has [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>The sources are now available for download. It would have uploaded it yesterday, but <a href="http://imdb.com/name/nm0000158/">Tom</a> and <a href="http://imdb.com/name/nm0851582/">Audrey</a> starred in a <a href="http://imdb.com/title/tt0382625/">nice film</a>, I had to see.
</p>
<p><span id="more-11"></span></p>
<p>Below are the complete sources of AS-classes, FLA-file and presentation. The presentation is in Danish, but all classes are written and documented in English, and the software itself has English language GUI.</p>
<ul>
<li><a id="p14" href="http://www.barklund.org/blog/wp-content/uploads/2006/05/Biteboard.zip">Complete source of AS2-classes and FLA-file &ndash; zipped.</a></li>
<li><a id="p13" href="http://www.barklund.org/blog/wp-content/uploads/2006/05/Biteboard.odp">Presentation in ODP (OpenOffice) format &ndash; in Danish.</a></li>
<li><a id="p12" href="http://www.barklund.org/blog/wp-content/uploads/2006/05/Biteboard.ppt">Powerpoint (converted from ODP) &ndash; in Danish.</a>
</li>
</ul>
<p>The program itself can be demoed <a href="/examples/biteboard/biteboard.html">here</a>, and I will try to have the server running for at least some weeks to come.</p>
<p>The server is made in Java by my good friend Mads JÃ¸rgensen, and will (hopefully) be available for download at his blog at <a href="http://swag.dk">swag.dk</a></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2006/05/21/biteboard-sources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FlashVision 2006</title>
		<link>http://www.barklund.org/blog/2006/05/20/flashvision-2006/</link>
		<comments>http://www.barklund.org/blog/2006/05/20/flashvision-2006/#comments</comments>
		<pubDate>Sat, 20 May 2006 08:30:27 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[AS2]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/2006/05/20/flashvision-2006/</guid>
		<description><![CDATA[Is now over. I came home late last night by train after having attended FlashVision 2006. My presentation went very well &#8211; I think. Later a video of the entire conference/award show will be posted on the website. I hope to have a segment of it (the part featuring me) posted here. Also, both my [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Is now over. I came home late last night by train after having attended <a href="http://flashvision.dk" title="FlashVision website">FlashVision 2006</a>. My presentation went very well &ndash; I think. Later a video of the entire conference/award show will be posted on the website. I hope to have a segment of it (the part featuring me) posted here. Also, both my collegue, <a href="http://flashorbit.dk" title="His new blog">Morten Reinholdt</a>, and the hosts took a lot of pictures &ndash; some of which I will post here as well.<br />
<span id="more-9"></span><br />
After my presentation, <a href="http://goober.nu" title="The website of Ola">Ola Bergnar</a> gave an insight into how he created very amazing 3d-like (and yet nothing like 3d) animations using very simple masking techniques in Flash 8. It was quite insightful and interesting.</p>
<p>Later, the actual award show started. <a href="http://bitman.dk" title="Bitman website">Bitman</a> won the award for Best Branding and Best Animations, <a href="http://thomashelmig.dk" title="Thomas Helmig website">Thomas Helmig.dk</a> won for Best Experimental, and the <a href="http://www.iform.dk/bohp/jsp/polopoly.jsp?d=1756&#038;a=10447" title="iForm route planner"><em>iForm</em> running route planner</a> won for Best Rich Internet Application. Overall, the nominees displayed some very exciting usage of Flash.</p>
<p>It was a very nice event put together by the good FlashVision team. I do hope, that they will keep it up as an annual event, and that it will have even better attendance next year &ndash; both for nominees, but also regarding turnout for the event itself.</p>
<p>As for my presentation, full source of <abbr title="OpenOffice Presentation">ODP</abbr>, Flash files and class files will be published later today &ndash; when I&#8217;ve just had some time to correct minor errors, insert missing comments and add the proper license.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2006/05/20/flashvision-2006/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Biteboard</title>
		<link>http://www.barklund.org/blog/2006/05/18/biteboard/</link>
		<comments>http://www.barklund.org/blog/2006/05/18/biteboard/#comments</comments>
		<pubDate>Thu, 18 May 2006 21:40:20 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[AS2]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/2006/05/18/biteboard/</guid>
		<description><![CDATA[For my upcoming speak at FlashVision, I&#8217;ve made a little demo of a multiuser whiteboard application entitled Biteboard, which can be demoed here. Source code will be available late saturday, when I&#8217;m fully settled back in mainland Denmark and final corrections and documentation have been completed. It will of course adhere to the given license. [...]


Related posts:<ol><li><a href='http://www.barklund.org/blog/2010/05/07/events-suck-actionscript-3/' rel='bookmark' title='Permanent Link: Why events suck in ActionScript 3'>Why events suck in ActionScript 3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For my upcoming speak at <a href="http://flashvision.dk">FlashVision</a>, I&#8217;ve made a little demo of a multiuser whiteboard application entitled <em>Biteboard</em>, which can be demoed <a href="http://barklund.org/examples/biteboard/biteboard.html">here</a>.</p>
<p>Source code will be available late saturday, when I&#8217;m fully settled back in <a href="http://maps.google.com/maps?f=q&#038;hl=en&#038;sll=37.0625,-95.677068&#038;sspn=57.945758,110.566406&#038;ll=55.550388,12.046509&#038;spn=1.312874,3.4552&#038;om=1">mainland Denmark</a> and final corrections and documentation have been completed. It will of course adhere to the given <a href="/blog/license/">license</a>.</p>
<p>The server is made by my good friend Mads JÃ¸rgensen (at <a href="http://swag.dk">swag.dk</a>), and it will as well be published under some <em>some rights reserved</em> <a href="http://creativecommons.org">Creative Commons</a> license.<br />
<span id="more-6"></span><br />
My primary love for this simple application is a new &ndash; but very simple &ndash; event listener model. The event dispatching is done via the regular EventDispatcher-model, but the event listener signup is done by implementing the interfaces with the events to listen for and dedicated signup methods for the actual listeners.</p>
<p>This can be examplified by for instance listening to connection changes:</p>
<pre lang="'actionscript">
public function addConnectionListener(cl:ConnectionListener):Void {
	addEventListener("onConnect", cl);
	addEventListener("onDisconnect", cl);
}
</pre>
<p>It is evident, that the <code>ConnectionListener</code> defines the two methods: <code>onConnect</code> and <code>onDisconnect</code>. Event dispatching is still done simply via <code>dispatchEvent("onConnect")</code>.</p>
<p>I considered having the communication class implementing all these interfaces and having <em>shim</em> methods for all these call (thus type checking while dispatching as well as while listening), but the excess of writing those functions within the same class that would call them (or directly dispatch themselves) did not seem worth it.</p>
<p>Anyway, you can judge for yourself when the complete source will be available saturday.</p>


<p>Related posts:<ol><li><a href='http://www.barklund.org/blog/2010/05/07/events-suck-actionscript-3/' rel='bookmark' title='Permanent Link: Why events suck in ActionScript 3'>Why events suck in ActionScript 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2006/05/18/biteboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
