View Full Version : Timing to goto frame
BlackPhantom
01-12-2005, 06:02 PM
I am making a game and I want a timer to:
make the gotoandplay action script to happen, in lets say 5mins? So you are playing the game, and in 5 mins it goes to the score frame...
CyanBlue
01-12-2005, 06:03 PM
Howdy and Welcome... :)
Check out the setInterval() function to achieve your goal... :)
BlackPhantom
01-12-2005, 06:24 PM
I can't seem to do it, I put in setInterval(gotoAndStop(2); , 30) and it doesn't seem to work, any help people? All the game is in the first frame and i want the total score to show up at the end, I need the game to last about 3-5 mins and goto frame 2 with the score showing and the music stopped...
CyanBlue
01-12-2005, 06:29 PM
Please take a look at the setInterval() function in the Flash manual...
Its syntax is...
setInterval(functionName:Function, interval:Number [, param1:Object, param2, ..., paramN]) : Number
and you can use it like this...
function sayHello()
{
trace("HELLO!!!");
clearInterval(go_iv);
}
go_iv = setInterval(sayHello, 3000);
That will execute the function 'sayHello' in 3 second and the sayHello function will clear the interval so that it won't call every other 3 seconds...
BlackPhantom
01-12-2005, 06:45 PM
Sorry to say I'm a noob at action sript and cannot seem to get it right... Anything else that would help me?
CyanBlue
01-12-2005, 07:02 PM
Well... You could try this...
function sayHello()
{
trace("HELLO!!!");
_root.gotoAndPlay(2);
clearInterval(go_iv);
}
go_iv = setInterval(sayHello, 1000 * 60 * 5);
mvhall
01-18-2005, 10:00 PM
Hey CB,
Long time no see.
Back to good old Flash again, and used the setinterval to start a mc every so many sec's. Works ok but the setInterval seems to effect the main timeline.
Both function and star1 mc are on frame 80 (with a stop) but after the first trace the main timeline goes back to 1.
It does not matter if I include this function in the MC or on the main timeline (in frame 80).
Any idea why? ATH Maurice
id = new Object();
id.interval=function() {
trace("interval called");
_root.star1.gotoAndPlay(3);
}
setInterval( id,"interval" , 3000 );
CyanBlue
01-18-2005, 10:17 PM
You totally got me, Maurice... I have no idea... :D
I just did a test and it doesn't happen on this sample... Check it out and post the sample if you still have problem... :)
(Gotta join the traffic...)
mvhall
01-18-2005, 10:32 PM
Sample works OK thanks. Have to dig a bit deeper myself then. Maybe use the debugger ohh-sssht :eek:
Will let you know. Cherio
mvhall
01-19-2005, 07:53 PM
Found it, bit of code in an mc that I oversaw, with gotoAndPlay(2) in stead of this.gotoAndPlay(2); Good old Alt+F3 uh.
Sorry, and thanks
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.