简体   繁体   中英

Custom cursor with mouse_down in as3

I want to get the a different cursor to show up for my custom cursor and this is the code I have so far. I've created the function but I am not sure where to go from here.

Ideally I would like to switch one cursor our for another, or use a different frame within the cursor's timeline. Please help if you can.

import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;

var myCursor:Sprite;

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

function init()
    {
        Mouse.hide();


        myCursor = new CursorClass();
        myCursor.mouseEnabled = false;
        myCursor.visible = false;


        addChild(myCursor);

        stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
        stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler);
        stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    }

    function mouseMoveHandler(evt:MouseEvent):void
    {
        myCursor.visible = true;
        myCursor.x = evt.stageX;
        myCursor.y = evt.stageY;
    }

    function mouseDownHandler(evt:MouseEvent):void
    {

    }

    function mouseLeaveHandler(evt:Event):void
    {
        myCursor.visible = false;
    }

init();

If myCursor have timeline with different shape for cursor than in mouseDownHandler set myCursor.gotoAndStop(2). Else you can change myCursor with instance of some MovieClip from library.

This topic looks like :

Flex 3: How can I change the Mouse Cursor when mousing over a Text Input?

Perhaps it will help you...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM