views:

77

answers:

1

I am trying to capture mouse events in flash while the mouse is being held down. The intention is to keep reciving events as long as the mouse is pressed, even if the cursor leaves the flash element. That's the behavior I get on all browsers other than IE, which only fires events while the cursor is inside the stage.

I'm pretty sure I've seen such "well behaved" flash applets work in IE before. How do I fix that?

+1  A: 

In all technicality, you aren't leaving the stage when still dragging (mouse down) if you started the event inside the flash applet. The second you click outside the applet, the applet will lose focus. In most cases, the applet will lose focus as soon as you mouse out of the visible applet.

I believe it's an unintended effect and not meant for normal use to be able to continue to use focus outside of the applet, otherwise Flash objects could theoretically high-jack your browser via a mapping over an entire web page.

Not that this POSSIBLY couldn't be done, but maybe a description of the problem you are trying to solve will lead to better methodology suggestions.

EDIT: After doing some digging, I came up with this as the closest thing to your situation, http://stackoverflow.com/questions/82509/is-it-possible-to-drag-and-drop-from-to-outside-a-flash-applet-with-javascript

EDIT2: More digging came up with this answer: http://stackoverflow.com/questions/1563434/detect-mouse-leave-stage-while-dragging-in-actionscript-3 If that is more of the same (not working in IE) I'm back to suggesting javascript for true cross compatibility solving issues. You could also ask the people who made the demo you displayed if this is not sufficient.

Organiccat
I think you misunderstood me. In my situation the applet has the focus, the mouse is pressed inside the applet, and then dragged outside while still being pressed. What'd you'd normally expect in this situation is for the applet to "capture" further mouse events until it's released. I get this behavior "for free" in any browser but IE. Sorry if I wasn't clear enough.
uj2
The functionality is unintended, therefore unreliable, despite being somewhat "usable/free" in some browsers. The best solution is probably to use javascript to track movements and mouseclicks and pass them back to the flash element. I posted a link to another question that sounds very similar to what you are trying to do.
Organiccat
I really don't think this is unintended behavior. It's actually a very "standard" UI behavior. I found some applet that makes use of this, and works in IE. While dragging the mouse it captures it's movement outside the flash element, and outside the browser. It doesn't seem to involve any special JS. Here's the link: http://www.infiniteturtles.co.uk/projects/away3d/demos/hacienda/BSPImportTest.html
uj2
At a glance it appears that page is using an ActiveX object to do what you are asking, here is the link to the code (you can also find it be viewing the source on the page) http://www.infiniteturtles.co.uk/projects/away3d/demos/hacienda/AC_OETags.js. That's the reason it works in IE. Regardless, apparently you can do it using the javascript demo posted in the other question. If you don't want to use JS, you'll have to use ActiveX or some other external controller. Flash does not have direct control over any elements outside it's container as far as I know.
Organiccat
The only ActiveX object it uses AFAIC is the flash player.
uj2