Actionscript에 CircleButton 클래스가 있습니다. 누군가가 외부에서 'on'속성을 변경했을 때를 알고 싶습니다. 'onChange'를 듣고 있지만 그 이벤트 핸들러를 절대 안타 봅니다.Actionscript 구성 요소가 자체의 propertyChange 이벤트를 수신 할 수 있습니까?
은 내가이 (가) GET/세터 재산 '에'쓸 수 있습니다 알고 있지만 난 그냥 객체가 자신의 이벤트를 수신 할 수 없습니다 [바인딩]
를 사용의 단순함을 좋아한다?
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' 참조가 필요 없습니다. –
당신은 그렇지 않지만, 청취자를 추가하는 사람을 명확히하기 위해 추가되었습니다. – Laura