PDA

View Full Version : unloading / closing External SWF with button



roxdedy
September 20th, 2008, 09:06 AM
I would be glad If You could help me with that problem, there are many post about it but it is not solve clearly.

I have got 2 files main.swf, picture.swf

My aim is to load picture.swf in main.swf and than close it using button that is place in picture.swf

AS code in main.swf looks like:

var imageRequest:URLRequest = new URLRequest ("picture.swf");
var imageLoader:Loader = new Loader();
imageLoader.x = 352;
imageLoader.y = 144;
addChild(imageLoader);

function addClick(event:MouseEvent):void
{
imageLoader.load(imageRequest);
}
button1.addEventListener(MouseEvent.CLICK, addClick);

In picture.swf i create a button close_btn and here i have no idea what to do next ....
i wonder to use lightbox but there are problems with it as well so I AM BARGING YOU FOR A HELP GUYS :/

romantique
September 21st, 2008, 06:57 AM
To tryely unload external swf you should remove all event listeners, referencing it. Remove all the pointers to that. Remove everything that can somehow point to it. Only after that swf can be unloaded.

When you have a button inside your picture.swf, there is a reference remaining there.

Correct me if I'm wrong ...