2
votes

Is there any workaround to the issue with Adobe Flash where a Flash Movie does not receive a mouse up event if the mouse is dragged outside of the movie?

EDIT: This issue seems to affect Firefox only

See: http://bugs.adobe.com/jira/browse/FP-234

Basically the issue is, I have a Flash movie which contains a text box, and if the user clicks in the text box and drags to select (highlight) text, and they drag outside the flash movie and release the mouse, then the FLash move doesn't receive the mouse release event and even though the mouse is up, moving the cursor around the page continues to change the selected text within the flash.

Many have suggested using ActinScript to listen for a MOUSE_LEAVE event but there's two issues. One, I am using AS2 not AS3, and second, it seems like MOUSE_LEAVE doesn't fire if the mouse is held down when it leaves the stage.

EDIT 2: George Profenza's "dirty hack" had been mostly working for me for months... but as of 8/24/10, I now see that Adobe has marked this issue as resolved, finally!

1

1 Answers

2
votes

I can imagine what the problem is, but I can't seem to reproduce in a simple context.

Here is a 'dirty hack'...as2 style , based on the MOUSE_LEAVE thing.

input.onKillFocus = function(newFocus:Object) {
    trace(this._name+" lost focus. New focus changed to: "+newFocus._name);
    delete input._parent.onEnterFrame;
};
input.onSetFocus = function(oldFocus:Object) {
    trace(this._name+" gained focus. Old focus changed from: "+oldFocus._name);
    input._parent.onEnterFrame = trackMouse;
}

function trackMouse():Void{
    if(input._xmouse < 0 || input._xmouse > (input._x + input._width)) onMouseOut();
    if(input._ymouse < 0 || input._ymouse > (input._y + input._height)) onMouseOut();
}

function onMouseOut():Void{
    Selection.setFocus(dummyBtn);
}

Assuming input is a selectable textfield. If the textfield is focused I add an enterFrame listener to check if the mouse is over or outside the textield ( using input._xmouse, opposed to _xmouse which is global ). If the mouse is outside the text area, I change the focus to a dummy object( a Button called dummyBtn ). This works if you're in Firefox and you have a selection and release outside the swf, because as soon as you leave the textfield the focus shifts to the dummyBtn.

I admit it is a bit rough, if you still need the selection or something, so let me know.

Goodluck.