2 Replies Latest reply on Jul 30, 2009 2:49 PM by Ned Murphy

    if else statement not working

    rainestorm

      I'm sure I have the conditions and statements typed in wrong. Here is the original code:

       

      stop();

       

      var my_timedReveal:Number = setTimeout(my_delayedReveal,15000,1);

      function my_delayedReveal(arg1) {
          gotoAndPlay("reveal2");
      }

       

      cardA.Mouse.addListener(mouseDown);
      cardB.Mouse.addListener(mouseDown);
      cardC.Mouse.addListener(mouseDown);

       

      cardA.onRelease = function() {
          gotoAndPlay("reveal1");
      }

      cardB.onRelease = function() {
          gotoAndPlay("reveal2");
      }

      cardC.onRelease = function() {
          gotoAndPlay("reveal3");
      }

       

      only now I want to add an if/else statement so that if none of the mouseDown conditions are met, it then goes the the Timeout variable:

       

      I tried this to no avail:

       

      var my_timedReveal:Number = setTimeout(my_delayedReveal,15000,1);

      if (cardA.mouseDown = true) {
          gotoAndStop("reveal2")
      }

      else {
          my_delayedReveal = true;
      }

       

      What am I missing? Am I even close?

        • 1. Re: if else statement not working
          Ned Murphy Adobe Community Professional & MVP

          I haven't tried to reason out your code, but when you are comparing things for equality you use ==, not =

           

          if (cardA.mouseDown == true) {

           

          And in the case of a boolean comparison like that you could just use...

           

          if (cardA.mouseDown) {

           

          So see if whatever you are trying or might have tried works when using the comparison correctly.

          • 2. Re: if else statement not working
            rainestorm Level 1

            Thanks, Ned. I actually originally tired it without the =true statement.

             

            What I'm trying do is this: A user has the option to click on an object and that object flips over. If they fail to click an object, that object flips over after 15 seconds. But the setTimeout variable can ONLY come into play if the the user does not click an object. Otherwise, what's happens is the user clicks the object, the object flips over, and 15 seconds later it flips over again.