Skip to main content
May 4, 2010
Answered

Quick question about looping movie clips

  • May 4, 2010
  • 1 reply
  • 760 views

I'm a REAL Flash novice, and I'm trying to get a movie clip to loop 3 times, and then continue on.

Here's the code I've written (I'm sure it's painful to see)

stop();

if (!loopCount) {

  var loopCount:Number = 0;

}

loopCount++;

if (loopcount < 3) {

gotoAndPlay (1)

}

if (loopCount = 3) {

  gotoAndPlay(363);

}

Could someone help me out?

Thanks,

Brandon

This topic has been closed for replies.
Correct answer kglad

actually, that should generate an error message.

use:

var loopCount:Number;


if (!loopCount) {

    loopCount = 1;

} else {

    loopCount++;

}

if (loopCount < 3) {
    gotoAndPlay(1);
} else {
    gotoAndPlay(363);
}

1 reply

kglad
Community Expert
Community Expert
May 4, 2010

use double equal (==) to test for equality:


stop();

if (!loopCount) {

  var loopCount:Number = 0;

}

loopCount++;

if (loopcount < 3) {

gotoAndPlay (1)

}

if (loopCount == 3) {

  gotoAndPlay(363);

}


May 4, 2010

Thanks for the input.

Now, the movie stops after the first iteration.

I tried removing the "stop();" at the beginning of my ActionScript, and now it's again looping once, then going on to my next frames.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 4, 2010

actually, that should generate an error message.

use:

var loopCount:Number;


if (!loopCount) {

    loopCount = 1;

} else {

    loopCount++;

}

if (loopCount < 3) {
    gotoAndPlay(1);
} else {
    gotoAndPlay(363);
}