AS3 click event added to stage but fires when clic

2019-08-26 12:15发布

问题:

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