Hi guys,
I have a simple image swap script that loads each new image into a duplicated mc. When it loads the new movie, it scales and unloads the old movies However between loading the new movie and the removing the old, i dont want to remove the old movie clip until the new one has completely loaded. I have played around and cant get it to work. Here is a sample of my script.
var default_image='m.jpg';
maskMC._visible=0;
_root.b1.onRollOver = function(){
clearInterval(myInt);
if(curPic!='m2.jpg'){
loadImage("m2.jpg");
}
}
_root.b2.onRollOver = function(){
clearInterval(myInt);
if(curPic!='m1.jpg'){
loadImage("m1.jpg");
}
}
_root.b3.onRollOver = function(){
clearInterval(myInt);
if(curPic!='m3.jpg'){
loadImage("m3.jpg");
}
}
myTime=0;
_root.b1.onRollOut = function(){
myInt = setInterval(myFunction,1000)
}
_root.b2.onRollOut = function(){
myInt = setInterval(myFunction,1000)
}
_root.b3.onRollOut = function(){
myInt = setInterval(myFunction,1000)
}
function myFunction(){
if(myTime<2){
myTime++;
}else{
clearInterval(myInt);
loadImage(default_image);
myTime=0;
trace('3 secs');
}
}
myTime=0;
MovieClip.prototype.scaleIt = function() {
//trace(this);
var speed = 2;
var spacing=0;
var duration = 7;
var step = 100/duration;
this._alpha = 100;
//this.setMask(maskMC);
this.onEnterFrame =function(){
//this.setMask(maskMC);
this._x = -this._width/speed;
this._y = -this._height/speed;
this._alpha -= step;
if (this._xscale<500) {
this._width += 50;
this._yscale = this._xscale;
//this.setMask(maskMC);
} else {
delete this.onEnterFrame;
this.unloadMovie();
this._yscale = this._xscale=500;
}
}
};
myTime=0;
function loadImage(pic){
pos=pos+1;
var clip=imageMC.duplicateMovieClip("cont"+pos, this.getNextHighestDepth());
var mask=maskMC.duplicateMovieClip("mask"+pos, this.getNextHighestDepth());
mask._visible=0;
clip.swapDepths(curIm);
curImage.setMask(mask);
oldImage=curImage;
curImage=clip.clipMC;
curIm=clip;
curPic=pic;
curImage.loadMovie(pic);
// i want to call this function once the loadMovie has been loaded
oldImage.scaleIt();
curImage._x=(-maskMC._width/2)+20;
curImage._y=-(maskMC._height/2)+20
clip.setMask(maskMC);
}
function init() {
pos=0;
loadImage(default_image);
}
init();
Any help would be much appreciated
Thanks
Daniel