first i show the code:
//the MovieClipLoader object and other variables are cropped
//---------------------------------------
all.onRelease = function() {
changingImg();
};
//-----loading methods
stickerLi_2.onLoadComplete = function(holder) {//if image is loaded
holder.onEnterFrame = fadeIn; //fade in
if (currentImg == 1) {
currentImg = 2;
} else if (currentImg == 2) {
currentImg = 1;
} else {
currentImg = 1;
}
};
//-----Functions
function changingImg() {
image = all.stick1.image;
image.onEnterFrame = fadeOut; //fade out image
if (image._alpha<1) { //if faded out, load image
if (currentImg == 1) {
stickerMCL_2.loadClip(sub+images[0],image);
} else if (currentImg == 2) {
stickerMCL_2.loadClip(sub+images[1],image);
} else {
trace("Error");
}
}
}
function fadeIn() {
this.onEnterFrame = function() {
this._alpha += 20;
if (this._alpha>99) {
delete this.onEnterFrame;
}
};
}
function fadeOut() {
this.onEnterFrame = function() {
this._alpha -= 20;
if (this._alpha<1) {
delete this.onEnterFrame;
}
};
}
ok, what i am hoping to achieve is, when i click, the image fades out, then load in another image, then fade in again. It is working, but I have to click again to fade the image in. I want it to be continuous. What’s wrong here? Shouldn’t the onLoadComplete method be called automatically after the image is loaded?