1 Reply Latest reply on Apr 22, 2008 5:18 PM by robdillon

    If(commands) question!  I'm rusty.

    DumbFudge
      I don't know which Actionscript number this would be best for so I guessed.

      Anyways I used to know some basic actionscripting but haven't messed with it for a few years so I've forgotten everything.

      First question is... How do you do an If, If Not thing again?
      Example:
      this.onEnterFrame = function(){
      if(homepressed == true){
      prevFrame();
      }
      }
      There's the if kind of thing I want to do. It's for a button. Basically if the button is pressed a drop down menu pops down (another movie clip) and it makes "homepressed" true. With it being true that means the next time you click that same butt it sucks the menu back up and makes it false. With it being false you can press it again which in turn makes it true and dumps the menu out and visible again.
      Basically an expandable menu. I've seen lots of tutorials and they all tend to go way over the top with what you actually need to do. I've done this before but again, that was years ago and I've completely forgotten how (plus my old harddrive died killing all my old work).

      So again...

      Basically when you click this button (which is actually a movie clip) it turns "homepressed" to true and drops the menu down via starting up it's animation (which is another movie clip).
      I use code something like this:
      homebutton.onMouseUp = function(){
      homeanim.gotoAndPlay(2);
      homepressed = true;
      }
      Somehow turning "homepressed" to true makes the button do a different thing. It makes it so next time you click it the menu reverses (prevFrame();) and becomes hidden again plus turns "homepressed" to false to start the cycle all over again at the click of a button.


      I'm having real trouble translating this into code. I've forgotten 99% of the stuff I learned. HELP!


      EDIT: Whoa my name is "DumbFudge" here... lol doesn't seem like something I'd do.
        • 1. Re: If(commands) question!  I'm rusty.
          robdillon Most Valuable Participant
          This example may help to refresh your memory. You need to create a variable to toggle between true and false, then use the mouse event on the button to toggle that value. If the menu is not showing then let the mouse event start the clip that holds the menu playing. If the menu is showing then use the variable's value to reverse the menu movie clip until it gets back to its first frame.