1 Reply Latest reply on Sep 16, 2007 3:07 PM by theLoggerGuy

    ChangeWatcher.watch not firing

    theLoggerGuy Level 1
      Help!

      I can't seem to get my data binding change watcher to fire. I be pouring over the forum and I'm not alone. The ChangeWatcher obviously has some tricks. Anyway I have a custom DTO with a setter and getter as follows:

      package dto
      {
      import mx.collections.ArrayCollection;
      import flash.events.Event;
      import flash.display.Sprite;

      public class ChannelData extends Sprite
      {
      private var _channelList: ArrayCollection;

      [Bindable( event = "channelDataChanged" ) ]
      public function get myList( ): ArrayCollection
      {
      return _channelList;
      }

      public function commitChannelUpdates( ): void
      {
      // Create and dispatch event.
      dispatchEvent( new Event( "channelDataChanged" ) );
      }
      }


      When I create the following code I expect to see a nice Alert box, but instead I get nothing.

      <mx:Script>
      <![CDATA[
      import dto.ChannelData;

      [Bindable]
      public var channelList: ChannelData;

      public var myWatcher: ChangeWatcher;

      private function init( ): void
      {
      if ( ChangeWatcher.canWatch( channelList, "myList" ) )
      {
      ChangeWatcher.watch( this.channelList, "myList", channelDataChangedHandler );
      }
      }

      private function channelDataChangedHandler( event: Event ): void
      {
      Alert.show( "handler triggered" );
      }
      }
      ]]>
      </mx:Script>
        • 1. Re: ChangeWatcher.watch not firing
          theLoggerGuy Level 1
          Shame nobody could help me :-(, so I thought I'd post what eventually worked.

          I changed the line of code from:
          ChangeWatcher.watch( this.channelList, "myList", channelDataChangedHandler );

          to this:
          ChangeWatcher.watch( this, [ "channelList", "myList" ], channelDataChangedHandler );

          where myList is a method to return an ArrayCollection.