了解导入到 Flex Builder 3 中的 Flash SWC 和关键帧动画
我试图了解从 Flash CS4 导入 Flex Builder 3 的 SWC 中发生了什么。具体来说,我使用设计者提供的 SWC 作为自定义预加载器(子类 DownloadProgressBar)的动画。
我想要理解的问题是,一旦触发了 FlexEvent.INIT_COMPLETE,我就会通过运行以下命令来删除 swc 来进行清理:
removeChild(myPreloader);
myPreloader = null;
即使在我删除了它之后(这是成功的,因为我通过比较 this.numChildren 之前和之前进行了检查)调用后)关键帧动画仍然继续运行(不可见)。设计者已在动画的时间线(在 Flash 中)中放置跟踪来检测到这一点。
谁能告诉我为什么,即使我从子类 DownloadProgressBar 中删除了动画,它仍然继续运行?
另外,导入 SWC 来管理 Flash 端的资源清理(很像释放 obj-c 中的内存)是标准做法吗?我发现从 Flex 一侧移除子项并不会停止动画是违反直觉的。
任何有关这方面的线索将不胜感激。
I am trying to understand what is going on in a SWC that I am importing from Flash CS4 into Flex Builder 3. Specifically I am using a SWC supplied by a Designer as the animation for a custom preloader (a subclassed DownloadProgressBar).
The issue I am trying to understand is, once the FlexEvent.INIT_COMPLETE is fired, I cleanup by removing the swc by running this :
removeChild(myPreloader);
myPreloader = null;
though even after I have removed this (which is successful, as I have checked by comparing this.numChildren before and after the call) the key framed animation still continues to run (not visibly). This has been detected by the Designer placing a trace in the time line of the animation (in Flash).
Can anyone tell me why is it, that even after I have removed the animation from the subclassed DownloadProgressBar, it still keeps running ?
Also, is it standard practice when importing SWCs to manage the cleanup of resources from the Flash side of things (much like releasing memory in obj-c). I find it counter intuitive that removing the child from the Flex side does not stop the animation.
Any clues to this would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,您的 SWC 文件只不过是包含 SWF 的 ZIP。因此,您要做的就是从舞台上删除 MovieClip,但不会停止或卸载它。 您可能想要尝试
停止动画
在从舞台上删除该项目以释放内存后,
。但请注意:Flash Player 垃圾收集并不总是正常工作。如果 myPreloader 中运行任何类型的 ActionScript,它很可能会继续运行,并且在垃圾收集期间将被忽略。通常最好为所有 AS 类包含
clear()
或destroy()
方法,并在Event.REMOVED_FROM_STAGE
上调用它。这必须由您的设计师同事完成,但根据我的经验,这是最干净的程序。
Basically, your SWC file is nothing more than a ZIP containing a SWF. So what you're doing is removing a MovieClip from the stage, but it is NOT stopping or unloading it. You might want to try
to stop the animation and
after you removed the item from the stage to free up memory.
Beware, though: the Flash Player garbage collection does not always work correctly. If there is any kind of ActionScript running within myPreloader, chances are it will continue to run, and it will be ignored during garbage collection. It is usually best to include a
clear()
ordestroy()
method for all AS classes and call it uponEvent.REMOVED_FROM_STAGE
.This would have to be done by your designer colleague, but in my experience it is the cleanest procedure.