如何在 Flex 和 AS3 中的屏幕区域中显示 PopUp

发布于 2024-09-10 10:30:24 字数 1277 浏览 5 评论 0原文

您好,我正在尝试在图像鼠标悬停时显示我的弹出窗口 显示良好 当我尝试将鼠标悬停在右侧时,最后一个图像弹出窗口将离开屏幕 这里 TalentInfoPopUp 是 **TitleWindow

这是我的示例代码

private static var staticWindow :TalentInfoPopUp = null;  
private static var visibleWindow:TalentInfoPopUp = null;

public static function show(t:Object, parent : DisplayObject, x:Number , y:Number):void
{
if(staticWindow == null)
{
visibleWindow = staticWindow = PopUpManager.createPopUp( parent , TalentInfoPopUp , false) as TalentInfoPopUp;
    }

    else if(visibleWindow == null)
    { 
        visibleWindow = staticWindow;
        PopUpManager.addPopUp(staticWindow, parent, false);

    }

    PopUpManager.centerPopUp(staticWindow);

    staticWindow.talent = t;
    staticWindow.x = x;
    staticWindow.y =y;      

    PopUpManager.bringToFront(staticWindow);
    staticWindow.talent = t;
    staticWindow.move(x,y);
    staticWindow.callLater(staticWindow.setPosition,[x,y]);
    //staticWindow.setPosition(x,y);

}



private function setPosition(nx:int,ny:int):void
{
    var maxWidth:int =  stage.width ;
    var maxHeight:int = stage.height;

    if(nx>maxWidth-width)
    {
        nx=nx-width;
    }
    if(ny>maxHeight-height)
    {
        ny=ny-height;
    }

    this.move(nx,ny); 
}

Hi i am trying to show my popup on the image mouse over
it is showing fine
when i trying mouse over right side last images popup is going out of the screen
Here TalentInfoPopUp is **TitleWindow

This is my sample code

private static var staticWindow :TalentInfoPopUp = null;  
private static var visibleWindow:TalentInfoPopUp = null;

public static function show(t:Object, parent : DisplayObject, x:Number , y:Number):void
{
if(staticWindow == null)
{
visibleWindow = staticWindow = PopUpManager.createPopUp( parent , TalentInfoPopUp , false) as TalentInfoPopUp;
    }

    else if(visibleWindow == null)
    { 
        visibleWindow = staticWindow;
        PopUpManager.addPopUp(staticWindow, parent, false);

    }

    PopUpManager.centerPopUp(staticWindow);

    staticWindow.talent = t;
    staticWindow.x = x;
    staticWindow.y =y;      

    PopUpManager.bringToFront(staticWindow);
    staticWindow.talent = t;
    staticWindow.move(x,y);
    staticWindow.callLater(staticWindow.setPosition,[x,y]);
    //staticWindow.setPosition(x,y);

}



private function setPosition(nx:int,ny:int):void
{
    var maxWidth:int =  stage.width ;
    var maxHeight:int = stage.height;

    if(nx>maxWidth-width)
    {
        nx=nx-width;
    }
    if(ny>maxHeight-height)
    {
        ny=ny-height;
    }

    this.move(nx,ny); 
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦中的蝴蝶 2024-09-17 10:30:24

尝试使用 systemManager.screen.widthsystemManager.screen.height 而不是 stage.widthstage.height ;还了解 localToGlobalglobalToLocal 方法以及如何使用它们。

Try using systemManager.screen.width and systemManager.screen.height instead of stage.width and stage.height; also learn about the localToGlobal and globalToLocal methods and how to use them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文