R – Activating a button underneath the mouse: how do you capture the OVER event

actionscript-3flash

Observed behavior:

  1. I have a page of UI sliding onto the screen.
  2. On slide complete, activate buttons.
  3. If mouse already over a button, the rollover does not happen (since MOUSE_OVER hasn't technically occurred)

Desired behavior: 1, 2 the same, but on 3, I see my rollover.

Is there any way to easily do this, aside from something brute-force, like tracking the mouse and comparing its position against all buttons dims?

Thanks!

Best Answer

You can dispatch a mouseMove event to your top most container with x and y coordinates of the current mouse position. This will emulate the effect of the user having moved his mouse.

private function moveComplete():void
{
    topLevelContainer.dispatchEvent(new MouseEvent(MouseEvent.MOUSEMOUSE, true, false, topLevelContainer.mouseX, topLevelContainer.mouseY);
}
Related Topic