在 Flash CS4 (Actionscript 3) 中使用外部影片剪辑
我正在构建一个 Flash CS4 应用程序 (AS3),但我无法将所有影片剪辑保留在库中,因为会有数百个影片剪辑,并且会一直添加新的影片剪辑。
问题分为两个部分:
如何从外部加载影片剪辑以在运行时使用?加载后,我仍然需要能够操作它,就像从内部库创建它的新实例一样。
如何根据名称加载影片剪辑?
谢谢!
I'm building a Flash CS4 application (AS3) and I can't keep all my movie clips in the library because there will be hundreds of them, and new ones will be added all the time.
Two parts to the question:
How can I externally load in a movieclip to use during run time? After loading I still need to be able to manipulate it as if I created a new instance of it from the internal library.
How can I load a movieclip based on its name?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要在运行时加载影片剪辑,请使用 Loader 和 URLRequest 类。收听
Event.Complete
以了解何时可以使用它。要在运行时实例化类,请使用函数 getDefinitionByName 或 getDefinition
查看 当前文档
To load a movie clip at runtime use the Loader and URLRequest classes. Listen to the
Event.Complete
to know when it is ready to be used.To instanciate a Class at runtime use the function getDefinitionByName or getDefinition
Look at a complete example (mixing the different concept) in the current doc
您无法在运行时加载影片剪辑,就像您从库面板中知道的那样(因为如果没有 .swf 等容器格式,它们就无法存在)。但您可以通过 Loader 类加载包含这些 MovieClip 的其他 .swf 文件。您还可以在运行时创建一个类的新实例,该实例扩展了 MovieClip 类,但我认为这对您没有帮助,因为这个类也必须位于库内部(或者至少导入)与actionscript),即使您在阶段不使用它。
you can't load movieclips, like you know them form the library panel, at runtime (because they can't exist without a container format like .swf). but you can load other .swf files that contain those MovieClips via the Loader class. You also can create a new instance of a Class, at runtime, that extends the MovieClip Class, but i don't think this will be helpful for you, because this class would have to be inside the library as well (or at least imported with actionscript), even though you don't use it at the stage.