Groups | Blog | Home
all groups > flash actionscript > february 2006 >

flash actionscript : Loop and go


-->dan mode
2/22/2006 4:33:27 PM
Sample here:
http://www.smithmediafusion.com/blog/?p=19

Just adjust the stop to a gotoAndPlay(frameNumberHere) and you'll be fine.

--

Dan Mode
*Must Read* http://www.smithmediafusion.com/blog
*Flash Helps* http://www.smithmediafusion.com/blog/?cat=11

[quoted text, click to view]

Brian Battles
2/22/2006 11:13:10 PM
At the end of 120 frames my Flash movie loops five frames continuously. I would
like to have those five frames loop 10 times then continue further along the
timeline. Where can I find the action script to control this activity?
blemmo
2/22/2006 11:26:02 PM
You'll need a counter variable for this. Put this on Frame 120:
if(!counter){
counter=0;
}
else{
counter++;
}
if(counter<10){
gotoAndPlay(115);
}

Once the counter reaches 10, the movie will play on normally.

cheers,
blemmo
Wolli World
2/22/2006 11:29:47 PM
I'm assuming you've already created the loop in actionscript that loops through
the frames. If you have, just create a counter variable and initialize it to 0
in the frame before the loop start frame (very important, otherwise it will get
reinitialized everytime you move through the looped frames) and in the last
looped frame increment the variable by 1. Create an if/then statement that
checks the value of the counter variable and when it reaches 10 goto your next
frame.
Brian Battles
2/22/2006 11:38:19 PM
blemmo, My movie loops from frame 115 to 120. Frame 120 says gotoAndPlay(115).
So, I need to add the extra code above it (as you wrote in your reply). With
that, after it plays ten times it will automatically move on to frame 121 and
play?
blemmo
2/22/2006 11:55:58 PM
You should delete the gotoAndPlay(115) because it is contained in the
if(counter<10) part. If counter equals 10, nothing happens codewise, so the
movie will go on playing the next frame.

cheers,
blemmo
Brian Battles
2/23/2006 12:11:32 AM
Brian Battles
2/23/2006 9:30:28 PM
blemmo, I entered the code exactly as you wrote in your message. The only
difference is I used a frame label instead of a number in the
"gotoAndPlay(framename)" line. The animation continues to loop and does not
move past frame 120 after it plays through 10 times. What I am wanting to do is
to play the animation 10 times then the movie continues forward in the timeline
for a couple of frames where the action becomes getURL. I want it to forward to
another page. In other words, I am using the initial page as a splash page with
an automatic forward to the home page.

I read Wolli's post, which seems a little different. I don't quite understand
it. Frame 120 is at the END of the looping, not BEFORE it.
blemmo
2/24/2006 12:32:10 AM
Oops, sorry... the first line is wrong. Replace it with
if(counter == undefined){

I was thinking that "counter = 0" defines the variable (what it does in the
way that now 'counter' exists and returns '0'), but it is also set to 'false'
because of the value Zero. So "!counter" is always true...
It would also work with the first code and "counter = 1" in the second line,
and in the second if 11 instead of 10.

Wolli's way is quite the same idea, here it's just the initialisation of the
counter and the checking put all in one frame.

cheers,
blemmo
Brian Battles
2/24/2006 1:12:53 AM
Flog me if you must, it still doesn't work. Here is the scoop.

I placed the Actionscript seen below in frame 120. The loop goes back to a
frame labeled "wag" and I want it to play about 5 to 10 times, depending on
what timing works out best. After it loops X number of times I want it to jump
to frame 121 and continue to play.

I can post a screen shot of the timeline on my website if that will help.

if (!counter) {
counter = undefined;
} else {
counter++;
}
if (counter<10) {
gotoAndPlay("wag");
blemmo
2/24/2006 1:55:03 AM
Well... can't find my whip... but here the complete code:

if (counter == undefined) {
counter = 0;
} else {
counter++;
}
if (counter<10) {
gotoAndPlay("wag");

but this would also do it:

if (!counter) {
counter = 1;
} else {
counter++;
}
if (counter<11) {
gotoAndPlay("wag");

cheers,
blemmo
AddThis Social Bookmark Button