AS3 flash on

I have a script that once clicked (button), some other thing hid, and then clicked it again. the problem was once hidden, it never shows up again, here is the script:

menu_start.addEventListener(MouseEvent.CLICK, myClickFunction);


function myClickFunction(event:MouseEvent) {

      // Hide the first and show the next here
      if (menu_menu.visible == true){
      menu_menu.visible = false;

      } 
      if (menu_menu.visible == false) {
          menu_menu.visible == true;
      }

}

Many thanks.

+3
source share
5 answers

The reason is when you click on, it hides, but again, when you click on the same button as not showing back

Correct me if I am mistaken in the statement above.

Now try something on what I'm saying, I have two Hide and Show buttons. Create two new functions and try, if it works, there is something in your logic that you are missing, if it does not work, let us know.

.

function myClickFunction(event:MouseEvent) {

      // Hide the first and show the next here
      if (menu_menu.visible){
      menu_menu.visible = false;

      } else {
         menu_menu.visible = true;
      }

}

, , , , menu_menu . - ?

+5

​​ :

menu_menu.visible = !menu_menu.visible;
+10

"if" .visible true, , true - .

function myClickFunction(event:MouseEvent) {

  // Hide the first and show the next here
  if (menu_menu.visible == true){
  menu_menu.visible = false;

  } 
  if (menu_menu.visible == false) {
      menu_menu.visible = true;
  }

}

+3

, , , .

Buttonname.addEventListener (MouseEvent.CLICK, FunctionName);
function FunctionName(event:MouseEvent) {

  if (name1.alpha == 1){
  name1.alpha = 0;} else {name1.alpha = 1}
}

script: name1 ( Movie Clip) Alpha, 1 , Alpha 0, Alpha 1.

"" :

Buttonname.addEventListener (MouseEvent.CLICK, FunctionName);
function FunctionName(event:MouseEvent) {

  if (name1.visible == true){
  name1.visible = false;} else {name1.visible = true}
}
+1

alpha = 0,1 visible = false alpha = 1 visible = true.

The problem is that when using visible = false, it also disables mouse interaction, so your second click never works.

0
source

Source: https://habr.com/ru/post/1773404/


All Articles