Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 457691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:35:47+00:00 2026-05-12T22:35:47+00:00

Event.MOUSE_LEAVE is great in Actionscript 3, but it doesn’t seem to fire if the

  • 0

Event.MOUSE_LEAVE is great in Actionscript 3, but it doesn’t seem to fire if the user is holding their left (or right for that matter) mouse button down.

Is there a way to detect if the mouse leaves the Flash movie while the mouse is held down? Or if it is released outside the flash movie?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:35:47+00:00Added an answer on May 12, 2026 at 10:35 pm

    To get all of that requires a little bit of a hack. You have to store whether the mouse is off the stage or not and handle the Event.MOUSE_LEAVE event accordingly. Doing it this way gives you all the normal mouse functionality including not stopping the drag just because the mouse went off stage. Since the user might come back on stage and continue the drag it waits ’til the user releases the mouse either on or off stage.

    var mouseOffStage:Boolean;
    
    var bonk:YourDisplayObject = new YourDisplayObject()
    addChild(bonk);
    bonk.addEventListener(MouseEvent.MOUSE_DOWN, function():void {
      mouseOffStage = false;
    
      bonk.startDrag();
    
      stage.addEventListener(MouseEvent.MOUSE_UP, mouseUp);
      stage.addEventListener(Event.MOUSE_LEAVE, mouseLeave);
      stage.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
      stage.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
    })
    
    private function mouseUp(e:MouseEvent) :void {
      trace("Mouse Up On Stage")
      bonk.stopDrag()
    }
    
    private function mouseLeave(e:Event) :void {
      if(mouseOffStage){
        trace("mouse up and off stage");
        bonk.stopDrag();
      }else{
        trace("mouse has left the stage");
        //no reason to stop drag here as the user hasn't released the mouse yet
      }
    }
    
    private function mouseOut(e:MouseEvent) :void {
      mouseOffStage = true;
      trace("mouse has left the stage")
    }
    
    private function mouseOver(e:MouseEvent) :void {
      mouseOffStage = false;
      trace("mouse has come back on stage");
    }
    

    The hack is that the MOUSE_LEAVE event, not the MOUSE_UP event, gets fired when the mouse is released off stage so you have to keep track of whether or not the mouse was already off stage when it was released.

    after the drag is finished you of course want to remove all the event listeners associated with detecting mouse-outs and mouse-ups but that code was left out for readability.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have a program that fades out on mouse leave event. but the problem is
I'm using the MouseLeave event to check if the user left my form and
I can get MouseEnter , MouseLeave , and Click events to fire, but not
I want to know that can mouse click event detects colors or even strings.
I have a canvas which listens for mouse down event... but I wanted to
I have an html link that has uses hover() (well, the hoverIntent plugin...but same
I want that when mouse is over an image, an event should be triggered
EVENT.DEACTIVATE doesn't work with safari in mac, is there any possible way to do
At the moment I have an image, and when the user puts their mouse
Here's a tooltip script from webdesign tuts+ . Works great, but it fails to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.