Reputation: 46
I have a date object and I want to listen to any changes made to it. The changes can be made by either directly assigning another date object
var newDate:Date = new Date(2009,10,9);
date = newDate;
and by using
date.setTime(timeInMilliSeconds)
I tried using BindingUtils.bindsetter:
var myWatcher:ChangeWatcher = BindingUtils.bindSetter(updateDate,date,"time");
private function updateDate(value:Number):void
{
trace(value);
}
but this doesn't seem to work. I wish to know what am I doing wrong or if there is someother way to do this.
Thanks!
Upvotes: 1
Views: 168
Reputation: 1995
You could use the PropertyChange
/ PropertyChangeEvent
mechanism.
objectProxy = new ObjectProxy(newDate);
objectProxy.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, propertyChangeHandler);
private function propertyChangeHandler(evt:PropertyChangeEvent):void {
// Do what you want
}
The code above is an excerpt from an example found at blog.flexexamples.com.
Upvotes: 0
Reputation: 6961
You have to make a variable bindable before you can watch it (or you need to dispatch the change events for it yourself).
Upvotes: 2