如何访问可绑定Flex对象的隐式事件调度程序?

时间:2010-03-04 21:44:50

标签: flex actionscript-3 actionscript flex3

如果我像这样创建一个对象:

class Foo {
    [Bindable] public var property: String;
}

Foo有一个隐式事件调度程序来处理属性更改事件。如何在不Foo显式扩展EventDispatcher的情况下访问该内容?

1 个答案:

答案 0 :(得分:3)

如果将-keep参数添加到编译行,您将能够看到它生成的内容。但要快速解释它,您可以像处理常规EventDisaptcher一样处理它。

所以在你的主文件中你可以粘贴它:

function callFirst(event:FlexEvent):void
{
   foo.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,test);
   foo.property = 'something';
}

function test(E:Event):void
{
   trace (ObjectUtil.toString(E));
}

将打印出来:

(mx.events::PropertyChangeEvent)#0
  bubbles = false
  cancelable = false
  currentTarget = (Foo)#1
    property = "something"
  eventPhase = 2
  kind = "update"
  newValue = "something"
  oldValue = (null)
  property = "property"
  source = (Foo)#1
  target = (Foo)#1
  type = "propertyChange"