AS3 Access Library asset
I am using Flash CS3. In the library of my fla file I have several animated MovieClips. How do I access these from external .as files?
[edit]
To clarify, my fla file has a class definiti开发者_StackOverflow社区on (Main) which in turn is loading a new class, which in turn is loading another new class. It is this final class that I would like to give access to the library.
Library in flash holds classes of graphic objects. So, any class knowing the names of library classes, can create them with getDefinitionByName
:
//create resource called "myButton" in the library:
var buttonClass:Class = getDefinitionByName("myButton");
var myButton:DisplayObject = new buttonClass() as DisplayObject;
But if your external classes have no idea about the names, you should pass those names to them (through constructor argument, setter or public var.)
精彩评论