I have a chunk of code in AS2 that calls a random image. I’ve been trying to figure out how to add a fade to it without any luck.
Here’s the code for the RANDOM background:
function randomBG(){
function randRange0(min:Number, max:Number):Number {
// Generate a number between and including 20-25
var randomNum0:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum0;
}
// Get random number created
var bg:Number = randRange0(20, 24);
// Load image into holder on the stage. images should be numbered sequentially
background_mc.loadMovie("images3-bg/"+bg+".jpg");
trace(bg);
}
setInterval(randomBG,35000);
Here’s the code for the FADE on the background (that I’ve been trying to combine):
background_mc._alpha = 0;
background_mc.onEnterFrame = function(){
if(background_mc._alpha == 100){
delete background_mc.onEnterFrame;
} else {
background_mc._alpha += 5;
}
}
I’ve been trying to combine the two chunks of code in different ways but it ends up loading the background with an alpha of 5 (I’ve tested this by changing the number to 90/100 and it loads with almost a full alpha).
How come it is not fading in no matter where/how I put in the code? Someone please help me with an example (or the solution)…