Call Function Sequence Randomly

Posted on 2008-09-29
Last Modified: 2013-11-11
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 */
var fnArray = [show1, show2, show3, show4];
var counter = 0;
var intervalId;
function callfunctions() {
        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 */

Open in new window

Question by:webrhp
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 34

Accepted Solution

Aneesh Chopra earned 500 total points
ID: 22597264
below is the updated code:

var fnArray = [show1, show2, show3, show4];
var counter = 0;
var intervalId;
function callfunctions() {
	var rnd = random(fnArray.length);
	if (rnd == counter) {
	counter = rnd;
function startTimer() {
	intervalId = setInterval(callfunctions, 5500);
function show1() {
function show2() {
function show3() {
function show4() {

Open in new window


Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question