3 Replies Latest reply on May 4, 2009 12:56 PM by kglad

    Toggle a boolean

    brian914 Level 1

      I would like to toggle my boolean value when I click my button.

      My boolean var looks like this:

      var playAllOn:Boolean = false;

       

      Then I have a button that calls a function to set the playAllOn to the boolean value it currently is not.

       

      So, if for example if playAllOn is false, I would like to call:

      setPlayAllBtn(true);

      and vice versa.

       

      My button code:

      myToggleBtn.onRelease = function():Void {

       

           setPlayAllBtn(//boolean value);

      }

       

      I know I could do this with an ifStatement in the myToggleBtn.onRelease, but am wondering if there is a better more efficient way to write this. Something like setPlayAllBtn(!= playAllOn); <!-- Obviously that one does not work...

       

      Thanks a lot for any help with this!