Highlighted

Load/Unload Child SWF but Audio keep Playing (Very Important)

Community Beginner ,
Feb 27, 2019

Copy link to clipboard

Copied

Hello Everyone..

This is very important query for me.

I've 3 SWFs, 1st parent and 2 other child SWFs. Both Child SWFs have its own audio/voiceover.

I used script from code snippets section which is 'click to Load/Unload SWF or Image'. So i linked both child swf to parent swf using 2 separate buttons in parent swf.

Finally when i click on any button in parent swf to call child swf, it's working fine and if i click again on same button, it unloads successfully but my problem is when it unloads swf, sound keep plays on background.

What to do for complete unload with sound?

Looks like only video unloads but the audio of child swf keep plays in background. How can i unload audio of child swf permanently ?

I tried 'click to stop all sound' but looks like it's only mutes the sound, not unloads.

Plz help! this is very important for me.

Code which i'm using right now in parent swf-

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);

import fl.display.ProLoader;

var fl_ProLoader:ProLoader;

//This variable keeps track of whether you want to load or unload the SWF

var fl_ToLoad:Boolean = true;

function fl_ClickToLoadUnloadSWF(event:MouseEvent):void

{

if(fl_ToLoad)

{

fl_ProLoader = new ProLoader();

fl_ProLoader.load(new URLRequest("Child !.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;

}

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

Hi.

This happens because you're using the ProLoader class and the method this class has to unload doesn't necessarily destroys the child, references, stops sound, and so on.

Removes a child of this ProLoader object that was loaded by using the load() method. The property of the associated ProLoaderInfo object is reset to null. The child is not necessarily destroyed because other objects might have references to it; however, it is no longer a child of the ProLoader object.

Loader - Adobe ActionScript® 3 (AS3 ) API Reference

I think you should instead opt for the Loader class and use the unloadAndStop method.

Attempts to unload child SWF file contents and stops the execution of commands from loaded SWF files. This method attempts to unload SWF files that were loaded using Loader.load() or Loader.loadBytes() by removing references to EventDispatcher, NetConnection, Timer, Sound, or Video objects of the child SWF file. As a result, the following occurs for the child SWF file and the child SWF file's display list: 

  • Sounds are stopped.
  • Stage event listeners are removed.
  • Event listeners for enterFrame, frameConstructed, exitFrame, activate and deactivate are removed.
  • Timers are stopped.
  • Camera and Microphone instances are detached
  • Movie clips are stopped.

When you call the unloadAndStop() method, the Loader object's contentLoaderInfo property is set to null. Any visual assets that were loaded with the SWF are unloaded and removed from memory. ActionScript class definitions in the loaded SWF remain in memory, and code in the same application domain as the loaded SWF can access instances of those classes and create new instances.

Loader - Adobe ActionScript® 3 (AS3 ) API Reference

Regards,

JC

TOPICS
ActionScript

Views

248

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

Load/Unload Child SWF but Audio keep Playing (Very Important)

Community Beginner ,
Feb 27, 2019

Copy link to clipboard

Copied

Hello Everyone..

This is very important query for me.

I've 3 SWFs, 1st parent and 2 other child SWFs. Both Child SWFs have its own audio/voiceover.

I used script from code snippets section which is 'click to Load/Unload SWF or Image'. So i linked both child swf to parent swf using 2 separate buttons in parent swf.

Finally when i click on any button in parent swf to call child swf, it's working fine and if i click again on same button, it unloads successfully but my problem is when it unloads swf, sound keep plays on background.

What to do for complete unload with sound?

Looks like only video unloads but the audio of child swf keep plays in background. How can i unload audio of child swf permanently ?

I tried 'click to stop all sound' but looks like it's only mutes the sound, not unloads.

Plz help! this is very important for me.

Code which i'm using right now in parent swf-

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);

import fl.display.ProLoader;

var fl_ProLoader:ProLoader;

//This variable keeps track of whether you want to load or unload the SWF

var fl_ToLoad:Boolean = true;

function fl_ClickToLoadUnloadSWF(event:MouseEvent):void

{

if(fl_ToLoad)

{

fl_ProLoader = new ProLoader();

fl_ProLoader.load(new URLRequest("Child !.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;

}

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

Hi.

This happens because you're using the ProLoader class and the method this class has to unload doesn't necessarily destroys the child, references, stops sound, and so on.

Removes a child of this ProLoader object that was loaded by using the load() method. The property of the associated ProLoaderInfo object is reset to null. The child is not necessarily destroyed because other objects might have references to it; however, it is no longer a child of the ProLoader object.

Loader - Adobe ActionScript® 3 (AS3 ) API Reference

I think you should instead opt for the Loader class and use the unloadAndStop method.

Attempts to unload child SWF file contents and stops the execution of commands from loaded SWF files. This method attempts to unload SWF files that were loaded using Loader.load() or Loader.loadBytes() by removing references to EventDispatcher, NetConnection, Timer, Sound, or Video objects of the child SWF file. As a result, the following occurs for the child SWF file and the child SWF file's display list: 

  • Sounds are stopped.
  • Stage event listeners are removed.
  • Event listeners for enterFrame, frameConstructed, exitFrame, activate and deactivate are removed.
  • Timers are stopped.
  • Camera and Microphone instances are detached
  • Movie clips are stopped.

When you call the unloadAndStop() method, the Loader object's contentLoaderInfo property is set to null. Any visual assets that were loaded with the SWF are unloaded and removed from memory. ActionScript class definitions in the loaded SWF remain in memory, and code in the same application domain as the loaded SWF can access instances of those classes and create new instances.

Loader - Adobe ActionScript® 3 (AS3 ) API Reference

Regards,

JC

TOPICS
ActionScript

Views

249

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
Feb 27, 2019 0
Adobe Community Professional ,
Feb 27, 2019

Copy link to clipboard

Copied

Hi.

This happens because you're using the ProLoader class and the method this class has to unload doesn't necessarily destroys the child, references, stops sound, and so on.

Removes a child of this ProLoader object that was loaded by using the load() method. The property of the associated ProLoaderInfo object is reset to null. The child is not necessarily destroyed because other objects might have references to it; however, it is no longer a child of the ProLoader object.

Loader - Adobe ActionScript® 3 (AS3 ) API Reference

I think you should instead opt for the Loader class and use the unloadAndStop method.

Attempts to unload child SWF file contents and stops the execution of commands from loaded SWF files. This method attempts to unload SWF files that were loaded using Loader.load() or Loader.loadBytes() by removing references to EventDispatcher, NetConnection, Timer, Sound, or Video objects of the child SWF file. As a result, the following occurs for the child SWF file and the child SWF file's display list: 

  • Sounds are stopped.
  • Stage event listeners are removed.
  • Event listeners for enterFrame, frameConstructed, exitFrame, activate and deactivate are removed.
  • Timers are stopped.
  • Camera and Microphone instances are detached
  • Movie clips are stopped.

When you call the unloadAndStop() method, the Loader object's contentLoaderInfo property is set to null. Any visual assets that were loaded with the SWF are unloaded and removed from memory. ActionScript class definitions in the loaded SWF remain in memory, and code in the same application domain as the loaded SWF can access instances of those classes and create new instances.

Loader - Adobe ActionScript® 3 (AS3 ) API Reference

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

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...
Feb 27, 2019 1
Community Beginner ,
Feb 27, 2019

Copy link to clipboard

Copied

unloadAndStop() works for me!

Thanks !

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...
Feb 27, 2019 1
Adobe Community Professional ,
Feb 28, 2019

Copy link to clipboard

Copied

You're welcome!

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

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...
Feb 28, 2019 0