Flex 2.1 ChangeWatcher working only once

I have been working with flex 2.1 for a while now and have recently used the ChangeWatcher for finding out when the value of the variable changes.

The handler is getting invoked once when the value is getting changed. But for subsequent changes, I believe the handler is not being called.

My code is something as follows:

Could someone please advice as to what could be going wrong?

File:Caller.mxml(it is a popup screen)

//in mx:Script

private var watch:ChangeWatcher = ChangeWatcher.watch(a,"numberOfItems",updateScreen);

private function updateScreen(event:Event):void{

Open in new window

File: A.as

[Bindable] public var numberOfItems:int;

Open in new window

Who is Participating?
dgofmanConnect With a Mentor Commented:
Workd for me, only exception when you may not get fire event is assigning value is the same as exisitng numberOfItems, in this cse you should create a setter and dispatchEvent manually or temporary assign to -1 or some other number


<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
				xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%" initialize="init()" xmlns:projectWork="*">
			import mx.binding.utils.ChangeWatcher;
			import mx.controls.Alert;

			private var a:A = new A();
			private var watch:ChangeWatcher = ChangeWatcher.watch(a,"numberOfItems", updateScreen);
			private function updateScreen(event:Event):void{
	<s:Button label="Increment" click="a.numberOfItems++"/>

Open in new window


	public class A
		public var numberOfItems:int = 0; 

Open in new window

All Courses

From novice to tech pro — start learning today.