claus / as3swf

Low level Actionscript 3 library to parse, create, modify and publish SWF files.
MIT License
526 stars 127 forks source link

run-time variable injection? #12

Closed KyleT closed 13 years ago

KyleT commented 13 years ago

Wasn't sure where best to bring this up, but I've a question about taking run-time display variables when using as3swf.

It seems like this could/can take "DisplayObject"s created at runtime (e.g. "MovieClip"s), and store them in the swf being created. Basically emulating the "DefineSprite" tag, but, also recursively scanning through adding children, retaining matrix information (position, scaling etc) for all children of the added object.

Something akin to;

var asset:DisplayObject; // thing that's full of visuals altered at run-time var assetTag:TagDefineSprite = new TagDefineSprite(); assetTag.ParseAsset( asset ); var swf:SWF = new SWF(); swf.tags.push( new TagFileAttributes() ); swf.tags.push( assetTag ); ...

Is there a way of doing this?

Perhaps some way of serialising "DisplayObject"s into "ByteArray"s that "SWF" could take as a valid constructor parameter, like how stage.loaderInfo.bytes can be used. I know that ByteArray.writeObject( obj ) doesn't play well with MovieClips, but is there a nice away around this?

It seems like a pretty useful thing if it is possible, so I'm surprised no else has asked... (sorry if this is because the answer is obvious!)

claus commented 13 years ago

Well you could create a SWF off a DisplayObject(Container), however if you use the drawing API to draw something into that DO or one of its children, i wouldn't know how you'd access that info.

KyleT commented 13 years ago

Actually, just being able to make a SWF off of a DisplayObject[Container] would be great. Could you give an example of doing that?

claus commented 13 years ago

Sorry, i don't have such an example handy, it's not on my roadmap and not really trivial to do.

KyleT commented 13 years ago

fair enough, I can see how its not exactly the world's easiest thing. Thanks for the quick replies!