1 Reply Latest reply on Jul 27, 2009 1:22 PM by babo_ya

    ChangeWatcher alternatives ?

    jeffreypritchard Level 1

      I've recently posted a question about the usage of the ChangeWatcher to monitor a property of an object. To make a long story short, the my ChangeWatcher stopped working without my making any changes to it (a bug possibly, I don't know because the documentation is kind of brief). I was told to try and see if the PropertyChangeEvent is dispatched , but I don't know what that means. I've stepped through the setter method and I can see that the Event is created and the values are populated properly, but as to whether or not it's actually firing, I can't tell. I'm thinking it might be a bug, but I don't want to say that because I honestly don't know enough about it to be sure I am using it correctly.

       

      Is there another way to monitor a property for changes, because I've wasted too much time trying to make the ChangeWatcher work. I've seen the bindSetter methos in the bindingUtils, but I'm not sure how to implement. If anyone can steer me in the right direction I'd appreciate it.

       

      Thanks a lot for taking the time to read this.

        • 1. Re: ChangeWatcher alternatives ?
          babo_ya Level 3

          Before I explain this to you.  Well, seems to me that you have no idea how "Event" work in Flex which is very basic and required to write any type of Flex app.

           

          Anywayz,

           

          When you use "[Bindable]" as below..

           

          [Bindable]

          public var obj:MyObj;

           

           

          private function myFunction():void

          {

               obj.name = "BaBo";

          }

           

          When [Bindable] tag is used it's basically same thinge as [Bindable (event="PropertyChangedEvent")] and every property dispatches this event when value is changed.

           

          So, inside of the setter function ....

           

          var e:Event = new Event("NamePropertyChanged");

          dispatchEvent(e);

           

          //make sure your object extends from EventDispatcher...

           

          and add an listener..

           

          obj.addEventListener("NamePropertyChanged", onNameChangeHandler);

           

           

          private funciton onNameChangeHandler(event:Event):void

          {

               trace("Name changed");

          }

           

          Hope this helps,

           

          BaBo,