Highlighted

Unload SWF

Explorer ,
Mar 13, 2020

Copy link to clipboard

Copied

Hi Community, 

 

I am creating an app in AS3.

One of the things I am doing is I am loading several swfs from outside my app. 

I can load and unload them using the action scrip:

 

 

tourdoc.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);

import fl.display.ProLoader;
var fl_ProLoader:ProLoader;

var fl_ToLoad:Boolean = true;
function fl_ClickToLoadUnloadSWF(event:MouseEvent):void
{
	if(fl_ToLoad)
	{
		fl_ProLoader = new ProLoader();
		fl_ProLoader.load(new URLRequest("swfs/tour.swf"));
		addChild(fl_ProLoader);
	}
	else
	{
		fl_ProLoader.unload();
		removeChild(fl_ProLoader);
		fl_ProLoader = null;
	}
	// Toggle whether you want to load or unload the SWF
	fl_ToLoad = !fl_ToLoad;
}

 


and it works fine, although I need a close button to unload each swf.

Is there any easy way to do it?

 

Thank you all

Best Regards 

Ana 

 

 

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

import fl.display.Proloader;

var proloader:Proloader=new Proloader;

var urlReq:URLRequest = new URLRequest("swfs/tour.swf");

 

load_button.addEventListener(MouseEvent.CLICK,loadF);

unload_button.addEventListener(MouseEvent.CLICK.unloadF);

 

function loadF(e:MouseEvent):void{

proloader.load(urlReq);

addChild(proloader);

}

function unloadF(e:MouseEvent):void{

proloader.unload();

removeChild(proloader);

}

Views

205

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Unload SWF

Explorer ,
Mar 13, 2020

Copy link to clipboard

Copied

Hi Community, 

 

I am creating an app in AS3.

One of the things I am doing is I am loading several swfs from outside my app. 

I can load and unload them using the action scrip:

 

 

tourdoc.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);

import fl.display.ProLoader;
var fl_ProLoader:ProLoader;

var fl_ToLoad:Boolean = true;
function fl_ClickToLoadUnloadSWF(event:MouseEvent):void
{
	if(fl_ToLoad)
	{
		fl_ProLoader = new ProLoader();
		fl_ProLoader.load(new URLRequest("swfs/tour.swf"));
		addChild(fl_ProLoader);
	}
	else
	{
		fl_ProLoader.unload();
		removeChild(fl_ProLoader);
		fl_ProLoader = null;
	}
	// Toggle whether you want to load or unload the SWF
	fl_ToLoad = !fl_ToLoad;
}

 


and it works fine, although I need a close button to unload each swf.

Is there any easy way to do it?

 

Thank you all

Best Regards 

Ana 

 

 

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

import fl.display.Proloader;

var proloader:Proloader=new Proloader;

var urlReq:URLRequest = new URLRequest("swfs/tour.swf");

 

load_button.addEventListener(MouseEvent.CLICK,loadF);

unload_button.addEventListener(MouseEvent.CLICK.unloadF);

 

function loadF(e:MouseEvent):void{

proloader.load(urlReq);

addChild(proloader);

}

function unloadF(e:MouseEvent):void{

proloader.unload();

removeChild(proloader);

}

Views

206

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 13, 2020 0
Explorer ,
Mar 16, 2020

Copy link to clipboard

Copied

Any help here? pleassssseeeeeeeeeeee 😉

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 16, 2020 0
Adobe Community Professional ,
Mar 16, 2020

Copy link to clipboard

Copied

It would help if we could figure out what you're asking.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 16, 2020 0
Adobe Community Professional ,
Mar 16, 2020

Copy link to clipboard

Copied

what's wrong with the unload() method?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 16, 2020 0
Explorer ,
Mar 19, 2020

Copy link to clipboard

Copied

Sorry, if I am not explaining right. I will try better...

So, I would like to use one button to load the SWF and a diferent one to unload the same SWF, like one button to open a window and a close button. Somehow it is not working the way I am doing it. I am not able to unload the SWF unless I press it twice. Probably I am doing something wrong...

Sorry for bothering you with my nonsense... 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 19, 2020 0
Adobe Community Professional ,
Mar 19, 2020

Copy link to clipboard

Copied

import fl.display.Proloader;

var proloader:Proloader=new Proloader;

var urlReq:URLRequest = new URLRequest("swfs/tour.swf");

 

load_button.addEventListener(MouseEvent.CLICK,loadF);

unload_button.addEventListener(MouseEvent.CLICK.unloadF);

 

function loadF(e:MouseEvent):void{

proloader.load(urlReq);

addChild(proloader);

}

function unloadF(e:MouseEvent):void{

proloader.unload();

removeChild(proloader);

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 19, 2020 0
Explorer ,
Mar 20, 2020

Copy link to clipboard

Copied

Thank you for your answer.

It makes sence to me, just getting this two errors:

 

Scene 1, Layer 'Actions', Frame 1, Line 13, Column 49 1119: Access of possibly undefined property unloadF through a reference with static type String.
Scene 1, Layer 'Actions', Frame 1, Line 13, Column 49 1136: Incorrect number of arguments. Expected 2.

 

Thank you for your patience.

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 20, 2020 0
Adobe Community Professional ,
Mar 20, 2020

Copy link to clipboard

Copied

there's a typo in line 2.  the last period should be a comma:

 

unload_button.addEventListener(MouseEvent.CLICK.unloadF);

 

should be

 

unload_button.addEventListener(MouseEvent.CLICK,unloadF);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 20, 2020 0
Explorer ,
Mar 20, 2020

Copy link to clipboard

Copied

YES!!!

Working now!!! 

You can't imagine how many times I looked at the code to see if there was something wrong...

Thank you very much 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 20, 2020 0
kglad LATEST
Adobe Community Professional ,
Mar 20, 2020

Copy link to clipboard

Copied

you're welcome.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 20, 2020 0