Recommended Posts

Hello everyone...

This is my biggest problem in Adobe Animate AS3 ever. So the problem is-

I have 8 SWFs which have separate topic in each and one main SWF file and i want to connect all of them together like-

Firstly i open Main SWF then it shows all the 8 topics name with each button. i used script from code snippets which is 'Click to load/unload SWF' and i assigned all the SWF as it required to open. I have created a button in each SWF to go back to main SWF using same code as i mentioned.... It is working properly but i realized that each time i click to open new SWF, it overlape on old one and when i open multiple times all SWFs, it become very heavy and get legging and hangs very much, consumes more memory...

So what can i do to load new SWF and unload all previous SWFs by clicking on same button in each SWF ???????

 

Please give some idea with whole detailed script which i have to paste with button name and file name(u can assume any button name and file name).

As i don't have enough knowledge about writing manual code.

 

Please give some positive response.

Thanks....

Share this post


Link to post
Share on other sites

I used Flex as3 code to load and unload the pages. I had problems with loading/unloading swf pages.  The Garbage Collector doesn't remove the object from memory, if the loaded asset (child swf) has event listeners, or loaded an asset. If you are using away3d or something similar you need to unload all children from it too.

So to fix this problem, I created killEvents() function inside of each loaded child swf. Inside of each swf I unload all loaded assets, kill all event listeners, kill all sounds. I tried to change the names. You might need to look online to see what others are suggesting

 

function killEvents() {
  try { 
    ChildSwf.Button.removeEventListener(MouseEvent.MOUSE_UP, childSwfButtonListener); 
    //Killing events that parent element is listening
  } catch (error:Error) { } 

  try { 
    ChildSwf.kill(); //Calling kill function inside the child swf
  } catch (e:Error) { 
     debugTxt('ERROR in removeLoader(), calling kill().'); 
  } 

  try { 
    ParentSWFLoader.unloadAndStop(true); //unloading 
  } catch (e:Error) { 
    debugTxt('ERROR in removeLoader(), calling unloadAndStop.'); 
  } 

  try { 
    ParentSWFLoader.source = null; 
  } catch (e:Error) { 
    debugTxt('ERROR in removeLoader(), calling unloadAndStop.'); 
  } 

  SoundMixer.stopAll(); 

  THe code below is suggested to use to clear the swfloader
  try { 
    new LocalConnection().connect('foo');
    new LocalConnection().connect('foo'); 
  } catch (e:*) { }

  System.gc(); 
  System.gc();

  removeTimer()
}

 

Share this post


Link to post
Share on other sites

Multiaki, 

 

Thank you very much jumping in and helping. Very kind of you.

 

---

 

Ankush,

 

Sorry, but we just don't have the resources (time) to get deeply involved with AS3 questions. We stopped supporting the tools years ago and quite frankly I've forgotten a lot of the specifics of working with AS3.

 

Hopefully, Multiaki's advice will get you in the right direction.  The only thing I can add is that if you want to unload a bunch of swfs at once you may want to use an array to store references to all the SWFLoaders you have created and loaded. You can then loop through that array and unload them all. If you use a LoaderMax instance to load all the swfs then perhaps you can just get its content (an array of loaders) and check their status to see if they are loaded or not.

 

 

status: https://greensock.com/asdocs/com/greensock/loading/LoaderMax.html#content

content: https://greensock.com/asdocs/com/greensock/loading/LoaderMax.html#status

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.