简体   繁体   English

AS3:如何动态地从库中加载movieclip而不在第1帧中导出?

[英]AS3: How to dynamically load movieclip from library without exporting in frame 1?

I have some fairly large movieclips in the library which need to be dynamically loaded at runtime. 我的库中有一些相当大的动画片段,需要在运行时动态加载。 I don't want to export them all in frame 1, because that would slow down initial loading of the movie. 我不想将它们全部导出到第1帧,因为这会减慢影片的初始加载速度。

I tried putting an instance of each of these clips later in the timeline where they wouldn't normally be encountered. 我稍后尝试在时间线中放置这些剪辑的每个实例,而通常不会遇到它们。 When I then tried to load one from the library dynamically, I was able to successfully get an instance of the movieclip, but its currentFrame property was 0 and I couldn't see anything on the stage. 然后,当我尝试从库中动态加载一个时,我能够成功获取movieclip的实例,但是其currentFrame属性为0,并且在舞台上看不到任何东西。 As soon as I enabled "Export in frame 1", it worked properly. 一旦启用“在第1帧中导出”,它就会正常工作。

Does this old trick of putting an instance on the timeline somewhere no longer work in AS3? 将实例放在时间轴上某个地方的旧技巧在AS3中不再有效吗?

I have had similar issues with large library assets and to solve my issue I would always just put the assets into separate swf's and load the external swf file when I needed it. 对于大型图书馆资产,我也遇到过类似的问题,为了解决我的问题,我总是将资产放入单独的swf文件中,并在需要时加载外部swf文件。

Check out the Loader class 'content' property - http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html#content 检出Loader类的“内容”属性-http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html#content

The only downfall to this is managing the assets in separate files. 唯一的缺点是在单独的文件中管理资产。

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM