Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top