R – How to access a stage instance name from a SWF embedded w/ the Flex compiler

actionscript-3apache-flexflash

I've embedded a MovieClip symbol with the [Embed] syntax into my AS3 project, which I'm compiling with the Flex 3 SDK. That MovieClip has instances of other clips within it that are placed on stage with instance names. I can't just access them by instance name like I would if I were compiling with the Flash IDE.

How can I reference them?

Best Answer

you need to both give them instance names in the IDE and declare them in the class you've embedded them on.

So say that you have instances of baz and frr on your embedded class InfoPopup, you need to declare them like this:

package foo {

    import flash.display.Sprite;    

    [Embed(source='../../../../../../assets/Assets.swf', symbol='InfoPopup')]
    public class InfoPopup extends Sprite {

        public var baz:Sprite;
        public var baz:MovieClip;

        public function InfoPopup(){
                trace("constructor!");
        }

    }

}

When added like this they have to be public properties or else the compiler will complain.

Related Topic