是有關於事件的方法,你可以使用。因此,儘管事件仍然發出,但這會讓您完全控制發生的事情。
// first set the useCapture flag to true
// this tell flex that onChange gets the event before it starts bubbling
myCustomComponentThatDispatchesALotOfChangeEvents.addEventListener(Event.CHANGE, onChange, true);
private function onChange(event:Event):void{
// here is the method you want
// this stops the event from bubbling and lets you handle
// all functionality in this listener only
event.stopImmediatePropogation();
// now look at what happened and see if you want to
// do anything else based on what actually changed
}
作爲一個側面說明,你也可以看看Event.preventDefault(),它取消的事件默認行爲
「變」也是柔性的事情。它只想在一個特定的場景中分派事件,創建一個類似MyChangeEvent的SubClasses事件的新事件類。該當你讓你變...
dispatchEvent(new MyChangeEvent(MyChangeEvent.STUFF_CHANGED))
然後
myCustomComponentThatDispatchesALotOfChangeEvents.addEventListener(MyChangeEvent.STUFF_CHANGED, onChange);
感謝您的回答傑森。如果我有任何問題,我會試一試並回復你。看起來很有希望。 – GuyOxford