2

I'm encountering something a bit bizarre, but maybe someone else came across this before.

I've got a base class, that doesn't extend anything. Let's call it...

public class FooBar {
    //...
}

But I want to bind EVERY single one of its exposed properties:

[Bindable] public class FooBar {
    public var propertyOne:String;
    public var propertyTwo:String;
}

While Debugging / Profiling the class, I'm noticing that each time a property is changed - the instance of FooBar is calling ".dispatchEvent()" on it. But my class doesn't extend EventDispatcher.

What gives?

Does this mean, at compile time, my class automatically extends EventDispatcher or some other class with the ability to dispatch events? How could I listen to the PropertyChangeEvent if my class doesn't have the "addEventListener" method declared in it?

4

1 回答 1

3

当您使用[Bindable]元数据时,Flex 编译器会为您生成大量代码。如果您想知道究竟发生了什么,请查看Flex [Bindable] 标签的作用的答案?以及在那里发布的链接。

回答您的问题:不,您的课程没有扩展EventDispatcher. 但是,编译器会更改您的类,以便它实现IEventDispatcher接口。该接口的生成实现使用EventDispatcher.

于 2011-09-29T19:14:46.753 回答