A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Detecting Mouse_OUT on Moving Object

  1. #1
    Member
    Join Date
    Jan 2003
    Location
    Ontario
    Posts
    59

    Detecting Mouse_OUT on Moving Object

    Hi all

    I'm working on something where when a user places their mouse over a horse in a race, it will display the horse's name and post position. This works great and has a Mouse_OUT which then removes the display of the name/post position. However, I've noticed that if I place my mouse over a horse and leave it there and said horse moves away from underneath where my mouse was, the name/post position become stuck on the screen until you mouse over that horse again.

    Here is what I have set up so far: http://www.equination.net/images/raceviewer1.html

    In a nutshell, it's just a very simple listener triggering a function...

    Actionscript Code:
    horse1.addEventListener(MouseEvent.MOUSE_OVER, showPost1, false, 0, true);
    horse1.addEventListener(MouseEvent.MOUSE_OUT, hidePost1, false, 0, true);

    function showPost1(evt:MouseEvent):void {
       stuff in here to display the post number over the horse in relation to their current x/y values, display the text field and update with the name
    }

    function hidePost1(evt:MouseEvent):void {
      remove the post number/name children from the stage
    }

    I'm not really sure how to handle this scenario so that it will use the hidePost1 if the object moves out from underneath the horse.

    Thanks for reading

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    That's the correct method. Perhaps it is due to how you target, store and remove the info. You'll have to show some of that code in order to troubleshoot.

  3. #3
    Member
    Join Date
    Jan 2003
    Location
    Ontario
    Posts
    59
    That's basically it in a nutshell, along with a timer that moves the horses along their x axis.

    I wound up putting an event listener on the scrolling background for a MOUSE_OVER. On Mouse Over I triggered a function that simple set the visibility of all the post position numbers to false and cleared the horse name text field at the bottom. It seems to have resolved the problem, though it is a bit of a pain to have to go the extra mile because it can't detect mouse_out if the object moves out from under the mouse. But, it seems to work perfectly and detects when the mouse seems to move onto it as the object in between gets out of the way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center