lundi 21 décembre 2015

How to have different mouse cursor on MOUSE_DOWN in as3?

I'm new to as3 and I need to do a very simple thing. I have following code and it works pretty well. But what I need and can't figure out how to do it is:

  1. change mouse cursor when I hold mouse button (choose from symbols)
  2. ability to move with it (normally it would disappear when I move with mouse)

        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();
    
    

Aucun commentaire:

Enregistrer un commentaire