开发者

Flash Player on Firefox Mac does not give correct mouse position when outside frame

I'd been having problems with the mouse position in Firefox in my flash games, so I devised this little program to check things out.

package
{    
    import flash.display.Sprite;
    import flash.events.Event;

    [SWF(width="750", height="520", frameRate="40", backgroundColor="#000000")]

    public class HelloWorld extends Sprite
    {
        private var _mouseX:Number;
        private var _mouseY:Number;

        public function HelloWorld()
        {
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }

        public function onEnterFrame(event:Event):void
        {
            if ((mouseX != _mouseX) || (mouseY != _mouseY))
            {
                _mo开发者_StackOverflow社区useX = mouseX;
                _mouseY = mouseY;
                trace(_mouseX, _mouseY);
            }
        }
    }
}

I placed the swf in a web page, center top.

When the mouse goes outside the flash frame, the mouse is no longer updated. So every frame works with the last position.

In Chrome and Safari, the last position is the position where the mouse exited the frame. Actually, it's probably an interpolation based on the previous speed of the mouse, since I can have negative coordinates if I exit through the left or top edge.

In Firefox, the mouse position defaults to (5, 5). For some strange reason.

Is there a way around this? This probably depends on the browser implementation (since they are using the same plugin).

How does it behave in Windows browsers?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜