Jamash1989
Jamash1989

Reputation: 29

Closing an SWF File using AS3

How do I close an SWF file using AS3? I want to include the close in an event listener, so when the user clicks a button the application will close. I tried:

fscommand("quit");

which doesn't work.

I simply want to unload an SWF running from an FLA file.

Upvotes: 1

Views: 3421

Answers (2)

user2926940
user2926940

Reputation: 11

When I faced the same situation, I designed externally loaded swf smaller than root scene. Placed a close button at root scene to unload the swf. by setting visibility of close button, I managed it.

//loading command

fl_ProLoader = new ProLoader();    
fl_ProLoader.load(new
URLRequest("OrgChart.swf"));    
addChild(fl_ProLoader);

//unloading command

fl_ProLoader.unload();    
removeChild(fl_ProLoader);    
fl_ProLoader = null;

Upvotes: 1

Daniel
Daniel

Reputation: 35734

well that's not that easy. You can't unload the movie clip from within itself. This is only possible through Loader.unloadAndStop() meaning you have to load the swf from another swf.

The other option is to create a JavaScript that you can call from the swf, to remove the swf file reference from the page.

Upvotes: 1

Related Questions