Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-18-2008, 11:03 AM   #1
Dr.Mabuse
BoyWonder
 
Join Date: Sep 2007
Posts: 143
Default Event.MOUSE_LEAVE doesn't trigger when mouse button pressed

Hi there,
I've come across a rather strange problem with the Event.MOUSE_LEAVE event. It does not trigger if you leave the stage with your mousebutton pressed. Is there a reason for this? I find it kind of bizarre because leaving the stage while pressing the mousebutton is typically when you need this event.

Just pop this into CS3 and test yourself :

ActionScript Code:
stage.addEventListener( Event.MOUSE_LEAVE, test ); function test(evt:Event):void     {     trace( "left stage" );     }
Anyone got a workaround?
__________________
-Signing off from the Road to Ruin-

TM

Last edited by Dr.Mabuse; 05-18-2008 at 11:29 AM.
Dr.Mabuse is offline   Reply With Quote
Old 05-18-2008, 06:03 PM   #2
Mazoonist
Site Contributor
 
Mazoonist's Avatar
 
Join Date: Jun 2006
Posts: 3,160
Send a message via AIM to Mazoonist
Default

Apparently it's not possible. But in searching, I found a website I didn't know existed, a flash wiki! See this page: http://www.flashwiki.net/index.php?title=Events and scroll down a bit to the MOUSE_LEAVE section.
__________________
My Tutorials * My Website
Mazoonist is offline   Reply With Quote
Old 05-18-2008, 06:52 PM   #3
Dr.Mabuse
BoyWonder
 
Join Date: Sep 2007
Posts: 143
Default

Thanks for the link Mazoonist, I was afraid that was the case.
Would I be wrong in calling this a bug? Or at least poor design?

Anybody have a workaround for this then? I can't be the first person in the world wanting to know when the mouse leaves my stage, with the left mouse button pressed?

Thanks!
__________________
-Signing off from the Road to Ruin-

TM

Last edited by Dr.Mabuse; 05-18-2008 at 06:54 PM.
Dr.Mabuse is offline   Reply With Quote
Old 02-05-2009, 05:47 AM   #4
thearc
Senior Member
 
thearc's Avatar
 
Join Date: Sep 2006
Posts: 147
Default

did anyone ever solve this mystery?

Also to dive even further into this, the MOUSE_LEAVE event also fails if you click outside of the stage.
thearc is offline   Reply With Quote
Old 02-18-2010, 08:47 PM   #5
mudabbas
Registered User
 
Join Date: Sep 2009
Posts: 3
Default

I was able to track it using javascript. I created a flashobj.onmouseout = function() { flashobj.mouseLeave(); }
And inside flash, I created ExternalInterface.addCallback. To make same effect as an even which can be handled by multiple objects at the same time, I just dispatched a custom event on stage.

Anyways, if your container application isn't your browser, you would have to work a bit more to find out when the mouse leaves the flash object.
mudabbas is offline   Reply With Quote
Old 02-19-2010, 01:41 AM   #6
tadster
tadster
 
tadster's Avatar
 
Join Date: Feb 2009
Location: Texas
Posts: 2,111
Default

you can also have the flash just respond to just wrapper events also:
(via my niffty class )
ActionScript Code:
import flash.events.*; import com.tadSrc.tadsClasses.DOMExEventDispatcher; import com.tadSrc.tadsClasses.DOMExEvent; ... var wrapperEventHandler:DOMExEventDispatcher = new DOMExEventDispatcher("document.onmousemove", ["clientX", "clientY"]); wrapperEventHandler.addEventListener(DOMExEvent.DOMEX_EVENT, universalMouseMoveHandler); stage.addEventListener(MouseEvent.MOUSE_MOVE, universalMouseMoveHandler); private function universalMouseMoveHandler(e:Event):void {     var xPositionOfMouse:Number = (e is MouseEvent) ? mouseX : e.eventPropertiesArray[0];   //same for y it would be in [1] }

that way, the flash would just respond to the mouse at all times, and you would not need a mouse leave event.... but i guess it also depends on what your doing though...
here's an example:

http://www.actiontad.com/components/...xEventExample/

oh, and the cool thing is, there's 0 javascript setup, no scripting for the flash object or anything, just the DOMExEventDispatcher class and DOMExEvent

it may help
__________________
www.actiontad.com - ActionScript and JavaScript sitting in a tree...

Last edited by tadster; 02-19-2010 at 01:43 AM.
tadster is offline   Reply With Quote
Old 02-19-2010, 05:50 AM   #7
sparX
!Senior Member
 
Join Date: Jan 2010
Posts: 1,675
Default

hmmm...i thought i had this one solved the other day,but maybe i havent......

I'll see if i can strip the guts out of this solution i think i found when i get home soon & post it up & tell me if this works in the real world tadster....

I just tested it a couple of times in firefox & thought ok,fixed that problem,whats next lol.....
sparX is offline   Reply With Quote
Old 02-19-2010, 09:08 AM   #8
sparX
!Senior Member
 
Join Date: Jan 2010
Posts: 1,675
Default

Ok heres my psuedo 'LEAVE',let me know if this solves anything or did i just solve nothing...

I just published it 400 x 400 & tested it on FF a couple of times,but is this the same as embedding in web pages?

So when u open this sort of thing directly in FF,the blank background area outside the 400 x 400 defined area is that still 'stage'?

I just opened the 'y' parameters on this & noted that it worked even when u roll up past the title bar & down into the taskbar,so i thought ok thats fixed it....dont know how big your screen is u might want to change the 'y'....

ActionScript Code:
stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; var bG:Shape = new Shape(); var bnds:Rectangle = new Rectangle(30,30,340,340); var txt:TextField = new TextField(); var txtf:TextFormat = new TextFormat("Arial",30,0xFF0000); var circ:Sprite = new Sprite(); var et:Sprite; var pt:Point; var X:int,Y:int; bG.graphics.beginFill(0); bG.graphics.drawRect(0,0,400,400); bG.graphics.endFill(); txt.x = 150 ; txt.y = 25 ; txt.defaultTextFormat = txtf ; txt.autoSize = "center" ; txt.mouseEnabled = false ; circ.x = 200; circ.y = 200; circ.graphics.beginFill(0xFFFFFF); circ.graphics.drawCircle(0,0,30); circ.graphics.endFill(); circ.buttonMode = true; addChild(bG); addChild(txt); addChild(circ); //======================================================================= addEventListener(MouseEvent.MOUSE_DOWN, dragIt); function dragIt (e:MouseEvent):void {         et = Sprite(e.target);         X = et.x; Y = et.y;     et.startDrag(false,bnds) ;         stage.addEventListener(MouseEvent.MOUSE_MOVE,outFix);     addEventListener(MouseEvent.MOUSE_UP,dropIt); } function outFix (e:MouseEvent):void {         if (mouseX < 0 || mouseX > 400 || mouseY < -100 || mouseY > 900) {         et.x = X; et.y = Y;         dropIt();     }         pt = new Point(mouseX,mouseY);       txt.text = String(pt);     e.updateAfterEvent(); } function dropIt (e:MouseEvent = null):void {         et.stopDrag();     stage.removeEventListener(MouseEvent.MOUSE_MOVE,outFix);     removeEventListener(MouseEvent.MOUSE_UP,dropIt); }

Last edited by sparX; 06-24-2010 at 08:43 AM.
sparX is offline   Reply With Quote
Old 02-19-2010, 04:41 PM   #9
tadster
tadster
 
tadster's Avatar
 
Join Date: Feb 2009
Location: Texas
Posts: 2,111
Default

hey nice! seems what you have there would work for the original problem of this thread, SparX.

Using my DOMExEvent is not really suited for a mousedown event, cause then the flash would need to fill the page, and there would be no point... the idea behind DOMExEvent is a way to have the swf respond to outside events...
but if you wanted to get crazy with it... have something draging then when it leaves the flash, (and a DOMEx mousemove event is there) you could have the page then take over with the drag...
so technically you could "pass" an object from the swf to the wrapper and maintain drag status, with a complex setup of my DOMExEvent and possibly some jQuery....
I should make an example of this to show the concept is possible........
__________________
www.actiontad.com - ActionScript and JavaScript sitting in a tree...
tadster is offline   Reply With Quote
Old 02-19-2010, 08:07 PM   #10
sparX
!Senior Member
 
Join Date: Jan 2010
Posts: 1,675
Default

Oh ok,i think i understand ya.

Im just eliminating that annoying dragee gets stuck to my mouse when i MOUSE_UP outside the swf problem......but your talking about actually connecting interactivity back to the swf from outside it.

Guess i'll understand that better when i try some stuff in the real world & i come searching for your DOMEexEvent lol.
sparX is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
6 Button movieclip Problem Using AsBroadcaster systemfx ActionScript 2.0 2 05-23-2007 12:33 AM
Mouse left button isDown: Key.isDown(1) Doesn't work on Macs Arayh ActionScript 2.0 4 03-05-2007 01:26 AM
Button not working due to mouse... Robbamcrob ActionScript 2.0 0 06-07-2006 03:27 AM
Loading text in textfield dynamically depending on button pressed...??? hoppl ActionScript 2.0 6 11-30-2005 04:29 PM
Movieclip plays - despite condition! visualizer29 ActionScript 1.0 (and below) 2 06-17-2004 06:29 PM


All times are GMT. The time now is 02:06 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.