Copy link to clipboard
Copied
Hello everyone...
This is my biggest problem in 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 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....
Copy link to clipboard
Copied
use one loader for all your loads (eg, loader) and use:
if(loader.content){
loader.unloadAndStop();
}
loader.load(new URLRequest(whatever));
Copy link to clipboard
Copied
Sir,
Thanks for your reply... But can you please give detailed script for just one file ???
Copy link to clipboard
Copied
I mean, full script... Not just a part....
Copy link to clipboard
Copied
remove the code in your loaded swfs that unloads them.
in your main swf youl would use something like:
var loader:Loader=new Loader();
addChild(loader);
// if you're using movieclip buttons topic_0, topic_1 etc to load swfs topic_0.swf, topic_1.swf etc
for(var i:int=0;i<8;i++){
this['topic_'+i].ivar=i;
this['topic_'+i].addEventListener(MouseEvent.CLICK,loadF);
}
function loadF(e:MouseEvent):void{
if(loader.content){
loader.unloadAndStop();
}
loader.load(new URLRequest('topic_'+MovieClip(e.currentTarget).ivar+'.swf'));
}
Copy link to clipboard
Copied
These are the actual files which you can see how is it working...
So when i open again and again these files it gets heavier and lags...
please describe code....
Copy link to clipboard
Copied
use the code i suggested. change button names and swf names to match the code, or change the code to match your button and swf names.
Copy link to clipboard
Copied
i pasted the code but nothing happen... Please describe me where i have to paste button name and SWF's name?
Copy link to clipboard
Copied
:
var loader:Loader=new Loader();
addChild(loader);
// if you're using movieclip buttons topic_0, topic_1 etc to load swfs topic_0.swf, topic_1.swf etc
for(var i:int=0;i<8;i++){
this['topic_'+i].ivar=i; // this['topic_'+i] are your button names
this['topic_'+i].addEventListener(MouseEvent.CLICK,loadF);
}
function loadF(e:MouseEvent):void{
if(loader.content){
loader.unloadAndStop();
}
loader.load(new URLRequest('Smart Achivement'+MovieClip(e.currentTarget).ivar+'.swf'));
}
Copy link to clipboard
Copied
It's showing this error....
TypeError: Error #1010: A term is undefined and has no properties.
at SmartAchivment_fla::MainTimeline/frame1()
I pasted this code-
var loader:Loader=new Loader();
addChild(loader);
// if you're using movieclip buttons topic_0, topic_1 etc to load swfs topic_0.swf, topic_1.swf etc
for(var i:int=0;i<8;i++){
this['button_2'+i].ivar=i; // this['topic_'+i] are your button names (Button Name which i have to press to go to other SWF =button_2
this['button_2'+i].addEventListener(MouseEvent.CLICK,loadF);
}
function loadF(e:MouseEvent):void{
if(loader.content){
loader.unloadAndStop();
}
loader.load(new URLRequest('Index'+MovieClip(e.currentTarget).ivar+'.swf')); (SWF name which is Main SWF, i have to load = Index.swf)
}
Copy link to clipboard
Copied
your button names are incorrect.
do you have movieclips named button_0, button_1 etc?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
and what's ButtonHome supposed to do?
Copy link to clipboard
Copied
a little suggestion, GreenSock is a wonderful library to load multiple swf with maximum of optimization
Copy link to clipboard
Copied
'ButtonHome' will load main SWF.
Copy link to clipboard
Copied
again, remove the code in your loaded swfs that unloads them.