touch event on a display object and screen

Hi,

I want to distinguish between touch event on a display object and other areas of the screen. What I want to do is having two display objects called A and B. If I touch on A, it will be removed and B doesn’t jump. If I touch on B or other area of the screen then I’d like to make B jump. I try to use Runtime but it also detect the event when I click on A(no doubt since its global).

Hope someone can share me the code. Thanks.

Steve [import]uid: 84159 topic_id: 13908 reply_id: 313908[/import]

Rather than using runtime add an event listener to the object to run the different functions? [import]uid: 68741 topic_id: 13908 reply_id: 51125[/import]

I can add to B but how to touch anywhere on the screen to make B jump?

Steve [import]uid: 84159 topic_id: 13908 reply_id: 51128[/import]

There are several ways to do that,

  1. have three objects, A, B and a rectangle with 0.1 opacity which is nearly invisible, but will capture all events. So you can handle which object was touched. eliminating the need for runtime eventHandler

  2. have a runtime handler, but then return true to indicate that you have handled the touches somewhere.

I guess this should get you going,

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 13908 reply_id: 51194[/import]

That works. Thank you.

Steve [import]uid: 84159 topic_id: 13908 reply_id: 51258[/import]