3 Replies Latest reply on May 7, 2007 9:57 AM by Newsgroup_User

    Changing the value of  a var

    cre8ive1974 Level 1
      I have no idea if I am even asking this right. is it possible to change the value of a var by pressing a button?

        • 1. Re: Changing the value of  a var
          Level 7
          cre8ive1974,

          > I have no idea if I am even asking this right. is it possible to
          > change the value of a var by pressing a button?

          Sure, you could change the value of a variable by pressing a button, but
          button would have to be programmed to do so. Is that what you're aiming
          for? If so, I can help, but I'll need to know what language you're using,
          ActionScript 2.0 or 3.0.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Changing the value of  a var
            cre8ive1974 Level 1
            I am using ActionScript 2.0

            I have a global variable

            when I click a button I want the varaible to change.
            then based on the change
            I want something to happen based on what that variable is.

            for example the original global var = 1
            then you hit the button and the global var = 0
            then because the global var = 0 something happens
            • 3. Re: Changing the value of  a var
              Level 7
              cre8ive1974,

              > I am using ActionScript 2.0

              Okay.

              > I have a global variable

              By that, I'm assuming you mean a property of the _global object.

              > when I click a button I want the varaible to change.
              > then based on the change
              > I want something to happen based on what that variable is.

              All right.

              > for example the original global var = 1

              Okay, let's say the variable's name is myVar. Then you might have
              something like this:

              _global.myVar = 1;

              > then you hit the button and the global var = 0

              Assuming a button instance name of myButton ...

              myButton.onRelease = function():Void {
              _global.myVar = 0;
              }

              > then because the global var = 0 something happens

              Where should this last part go? Also inside the button? If so ...

              myButton.onRelease = function():Void {
              _global.myVar = 0;
              // something else here
              }

              ... otherwise, you could use that "other thing" to check the _global.myVar
              property:

              if (_global.myVar == 0) {
              // do something
              }