views:

310

answers:

2

I have a Flash movie that is embedded in an HTML page that has a DIV in a layer over the top of the movie. The Flash movie scrolls based on the mouse position over the movie. The client wants the scrolling to stop when the mouse is over the DIV. I've tried using the mouseLeave event, but that is not triggered by the DIV.

Is there a way that the Flash movie can detect when the mouse is over the DIV?

The Flash movie was developed using Flash CS4 and AS3.

Here's the DIV tag:

<div style="position:absolute;top:0;left:0;width:1024;background:#fff;font-size:24px;z-order:2">
some text
</div>
A: 

Flash movies (in general) always have the highest z-index. Have you tried adding:

<param name="wmode" value="transparent"> 

to your embed code?

jodeci
Slight pedantry - embedded Flash movies don't use the highest z-index, they render directly to screen, bypassing the browser. Setting `wmode` to `transparent` or `opaque` makes them render within the browser context, making them amenable to stacking and overlays
K Prime
+1  A: 

The MOUSE_LEAVE event doesn't work because even though the mouse is over the div, it's still within the bounding area of the SWF. You'd have to use ExternalInterface in Flash to register a function that will be available to javascript, then you call that when the mouse hovers over the div. The Flash function turns off the scrolling.

In Flash:

import flash.external.ExternalInterface;
function stopScrolling() {
    // stop scrolling
}
ExternalInterface.addCallback('stopFlashScrolling', stopScrolling);

In Javascript:

document.getElementById('theDiv').onmouseover = function(e) {
    MySWF.stopFlashScrolling();
}

MySWF is the id of your SWF.

wmid