View Full Version : Loop on current frame
notsofast
04-16-2002, 08:05 PM
I'm observing that "gotoAndPlay(_currentframe)" does not loop on the frame, but just keeps going. It looks like you need at least two frames to loop on. Is that true? If so, it must be well known, but I didn't find it in the Flash docs.
(Sorry if this is a FAQ. I missed it.)
Puzzled.
jimburton
04-16-2002, 09:10 PM
There's a tutorial on pausing movies in the tutorial section on this - not sure if that loops or stops on one frame.
To stop on current frame you need to use a process clip - an otherwise empty movieclip that has some code on it that is executed repeatedly and controls the main timeline. This code should do it if you want to wait for a specified period - adapt it to wait for an event if need be...
//on frame 1
waiting = false;
//button on main timeline
on (release) {
if (!waiting) {
stop();
waiting = true;
}
}
//code on process clip
onClipEvent(load) {
count = 0;
}
onClipEvent (enterFrame) {
if (_parent.waiting) {
if (count > 100) {//waits 100 frames
_parent.waiting = false;
_parent.play();
count = 0;
} else {
count++;
}
}
}
You can do this sort of thing more precisely with getTimer(), but try to avoid using that - it's very expensive with memory.
notsofast
04-16-2002, 09:51 PM
Yeeesh! Seems easier to just copy the current frame and put "gotoAndPlay(_currentframe - 1)" in the second one.
The process clip idea is great, though. I remember reading about it once. It'll come in handy. Thanks for the reminder!
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.