简体   繁体   中英

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

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.

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

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. 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() or destroy() method for all AS classes and call it upon Event.REMOVED_FROM_STAGE . This would have to be done by your designer colleague, but in my experience it is the cleanest procedure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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