views:

234

answers:

3

I have a clip that catches the click event using on(release) { .... }

In this clip, I have a button that also catches clicks with on(release) {...}

The problem is that the button never receives the release event. I believe that the event is not bubbled, being caught and handled by the parent container. How can I bubble it to the button (I need both events to trigger, as one does an animation and the other opens a page).

A: 

Try adding event listeners to both the clip and the button.

Rick J
+2  A: 

The fact that you are using the on(release) syntax says to me you're using a really old coding style, plus you are coding for as2. If this is wrong sorry. If that is correct i seriously suggest that if you can (some clients still require flash 8 compatible swfs for some reason), you should try and come up with a solution in AS3 rather than the older AS2. In my opinion it's a bit of a waste of time learning as2 when as2 is well on it's way out. I do appreciate that you need to use the older methods sometimes though.

So that's neither here nor there in terms of the question. In essence, once you put an interactive element inside another interactive element you won't be able to handle events that occur on the inner element. Basically the mouse event gets handled at the first component that has events registered with it, that is also directly underneath it. Then the click action stops looking for more items. It stops you from receiving multiple events from one click.

One way i think to solve this (although buttons inside buttons is a really bad usability decision) would be to have a non interactive container n.b. for as2 a MovieClip, and then add two buttons inside that, one larger than the other with the smaller one on top. That would mean that you can handle clicks to both of the elements separately.

Hope this helps

James Hay
A: 

your code is obviously AS2, since AS3 does not support this syntax anymore ...

event bubbling only works in AS3 ... in AS2, if a movieclip/button has a registered handler/callback for any mouse event, then no children will ever receive any events ...

i once wrote a library for AS2, that solve's the problem ... if you really need to stick to AS2, then i can look for it ... but as james stated, you really should not ...

back2dos