为什么弹出式面板的子项出现在面板之外

时间:2011-08-12 10:09:50

标签: flex layout flex4 air popup

我正在使用flex 4弹出式管理器弹出一个面板,但面板的子节点没有停留在面板内。但当我关闭弹出窗口时,孩子们正在被移除。

像这样:(抱歉,我不能发布照片)

           ----------
           l________l
           l        l
  ..... please enterl
           l--------1

有人知道为什么吗?这是我的代码:

var forgotPopup:Panel = PopUpManager.createPopUp(this, forgottenForm, true) as Panel;
        PopUpManager.centerPopUp(forgotPopup);

这就是我突然出现的事情:

<?xml version="1.0" encoding="utf-8"?>
<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" width="218" height="168" skinClass="PanelSkin" title="Reset Details">


    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <fx:Script>
        <![CDATA[

            import mx.controls.Alert;
            import mx.events.FlexEvent;
            import mx.managers.PopUpManager;

            // Handle the close button and Cancel button.
            private function handleCloseEvent():void {
                PopUpManager.removePopUp(this);
            }

        ]]>
    </fx:Script>

    <mx:Form horizontalCenter="0" verticalCenter="0">
        <mx:FormHeading label="Please enter your e-mail address and your login details will be e-mailed to you"/>
        <mx:FormItem label="E-mail">
            <s:TextInput id="userInput" x="78" y="49"/>
        </mx:FormItem>
        <mx:FormItem direction="horizontal">
            <s:Button id="okButton" label="Submit" skinClass="ButtonSkin" />
            <s:Button id="cancelButton" label="Cancel" skinClass="ButtonSkin"/>
        </mx:FormItem>  
    </mx:Form>

</s:Panel>

对此有任何帮助都很棒,谢谢。

2 个答案:

答案 0 :(得分:0)

尝试使用以下内容:

<?xml version="1.0" encoding="utf-8"?>
<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" width="218" height="168" skinClass="PanelSkin" title="Reset Details">


    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <fx:Script>
        <![CDATA[

            import mx.controls.Alert;
            import mx.events.FlexEvent;
            import mx.managers.PopUpManager;

            // Handle the close button and Cancel button.
            private function handleCloseEvent():void {
                PopUpManager.removePopUp(this);
            }

        ]]>
    </fx:Script>

    <mx:Form left="10" right="10" top="10" bottom="10">
        <mx:FormHeading label="Please enter your e-mail address and your login details will be e-mailed to you"/>
        <mx:FormItem label="E-mail">
            <s:TextInput id="userInput" x="78" y="49"/>
        </mx:FormItem>
        <mx:FormItem direction="horizontal">
            <s:Button id="okButton" label="Submit" skinClass="ButtonSkin" />
            <s:Button id="cancelButton" label="Cancel" skinClass="ButtonSkin"/>
        </mx:FormItem>  
    </mx:Form>

</s:Panel>

如果您需要包含标题字,则应拒绝标准FormHeading并将其替换为Label

<?xml version="1.0" encoding="utf-8"?>
<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" width="218" height="168" skinClass="PanelSkin" title="Reset Details">


    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <fx:Script>
        <![CDATA[

            import mx.controls.Alert;
            import mx.events.FlexEvent;
            import mx.managers.PopUpManager;

            // Handle the close button and Cancel button.
            private function handleCloseEvent():void {
                PopUpManager.removePopUp(this);
            }

        ]]>
    </fx:Script>

    <mx:Form left="10" right="10" top="10" bottom="10">
        <s:Label width="100%" text="Please enter your e-mail address and your login details will be e-mailed to you" fontWeight="bold" />
        <mx:FormItem label="E-mail">
            <s:TextInput id="userInput" x="78" y="49"/>
        </mx:FormItem>
        <mx:FormItem direction="horizontal">
            <s:Button id="okButton" label="Submit" skinClass="ButtonSkin" />
            <s:Button id="cancelButton" label="Cancel" skinClass="ButtonSkin"/>
        </mx:FormItem>  
    </mx:Form>

</s:Panel>

但最好的方法是切换到自Flex 4.5以来可用的Spark Form

答案 1 :(得分:0)

请避免X和Y位置 这也可能导致对象位置。