AS3 click event added to stage but fires when clicking on a movieclick

妖精的绣舞 提交于 2019-12-12 05:54:57

问题


i am a as3 newbie! I added a click event to the stage but this event also fires when i'm clicking a movieclip on the stage.

How can i make this event fire only if i click directly on the stage?

Thanks for any advice!


回答1:


because of event bubbeling every click will also fire an stage click event. You can check in your function what the clicked target was by checking the currentTarget of the event.

if(e.currentTarget == stage){
     //do your stuff
}



回答2:


create layer at the bottom, add graphic that covers whole screen, convert it to symbol, add name to it and assign click event



来源:https://stackoverflow.com/questions/6062339/as3-click-event-added-to-stage-but-fires-when-clicking-on-a-movieclick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!