사용자 삽입 이미지








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

'기타 > Old' 카테고리의 다른 글

私(わたし)の 日常(にちじょう)  (0) 2008.05.21
2008年 5月 19日 月曜日  (0) 2008.05.20
두수 사이에서 랜덤수 만들어내기  (0) 2008.05.16
2008年 5月 16日 金曜日  (0) 2008.05.16
2008-05-15 火曜日  (0) 2008.05.15
이벤트를 등록한 다음 trace를 걸어보면 bubbles 라는 항목을 볼 수 있다.

[함수]
function addedHandler(event:Event):void {
 trace("addedHandler: " + event);
}

[결과]
addedHandler: [Event type="added" bubbles=true cancelable=false eventPhase=3]

bubbles : Boolean
[read-only] Indicates whether an event is a bubbling event. 버블링 이벤트인지 여부를 나타냄.

여기서 말하는 bubbles란 간단하게 말해서 연쇄 이벤트 발생을 뜻함.
해당 이벤트가 등록됨에 따라 연쇄적으로 다른 이벤트가 발생하는지의 여부를 알려준다.

+ Recent posts