Domanda

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();
È stato utile?

Soluzione

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.

Altri suggerimenti

This topic looks like :

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

Perhaps it will help you...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top