I have created an expandable banner ad in Flash. Everything is great except one thing. How can I detect when the user is no longer hovering over the flash ad? I have tried to ad a “hit area” which can be used to detect MOUSE_OUT. The issue is, there is a video playing, as well as social media buttons which need to be clickable. If I place a hit area over these, they are no longer clickable. If I place the hit area behind the buttons, the MOUSE_OUT event triggers when you hover over the button.
What is the best practice for a scenario such as this? I have also tried detecting MOUSE_LEAVE on the stage object, but this doesn’t seem to function correctly once deployed on an HTML page. Thanks for the assistance.
You can try adding an
ENTER_FRAMEevent that constantly checksstage.mouseXandstage.mouseY. These values should report correctly while the mouse is on the Flash content, and will report the last known mouse coordinates when the mouse is no longer on the stage. However, the last known mouse coordinates may not always be the actual width or height of the stage, so you probably want to add some tolerance in there.For instance, if your (expanded) Flash content width is 500px, in the
ENTER_FRAMEevent you can check ifstage.mouseXis less than 10px (mouse moving off to the left) or more than 490px (mouse is moving off to the right) and minimize the Flash content. Repeat for the height, and adjust tolerance values as needed.This should give you the effect you want. The only downside that I can see is the overhead of the
ENTER_FRAMEevent just to check whether the mouse has left the content, but I don’t see any way around that.