webrhp
asked on
Call Function Sequence Randomly
My code is below. I'm simply trying to make the functions random, instead of sequential, Please help, as this is urgent!
/* Start from panel 1 */
_root.show1();
var fnArray = [show1, show2, show3, show4];
var counter = 0;
var intervalId;
function callfunctions() {
fnArray[counter]();
counter = counter+1<fnArray.length ? counter+1 : 0;
}
function startTimer(num) {
clearInterval(intervalId); /* Cleared interval, because clicking each button would offset the timer */
counter = num; /* Removed "-1" because of odd jump */
intervalId = setInterval(callfunctions, 5500);
}
/* Also removed stopTimer(); because we're calling startTimer(); in each button */
_root.startTimer(1); /* Starts the timer for panel 1 */
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.