PDA

View Full Version : Random bg fade



reweb
May 7th, 2005, 12:00 PM
I want to load an random background image:

This is what I fond on the forum:



images = ["1.swf", "2.swf", "3.swf"];
randomNr = Math.round(Math.random(images.length-1)*10)
container.loadMovie(images[randomNr]);


but :thumb:

i need to fade out the bg after 20 seconds and fade in another random background image

help me :flower:

scotty
May 7th, 2005, 01:19 PM
Have a look/search for setInterval() :)

scotty(-:

nathan99
May 7th, 2005, 08:47 PM
hmmmm, you could try a noob-ish way, wich is just create a mc with each picture the size of the movie.

And just put stop in each layer along with;



var numTimeLimit = 20000; // 1 sec = 1000, so this is for 20 seconds
var bolFirstTime = true;
function countDownF() {
if (bolFirstTime) {
numTimeStart = getTimer();
bolFirstTime = false;
}


numTimePassed = getTimer() - numTimeStart;
display = Math.round((numTimeLimit - numTimePassed)/1000);
if (numTimePassed > numTimeLimit) {
_root.randomise = random(5);
clearInterval(countDownI); // clear the interval
}
}
countDownI = setInterval(countDownF, 50);


On frame 1 of the movie put _root.randomise = random(5).

NOTE** you can change the 5, to any number, just remeber that when it is a number, for eg 5, it will randomly choose from 0,1,2,3,4.

then on the IMAGES MC put this code;


onClipEvent(enterFrame){
if (_root.randomise == 1) {
this.gotoAndStop(2);
}
if (_root.randomise == 2) {
this.gotoAndStop(3);
}
if (_root.randomise == 3) {
this.gotoAndStop(4);
}
if (_root.randomise == 4) {
this.gotoAndStop(5);
}
if (_root.randomise == 0) {
this.gotoAndStop(1);
}
}




hope it helps :thumb: