You can call either the event's stopPropagation() method or the stopImmediatePropagation() method to prevent an Event object from continuing on its way through the event flow.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init(event)">
<mx:Script>
<![CDATA[
import flash.events.MouseEvent;
import flash.events.Event;
public function init(e:Event){
myBtn_1.addEventListener(MouseEvent.CLICK,clickBtn_1);
myBtn_1.addEventListener(MouseEvent.CLICK,clickBtn_2);
myBtn_1.addEventListener(MouseEvent.CLICK,clickBtn_3);
myPanel.addEventListener(MouseEvent.CLICK, clickPanel);
}
private function clickBtn_1(evt:Event):void{
myText.text += "/n/nButton 1 clicked !";
}
private function clickBtn_2(evt:Event):void{
myText.text += "/n/nButton 2 clicked !";
}
private function clickBtn_3(evt:Event):void{
myText.text += "/n/nButton 3 clicked !";
}
public function clickPanel(e:Event) {
myText.text += "/n Panel clicked !";
}
]]>
</mx:Script>
<mx:Panel x="37" y="51" width="250" height="200" layout="absolute" id="myPanel">
<mx:Text x="126" y="212" text="Text" width="100" id="myText"/>
</mx:Panel>
<mx:Button x="126" y="116" label="Button" id="myBtn_1"/>
</mx:Application>
output:
Button 1 clicked !
Button 2 clicked !
Button 3 clicked !
Panel clicked !
add evt.stopPropagation();on clickBtn_2
output:
Button 1 clicked !
Button 2 clicked !
Button 3 clicked !