在FLEX 3.0中创建弹出窗口

时间:2012-01-23 05:48:18

标签: actionscript-3 flex actionscript flex3

我创建了一个自定义组件的Popup扩展Canvas我希望画布的外观与图像中显示的类似。有没有想过如何创建类似的弹出窗口。enter image description here

在这里,我将为您提供我迄今为止所做的示例代码......

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="550" height="350" backgroundAlpha="0">
<mx:Script>
    <![CDATA[
        import mx.managers.PopUpManager;

        public function btnImage_click():void
        {
            PopUpManager.removePopUp(this);
        }

    ]]>
</mx:Script>
<mx:Image source="Images/close.png" top="4" left="500" useHandCursor="true" buttonMode="true" click="{btnImage_click();}" />
<mx:Fade id="fadeIn" duration="700" alphaFrom="0.0" alphaTo="1.0"/>
<mx:VBox height="100%" width="100%" horizontalAlign="center" verticalAlign="middle">
    <mx:Canvas height="85%" width="90%" backgroundColor="#ffffff" backgroundAlpha="1" >
        <mx:VBox height="100%" width="100%">
            <mx:HBox height="70%" width="100%" horizontalAlign="center" verticalAlign="middle">
                <mx:Image id="btnPrevious" source="Images/previous.png" 
                    click="{vsSubImages.selectedIndex--}" enabled="{vsSubImages.selectedIndex!=0}"/>
                <mx:ViewStack height="100%" width="90%" creationPolicy="all" id="vsSubImages">
                    <mx:VBox height="100%" width="100%" horizontalAlign="center" verticalAlign="middle" showEffect="{fadeIn}">
                        <mx:Image id="img1" maintainAspectRatio="true" height="100%" width="100%" horizontalAlign="center" verticalAlign="middle" />    
                    </mx:VBox>                  
                    <mx:VBox height="100%" width="100%" horizontalAlign="center" verticalAlign="middle" showEffect="{fadeIn}">
                        <mx:Image id="img2" maintainAspectRatio="true" height="100%" width="100%" horizontalAlign="center" verticalAlign="middle" />    
                    </mx:VBox>                  
                    <mx:VBox height="100%" width="100%" horizontalAlign="center" verticalAlign="middle" showEffect="{fadeIn}">
                        <mx:Image id="img3" maintainAspectRatio="true" height="100%" width="100%" horizontalAlign="center" verticalAlign="middle" />    
                    </mx:VBox>                  
                </mx:ViewStack>
                <mx:Image id="btnNext" source="Images/next.png" 
                    click="{vsSubImages.selectedIndex++}" enabled="{vsSubImages.selectedIndex!=2}" />
            </mx:HBox>
            <mx:Box height="30%" width="100%" horizontalAlign="right" verticalAlign="top">
                <mx:Form height="100%" width="100%">
                    <mx:FormItem label="Project Name : " >
                        <mx:Label id="lblName" />
                    </mx:FormItem>
                    <mx:FormItem label="Description : " >
                        <mx:Label id="lblDescription" />
                    </mx:FormItem>
                    <mx:FormItem label="Technology Name : " >
                        <mx:Label id="lblTechnology" />
                    </mx:FormItem>
                </mx:Form>
            </mx:Box>
        </mx:VBox>
    </mx:Canvas>
</mx:VBox>
</mx:Canvas>

主要想法是在Canvas上显示关闭按钮,目前我正在Canvas背后。 请帮助我。

1 个答案:

答案 0 :(得分:1)

<mx:Image source="Images/close.png" top="4" left="500" useHandCursor="true" buttonMode="true" click="{btnImage_click();}" />标记置于最后</mx:Canvas>标记之前的代码的最底部。因为canvas的行为与la​​st在z-index中位于最顶端。