I am building a small application in Flash CS5, and I have run into a problem. I have imported a rather complex Adobe Illustrator file, created by a designer, into my application. This file is full of all kinds of images, text, and other components which I can manipulate inside of Flash.
There is one component in my application, consisting of a group containing a basic square with text on top of it, that I would like to make into a hotspot, which a user can mouse over and trigger a tooltip to display. I have converted this entire group into a MovieClip, which will trigger the tooltip to display on MOUSE_OVER. Its only choking point is when the user triggers it.
For some reason, whenever I move my pointer over different areas of the MovieClip, the MOUSE_OVER event is called several times. For example, mousing over the background fires it once, then mousing over different areas of the text will fire it several times, even though all of these components are grouped together inside of one MovieClip.
How can I cause these objects to behave as one MovieClip, so that mousing over any area of the MovieClip will only fire the MOUSE_OVER event listener once?
The problem is that MOUSE_OVER is being fired by each of the items — and that is expected, each of them will fire that event natively and the events all bubble. Look up event bubbling to find more on that.
There are a couple of ways to work around this:
useCaptureparameter which, in my experience, will fix many of these problems. Instead ofaddEventListener(name, callback)you would calladdEventListener(name, callback, true). This is also true ofremoveEventListener.