windowswarrior,
> Working in Flash CS2 so I'm pretty sure it's AS3.
However,
> your suggestion doesn't work. It just keeps looping.
Flash CS3 is the first in the Flash family to include a "CS"
in the
name, so you're either working with Flash CS3 (the first to
support
ActionScript 3.0) or ... maybe Flash 8? If the letter, then
you'll have to
use ActionScript 2.0 or lower. But now that I'm looking at
this code again,
the ActionScript 2.0 and 3.0 versions are so similar, it
really doesn't
matter in this case.
Let's assume ActionScript 3.0, and we'll take it step by
step.
Bear with me and start a new FLA file, because if we start
from scratch,
it's a lot more likely we'll catch what's going wrong where.
1) Select File > New and choose Flash File (ActionScript
3.0).
2) Select frame 1 of the main timeline, open your Actions
panel, and type
this:
var loop:int = 0;
So far, we're doing nothing more than creating a variable
(happens to be
an integer) in frame 1 and setting it to 0. (Previous code
showed :Number
instead of :int, and honestly, either one will do. Because
this number is
only going to be an integer, :int is technically the better
choice.)
3) Add a keyframe to frame 10. Enter the following
ActionScript in frame
10:
loop = loop + 1;
trace(loop);
if (loop < 3) {
this.gotoAndPlay(2);
} else {
this.stop();
}
At this point, the variable, loop, is incremented by 1. The
first time
this happens, its value becomes 1 (because 0 + 1 is, of
course, 1). Next, a
trace() function traces the value of loop to the Output
panel. You'll see
"1", without quotes, appear in the Output panel when the
playhead enters
this frame.
Next, an if() statement compares the value of loop (which is
currently
1) to the number 3. If it's less than 3 -- at this point, it
is -- the
playhead is sent back to frame 2. Otherwise, it stops.
4) Test your movie. In short order, you should see the
numbers 1, 2, and 3
appear in the Output panel. After that, nothing else --
because the
playhead has stopped at frame 10 and no longer loops.
Let me know if that happens for you.
David Stiller
Contributor, How to Cheat in Adobe Flash CS3
http://tinyurl.com/2cp6na
"Luck is the residue of good design."