简体   繁体   English

了解将Flash SWC导入Flex Builder 3和关键帧动画

[英]Understanding Flash SWC's imported into Flex Builder 3 and key framed animation

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). 我试图了解从Flash CS4导入Flex Builder 3的SWC中发生了什么。具体地说,我正在使用Designer提供的SWC作为自定义预加载器(子类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 : 我试图理解的问题是,一旦触发了FlexEvent.INIT_COMPLETE,我将通过运行以下命令删除swc进行清理:

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.numChildren进行的检查),关键帧动画仍然继续运行(不明显)。 This has been detected by the Designer placing a trace in the time line of the animation (in Flash). 设计器已将其放置在动画的时间线中(在Flash中)来检测到此情况。

Can anyone tell me why is it, that even after I have removed the animation from the subclassed DownloadProgressBar, it still keeps running ? 谁能告诉我为什么,即使从子类DownloadProgressBar中删除了动画之后,动画仍然可以继续运行?

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). 另外,导入SWC来从事物的Flash端管理资源清理时,这是否是标准做法(就像在obj-c中释放内存一样)。 I find it counter intuitive that removing the child from the Flex side does not stop the animation. 我发现与从Flex一侧移除子对象不会停止动画相反,这很直观。

Any clues to this would be greatly appreciated. 任何线索,将不胜感激。

Basically, your SWC file is nothing more than a ZIP containing a SWF. 基本上,您的SWC文件只不过是包含SWF的ZIP文件。 So what you're doing is removing a MovieClip from the stage, but it is NOT stopping or unloading it. 因此,您要做的是从舞台上删除MovieClip,但它不会停止或卸载它。 You might want to try 您可能要尝试

myPreloader.stop();

to stop the animation and 停止动画并

myPreloaderLoader.unload();

after you removed the item from the stage to free up memory. 从舞台上删除该项目以释放​​内存之后。

Beware, though: the Flash Player garbage collection does not always work correctly. 但是要当心:Flash Player垃圾回收并不总是能正常工作。 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. 如果myPreloader中正在运行任何类型的ActionScript,则它可能会继续运行,并且在垃圾回收期间将被忽略。 It is usually best to include a clear() or destroy() method for all AS classes and call it upon Event.REMOVED_FROM_STAGE . 通常最好为所有AS类包括clear()destroy()方法,并在Event.REMOVED_FROM_STAGE调用它。 This would have to be done by your designer colleague, but in my experience it is the cleanest procedure. 这必须由您的设计师同事完成,但是以我的经验,这是最干净的过程。

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

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