Copy link to clipboard
Copied
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");
}
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.ne
...Copy link to clipboard
Copied
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");
};
Copy link to clipboard
Copied
oh yeah, I meant frame not layer. Thanks for your correction and so much thanks for your help. The code works really well
Copy link to clipboard
Copied
Glad to hear it!
Copy link to clipboard
Copied
Hello I'm back, is it okay to ask here or I should post a new thread?
I have a button, check_btn, I want to check if the number of shoes has reached a certain number. So I think to use this:
shoes_mc.stop();
plus_btn.onPress = function()
{
shoes_mc.nextFrame();
trace("works1");
}
minus_btn.onRelease = function()
{
shoes_mc.prevFrame();
trace("works2");
}
check_btn.onPress = function()
{
if (shoes_mc.currentFrame == 11)
{
trace("OK FULL");
}
else
trace("NOT YET");
}
The problem is, eventhough I have reached the 11th rame, the trace of check_btn still show NOT YET. I'm thinking about using a var, so I changed the code like this:
shoes_mc.stop();
var fullshoes:Boolean = false;
plus_btn.onPress = function()
{
shoes_mc.nextFrame();
trace("works1");
if(currentFrame == 11)
{
fullshoes = true:
}
}
minus_btn.onRelease = function()
{
shoes_mc.prevFrame();
trace("works2");
}
check_btn.onPress = function()
{
if (fullshoes == true)
{
trace("OK FULL");
}
else
trace("NOT YET");
But, it's still not working. Which part am I doing wrong? and why? Thank you in advance.