监听对 flex Date 对象所做的更改
我有一个日期对象,我想听听对其所做的任何更改。 进行更改,
var newDate:Date = new Date(2009,10,9);
date = newDate;
可以通过直接分配另一个日期对象并使用
date.setTime(timeInMilliSeconds)
我尝试使用 BindingUtils.bindsetter: 来
var myWatcher:ChangeWatcher = BindingUtils.bindSetter(updateDate,date,"time");
private function updateDate(value:Number):void
{
trace(value);
}
但这似乎不起作用。我想知道我做错了什么或者是否有其他方法可以做到这一点。
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须先使变量可绑定,然后才能观看它(或者您需要自己为其分派更改事件)。
You have to make a variable bindable before you can watch it (or you need to dispatch the change events for it yourself).
您可以使用
PropertyChange
/PropertyChangeEvent
机制。上面的代码摘自 blog.flexexamples.com。
You could use the
PropertyChange
/PropertyChangeEvent
mechanism.The code above is an excerpt from an example found at blog.flexexamples.com.