|
-
Who needs pants?
Perform action after random time ?
what i want is the mc to perform so actions after the random time which is chosen. So just say the random time is 10 seconds, the mc will wait 10 seconds before it will perform the actions. I just cant get the getTimer(); to work.
would anyone have a good way to do this
Thanks in AdvancE
[h]ooligan
-
if Flash MX:
myDelay=Math.floor(8*(Math.random())+1.5)*1000 // random numeber between 9-1. change accordingly
myInterval=setInterval(doAction,myDelay,_root.myMo vieClip)
function doAction(MC)
{
clearInterval(myInterval)
//put action code here i.e.
MC.gotoAndPlay(3)
}
if Flash 5:
1 Frame loop
Frame1:
D_Time=Math.floor(8*(Math.random())+1.5)*1000
StartTime=getTimer()
Frame 2:
Play()
Frame 3:
Time_Elapsed = (getTimer () - SoundStart)/1000;
if (Time_Elapsed >= D_Time) {
play ();
} else {
prevFrame ();
}
hope that helps
-
Who needs pants?
-
Who needs pants?
I just tried but it wouldnt work , the only actions i changed where the gototAndPlay(2); to _y += 10;
??
-
myDelay=Math.floor(8*(Math.random())+1.5)*1000 // random numeber between 9-1. change accordingly. *1000 gives a value in milliseconds
myInterval=setInterval(doAction,myDelay,_root.myMo vieClip)
//create an interval of milliseconds (myDelay) and Call function (doAction) after interval duration. Pass the Name of the Clip to be targeted (_root.myMovieClip) to the function called
//function called after Interval
function doAction(MC)
{
//delete the Interval so not called again
clearInterval(myInterval)
//put action code here i.e.
//target MovieClip via function parameter MC
MC.gotoAndPlay(3)
}
hope that makes more sense.
-
Who needs pants?
thanks Jayhoo you have been a great help
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
|