Search code examples
actionscript-3flash-builder

An external swf in Flash builder


I embed an external swf in flash builder like so:

[Embed(source="assets/sounds/mytestswf.swf")]
private static var mySwf: Class;

How can I access it and add it to another sprite on stage?


Solution

  • i don't think you need a loader, that's for libraries that are added at runtime. Embed compiles the assets directly in the swf, so addChild(new mySwf()); is enough to add it to the the display object list.

    obviously, you'd like to assign it to a variable, so

    var $mySwf:mySwf = new mySwf();
    addChild($mySwf);
    

    On a side note, you should name your classes consistently. Class names start with the first letter capitalized, so you can tell it apart from variables

    [Embed(source="/assets/sounds/mytestswf.swf")]
    private static var MySwf: Class;
    ...
    var $mySwf:MySwf = new MySwf();
    addChild($mySwf);