-
Going Random! (a little help?)
Hi guys,
I have my main .swf, and let us say three MC's waiting on the edge of the stage. What I want is for the script to make a random decision about playing one of these three MC's every few seconds (let's say every four seconds). Can anybody help?
Thanks very much
Simon Fox.
Good lord, it's been a while
-
Senior Member
You should gibe those 3 mcs instance name like "mc1", "mc2" and "mc3". Now its easy to control them randomly by:
_root["mc"+(random(3)+1)].play();
-
Just assume for a minute that i'm completely clueless, and explain exactly where I should be applying that code? On the MC's? or in the main timeline?
thanks again,
Simon Fox.
Good lord, it's been a while
-
Senior Member
Here is basic function with timer. This should be placed in the frame in main timeline:
code: this.onEnterFrame = function() {
//time to wait between playing another mc
pauseTime = 4000;
//set timer variable at the start
if (lastTime == undefined) {
lastTime = getTimer()+pauseTime;
}
//check if time has passed
if (getTimer()>lastTime) {
//increase timer
lastTime = getTimer()+pauseTime;
//play random mc
_root["mc"+(random(3)+1)].play();
}
};
-
Much obliged tonypa, Very very helpful,
Thanks alot,
Simon.
Good lord, it's been a while
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|