<?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>w3blog &#187; WebDev</title>
	<atom:link href="http://wahlers.com.br/claus/blog/category/webdev/feed/" rel="self" type="application/rss+xml" />
	<link>http://wahlers.com.br/claus/blog</link>
	<description>Claus Wahlers on Application Development, Web Standards and what not</description>
	<lastBuildDate>Sat, 10 Sep 2011 02:01:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ActionScript 3 Bitmap Tracer (Vectorizer): as3potrace</title>
		<link>http://wahlers.com.br/claus/blog/as3-bitmap-tracer-vectorizer-as3potrace/</link>
		<comments>http://wahlers.com.br/claus/blog/as3-bitmap-tracer-vectorizer-as3potrace/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 05:23:35 +0000</pubDate>
		<dc:creator>Claus Wahlers</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://wahlers.com.br/claus/blog/?p=262</guid>
		<description><![CDATA[Ever wanted to convert a bitmap to vector shapes, at runtime, in Flash? Look no further. Let me introduce you to as3potrace, an ActionScript 3 library to trace bitmaps. As the name suggests, this is a port of the well known C library potrace by Peter Selinger. To be more exact, it is a AS3 [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwahlers.com.br%252Fclaus%252Fblog%252Fas3-bitmap-tracer-vectorizer-as3potrace%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fgw6qJI%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22ActionScript%203%20Bitmap%20Tracer%20%28Vectorizer%29%3A%20as3potrace%22%20%7D);"></div>
<p>Ever wanted to convert a bitmap to vector shapes, at runtime, in Flash? Look no further. Let me introduce you to <a href="https://github.com/PowerflasherBR/as3potrace">as3potrace</a>, an ActionScript 3 library to trace bitmaps.</p>
<p>As the name suggests, this is a port of the well known C library <a href="http://potrace.sourceforge.net/">potrace</a> by Peter Selinger. To be more exact, it is a AS3 port of <a href="http://www.drawing3d.de/Downloads.aspx">Vectorization</a>, a C# port of potrace 1.8 by Wolfgang Nagl.</p>
<p>Like potrace, as3potrace is released under GPL. The SWC and source code are available on GitHub:</p>
<p><a href="https://github.com/PowerflasherBR/as3potrace">https://github.com/PowerflasherBR/as3potrace</a></p>
<p><strong>Demo</strong></p>
<p>
<object width="475" height="475">
<param name="movie" value="http://wahlers.com.br/claus/blog/wp-content/uploads/POTrace.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="475" height="475" src="http://wahlers.com.br/claus/blog/wp-content/uploads/POTrace.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>Demo source code: <a href="https://gist.github.com/940219">https://gist.github.com/940219</a> (Warning: ugly)</p>
<p><strong>Usage example</strong></p>
<p>A minimal example of how to trace a bitmap with as3potrace, and draw the result into a <code>Shape</code>:</p>
<p><script src="https://gist.github.com/940180.js?file=gistfile1.as"></script></p>
<p>Note that you can write your own backends to ease handling/processing of generated shapes. The one backend that i already wrote, <code>GraphicsDataBackend</code>, produces <code>GraphicsData</code> structures that you can immediately draw using <code>Graphics.drawGraphicsData()</code>.</p>
<p><strong>Alternatives</strong></p>
<p>And as always, after i finished porting this little beauty, i found out that this has been done before by the amazing folks at LibSpark. Check out nitoyon&#8217;s <a href="http://www.libspark.org/wiki/nitoyon/PotrAs">PotrAs</a> (also GPL&#8217;ed).</p>

]]></content:encoded>
			<wfw:commentRss>http://wahlers.com.br/claus/blog/as3-bitmap-tracer-vectorizer-as3potrace/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Adobe iPhone Packager 2.0</title>
		<link>http://wahlers.com.br/claus/blog/adobe-iphone-packager-2-0/</link>
		<comments>http://wahlers.com.br/claus/blog/adobe-iphone-packager-2-0/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 06:46:05 +0000</pubDate>
		<dc:creator>Claus Wahlers</dc:creator>
				<category><![CDATA[Air]]></category>
		<category><![CDATA[SWF]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://wahlers.com.br/claus/blog/?p=258</guid>
		<description><![CDATA[The whole Flash community has been jumping for joy ever since Apple revised their controversial App Store License Agreement in early September this year. Apps created with Adobe&#8217;s &#8220;iPhone Packager&#8221; are not longer banned from the App Store, and Adobe started working on the product again. Section 3.3.1 now merely forbids the use of private [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwahlers.com.br%252Fclaus%252Fblog%252Fadobe-iphone-packager-2-0%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FbdMoZq%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Adobe%20iPhone%20Packager%202.0%22%20%7D);"></div>
<p>The whole Flash community has been jumping for joy ever since Apple revised their controversial App Store License Agreement in early September this year. Apps created with Adobe&#8217;s &#8220;iPhone Packager&#8221; are not longer banned from the App Store, and Adobe started working on the product again.</p>
<p><strong>Section 3.3.1</strong> now merely forbids the use of private APIs.. tooling and language restrictions have been lifted, especially the part that prohibits <em>&#8220;linking to documented APIs through an intermediary translation or compatibility layer or tool&#8221;</em> &#8211; the iPhone Packager uses LLVM to cross-compile ActionScript to iPhone-native byte code, which is now allowed.</p>
<p>I didn&#8217;t hear many people commenting on <strong>Section 3.3.2</strong> though, which i find weird. I think the real good news is this very section. Code interpreters are now explicitly allowed, given that <em>&#8220;all scripts, code and interpreters are packaged in the Application and not downloaded&#8221;</em>.</p>
<p>This means that Adobe could potentially shelve the existing, LLVM based iPhone Packager, and instead deploy a regular AIR runtime with a separate SWF. This would certainly make the publishing process a lot faster, as there is no cross-compilation step anymore &#8211; a standard SWF is published, which is then just packaged together with an iOS AIR runtime. I am uncertain which approach would perform better though: interpreted and JIT compiled via virtual machine, or LLVM translated native code.</p>
<p>Also feasible: a Flash Player engine that developers can plug in to their Cocoa apps, to mix UIKit and SWF. Best of both worlds.</p>
<p>Where do you think the iPhone Packager is heading?</p>

]]></content:encoded>
			<wfw:commentRss>http://wahlers.com.br/claus/blog/adobe-iphone-packager-2-0/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Mythbusting &#8220;HTML 5 Did Not Kill Flash&#8221;</title>
		<link>http://wahlers.com.br/claus/blog/mythbusting-html-5-did-not-kill-flash/</link>
		<comments>http://wahlers.com.br/claus/blog/mythbusting-html-5-did-not-kill-flash/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 17:52:56 +0000</pubDate>
		<dc:creator>Claus Wahlers</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[WebDev]]></category>

		<guid isPermaLink="false">http://wahlers.com.br/claus/blog/?p=248</guid>
		<description><![CDATA[So, i was thinking.. the Flash Player version number in the &#8220;HTML 5 Did Not Kill Flash&#8221; comic strip (258.1) &#8230; PLAUSIBLE? It is obvious that we deal with Jean-Luc Picard, captain of the Starship USS Enterprise NCC-1701-D, which places the scene in the Star Trek TNG series. According to Wikipedia, Star Trek TNG is [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwahlers.com.br%252Fclaus%252Fblog%252Fmythbusting-html-5-did-not-kill-flash%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fcy84Bj%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Mythbusting%20%5C%22HTML%205%20Did%20Not%20Kill%20Flash%5C%22%22%20%7D);"></div>
<p>So, i was thinking.. the Flash Player version number in the <a href="http://abstrusegoose.com/strips/clearly_HTML5_did_not_kill_Flash.PNG">&#8220;HTML 5 Did Not Kill Flash&#8221;</a> comic strip (258.1) &#8230; PLAUSIBLE?</p>
<p>It is obvious that we deal with Jean-Luc Picard, captain of the Starship USS Enterprise NCC-1701-D, which places the scene in the Star Trek TNG series. <a href="http://en.wikipedia.org/wiki/Star_Trek:_The_Next_Generation">According to Wikipedia</a>, Star Trek TNG is set in the 24th century from the year 2364 through 2370.</p>
<pre><code>Today: 1285956121684 (Fri Oct 1 15:02:01 GMT-0300 2010)
Star Trek TNG start: 12433402800000 (Wed Jan 1 00:00:00 GMT-0300 2364)
Star Trek TNG end: 12654327600000 (Fri Jan 1 00:00:00 GMT-0300 2371)
Assumed 18 months release cycle, in ms: 47304000000
Release cycles until Star Trek start:
   12433402800000 - 1285956121684 = 11147446678316
   11147446678316 / 47304000000 = 236
   236 + 10 = 246
Release cycles until Star Trek end:
   12654327600000 - 1285956121684 = 11368371478316
   11368371478316 / 47304000000 = 240
   240 + 10 = 250</code></pre>
<p>So assuming a strict 18 month release cycle, this places version 258.1 just about a decade or so after Star Trek TNG (versions 246-250) ends. If we further assume that new technologies will emerge in the coming 350 years that speed up release cycles a bit, i think we can safely say that Flash Player version 258.1 is indeed <strong>plausible</strong>.</p>
<p>Hypothetically speaking&#8230;</p>

]]></content:encoded>
			<wfw:commentRss>http://wahlers.com.br/claus/blog/mythbusting-html-5-did-not-kill-flash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flash IDE Inspired Flex 4 Timeline Component</title>
		<link>http://wahlers.com.br/claus/blog/flash-ide-inspired-flex-4-timeline-component/</link>
		<comments>http://wahlers.com.br/claus/blog/flash-ide-inspired-flex-4-timeline-component/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 18:45:29 +0000</pubDate>
		<dc:creator>Claus Wahlers</dc:creator>
				<category><![CDATA[Air]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[SWF]]></category>
		<category><![CDATA[WebDev]]></category>

		<guid isPermaLink="false">http://wahlers.com.br/claus/blog/?p=225</guid>
		<description><![CDATA[Here&#8217;s a little demo of a Flex 4 component i wrote that displays a Flash IDE-like timeline for any SWF you load into it. The timeline data is reconstructed by as3swf (i discuss how that works in a previous blog post, SWF Timeline Reconstruction with as3swf). The timeline is not interactive in this demo, and [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwahlers.com.br%252Fclaus%252Fblog%252Fflash-ide-inspired-flex-4-timeline-component%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fdllx07%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Flash%20IDE%20Inspired%20Flex%204%20Timeline%20Component%22%20%7D);"></div>
<p>Here&#8217;s a little demo of a Flex 4 component i wrote that displays a Flash IDE-like timeline for any SWF you load into it. The timeline data is reconstructed by <a href="http://github.com/claus/as3swf">as3swf</a> (i discuss how that works in a previous blog post, <a href="http://wahlers.com.br/claus/blog/timeline-reconstruction-with-as3swf/">SWF Timeline Reconstruction with as3swf</a>). The timeline is not interactive in this demo, and only the root timeline is shown.</p>
<p><span id="more-225"></span></p>
<p>
<object width="470" height="230">
<param name="movie" value="http://wahlers.com.br/claus/blog/wp-content/uploads/timeline/TestTimelineComponent.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="470" height="230" src="http://wahlers.com.br/claus/blog/wp-content/uploads/timeline/TestTimelineComponent.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>The component is a subclassed Spark List with a custom virtual layout and item renderer, capable of rendering SWF timelines with a lot of frames/layers in a high performance and memory efficient way.</p>
<p>I have no plans to publish the source code anytime soon, but in case you are interested in using this or anything related in your own projects, please feel free to <a href="http://wahlers.com.br/claus/">contact me</a> for licensing/consulting.</p>

]]></content:encoded>
			<wfw:commentRss>http://wahlers.com.br/claus/blog/flash-ide-inspired-flex-4-timeline-component/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>My Silly Gist Collection</title>
		<link>http://wahlers.com.br/claus/blog/my-silly-gist-collection/</link>
		<comments>http://wahlers.com.br/claus/blog/my-silly-gist-collection/#comments</comments>
		<pubDate>Sat, 25 Sep 2010 04:13:09 +0000</pubDate>
		<dc:creator>Claus Wahlers</dc:creator>
				<category><![CDATA[Air]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[SWF]]></category>
		<category><![CDATA[WebDev]]></category>

		<guid isPermaLink="false">http://wahlers.com.br/claus/blog/?p=198</guid>
		<description><![CDATA[I&#8217;ve been quite busy lately on both client and personal projects (can&#8217;t talk about the former, other than it being a big ass Flex 4 enterprise application i&#8217;ve been working on for the fine folks at Powerflasher; and it&#8217;s too early to talk about the latter.. stay tuned). In the last few weeks i silently [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwahlers.com.br%252Fclaus%252Fblog%252Fmy-silly-gist-collection%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fb55Llp%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22My%20Silly%20Gist%20Collection%22%20%7D);"></div>
<p>I&#8217;ve been quite busy lately on both client and personal projects (can&#8217;t talk about the former, other than it being a big ass Flex 4 enterprise application i&#8217;ve been working on for the fine folks at Powerflasher; and it&#8217;s too early to talk about the latter.. stay tuned).</p>
<p>In the last few weeks i silently released random little experiments on Gist &#8211; mostly fallout from personal projects of mine. Nothing super impressive, all pretty rough, but i thought some of you might be interested.</p>
<p><span id="more-198"></span></p>
<p>So here it is, my silly Gist collection.</p>
<p><strong>1. Show the compile date of a SWF</strong></p>
<p>You are developing a Flex application. You frequently publish the application to a staging server for QA to test. You want to ensure that QA always tests the latest version of your application, because aggressive cache settings in browser or proxy servers may result in QA seeing outdated, cached SWFs.</p>
<p>To make sure that QA looks at the latest version of the SWF, you can have the SWF inspect itself and search for a <code>ProductInfo</code> tag, which contains the compile date (<code>ProductInfo</code> is an undocumented SWF tag, i explain it in more detail <a href="http://wahlers.com.br/claus/blog/undocumented-swf-tags-written-by-mxmlc/">here</a>). You can then have your Flex application display this date in order to be able to verify that QA sees the latest version.</p>
<p>Here&#8217;s how to do that:</p>
<p><a href="http://gist.github.com/594367">http://gist.github.com/594367</a></p>
<p><strong>2. Bin Packer</strong></p>
<p>For a project i am working on, i needed an algorithm to fit as many randomly sized rectangles as possible into a given, larger rectangle (the bin). Turned out, there are a lot of different approaches out there (unfortunately none of the more elaborate ones is much better than O(argh) &#8211; the more rectangles you try to fit, the slower the algorithms get).</p>
<p>I found one resource particularly helpful: <a href="http://clb.demon.fi/">clb.demon.fi</a> explains some selected Bin Packer algorithms in great detail, and provides many links to others. They also provide a <a href="http://clb.demon.fi/projects/even-more-rectangle-bin-packing">C implementation</a> for a bunch of algorithms.</p>
<p>I ported their Max Rect Bin Packer implementation to ActionScript 3, and added the option to have it execute asynchronously:</p>
<p><a href="http://gist.github.com/543176">http://gist.github.com/543176</a></p>
<p>Demo (click to restart):</p>
<p>
<object width="400" height="256">
<param name="movie" value="http://wahlers.com.br/claus/blog/wp-content/uploads/BinPacker.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="400" height="256" src="http://wahlers.com.br/claus/blog/wp-content/uploads/BinPacker.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p><strong>3. De Casteljau: Move a point along a quadratic bezier</strong></p>
<p>Recently i needed an algorithm to split a quadratic bezier curve in two. The solution was <a href="http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/de-casteljau.html">De Casteljau&#8217;s algorithm</a>.</p>
<p><a href="http://gist.github.com/524163">http://gist.github.com/524163</a></p>
<p>Demo (click to restart):</p>
<p>
<object width="400" height="400">
<param name="movie" value="http://wahlers.com.br/claus/blog/wp-content/uploads/DeCasteljau.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="400" height="400" src="http://wahlers.com.br/claus/blog/wp-content/uploads/DeCasteljau.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p><strong>4. Silly font glyph plotter</strong></p>
<p>This Flash movie parses itself, grabs the first glyph of an embedded font and draws it on screen (uses <a href="http://github.com/claus/as3swf">as3swf</a> to parse itself, so you need <a href="http://github.com/claus/as3swf/tree/master/bin/">as3swf.swc</a>). Kinda silly.</p>
<p><a href="http://gist.github.com/523033">http://gist.github.com/523033</a></p>
<p>Demo:</p>
<p>
<object width="400" height="420">
<param name="movie" value="http://wahlers.com.br/claus/blog/wp-content/uploads/FontGlyph.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="400" height="420" src="http://wahlers.com.br/claus/blog/wp-content/uploads/FontGlyph.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p><strong>5. Convert HTML to XML and use E4X to access DOM (AIR required)</strong></p>
<p>Here&#8217;s a little utility function i wrote. <a href="http://github.com/claus/as3utils/blob/master/src/com/codeazur/utils/XMLUtil.as"><code>XMLUtils.jsDomToE4X()</code></a> converts HTML loaded via HTMLLoader (or the HTML DOM to be exact) into an AS3 XML object, so you can use simple E4X queries to scrape a HTML page. Evil.</p>
<p>And here&#8217;s the source code for a minimalistic web browser built upon the Adobe AIR Flex HTML component, that dumps out the URLs of SWFs embedded into the loaded HTML document.</p>
<p>The basic idea:</p>
<pre><code>var x:XML = XMLUtil.jsDomToE4X(htmlControl.domWindow.document);
var ns:Namespace = Namespace("http://www.w3.org/1999/xhtml");
var embeds:XMLList = <strong>x..ns::embed.@src</strong>;</code></pre>
<p>The full source:</p>
<p><a href="http://gist.github.com/456130">http://gist.github.com/456130</a></p>
<p><strong>That&#8217;s all, folks!</strong></p>
<p>I hope you enjoyed my silly little collection. Please also check out my &#8220;serious&#8221; work on <a href="http://github.com/claus">GitHub</a>, and feel free to <a href="http://twitter.com/cwahlers">follow me</a> on Twitter.</p>

]]></content:encoded>
			<wfw:commentRss>http://wahlers.com.br/claus/blog/my-silly-gist-collection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SWF Timeline Reconstruction with as3swf</title>
		<link>http://wahlers.com.br/claus/blog/timeline-reconstruction-with-as3swf/</link>
		<comments>http://wahlers.com.br/claus/blog/timeline-reconstruction-with-as3swf/#comments</comments>
		<pubDate>Sat, 08 May 2010 06:01:22 +0000</pubDate>
		<dc:creator>Claus Wahlers</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[SWF]]></category>
		<category><![CDATA[WebDev]]></category>

		<guid isPermaLink="false">http://wahlers.com.br/claus/blog/?p=167</guid>
		<description><![CDATA[In case you havent heard of it yet, as3swf is an ActionScript 3 library to parse and publish SWF files. It does that rather well by now, providing full roundtrip publishing, plus some neat extra features like shape export to AS3 Drawing API, AS3 GraphicsObjects, FXG, and Objective-C. Whenever i find some free time i&#8217;m [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwahlers.com.br%252Fclaus%252Fblog%252Ftimeline-reconstruction-with-as3swf%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FcPorVg%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22SWF%20Timeline%20Reconstruction%20with%20as3swf%22%20%7D);"></div>
<p>In case you havent heard of it yet, <a href="http://github.com/claus/as3swf">as3swf</a> is an ActionScript 3 library to parse and publish SWF files. It does that rather well by now, providing full roundtrip publishing, plus some neat extra features like shape export to AS3 Drawing API, AS3 GraphicsObjects, <a href="http://wiki.github.com/claus/as3swf/shape-export-to-fxg">FXG</a>, and <a href="http://wiki.github.com/claus/as3swf/shape-export-to-objective-c">Objective-C</a>.</p>
<p>Whenever i find some free time i&#8217;m working on adding new, useful features. One feature of as3swf, that i haven&#8217;t talked about much yet but is implemented for quite a while already, is the reconstruction of timelines as you know them from Adobe&#8217;s Flash IDEs.</p>
<p>In the first place, timelines in as3swf help you to export and render layered animations. Having a long list of parsed SWF tags won&#8217;t help much if you want to export or render frame X, as the Flash Player would display it.</p>
<p><span id="more-167"></span></p>
<p><strong>Flash Player Display List</strong></p>
<p>When executing a SWF, the Flash Player reads sequentially through all its tags, from start to end, and builds and maintains an internal display list along the way. This display list is manipulated by <code>PlaceObject</code> and <code>RemoveObject</code> tags, and rendered every time the Flash Player encounters a <code>ShowFrame</code> tag. Characters placed on the display list by <code>PlaceObject</code> tags stay on the display list until they are removed by a <code>RemoveObject</code> tag. <code>PlaceObject</code> tags are also used to manipulate a previously placed character (tweens).</p>
<p>In order to figure out which characters are displayed how and at which depths in any given frame, as3swf simulates the Flash Player behavior and builds its own display list structures while parsing the tags.</p>
<p>as3swf&#8217;s <code>SWF</code> (root) and <code>TagDefineSprite</code> (movieclips) classes each have a <code>timeline</code> property, containing an instance of the <code>SWFTimeline</code> class. Other than the <code>tags</code> itself, this class contains the following goodies:</p>
<ul>
<li><code>dictionary</code> &#8211; Contains references to all characters that may be placed on the display list. The dictionary&#8217;s key is the character ID as defined by the definition tag, the value is the index of the definition tag.</li>
<li><code>scenes</code> &#8211; Lists all scenes with their names and frame numbers.</li>
<li><code>frames</code> &#8211; Lists all frames. For each frame, you can access the contained characters and their depths, what tag placed the character on the display list, what tag modified its transformation/color matrices if any (for tweens) and whether this frame is a key frame or not.</li>
<li><code>layers</code> &#8211; Lists all layers. Each layer contains an array of active frames.</li>
<li><code>soundStream</code> &#8211; If present, contains this timeline&#8217;s sound stream complete with raw MP3 data, start frame, length, number of samples etc.</li>
</ul>
<p><strong>Example</strong></p>
<p>Consider the following very simple FLA. It has two layers, one containing a motion tween, the other a static on-stage shape starting at frame 5:</p>
<p><img src="http://wahlers.com.br/claus/blog/wp-content/uploads/MotionTweenFLA.png" alt="" /></p>
<p>Published to SWF:</p>
<p>
<object width="180" height="160">
<param name="movie" value="http://wahlers.com.br/claus/blog/wp-content/uploads/MotionTween.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="180" height="160" src="http://wahlers.com.br/claus/blog/wp-content/uploads/MotionTween.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>Parsed by as3swf, we get these timeline infos (get the <a href="http://wahlers.com.br/claus/blog/wp-content/uploads/MotionTween.txt">full trace dump here</a>):</p>
<pre><code>  Scenes:
    Name: Scene 1, Frame: 0
  Frames:
    [0] Start: 0, Length: 9
      Depth: 1 (Layer 0), CharacterId: 2, PlacedAt: 5, IsKeyframe
    [1] Start: 9, Length: 2
      Depth: 1 (Layer 0), CharacterId: 2, PlacedAt: 5, LastModifiedAt: 9
    [2] Start: 11, Length: 2
      Depth: 1 (Layer 0), CharacterId: 2, PlacedAt: 5, LastModifiedAt: 11
    [3] Start: 13, Length: 2
      Depth: 1 (Layer 0), CharacterId: 2, PlacedAt: 5, LastModifiedAt: 13
    [4] Start: 15, Length: 2
      Depth: 1 (Layer 0), CharacterId: 2, PlacedAt: 5, LastModifiedAt: 15
    [5] Start: 17, Length: 4
      Depth: 1 (Layer 0), CharacterId: 2, PlacedAt: 5, LastModifiedAt: 17
      Depth: 3 (Layer 1), CharacterId: 3, PlacedAt: 19, IsKeyframe
    [6] Start: 21, Length: 2
      Depth: 1 (Layer 0), CharacterId: 2, PlacedAt: 5, LastModifiedAt: 21
      Depth: 3 (Layer 1), CharacterId: 3, PlacedAt: 19
    [7] Start: 23, Length: 2
      Depth: 1 (Layer 0), CharacterId: 2, PlacedAt: 5, LastModifiedAt: 23
      Depth: 3 (Layer 1), CharacterId: 3, PlacedAt: 19
    [8] Start: 25, Length: 2
      Depth: 1 (Layer 0), CharacterId: 2, PlacedAt: 5, LastModifiedAt: 25
      Depth: 3 (Layer 1), CharacterId: 3, PlacedAt: 19
    [9] Start: 27, Length: 2
      Depth: 1 (Layer 0), CharacterId: 2, PlacedAt: 5, LastModifiedAt: 27
      Depth: 3 (Layer 1), CharacterId: 3, PlacedAt: 19
  Layers:
    [0] Frames 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
    [1] Frames 5, 6, 7, 8, 9</code></pre>
<p>Lets take a closer look at frame 6:</p>
<pre><code>  [5] Start: 17, Length: 4
    Depth: 1 (Layer 0), CharacterId: 2, PlacedAt: 5, LastModifiedAt: 17
    Depth: 3 (Layer 1), CharacterId: 3, PlacedAt: 19, IsKeyframe</code></pre>
<p>This tells us that this frame:</p>
<ul>
<li>displays character ID 2 (the red square movieclip) at depth 1. This character was originally placed on the display list by tag index 5 and was modified by tag index 17 (this character is tweened).</li>
<li>displays character ID 3 (the blue square shape) at depth 3. This character was placed on the display list by tag index 19. As the character was placed in this very frame, this is a key frame.</li>
<li>starts at tag index 17 and consumes 4 tags total:
<pre><code><span style="color:blue">17: </span>[26:PlaceObject2] Depth: 1, Matrix: (1,1,0,0,1400,400)
<span style="color:blue">18: </span>[83:DefineShape4] ID: 3, EdgeBounds: (2200,3200,1800,2800)
      FillStyles:
        [1] [SWFFillStyle] Type: 0 (solid), Color: FF0000FF
      LineStyles:
        [1] [SWFLineStyle2] Width: 200, Color: FF000000
      ShapeRecords:
        [SWFShapeRecordStyleChange] MoveTo: 3200,1800, FillStyle1: 1, LineStyle: 1
        [SWFShapeRecordStraightEdge] Vertical: 1000
        [SWFShapeRecordStraightEdge] Horizontal: -1000
        [SWFShapeRecordStraightEdge] Vertical: -1000
        [SWFShapeRecordStraightEdge] Horizontal: 1000
        [SWFShapeRecordEnd]
<span style="color:blue">19: </span>[26:PlaceObject2] Depth: 3, CharacterID: 3, Matrix: (1,1,0,0,0,0)
<span style="color:blue">20: </span>[01:ShowFrame]</code></pre>
</li>
</ul>
<p>As you can see, this info is a quite exact reconstruction of the original FLA&#8217;s timeline, and can be used to rebuild the original FLA (XFL, rather), to publish SWFs to run natively on alternative runtimes and platforms (HTML5, iPhone OS), or as a very first step to creating a web based version of the Flash IDE.</p>
<p>Happy hacking!</p>

]]></content:encoded>
			<wfw:commentRss>http://wahlers.com.br/claus/blog/timeline-reconstruction-with-as3swf/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>The Grand SWF Archive</title>
		<link>http://wahlers.com.br/claus/blog/the-grand-swf-archive/</link>
		<comments>http://wahlers.com.br/claus/blog/the-grand-swf-archive/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 20:34:45 +0000</pubDate>
		<dc:creator>Claus Wahlers</dc:creator>
				<category><![CDATA[SWF]]></category>

		<guid isPermaLink="false">http://wahlers.com.br/claus/blog/?p=165</guid>
		<description><![CDATA[What if somebody would write a spider (which respects common conventions like robots.txt etc) that searches for and archives publicly available SWF files, and a service that makes graphical assets found in those SWFs (vector shapes, bitmap images, videos, fonts, etc) available for public browsing, similar to what the Internet Archive&#8217;s Wayback Machine does? As [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwahlers.com.br%252Fclaus%252Fblog%252Fthe-grand-swf-archive%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22The%20Grand%20SWF%20Archive%22%20%7D);"></div>
<p>What if somebody would write a spider (which respects <a href="http://www2.sims.berkeley.edu/research/conferences/aps/removal-policy.html">common conventions</a> like robots.txt etc) that searches for and archives publicly available SWF files, and a service that makes graphical assets found in those SWFs (vector shapes, bitmap images, videos, fonts, etc) available for public browsing, similar to what the Internet Archive&#8217;s <a href="http://www.archive.org/web/web.php">Wayback Machine</a> does?</p>
<p>As SWF, at least according to Adobe, is an open format, this would be both technically and legally feasible, wouldn&#8217;t it? From a legal perspective, what line would need to be drawn where, and why exactly?</p>

]]></content:encoded>
			<wfw:commentRss>http://wahlers.com.br/claus/blog/the-grand-swf-archive/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>&#8220;Flash is as open as HTML5&#8243; &#8211; No, it isn&#8217;t.</title>
		<link>http://wahlers.com.br/claus/blog/flash-is-as-open-as-html5-no-it-isnt/</link>
		<comments>http://wahlers.com.br/claus/blog/flash-is-as-open-as-html5-no-it-isnt/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 10:49:26 +0000</pubDate>
		<dc:creator>Claus Wahlers</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://wahlers.com.br/claus/blog/?p=162</guid>
		<description><![CDATA[Lately, Adobe representatives and Flash fan boys alike became more vocal than usual about the alleged openness of Flash. This is probably spurred by the proposed feature set of HTML5, as well as the decisions of a certain vendor to ban Flash from some of their products, both potentially being threats to Adobe and the [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwahlers.com.br%252Fclaus%252Fblog%252Fflash-is-as-open-as-html5-no-it-isnt%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22%5C%22Flash%20is%20as%20open%20as%20HTML5%5C%22%20-%20No%2C%20it%20isn%27t.%22%20%7D);"></div>
<p>Lately, Adobe representatives and Flash fan boys alike became more vocal than usual about the alleged openness of Flash. This is probably spurred by the proposed feature set of HTML5, as well as the decisions of a certain vendor to ban Flash from some of their products, both potentially being threats to Adobe and the Flash Platform.</p>
<p>I originally posted the following article as comment to an article by Serge Jespers, &#8220;<a href="http://www.webkitchen.be/2010/04/22/flash-is-as-open-as-html5/">Flash is as open as HTML5</a>&#8220;. Serge is an Adobe Platform Evangelist. I thought this comment deserves its own post, so here we go.</p>
<blockquote><p>No, it isn’t.</p>
<p>And it is beyond me why so many independent Flash Platform developers fail to see it. I completely understand of course why Adobe evangelists downplay it.</p>
<p>It is irrelevant for the so called “open web” whether the Flash Player is going to get open sourced or not. That’s not the point. Microsoft won’t open source their browser, Opera won’t open source their browser, etc.</p>
<p>Relevant is who decides about the development of the data format that a runtime consumes, and the APIs a runtime provides to access that data. In the Flash world that’s SWF and the Flash Player APIs, both controlled by a single vendor: Adobe. In the HTML world that’s HTML and DOM, controlled by many vendors, including you and me, via standards bodies.</p>
<p>Adobe neither provides formal means for other companies and individuals to participate in the development of SWF and Flash Player APIs, nor does it provide detailed work-in-progress specs to the general public for discussion. This effectively rules out the possibility for third parties to provide alternative runtimes. The runtime and its specs are released to the public at the same time.</p>
<p>This is the exact opposite of “open”.</p>
<p>To make matters worse, the specs released by Adobe are incomplete and buggy (e.g. the SWF spec fails to explain how exactly shapes are supposed to be rendered and leaves out information on codecs, the ABC spec is plain wrong on some things) and generally infested with patented technologies.</p>
<p>Of course i understand why it is how it is (and likely always will be). If Adobe were to become truly open and put the development of SWF etc in the hands of standards bodies, the 1.5 year release cycle would become a 10+ years release cycle. Innovation would slow down significantly. I as a Flash Platform developer wouldn’t want that to happen.</p>
<p>However, sorry to say that, but to tout “Flash is as open as HTML5″ is pure FUD.</p></blockquote>

]]></content:encoded>
			<wfw:commentRss>http://wahlers.com.br/claus/blog/flash-is-as-open-as-html5-no-it-isnt/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Realtime MP3 Decoding in Actionscript 3</title>
		<link>http://wahlers.com.br/claus/blog/realtime-mp3-decoding-in-actionscript-3/</link>
		<comments>http://wahlers.com.br/claus/blog/realtime-mp3-decoding-in-actionscript-3/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 09:27:49 +0000</pubDate>
		<dc:creator>Claus Wahlers</dc:creator>
				<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://wahlers.com.br/claus/blog/?p=144</guid>
		<description><![CDATA[So did you ever try to play Shoutcast streams in Flash? Did you run into memory leaks? Did the playback sound pitched or otherwise screwed? Fear no more. Let me introduce you to <a href="http://github.com/claus/as3icy">as3icy</a>.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwahlers.com.br%252Fclaus%252Fblog%252Frealtime-mp3-decoding-in-actionscript-3%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FbYAwng%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Realtime%20MP3%20Decoding%20in%20Actionscript%203%22%20%7D);"></div>
<p>So did you ever try to play Shoutcast streams in Flash? Did you run into memory leaks? Did the playback sound pitched or otherwise screwed? Fear no more. Let me introduce you to <a href="http://github.com/claus/as3icy">as3icy</a>.</p>
<p><a href="http://github.com/claus/as3icy">as3icy</a> is a drop-in replacement for the Flash Player&#8217;s Sound object that can reliably play Shoutcast, Icecast and Limewire MP3 streams. And it extracts metadata info from the stream in real time. It also reliably plays VBR MP3.</p>
<p><span id="more-144"></span></p>
<p>DISCLAIMER IN CAPITAL LETTERS. This is experimental code. I basically threw this code together in two 24 hour coding sessions. Also, i know as much about sound engineering as i know about pottery &#8211; i blind-ported a big chunk of Java code (the excellent <a href="http://www.javazoom.net/javalayer/javalayer.html">JLayer MP3</a> decoder, originally ported from C if i&#8217;m not mistaken) to Actionscript 3 without really knowing what i was doing. So expect a few WTF moments when reading through the code, and do not expect everything to work perfectly just yet.</p>
<p><strong>Some known issues</strong></p>
<ul>
<li><span style="color: red;">IT IS SLOW AND STRESSES YOUR CPU</span>. Depending on the encoding, i get around 20-50% load on my 2.4GHz Core 2 Duo (Vista), which is way too much. On my MacBook Air 2.16 GHz: full load and playback chokes, which is unacceptable. There is plenty of room for optimization though, the code is currently not optimized at all. It&#8217;s probably worth taking a look at Apparat, or Alchemy in general for more performant alternatives to decode MP3..</li>
<li>Only Layer III is supported (Layer I and II decoders not ported yet).</li>
<li>Only 44100Hz playback is supported (up/down-sampling to 44100Hz not implemented yet).</li>
<li>Only stereo modes are supported (mono not implemented yet).</li>
<li>The stream parser seems to be with problems yet, sometimes it happens that it runs out of sync for some reason.</li>
</ul>
<p>Also, Adobe AIR is recommended to play Shoutcast streams, for two reasons: The meta data interval is passed back to the client via HTTP response headers, which are not available in the plugin version of the Flash Player, and as soon as you put the thing online you need the streaming server to host a crossdomain.xml file. If you happen to have access to the streaming server, you can of course solve these issues by hardcoding the meta data interval and have the streaming server serve an appropriate crossdomain.xml, or by using a proxy script of some sort. Also, this only applies to playing Shoutcast streams. You can play static MP3 files (for example VBR MP3s) using as3swf in the plugin version of the Flash Player without any problem (security restrictions still apply of course).</p>
<p><strong>A simple example: Shoutcast stream playback</strong></p>
<pre><code>package
{
  import com.codeazur.as3icy.ICYSound;
  import com.codeazur.as3icy.events.ICYMetaDataEvent;

  import flash.display.Sprite;
  import flash.events.HTTPStatusEvent;
  import flash.net.URLRequest;
  import flash.net.URLRequestHeader;

  public class SimpleShoutcastPlayer extends Sprite
  {
    protected static const URL:String = "http://72.233.14.70/hype";

    protected var icySound:ICYSound;

    public function SimpleShoutcastPlayer()
    {
      var req:URLRequest = new URLRequest(URL);
      req.requestHeaders = [ new URLRequestHeader("Icy-Metadata", "1") ];
      icySound = new ICYSound();
      icySound.addEventListener(ICYMetaDataEvent.METADATA, metaDataHandler);
      icySound.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, httpResponseStatusHandler);
      icySound.load(req);
      icySound.play();
    }

    protected function httpResponseStatusHandler(e:HTTPStatusEvent):void {
      // The HTTP_RESPONSE_STATUS event is fired when the stream is opened and starting to load.
      var s:String = "Connected!";
      if (icySound.icyName.length > 0) { s += "\rName: " + icySound.icyName; }
      if (icySound.icyDescription.length > 0) { s += "\rDescription: " + icySound.icyDescription; }
      if (icySound.icyUrl.length > 0) { s += "\rURL: " + icySound.icyUrl; }
      if (icySound.icyServer.length > 0) { s += "\rServer: " + icySound.icyServer; }
      if (icySound.icyMetaInterval > 0) { s += "\rMeta Interval: " + icySound.icyMetaInterval; }
      trace(s);
    }

    protected function metaDataHandler(e:ICYMetaDataEvent):void {
      // The METADATA event is fired when new metadata is available.
      if (e.metaData.length > 0) {
        trace("Now playing: " + e.metaData.slice(13, -2));
      }
    }
  }
}</code></pre>
<p>This code (Adobe AIR required) plays the <a href="http://hypem.com/#/radio/live">Hype Machine live radio stream</a>, and traces out general information about the station, as well as the names of currently playing songs.</p>
<p>Note that we set a custom request header, <code>Icy-Metadata: 1</code>. This tells the server to periodically send meta data with the stream. Under the hood, as3icy transparently extracts this meta data from the stream in real time and passes it to the application via the ICYMetaDataEvent. This event won&#8217;t be fired when the request header above is not sent.</p>
<p>The trace output should look something like this:</p>
<pre><code>Connected!
Name: Hype Radio
Description: Radio powered by music blogs
URL: http://hypem.com/radio/
Server: Icecast 2.3.1
Meta Interval: 16000
Now playing: Collider - Time Concerns
Now playing: Rogue Wave - Birds (Neil Young cover)
Now playing: The Big Pink – Dominos
[..]</code></pre>

]]></content:encoded>
			<wfw:commentRss>http://wahlers.com.br/claus/blog/realtime-mp3-decoding-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>SWFtrospection</title>
		<link>http://wahlers.com.br/claus/blog/swftrospection/</link>
		<comments>http://wahlers.com.br/claus/blog/swftrospection/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 21:58:10 +0000</pubDate>
		<dc:creator>Claus Wahlers</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[SWF]]></category>

		<guid isPermaLink="false">http://wahlers.com.br/claus/blog/?p=151</guid>
		<description><![CDATA[Open Flash CS4, create new AS3 FLA, add as3swf.swc and paste this on frame 1: import com.codeazur.as3swf.SWF; var swf:SWF = new SWF(root.loaderInfo.bytes); trace(swf); Trace output: [SWF] Header: Version: 10 FileLength: 149405 FileLengthCompressed: 149405 FrameSize: (550,400) FrameRate: 24 FrameCount: 1 Tags: [69:FileAttributes] AS3: true, HasMetadata: false, UseDirectBlit: false, UseGPU: false, UseNetwork: false [09:SetBackgroundColor] Color: #FFFFFF [86:DefineSceneAndFrameLabelData] [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwahlers.com.br%252Fclaus%252Fblog%252Fswftrospection%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22SWFtrospection%22%20%7D);"></div>
<p>Open Flash CS4, create new AS3 FLA, add <a href="http://github.com/claus/as3swf/blob/master/bin/as3swf.swc">as3swf.swc</a> and paste this on frame 1:</p>
<pre><code>import com.codeazur.as3swf.SWF;
var swf:SWF = new SWF(root.loaderInfo.bytes);
trace(swf);</code></pre>
<p>Trace output:</p>
<pre><code>[SWF]
  Header:
    Version: 10
    FileLength: 149405
    FileLengthCompressed: 149405
    FrameSize: (550,400)
    FrameRate: 24
    FrameCount: 1
  Tags:
    [69:FileAttributes] AS3: true, HasMetadata: false,
      UseDirectBlit: false, UseGPU: false, UseNetwork: false
    [09:SetBackgroundColor] Color: #FFFFFF
    [86:DefineSceneAndFrameLabelData]
      Scenes:
        [0] Frame: 0, Name: Scene 1
    [82:DoABC] Lazy: true, Length: 149219
    [76:SymbolClass]
      Symbols:
        [0] TagID: 0, Name: Untitled_fla.MainTimeline
    [01:ShowFrame]
    [00:End]</code></pre>
<p>Excercise: Draw something on stage, and run the code again.</p>
<p>Want more? Drop by my session <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=101&#038;presentation_id=1078">Hacking SWF</a> at <a href="http://www.fitc.ca/events/about/?event=101">FITC Amsterdam</a> (Feb 22th, 16:00).</p>
<p>[Edit] <a href="http://twitter.com/jimcheng">Jim Cheng</a> deserves credits. He was the one who whispered &#8220;root.loaderInfo.bytes&#8221; into my virtual ear on IM.</p>

]]></content:encoded>
			<wfw:commentRss>http://wahlers.com.br/claus/blog/swftrospection/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

