Search code examples
flashactionscript-2game-physicstouchscreen

Touch screen game control and Flash Stage


I am trying to make a touch based game and struggling with the Stage in Flash. I need a cannon to fire by touching an area in the sky (I have that working), but I also need the cannon to ignore/not aim and shoot when I touch a virtual button.

It comes down to the Stage and my inability to section off my virtual button from it. I feel I need to make the virtual button into a movieclip and then address it in the actionscript via some hierarchy method like: _root.button_mc.blahblahblah, but i can't seem to find the right method.

Thanks for any help


Solution

  • The stage represent the whole visible area. If you listen to the onMouseDown event for the stage, it will be fired for any click anywhere.

    You have to draw a clip "bigArea" on the stage that cover all the area you want to make clickable and listen to the click event on this. Then you draw your button and you also put it on the stage above bigArea

    Stage
    |- yourButton
    |- bigArea
    

    If you click on yourButton, you also click on the stage but not on bigArea.