开发者

How to detect when mouse is over HTML layer over Flash movie?

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 trigge开发者_如何学运维red 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>


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.


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

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

to your embed code?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜