PDA

View Full Version : my thoughts on the subject


JRBT
05-23-2002, 04:58 PM
the scenario you've presented is pretty vague, so I will just explain what you need to accomplish to make this happen.

First we need something to represent the time.

We need to give it a random value.

We need to specify how much time is too much so it doen't take forever to replay.

We need to make a counter that counts up to the random time in frame by frame fashion.

We need to tell your movie that it is time to play.

Lets pretend that your movie runs 1 frame per second, so we give the variable time a value of 60 seconds or less, and the variable counter to 0: The easiest thing to do is make a blank movieclip for the code so you have a timeline to work with that doesn't mess with anything else it shouldn't.

Frame 1
------------------------------------------------

var time = Math.random()*60; //random value between 0 and 60
var counter = 0; //value = 0

Frame 2
------------------------------------------------
if (counter >= time){ //is counter greater than or equal to time?
your movie clip.play(); //make a path to your clip and play it
}else{
gotoAndPlay(3); //if not gotoAndPlay(3)
}

Frame 3
-------------------------------------------------
counter = counter + 1; //increase counter
gotoAndPlay(2); //go back and compare the values again

The only other thing I think you would need to do is add an action to the last frame of your movieclip to tell the blank clip with the code to gotoAndPlay(1) which will create a new random value and start the cycle again.

Billy T
05-24-2002, 08:04 AM
you talking to yourself again man? ;)

JRBT
05-24-2002, 01:47 PM
I thought I was answering someone's question - I must have hit new thread rather than reply............

So, I guess I am just talking to myself! LOL!