Jan 23 2010

Unload an externally loaded swf file

Category: FAQadmin @ 12:09 am

How to remove or unload an externally loaded swf file from your project?

It happenes a lot that you try to load an external SWF file into your project. maybe in your portfolio or some swf movies or sound files. The problem I am going to talk about here is about the common problem of unloading the swf files!

you see, if you have loaded an swf file which has some music on it playing constantly, when you try to unload/remove that swf, the sound keeps playing! (not just sounds, maybe some Event.ENTER_FRAME or other listeners are still working)

to avoid this problem, the best solution I can think of is to add a REMOVED_FROM_STAGE listener in your external swf file so it can listen to when it’s removed from the stage so it can kill the running processes inside itself.

simply add it like this:

1
2
3
4
5
6
import flash.events.Event;
this.addEventListener(Event.REMOVED_FROM_STAGE, onStageRemoved);
function onStageRemoved(e:Event):void
{
// kill all listeneres and running processes here.
}

Regards,
Hadi

Tags: , , ,


Jan 17 2010

How to use SWC

Category: FAQadmin @ 7:08 pm

What is SWC?

SWC is a file containing ActionScript source codes in a compiled status. The good thing about a SWC file is that it will help your projects compile faster because your compiler (flash CS4 for example) doesn’t have to compile everything from scratch any more.

In simple words, you use SWC files to access class packages instead of accessing the class .as files manually. This is how flash and flex source codes are orgenized also. There might be other good things about SWC also but that’s what I know about, feel free to let me know if there’s anything else :)

Continue reading “How to use SWC”

Tags: , , ,