• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Dec 22, 2020 Dec 22, 2020

Copy link to clipboard

Copied

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;

TOPICS
ActionScript , Code

Views

294

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 22, 2020 Dec 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

Votes

Translate

Translate
Community Expert ,
Dec 22, 2020 Dec 22, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 22, 2020 Dec 22, 2020

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 22, 2020 Dec 22, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 22, 2020 Dec 22, 2020

Copy link to clipboard

Copied

Oops it worked, there was a letter missing in the code, thank you very much João César!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 22, 2020 Dec 22, 2020

Copy link to clipboard

Copied

LATEST

You're welcome!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines