A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 23

Thread: Really frustrating MOUSE_OVER, MOUSE_OUT behavior

  1. #1
    Junior Member
    Join Date
    Jan 2008
    Posts
    9

    Really frustrating MOUSE_OVER, MOUSE_OUT behavior

    This is driving me crazy. I'm trying to create a custom drag cursor when the mouse is over a dragable object. Here is an excerpt of the code:

    PHP Code:
    this.loader.addEventListener(MouseEvent.MOUSE_MOVEmouseMove);
    this.loader.addEventListener(MouseEvent.ROLL_OUTmouseOut);
    public function 
    mouseMove(e:MouseEvent) {
        
    dragCursor.alpha 1;
        
    Mouse.hide();
        
    dragCursor.stage.mouseX;
        
    dragCursor.stage.mouseY;
    }

    public function 
    mouseOut (e:MouseEvent) {
        
    trace (e.eventPhase ': mouse out called');
        
    dragCursor.alpha 0;
        
    Mouse.show();

    The frustrating part of this is that whenever I'm over any object with MOUSE_OUT and/or MOUSE_OVER funcs defined, the out and over funcs seemed to be called randomly, when I move the mouse over the object (in this case a simple jpg). That is to say that the out and over funcs are called randomly, without ever rolling out of the area of the image. Why would this be? I've read the documentation for bubbling etc, and can find no reason for this behavior. I've tried for 5 hours all kinds of tests, but nothing works... Someone PLEASE HELP!

  2. #2
    Junior Member
    Join Date
    Jan 2008
    Posts
    9

    little more info

    In the event.mouseOut documetation I read that:
    The event target is the object previously under the pointing device. The relatedObject is the object the pointing device has moved to.
    So I put the following my code:

    PHP Code:
    trace ('ro: ' e.relatedObject)
    trace ('t: ' e.target
    When I move my mouse around the image I get the output:

    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    ro: [object Loader]
    t: [object Loader]
    2: mouse out called
    Which means to me that the the mouse is on the Loader object, and then leaves the Loader object in order to go onto itself (Loader), thus calling the mouse_out func. What the #@!? That makes no sense... Help me?

  3. #3
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    My only guess would be that the mouse might be interacting with your dragCursor thing, though I don't know what the trace functions wouldn't tell you as much.

    If you add an extra 50 or however many pixels to the x position of it in that function you could be sure it's not interacting with the mouse and figure out if this is the problem or not~

  4. #4
    Junior Member
    Join Date
    Jan 2008
    Posts
    9
    My only guess would be that the mouse might be interacting with your dragCursor thing
    Believe it or not, I think this is the case. I thought I had taken care of this by making the drag icon completely transparent for 5 pixels or so around the actual mouseX,Y, but no...

    Anyway I've moved the cursor 5,5 pixels away from the mouse, and the mouseOut is only called when you move the cursor really fast over the image, which my client can live with. God... so what's point of making a custom cursor... if it can't actually point to anything closer than 5,5 pixels away?

  5. #5
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    Well you could sort of get around that by making an object that fills up all of the space your mouseover object doesn't.
    Since transparency apparently doesn't matter you could just make it invisible and have a mouseOver on it do what your Roll_Out event was triggering.

    But I think I have a better solution- if you make the mouse cursor a child of your roll_over thing then the mouse being over it should still register as being over that object.
    though, you'd need to have something to bound the cursor_image position
    Code:
    if (cursor.x < 0){
    cursor.x = 0
    }
    elseif{ //other direction stuff }
    else {
    //regular reposition code
    Last edited by Shokushu; 01-30-2008 at 09:34 PM.

  6. #6
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    If you can't make it work, try uploading the file because I'm sure it will be much easier for us to help you if we can actually test and see the project. Good luck.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  7. #7
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    set the mouseEnabled property of the drag cursor:

    cursor.mouseEnabled = false; That will cause it to not receive any mouse events. Thus not calling the MOUSE_OUT event.

  8. #8
    Arabic Flash Guru sand_monkey's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    169
    and also say

    cursor.mouseChildren = false;

    this stops any children of the cursor movieclip from receiving mouse events
    Sand Monkey

    Flying is learning how to throw yourself at the ground and miss!

  9. #9
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    Is the ROLL_OUT event received by the object you move on to or the object you move off of?
    Or does is there just sort of an internal "map" of all the objects that can receive mouse objects that is checked for these events?

    With the intuitive option these turning off options would cripple his program.
    If it works some other way info about that would be nice just so other people can know how they should structure their programs in the future~

  10. #10
    Arabic Flash Guru sand_monkey's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    169
    basically what's happening is the movieclip attached to the cursor is receiving mouse events so when you roll over a button, the movieclip lags behind the cursor a bit enabling the button to receive the mouse then it catches up and the mouse, in effect, rolls off the button onto the mouse cursor. Then when you move the mouse the same thing happens again. By disabling the movieclip attached to the cursor from receiving any mouse events, it stops the constant roll on, roll off event
    Sand Monkey

    Flying is learning how to throw yourself at the ground and miss!

  11. #11
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    So basically they called it 'roll off' because they didn't want to call it 'roll onto anything else'~

  12. #12
    Arabic Flash Guru sand_monkey's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    169
    not really, it's just that the listener is looking for the event of roll off one movieclip, not roll off or on anything. get what i mean?
    Sand Monkey

    Flying is learning how to throw yourself at the ground and miss!

  13. #13
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    They why would it matter if the object you put the mouse over can accept events?

  14. #14
    Arabic Flash Guru sand_monkey's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    169
    you want that movieclip too receive events but not the movieclip that is meant to be replacing the cursor
    Sand Monkey

    Flying is learning how to throw yourself at the ground and miss!

  15. #15
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    No, I'm asking why would it matter if ANY object recieves an event?
    Doesn't Roll Out go off the first time that the mouse is 'not on the object'?

  16. #16
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    This thread got long and still no solution.
    Maybe uploading the file will answer all our "whys"...



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  17. #17
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    Oh, do the two lines of code that disable mouse interaction with the cursor object not actually work?

    I've just been curious as to how the roll out event is dispatched.

  18. #18
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    Post the code that you've tried...



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  19. #19
    Funkalicious TOdorus's Avatar
    Join Date
    Nov 2006
    Location
    Nijmegen, Netherlands
    Posts
    697
    Quote Originally Posted by sand_monkey
    basically what's happening is the movieclip attached to the cursor is receiving mouse events so when you roll over a button, the movieclip lags behind the cursor a bit enabling the button to receive the mouse then it catches up and the mouse, in effect, rolls off the button onto the mouse cursor. Then when you move the mouse the same thing happens again. By disabling the movieclip attached to the cursor from receiving any mouse events, it stops the constant roll on, roll off event
    Well I think your question can't really be answered any clearer than that. SandMonkey actually taught me something to look out for in the future there.

    I think what you've got a hard time grasping, is why disabling events would matter? Well as far as I understand, the mouse checks which object it is hovering over. In Flash terminology: on which object the mouse is. When the mouse is on object a it can't be on object b.

    In the case that object a is in front of object b, if I hover with my mouse over object b, it is on object b. But if I hover it over object a, object b gets blocked so it is off object b and on object a. This triggers a mouseout event on object b and a mouseon event on object a.

    If you disable events for object a, it never gets an mouseon event on object a, so the mouse is never off object b when hovering over objecta. The mouseon and mouseoff events tell Flash which object the mouse is over (if I understand SandMonkey correctly).

    Hope this helps.

  20. #20
    Arabic Flash Guru sand_monkey's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    169
    thanks TOdorus! precisely what I meant
    Sand Monkey

    Flying is learning how to throw yourself at the ground and miss!

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