Loading external SWF over top of the previous
hi..
i have slideshow loads multiple swfs on button click , automatically.. i"m trying rid of white flash right after prev swf unloads , before new swf lods. tried moving removechild(loader); after loading function of next swf doesn't work.. can point me in reight direction please? effect i"m trying achieve:
and code i'm working now. ahead of time:
//import classes easier use
import fl.transitions.tween;
import fl.transitions.tweenevent;
import fl.transitions.easing.*;
//timer
var slideduration:uint = 8000; // or use whatever
var slidetimer:timer=new timer(slideduration,0);
slidetimer.addeventlistener(timerevent.timer,autoadvancef);
slidetimer.start();
var btna:array = [one_btn,two_btn,three_btn];
var previousbtn:simplebutton = one_btn // use class type of buttons
function autoadvancef(e:timerevent):void{
nextbuttonf(previousbtn).dispatchevent(new mouseevent(mouseevent.click));
}
function nextbuttonf(btn:simplebutton):simplebutton{ // use class type of buttons
for(var i:uint=0;i<btna.length;i++){
if(btna[i]==btn){
return btna[(i+1)%btna.length];
}
}
return null;
}
//load external swf main
var xpos:number = 0;
var ypos:number = 0;
var swf:movieclip;
var loader:loader = new loader();
var defaultswf:urlrequest = new urlrequest("swfs/one_btn.swf");
loader.load(defaultswf);
loader.x = xpos;
loader.y = ypos;
addchildat(loader,0);
//btns universal function (whenver button clicked, loader removed
function btnclick(event:mouseevent):void {
slidetimer.reset();
slidetimer.start();
previousbtn = simplebutton(event.currenttarget);
removechild(loader);
var newswfrequest:urlrequest = new urlrequest("swfs/" + event.target.name + ".swf");
var mytween:tween = new tween(loader, "alpha", none.easein, 0, 2, 1, true);
loader.load(newswfrequest);
loader.x = xpos;
loader.y = ypos;
addchildat(loader,0);
}
/// button listerners
one_btn.addeventlistener(mouseevent.click,btnclick);
two_btn.addeventlistener(mouseevent.click,btnclick);
three_btn.addeventlistener(mouseevent.click,btnclick);
More discussions in ActionScript 3
adobe
Comments
Post a Comment