AS3 click事件添加到阶段,但在movieclick当点击火灾但在、火灾、阶段、事件

2023-09-08 15:22:05 作者:寂寞快走开

我是一个AS3新手!我添加了一个click事件的阶段,但这一事件也触发,当我点击舞台上的影片剪辑。

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?

感谢您的任何意见!

推荐答案

。您可以检查你的函数是什么点击的目标是通过检查事件的currentTarget。

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
}