如何在as3的MOUSE_DOWN上使用不同的鼠标光标?

问题描述:

我是新来的as3,我需要做一件非常简单的事情。我有以下代码,它工作得很好。但我需要什么,不能弄清楚如何做到这一点是:如何在as3的MOUSE_DOWN上使用不同的鼠标光标?

  1. 改变鼠标光标,当我拿着鼠标中键(从符号选择)
  2. 与它(移动通常会消失时能力我用鼠标移动)

    import flash.display.Sprite; 
        import flash.events.Event; 
        import flash.events.MouseEvent; 
        import fl.motion.MotionEvent; 
    
        var CursorStill: Sprite; 
        var CursorAnim: Sprite; 
    
        function init() { 
         Mouse.hide(); 
    
         CursorStill = new CursorStillClass(); 
         CursorStill.mouseEnabled = false; 
         CursorStill.visible = false; 
    
         addChild(CursorStill); 
    
         stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); 
         stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler); 
         stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); 
        } 
    
        function mouseMoveHandler(evt: MouseEvent): void { 
         CursorStill.visible = true; 
         CursorStill.x = evt.stageX; 
         CursorStill.y = evt.stageY; 
         evt.updateAfterEvent(); 
        } 
    
        function mouseLeaveHandler(evt: Event): void { 
         CursorStill.visible = false; 
    
        } 
    
        function mouseDownHandler (evt: MouseEvent): void { 
         CursorStill.visible = false; 
        } 
    
        init(); 
    

我的一个朋友帮我,我理解了它。我希望这将帮助其他新手至少:)

import flash.events.Event; 
import flash.events.MouseEvent; 
import fl.motion.MotionEvent; 

function init() { 
    Mouse.hide(); 

    // this creates an instance of the library MovieClip with the 
    // name, "MyCursorClass". this contains your mouse cursor art 
    // 
    Cursor = new CursorClass(); 
    Cursor.mouseEnabled = false; 
    Cursor.visible = false; 

    // you'll want to make sure the child is added above everything 
    // else, possibly in its own container 
    // 
    addChild(Cursor); 

    // respond to mouse move events 
    stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); 
    stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler); 
    stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); 
    stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); 
} 

function mouseMoveHandler(evt: MouseEvent): void { 
    // whenever the mouse moves, place the cursor in the same spot 
    Cursor.visible = true; 
    Cursor.x = evt.stageX; 
    Cursor.y = evt.stageY; 
    // for smoother mouse pointer 
    evt.updateAfterEvent(); 
} 

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

} 

function mouseDownHandler(evt: MouseEvent): void { 
    Cursor.gotoAndStop(xx); 
} 

function mouseUpHandler(evt: MouseEvent): void { 
    Cursor.gotoAndStop(xx); 
} 

init(); 

最学分转到本教程虽然

http://danielmclaren.com/2008/03/tips-for-using-custom-mouse-cursors-in-flash-as3