views:

245

answers:

1

I have swf file with some graphics I need to use in my haxe(future compiled to swf too) program. There is no problem with embedding pictures by swfmill, so i tried to disassemble the swf with swfmill and found some entries like DefineSprite and DefineShape which have objectID's.

Is it possible to attach these elements from haxe using the swf file as a library?

+1  A: 

You can attach an element (picture, sound, etc) if they have:

  1. SymbolClass exported for it (or maybe ExportAsset)
  2. AS3 class stub generated (for flash9+ at least) - HaXe will take care of this, at least for resources on the first frame

For haxe, you have to support the -swf-lib mylib.swf switch, which takes only one swf as parameter. If you would like to use multiple libs, you can assemble them into one with either swfmill or SamHaxe, and suppprt the assembled lib.

From Haxe, you can then use

var mySprite: flash.display.Sprite = cast Type.createInstance(Type.resolveClass("the.exported.SpriteSymbolName"), []);

var myBitmap: flash.display.Bitmap = cast Type.createInstance(Type.resolveClass("the.exported.BitmapSymbolName"), []);

Hope this helps.

ron
Kinda helped. Not answers my question, but at least I know that I'm not the only one who cannot do it(link by ObjectID).
stroncium
I wanted to tell that if there isn't any SymbolClass for a given ID, then you can't instantiate it. However you may do some hack if you need it:Parse the SWF with the format.swf haxelib, add a SymbolClass tag to the parsed structure, and also an AS3 class stub (assembled using format.abc). You can peek in SamHaxe's sources to see how it does this.
ron
ron