我在Actionscript中有一个CircleButton类。 我想知道什么时候有人在外面更改了“开”属性。 我尝试聆听'onChange',但它从未击中该事件处理程序。Actionscript组件可以监听它自己的propertyChange事件吗?
我知道我可以写“上”属性为获取/ setter方法,但我喜欢只用[绑定]
一个对象可以不听自己的事件的简单?
public class CircleButton extends UIComponent
{
[Bindable]
public var on:Boolean;
public function CircleButton()
{
this.width = 20;
this.height = 20;
graphics.beginFill(0xff6600, 1);
graphics.drawCircle(width/2, height/2, width/2);
graphics.endFill();
this.addEventListener(MouseEvent.ROLL_OVER, rollover);
this.addEventListener(MouseEvent.ROLL_OUT, rollout);
this.addEventListener('onChange', onOnChange);
}
private function onOnChange(event:PropertyChangeEvent):void {
您不需要在方法调用前使用`this`引用。 – 2010-09-22 18:43:18