更改弹出面板的光标

时间:2011-05-30 08:55:49

标签: actionscript-3 flex3 popup cursor

当我的光标只在这个弹出式面板中而不是在主舞台中时,如何更改光标?

private function launchPopUp(e:MouseEvent):void 
{
     panel = new Panel();
          panel.width = stage.stageWidth;
          panel.height = stage.stageHeight;
     panel.setStyle("borderAlpha", 1);
     PopUpManager.addPopUp(panel, this, true);
          PopUpManager.centerPopUp(panel);
}

如果有人可以提供帮助,我们将不胜感激。

1 个答案:

答案 0 :(得分:0)

您可以使用以下代码更改鼠标光标。诀窍是隐藏鼠标光标并用精灵替换它。

function launchPopUp(e:MouseEvent):void 
{
     panel = new Panel();
     panel.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveFunc);
     panel.addEventListener(MouseEvent.MOUSE_OUT, mouseOutFunc);
     panel.width = stage.stageWidth;
     panel.height = stage.stageHeight;
     panel.setStyle("borderAlpha", 1);
     PopUpManager.addPopUp(panel, this, true);
     PopUpManager.centerPopUp(panel);
}

function mouseMoveFunc(e:MouseEvent):void
{
    Mouse.hide();
    customMouseSprite.visible = true;
    customMouseSprite.x = e.stageX;
    customMouseSprite.y = e.stageY;
}

function mouseOutFunc(e:MouseEvent):void
{
    Mouse.show();
    customMouseSprite.visible = false;;
}

当弹出窗口关闭时,您还需要调用mouseOutFunc。 customMouseSprite必须位于舞台的顶层。 customMouseSprite可以是精灵或动画片段(事实上任何显示对象)。