Stop event propagation
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical" creationComplete="initFunc()">
<mx:Script>
import mx.controls.Alert;
public function initFunc():void
{
myButton.addEventListener("click",respondToEvent,false,100);
myParentHBox.addEventListener("click",parentEventResponse, false,0);
}
public function respondToEvent(e:Event):void{
var msg:String = "hi";
Alert.show(msg,"First Event Listener");
e.stopPropagation();
}
public function respondToEventClick(e:Event):void
{
Alert.show("fire second ","Second Event Listener");
}
public function parentEventResponse(e:Event):void
{
Alert.show("You should never see this alert","Parent Event Response");
}
</mx:Script>
<mx:HBox id="myParentHBox">
<mx:Button id="myButton" label="Fire off Event" click="respondToEventClick(event)" />
</mx:HBox>
</mx:Application>
Related examples in the same category