flex学习-----获取鼠标坐标

<mx:Panel mouseMove="getLocation(event:MouseEvent)"><mx:Button label="Button" /></mx:Panel>

/**
    * 得到鼠标位置
    * */
   private function getLocation(event:MouseEvent):void{

        trace("localX:" + event.localX + ",localY:" + event.localY);  //相对于组件的坐标,(如果在button上,则相对于button)

        trace("stageX:" + event.stageX + ",stageY:" + event.stageY);  //相对于整个应用的坐标

        trace("mouseX:" + DisplayObject.mouseX + ",mouseY:DisplayObject.mouseY:" + DisplayObject.mouseY); //相对于 DisplayObject容器或组件的坐标

        trace("contentMouseX:" + Container.contentMouseX + ",contentMouseY:" + Container.contentMouseY);  //相对于容易的坐标

     }


你可能感兴趣的:(function,Flex,button)