Skip to main content
Inspiring
February 21, 2017
Answered

gotoandStop within a movie clip

  • February 21, 2017
  • 1 reply
  • 1371 views

I have a movie clip name shoes_mc, within this movie clip, there are 10 layers with increasing number of pair of shoes (1 pair in the 1st layer, 2 pairs in the 2nd, and so on). I also have a button name plus_btn, I apply the code below, so every time I click the button, it would gotoandstop to next layer within shoes_mc. I used trace("works") to se if the code works or not.

Then I tested the movie and the trace showed "works" but the layer didn't go to the next layer. It stayed in the 1st layer.

In addition, actually I'm looking for a way to make a plus minus button, every time I click plus, 1 pair of shoes appear, and every time I click minus, 1 pair of shoes disappear. But I don't get logic about this, and I thought the gotoanstop within movie clip will works. Please help me.

plus_btn.onRelease=function()

{

shoes_mc.nextFrame();

trace("works");

}

This topic has been closed for replies.
Correct answer Colin Holgate

You used the word 'layer' a few times when I hope you meant 'frame'. shoes_mc should have 10 frames, with 1 pair of shoes in frame 1, 2 pairs in frame 2, and so on.

If that is how you have it, then your script will work, other than the fact the movieclip will play in a loop until the first time you click the button.

Here's a script that stops the shoes_mc at the beginning, and also has the code for a minus_btn that you will need to make:

shoes_mc.stop();

plus_btn.onRelease = function()

{

  shoes_mc.nextFrame();

  trace("works");

};

minus_btn.onRelease = function()

{

  shoes_mc.prevFrame();

  trace("works");

};

1 reply

Colin Holgate
Colin HolgateCorrect answer
Inspiring
February 21, 2017

You used the word 'layer' a few times when I hope you meant 'frame'. shoes_mc should have 10 frames, with 1 pair of shoes in frame 1, 2 pairs in frame 2, and so on.

If that is how you have it, then your script will work, other than the fact the movieclip will play in a loop until the first time you click the button.

Here's a script that stops the shoes_mc at the beginning, and also has the code for a minus_btn that you will need to make:

shoes_mc.stop();

plus_btn.onRelease = function()

{

  shoes_mc.nextFrame();

  trace("works");

};

minus_btn.onRelease = function()

{

  shoes_mc.prevFrame();

  trace("works");

};

Inspiring
February 21, 2017

oh yeah, I meant frame not layer. Thanks for your correction and so much thanks for your help. The code works really well

Colin Holgate
Inspiring
February 21, 2017

Glad to hear it!