4 Replies Latest reply on Feb 7, 2015 12:55 PM by Johninus

    How to let the label move and follow the cursor?

    Johninus Level 1

      I tried with following code, but it didn't work well. Please advise, thanks.

       

      btn_chimg.addEventListener(MouseEvent.MOUSE_OUT, outofme);

      btn_chimg.addEventListener(MouseEvent.MOUSE_MOVE, moveme);

       

      function moveme(event:Event):void {

           trace("moveme");

           lab1.text = "Hi, Im here.";

           lab1.visible = true;

           lab1.x = mouseX;

           lab1.y = mouseY;

      }

       

      function outofme(e:Event):void {

           trace("outofme");

           lab1.visible = false;

      }