• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Unload SWF

Explorer ,
Mar 13, 2020 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 

 

 

Views

465

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
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 19, 2020 Mar 19, 2020

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

}

Votes

Translate

Translate
Explorer ,
Mar 16, 2020 Mar 16, 2020

Copy link to clipboard

Copied

Any help here? pleassssseeeeeeeeeeee 😉

Votes

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
community guidelines
LEGEND ,
Mar 16, 2020 Mar 16, 2020

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Community Expert ,
Mar 16, 2020 Mar 16, 2020

Copy link to clipboard

Copied

what's wrong with the unload() method?

Votes

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
community guidelines
Explorer ,
Mar 19, 2020 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... 

Votes

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
community guidelines
Community Expert ,
Mar 19, 2020 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);

}

Votes

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
community guidelines
Explorer ,
Mar 20, 2020 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.

 

Votes

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
community guidelines
Community Expert ,
Mar 20, 2020 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);

Votes

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
community guidelines
Explorer ,
Mar 20, 2020 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 

Votes

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
community guidelines
Community Expert ,
Mar 20, 2020 Mar 20, 2020

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

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
community guidelines