开发者

AS3 Access Library asset

开发者 https://www.devze.com 2023-02-26 03:25 出处:网络
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?

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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消