SWFtrospection
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]
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]
Excercise: Draw something on stage, and run the code again.
Want more? Drop by my session Hacking SWF at FITC Amsterdam (Feb 22th, 16:00).
[Edit] Jim Cheng deserves credits. He was the one who whispered “root.loaderInfo.bytes” into my virtual ear on IM.

February 6th, 2010 at 20:14
That’s great Claus! Does it also allow shape extraction ? It would be great if graphic paths could be extracted from the swf.
February 6th, 2010 at 20:26
I did not know you can get to the ABC of the current SWF. Wow! This is fantastic Claus. Looking forward to your talk at FITC!
February 6th, 2010 at 20:34
Ralph: It sure does. :)
Joa: And i am looking forward to yours! It’s right after mine (unfortunately in a different room though)
February 6th, 2010 at 20:37
Wow, years of looking for the perfect swf dump and now it was right under my node : ).
February 7th, 2010 at 16:42
Hi Claus, Amazing work. I would love to attend your talk at FITC, but I wont be there :( (too faraway for me). I’m starting a new project called xml2swf made with Actionscript. I’m checking out your as3SWF, I think it will be usefull for my project. I invite you to check out my project at http://github.com/rayaslokas/xml2swf maybe you can find some usefull classes. Best Regards :)
February 7th, 2010 at 18:18
Looks like this is a nice way to solve the offstage content bug when loading a swf – seems that where a swf with offstage content would return the content dimensions rather than its stage dimensions, by accessing FrameSize, we can get the actual stage dimensions. Nice.
February 7th, 2010 at 22:55
@Pedr
You should be able to get to this info through the content’s LoaderInfo.width /.height properties without needing a util class (not that I am devaluing Claus’ excellent work in any way)
February 8th, 2010 at 19:32
This is great work. I’ve been trying to figure out a way to get a vector SWF exported from Livebrush (with all the vector decorations). No luck so far. Wish I could attend.
February 8th, 2010 at 19:50
Great work! Gonna push this beauty into our running project first thing tomorrow morning and play around with it.
February 8th, 2010 at 20:19
Miguel: I too was thinking about creating some proprietary XML format to export to and import from (similar to what swfmill does). Care to contribute?
David: as3swf does not roundtrip yet, especially shape publishing is missing yet. Pure lazyness on my part, i might add.. it’s perfectly doable. Right now (until FITC) my focus is on shape-etc export though.
February 8th, 2010 at 20:44
Miguel: btw there is also XFL (or is it FLX? The new XML based FLA format) you could export to. I don’t think there are specs out there yet, though
February 9th, 2010 at 11:44
Claus: My library is very similar to swfmill. I was using swfmill, but it don’t work fine for the linkage names for as3, for this reason I wrote my own solution. My xml2swf for the moment only allow you to create a swf with only one MC into. I must improve that to support many MC into. I would love to contribute you (in the way I can). I will continue with my lib too. :)…. About XFL. I didn’t know it, I was reading and looks like will make the same work, then maybe my lib have not sense. jejeje, but well.. it is the life. My lib is more nostalgic, it is made with as3 :)
February 10th, 2010 at 14:17
Thanks for sharing. I’d be happy to help in any way I can.
February 14th, 2010 at 01:02
Great post, I like your project so much.
codeazur as3swf is a very complete framework!
Howerver if you want to get the bytecode out of a swf, you dont need any framework!
Check this out: http://jpauclair.net
It’s a set of hidden feature of flash, and one of theses enable you to print the SWF bytecode directly in your flashLog.
Thanks!
February 14th, 2010 at 13:12
Jean-Philippe, yeah i saw your post already, that’s very impressive!
March 3rd, 2010 at 14:01
[...] Wahlers sezierte in “Hacking SWF” eine Vektor SWF und parste die Pfadinformationen in [...]