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

help with else if

Contributor ,
Aug 01, 2016 Aug 01, 2016

I have 4 clips with corresponding buttons. Selecting btn1 highlights the mc1 (frame 2) and pops up a check answer. Selecting btn2 leaves the check answer button up. clicking mc2 again un-highlights (frame 1) it but needs to leave check answer button up. clicking btn1 again deselects mc1 (frame 1) and now nothing is highlighted, so the check answer needs to go away. Trying to figure out how to add the last if statement into the else code right above it.

Hope this makes a little bit of sense...

correct_btn1.addEventListener(MouseEvent.MOUSE_DOWN, check181);

function check181(event: MouseEvent): void {


if (correct18a < 1) {
  check_btn.visible = true;
  reset_btn.visible = false;
  correct18a = 1;
  checka = 1;
  trace("check 1");
  correct_mc1.nextFrame();
} else{
  correct_mc1.prevFrame();
  trace("check 0");
  check_btn.visible = false;
  reset_btn.visible = false;
  correct18a = 0;
} /*if (checka == 0 && checkb && checkc == 0){
  check_btn.visible = false;
  reset_btn.visible = false;
}*/
}

TOPICS
ActionScript
397
Translate
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
LEGEND ,
Aug 01, 2016 Aug 01, 2016

You have 4 multi-frame movieClips, correct_mc1 through correct_mc4, and four buttons, btn1 through btn4, is that correct?

Btn1 is for correct_mc1, and btn2 is for correct_mc2, etc. is that correct?

Is this a toggle sort of thing where the buttons are possible answer selections and the movieClips are a telltale to show which button was hit?

What is reset button? Is that one button that is supposed reset everything or are there 4 reset buttons also?

Can you explain in more detail or show a visual of what you are attempting?

Translate
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
Contributor ,
Aug 01, 2016 Aug 01, 2016

There are 3 correct answers and one wrong. The check button checks to see if all three are currently selected and wrong is not.They need to be able to deselect any of the buttons. Reset sets all vars to 0. I need the check button to stay on if any of the clips are highlighted. Actually the code above is incorrect. IT should be:

correct_btn1.addEventListener(MouseEvent.MOUSE_DOWN, check181);

function check181(event: MouseEvent): void {

//not selected

if (checka < 1) {

  check_btn.visible = true;

  reset_btn.visible = false;

  checka = 1;

//selects

  correct_mc1.nextFrame();

} else{

//deselects

  correct_mc1.prevFrame();

// this is what I don't want to happen until none are highlighted:

  check_btn.visible = false;

  reset_btn.visible = false;

  checka= 0;

} /*if (checka == 0 && checkb && checkc == 0){

  check_btn.visible = false;

  reset_btn.visible = false;

}*/

}

Translate
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
LEGEND ,
Aug 01, 2016 Aug 01, 2016

Is the check button the same thing as the correct button?

You have four possible answers for a question. Three of the answers are correct. The user has to select all three correct answers and not select the wrong answer. Does the user click on the answer or is there a separate button to select the answer. In any case is that a correct button? And the check button is a separate button that the user can use to test their selections?

I don't understand how many buttons there are and what the user does. Please clarify.

Translate
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
Contributor ,
Aug 02, 2016 Aug 02, 2016

The check button is a separate entity. I was trying to make an if, else, and if. Anyway, instead of trying to incorporate it into the mouse down, I put the necessary code into a MOUSE_UP. Problem solved. Thanks for giving it a shot tho...

Translate
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
LEGEND ,
Aug 02, 2016 Aug 02, 2016
LATEST

Glad you got it sorted out.

Translate
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