PDA

View Full Version : repeat or loop swf?


romio
11-24-2001, 11:48 AM
can ne body tell me

how can i publish swf with exect time duration like i want a swf which repeats every after 10 sec. is it possible

thanks

Ricod
11-26-2001, 11:43 AM
multiplu the number of second u want it to last with the frames per second (by default twelve) and on that frame u say gotoAndPlay(1);

But if u don't feel like making a 120 frames swf u could use the getTimer to check if 10 seconds have passed and then goto frame 1.

romio
11-26-2001, 01:25 PM
thanks man

but i m very new in scripting and dont know how to use timer

poab
11-26-2001, 01:40 PM
Hi,

If you're using an animation that needs to loop seemlessly you should use the method suggested by Ricod.

Otherwise getTimer() works like this:

Make two layers both 2 frames long, on one place the animation, inside a Movie Clip that runs across both frames. Go to the instances panel and label it myAnimation (or whatever you want).

On the second layer make two keyframes. Then add this code:

FRAME ONE:

var elapsed = Math.floor(getTimer()/1000);

if(elapsed >= 10);
myAnimation.gotoAndPlay(1);
}


FRAME TWO:

gotoAndPlay(1);


cheers

romio
11-26-2001, 01:44 PM
thanks u very much

let me try right now....

will tell u sure after complition

romio
11-26-2001, 02:14 PM
FRAME ONE:

var elapsed = Math.floor(getTimer()/1000);

if(elapsed >= 10);
myAnimation.gotoAndPlay(1);
}


FRAME TWO:

gotoAndPlay(1);
________________________________________

well the proble is i ve worked in scene1 ... and not its not possible to convert this scene in to movie symbol ...

so can i use scene1 and to like this

FRAME ONE:

var elapsed = Math.floor(getTimer()/1000);


if (elapsed>=10) {
gotoAndPlay ("Scene 1", 1);
}


FRAME TWO:

gotoAndPlay ("Scene 2", 1);
______________________________________

is this possible

poab
11-26-2001, 03:45 PM
Hi,

Nope, sorry. What the code is doing is basically saying "Has ten seconds passed yet?" if it has it sends the animation back to the start. If it hasn't the playhead automatically passes to the next frame. In the next frame it simply sends the playhead back again so that it tests if it's been ten seconds yet.

Bear in mind that if you're movie is running at 12 frames per second then this process will occur exactly 60 times (six times a second).

getTimer() gets the number of milliseconds since the start of the movie. dividing it by 1000 gives the number of seconds and the Math.floor bit tells flash to round off the number (because we don't want to be worrying about decimal places of numbers in something simple.

elapsed is a variable and can be called anything you want it to be called (as long as it's not a reserved word).

The gotoAndPlay() in the first frame does not relate to the stuff we're creating here. What it does (you forgot to target it which is fatal) is restart the animation if ten seconds has been reached or passed.

The gotoAndPlay in the second frame returns the playhead to the previous frame, where it can test again to see if ten seconds has passed.

NOTE: THIS WILL ONLY LOOP YOUR ANIMATION ONCE.

2ND NOTE: (I TYPED WRONG) THE CORRECT SCRIPT IS if(elapsed==10);..etc.

3RD NOTE: Call 'scene1' etc. whatever you like as long as the names match the script.


What exactly is it you're trying to do, because I don't understand why you don't just make the animation 120 frames long?

cheers.

lew
11-26-2001, 05:51 PM
um just a thought why dont you set your frames per second to 10 and on the 100 th frame double click the key frame/s you want to repeat and type this

gotoAndplay (1) ;
}

it will tell the last frame to go to the start of the animation and it will repeat every ten seconds
if that doesnt work just double click the key frame/s it so the actions box opens then in normal mode goto actions goto and type the fram in the code given
if that doesnt work best i dont know what will
this also works if you have a button and want to prevent it from going straight past the button

romio
11-27-2001, 04:20 AM
thanks poab

i will do it