<?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; SWF</title>
	<atom:link href="http://wahlers.com.br/claus/blog/category/webdev/swf/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>Thu, 22 Jul 2010 18:23:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<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[<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><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>
<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>5</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[<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>1</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[<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>17</slash:comments>
		</item>
		<item>
		<title>Undocumented SWF Tags written by MXMLC</title>
		<link>http://wahlers.com.br/claus/blog/undocumented-swf-tags-written-by-mxmlc/</link>
		<comments>http://wahlers.com.br/claus/blog/undocumented-swf-tags-written-by-mxmlc/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 20:45:51 +0000</pubDate>
		<dc:creator>Claus Wahlers</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[SWF]]></category>
		<category><![CDATA[WebDev]]></category>

		<guid isPermaLink="false">http://wahlers.com.br/claus/blog/?p=89</guid>
		<description><![CDATA[While testing my AS3 SWF library as3swf yesterday, i found that MXMLC (the compiler that comes with the Flex SDKs)  writes undocumented SWF tags to the SWFs it produces. I was able to identify two so far: ProductInfo (Tag ID 41) The ProductInfo tag contains infos about the tool used to generate the SWF, as [...]]]></description>
			<content:encoded><![CDATA[<p>While testing my AS3 SWF library <a href="http://github.com/claus/as3swf/tree/master">as3swf</a> yesterday, i found that MXMLC (the compiler that comes with the Flex SDKs)  writes undocumented SWF tags to the SWFs it produces.</p>
<p>I was able to identify two so far:</p>
<p><strong>ProductInfo</strong> (Tag ID 41)</p>
<p>The ProductInfo tag contains <em>infos about the tool used to generate the SWF</em>, as well as the <em>date and time the SWF was compiled</em>. It also contains info about the &#8220;Edition&#8221; of the software used (see below), and although this seems to be always set to &#8220;None&#8221; in Flex Builder 3 and Flash Builder 4, it potentially could become a privacy issue, especially being an undocumented feature (you better know about this tag just in case you accidentally publish commercial work with your non commercial Flash Builder license).</p>
<ul>
<li>ProductID (UI32)<br />
0: Unknown<br />
1: Macromedia Flex for J2EE<br />
2: Macromedia Flex for .NET<br />
3: Adobe Flex</li>
<li>Edition (UI32)<br />
0: Developer Edition<br />
1: Full Commercial Edition<br />
2: Non Commercial Edition<br />
3: Educational Edition<br />
4: Not For Resale (NFR) Edition<br />
5: Trial Edition<br />
6: None</li>
<li>MajorVersion (UI8)</li>
<li>MinorVersion (UI8)</li>
<li>BuildLow (UI32)</li>
<li>BuildHigh (UI32)</li>
<li>CompilationDate (UI64)<br />
Milliseconds since 1.1.1970</li>
</ul>
<p>Examples:</p>
<p>Flex 4.0 &#8211; [41:ProductInfo] ProductID: 3, Edition: 6, Version: 4.0.0.7791, CompileDate: Fri Aug 21 05:18:21 GMT-0300 2009</p>
<p>Flex 3.2 &#8211; [41:ProductInfo] ProductID: 3, Edition: 6, Version: 3.2.0.3958, CompileDate: Fri Aug 21 05:23:22 GMT-0300 2009</p>
<p><strong>DebugID</strong> (Tag ID 63)</p>
<p>This tag is written to SWFs that are enabled for debugging. It contains a 16 byte UUID.</p>
<ul>
<li>UUID (UI8[16])</li>
</ul>
<p>Example:</p>
<p>[63:DebugID] UUID: b8f36d6a-c735-a340-daa7-44730af92505</p>
<p><strong>Reference</strong></p>
<p>Flex SDK:</p>
<ul>
<li><a href="http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/modules/swfutils/src/java/flash/swf/TagValues.java">TagValues.java</a></li>
<li><a href="http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/modules/swfutils/src/java/flash/swf/tags/ProductInfo.java">ProductInfo.java</a></li>
<li><a href="http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/modules/swfutils/src/java/flash/swf/tags/DebugID.java">DebugID.java</a></li>
</ul>
<p>Community:</p>
<ul>
<address><span style="line-height: 33px; font-size: 21px; color: #3e3e3e;"> </span></address>
</ul>
<ul>
<li>Igor Costa: <a href="http://www.igorcosta.org/?p=220">Reading the compilation date of SWF with the magic of ByteArray</a></li>
<li>Judah Frangipane: <a href="http://www.judahfrangipane.com/blog/?p=252">Cache busting your Flex SWF and the SWF Compilation Date</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://wahlers.com.br/claus/blog/undocumented-swf-tags-written-by-mxmlc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
