Custom cursors
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Custom cursors

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    17

    Custom cursors

    I have added a custom cursor to my application, using the following code:
    Code:
    Mouse.hide();
    mouseEnabled = false;
    stage.addEventListener(MouseEvent.MOUSE_MOVE,follow);
    function follow(evt:MouseEvent)
    {
    	cursor.x = mouseX;
    	cursor.y = mouseY;
    }
    However it does not stay on top of the scene because new objects are created during the application run, and the cursor goes behind them as it is an older object. I want the cursor to stay on top at all times... How can I do this?

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,810
    You have to update it index as a new displayobject is added.

    stage.setChildIndex(cursor, stage.numChildren - 1);

    Or you can have it update it when it moves.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Junior Member
    Join Date
    May 2012
    Posts
    17
    I copied that code in the "follow" function but it tells me:

    "The supplied DisplayObject must be a child of the caller"

  4. #4
    Dignitary rynoe's Avatar
    Join Date
    Jan 2003
    Location
    Earth
    Posts
    756
    Use this:
    Code:
    if(getChildIndex(cursor) != numChildren-1){
         setChildIndex(cursor, numChildren-1);
    }
    Last edited by rynoe; 06-08-2012 at 09:50 AM. Reason: Locusts

  5. #5
    Junior Member
    Join Date
    May 2012
    Posts
    17
    That does make the cursor go on top, but unfortunately it makes the program no longer react when I click on objects.

    I've read somewhere that the image of a custom cursor can get in the way, but that mouseEnabled = false; is supposed to fix that. But it doesn't. I'm not sure what the problem is.

  6. #6
    Junior Member
    Join Date
    May 2012
    Posts
    17
    No one knows?

  7. #7
    Dignitary rynoe's Avatar
    Join Date
    Jan 2003
    Location
    Earth
    Posts
    756
    Within the custom cursor, move the graghic just off the anchor point.

  8. #8
    Junior Member
    Join Date
    Apr 2007
    Posts
    9
    maybe you should be doing
    cursor.mouseEnabled = false;
    If cursor is inside another movie clip, make it so its highest-level parent is mouse disabled too. The graphical-moving thing is more of a workaround than a true solution, but It should work too.

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

Poll by Flashkit.com