Skip to main content
Known Participant
December 16, 2020
Question

Multiple mouse cursor objects - is this possible?

  • December 16, 2020
  • 1 reply
  • 301 views

Is it possible to create different mouse cursor objects on separate frames within one scene? I want to have at least 3 different objects to serve as the mouse cursor depending on what is happening in the frame. I want to swap out the "greendot1" for different artwork and I found that swapping out the instance name alone does not work with the active buttons in the movieclip. Can I do this? If so, how..?

 

stop();
stage.addChild(greendot1);
greendot1.mouseEnabled = false;
greendot1.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor_5);
function fl_CustomMouseCursor_5(event:Event)
{
            greendot1.x = stage.mouseX;
            greendot1.y = stage.mouseY;
}
Mouse.show();

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    December 16, 2020

    yes, you can even use different "cursors" (more appropriately, moveiclips behaving as cursors) in the same frame if you wanted.

     

    but for different cursors on different frames:

     

    frame "cursor1":

    stop();

    // you may need to remove the other "cursors" depending on your possible navigations
    stage.addChild(greendot1);
    greendot1.mouseEnabled = false;
    greendot1.addEventListener(Event.ENTER_FRAME, gd1F);
    function gd1F(event:Event)
    {
                greendot1.x = stage.mouseX;
                greendot1.y = stage.mouseY;
    }

    Mouse.hide();

     

    frame "cursor2":

    stop();

    if(greendot1.stage){

    stage.removeChild(greendot1);

    }

    // you may need to remove the other "cursors" depending on your possible navigations
    stage.addChild(greendot2);
    greendot2.mouseEnabled = false;
    greendot2.addEventListener(Event.ENTER_FRAME, gd2F);
    function gd2F(event:Event)
    {
                greendot2.x = stage.mouseX;
                greendot2.y = stage.mouseY;
    }

    Mouse.hide();

     

    frame "cursor3":

    stop();

    if(greendot2.stage){

    stage.removeChild(greendot2);

    }

    // you may need to remove the other "cursors" depending on your possible navigations
    stage.addChild(greendot3);
    greendot3.mouseEnabled = false;
    greendot3.addEventListener(Event.ENTER_FRAME, gd3F);
    function gd3F(event:Event)
    {
                greendot3.x = stage.mouseX;
                greendot3.y = stage.mouseY;
    }

    Mouse.hide();

     

     

     

    cmdhAuthor
    Known Participant
    December 16, 2020

    Thank you so much kglad, I will try that! 

     

     

    kglad
    Community Expert
    Community Expert
    December 16, 2020

    you're welcome.