what i’m trying to achieve is to be able to create a random time frame betw 1 to 8 seconds before it calls a movie clip from the library.
function layEgg(hens) {
//set random time in sec
var timeGap = Math.floor(Math.random()*(8+1))+1;
hens.stop();
//converts to milliseconds by * 1000
var randomness = setInterval(hens,"playAfterRandomInterval", timeGap*1000);
}
//after time interval it should play the frame and call the MC from function placeEgg
hens.playAfterRandomInterval = function() {
trace("laying egg");
hens.gotoAndPlay("layeggs");
placeEgg(hens);
clearInterval(randomness);
}
//these hens are the MC
this.onEnterFrame= function(){
if(timeLeft >= 0){
layEgg(henMC1);
layEgg(henMC2);
layEgg(henMC3);
}else{
delete this.onEnterFrame();
}
}
//hens. refers to the henMC
//parent is where henMC is in
//this function calls the MC from library
function placeEgg(hens){
var depth:Number = hens._parent.getNextHighestDepth();
var egg:MovieClip = hens._parent.attachMovie("eggMC", "eggMC_" + depth, depth);
}
however the time interval is not working. i managed to trace the random timeGap. any idea?