Skip to main content
Participating Frequently
December 22, 2020
Answered

I'm a beginner and have difficulties with if and else on button

  • December 22, 2020
  • 5 replies
  • 475 views

Hello I'm starting to work with Animate and I'm having problems using the if and else conditions. I have a button that clicks it to check the status of my movieclips depending on the situation the action takes

 

_this.bt_Verifica.on('click', function () {

 

if (_this.mcUm.currentFrame == 1 && _this.mcDois.currentFrame == 1 && _this.mcCinco.currentFrame == 1 && _this.mcSete.currentFrame == 1) {
_this.gotAndStop(11);

} else {
_this.gotAndStop(12);
});

 

I'm learning now to mess with it, sorry if I'm asking a very stupid question;

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer JoãoCésar17023019

I think I'm getting the idea.

 

Your if statement should work if these four buttons are selected but it will also work if five or more are selected.

 

Also, now that I realized that there's a typo in your code.

 

It should be

_this.gotoAndStop

 

and not 

_this.gotAndStop

 

Please let us know.

 

Regards,

JC

5 replies

JoãoCésar17023019
Community Expert
Community Expert
December 22, 2020

Hi.

 

When you check if the current frame is 1, are you trying to find out if it is the first frame?

 

Because if so, keep in mind that in HTML5 Canvas documents the first frame is 0.

 

Can you check this out?

 

Regards,
JC

Participating Frequently
December 22, 2020

there are seven buttons that enable movieclips and then I have a button that checks if the person clicked on the correct ones. For example: the correct order is 1, 2, 5 and 7. If the person clicks on these and activates the play of the movieclip this is correct. And go to screen X, if you didn't click on those to screen Y.

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
December 22, 2020

I think I'm getting the idea.

 

Your if statement should work if these four buttons are selected but it will also work if five or more are selected.

 

Also, now that I realized that there's a typo in your code.

 

It should be

_this.gotoAndStop

 

and not 

_this.gotAndStop

 

Please let us know.

 

Regards,

JC