1 Reply Latest reply on Mar 6, 2007 5:02 PM by ntsiii

    reload a method during a variable change

    187_2007 Level 1
      I want to run a method when a variable changes.. Some sort of listener on the variable.. Something like that.. Is it possible? Any ideas?
        • 1. Re: reload a method during a variable change
          ntsiii Level 3
          One way to do this is to use a setter function. to the outside, it looks just like a variable, but is really a function in which you can do whatever you want. It has a special format:

          [Bindable]private var _sMyString:String;

          public function set myString(sValue:String):void {
          _sMyString = sValue; //normal variable stuff
          //now do whatever special processing you need to do.

          Use this property like this
          myString = "someValue";

          or:
          this.myString = "someValue";

          or
          myClass.myString = "someValue";

          You can also look into changeWatcher()
          Tracy