Multiple MCs, Single Listener, AsBroadcaster

I am currently working on trying to have multiple MCs inside an MC container that, when clicked on the mini MCs, will broadcast a message so that I can act on them. This would be easy in AS 3 as it would be mc.addEventListener (MouseEvent.CLICK, obj); however this is AS 2 and so I am semi-synchronous to use broadcastMessage ('myMessage'); and mc.addListener (obj); event handler.

The main problem is that the broadcaster is not broadcasting any messages.

The second problem is that there are 5 MCs and when I click one of them I get 5 click trace messages. I cannot show that MC clicks are unique, although they are all assigned separate instance names in the property bar.

Any help would be appreciated.

Link to my code here (pastie.org # 481511) . Do you see something wrong?

+1


a source to share


2 answers


I got half the answer. I missed "this" before calling broadcastMessage (), so as soon as I changed it to this.broadcastMessage ('myMessage', this) it started working.

There is still a problem with 5 different instances (i.e. dragging - and removing 5 times from the library and calling them different instance names) of one movieclip calling the same broadcast message at the same time. I am getting the following output:



Object: _level0.instance1.photo5
Object: _level0.instance1.photo4
Object: _level0.instance1.photo3
Object: _level0.instance1.photo2
Object: _level0.instance1.photo1
0


a source


Found it out. Ended up using hitTest () method to see if the click was within a specific movie clip or not.



0


a source







All Articles