是有关于事件的方法,你可以使用。因此,尽管事件仍然发出,但这会让您完全控制发生的事情。
// 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