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.
That’s great Claus! Does it also allow shape extraction ? It would be great if graphic paths could be extracted from the swf.
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!
Ralph: It sure does. :)
Joa: And i am looking forward to yours! It’s right after mine (unfortunately in a different room though)
Wow, years of looking for the perfect swf dump and now it was right under my node : ).
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 :)
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.
@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)
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.
Great work! Gonna push this beauty into our running project first thing tomorrow morning and play around with it.
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.
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
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 :)
Thanks for sharing. I’d be happy to help in any way I can.
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!
Jean-Philippe, yeah i saw your post already, that’s very impressive!
Pingback: FITC Amsterdam 2010: iPhone Topics » GELB der Powerflasher Blog
Hello Claus,
Really good work, very very useful !
Could you publish an example of how to use as3swf to create / publish swf files ?
good continuation !
I really loved w3blog » Blog Archive » SWFtrospection – Claus Wahlers on Application Development, Web Standards and what not.. This is achieved not by beginners luck, but by what is called Search engine optimization, or SEO for quick.
Wow, Thank you because of this blog. Thats all I’m able to say. You almost certainly have made this blog into some thing thats eyesight opening and important. You obviously know much about the topic, youve covered a lot of bases. Great stuff from this area of the internet. Again, thank you for this blog.