e.eventPhase == EventPhase.AT_TARGET 를 통하여 구분 처리 해준다.
그러면 _titleBar._btn1을 클릭하였을 경우 btnClick만 호출된다.
만약 위 구문을 빼고 코딩을 하였을 경우에는 _titleBar._btn1 을 클릭하였을 경우 titleDown -> titleUp - > btnClick 순서대로 함수가 호출된다._titleBar.addEventListener(MouseEvent.MOUSE_UP, titleUp);
function titleUp(e:Event):void{
if (e.eventPhase == EventPhase.AT_TARGET) {
// event came from object
// addEventListener was used with and
// is not result of propagation
trace("titleUp");
}
}
_titleBar.addEventListener(MouseEvent.MOUSE_DOWN, titleDown);
function titleDown(e:Event):void{
if (e.eventPhase == EventPhase.AT_TARGET) {
// event came from object
// addEventListener was used with and
// is not result of propagation
trace("titleDown");
}
}
_titleBar._btn1.addEventListener(MouseEvent.CLICK, btnClick);
function btnClick(e:Event):void{
if (e.eventPhase == EventPhase.AT_TARGET) {
// event came from object
// addEventListener was used with and
// is not result of propagation
trace("btnClick");
}
}
참조 : http://www.senocular.com/flash/tutorials/as3withflashcs3/?page=3