Flex弹出窗口的定位/滚动问题 [英] Positioning / Scrolling problem with Flex popup

查看:68
本文介绍了Flex弹出窗口的定位/滚动问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解决使用PopUpManager在Flex中定位时遇到的特定问题.基本上,我想创建一个弹出窗口,该弹出窗口将与父容器一起滚动-这是必需的,因为父容器很大,并且如果用户的浏览器窗口不够大(大多数情况下就是这种情况)-他们将不得不使用容器的滚动条向下滚动.问题在于弹出窗口是相对于另一个组件定位的,它需要停留在该组件的旁边.

I'm trying to work out a specific problem I'm having with positioning in Flex using the PopUpManager. Basically I'm wanting to create a popup which will scroll with the parent container - this is necessary because the parent container is large and if the user's browser window isn't large enough (this will be the case the majority of the time) - they will have to use the scrollbar of the container to scroll down. The problem is that the popup is positioned relative to another component, and it needs to stay by that component.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

  <mx:Script>
    <![CDATA[
      import mx.core.UITextField;
      import mx.containers.TitleWindow;
      import mx.managers.PopUpManager;

      private function clickeroo(event:MouseEvent):void {
        var popup:TitleWindow = new TitleWindow();
        popup.width = 250;
        popup.height = 300;

        popup.title = "Example";
        var tf:UITextField = new UITextField();
        tf.wordWrap = true;
        tf.width = popup.width - 30;
        tf.text = "This window stays put and doesn't scroll when the hbox is scrolled (even with using the hbox as parent in the addPopUp method), I need the popup to be local to the HBox.";
        popup.addChild(tf);

        PopUpManager.addPopUp(popup, hbox, false);
        PopUpManager.centerPopUp(popup);
      }
    ]]>
  </mx:Script>

  <mx:HBox width="100%" height="2000" id="hbox">
    <mx:Button label="Click Me" click="clickeroo(event)"/>
  </mx:HBox>

</mx:Application>

有人可以给我正确的方向吗?谢谢.

Could anyone give me any pointers in the right direction? Thanks.

推荐答案

PopUpManager添加了另一个与原始应用程序无关的层.
因此,如果您希望PopUpManager相对于第一层保持相对状态,则可能不希望使用它.您可以仅在Canvas顶部使用TitleWindow.

PopUpManager adds another layer which is independent of the original Application.
So you probably don't want to use PopUpManager if you want it to stay relative to the first layer. You can just use a TitleWindow on top of a Canvas.

您可能有过:

<mx:Application creationComplete="createPopup()">
    <mx:Script>
        <![CDATA[
            public var popupPanel:TitleWindow = new TitleWindow();

            private function createPopup():void
            {
                PopUpManager.addPopUp(popupPanel, myApp, true);
                PopUpManager.centerPopUp(popupPanel);
            }
        ]]>
    </mx:Script>

    <mx:Canvas id="myApp" width="100%" height="2000" />
</mx:Application>

但是相反,您将想尝试这样的事情:

But instead you will want to try something like this:

<mx:Application creationComplete="createPopup()">
    <mx:Script>
        <![CDATA[
            public var popupPanel:TitleWindow = new TitleWindow();

            private function createPopup():void
            {
                // Assuming MyApplication extends Canvas
                (myApp as Canvas).addChild(popupPanel);
                popupPanel.x = myApp.width/2;
                popupPanel.y = myApp.height/2;
            }
        ]]>
    </mx:Script>

    <mx:Canvas id="myApp" width="100%" height="2000" />
</mx:Application>

您将需要自己确定最适合您的应用的x,y值.

You will need to decide for yourself what the best x,y values are for your application.

如果您还想使TitleWindow可拖动/移动,则可以使用Sprite.startDrag()函数.

If you also want to make this TitleWindow draggable/moveable, then you can do so with the Sprite.startDrag() function.

让我知道这是否有帮助!

Let me know if this helps!

这篇关于Flex弹出窗口的定位/滚动问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆