0

我开发了一个应用程序,其中包含几个弹出窗口。每当弹出窗口出现时,弹出窗口的背景都会变亮,有什么方法可以使弹出窗口背景变暗。

提前致谢..

4

1 回答 1

1

如果您指的是 Alert 组件,则可以执行以下操作:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" 
           creationComplete="Alert.show('Hello!')">
<fx:Style>
    @namespace s "library://ns.adobe.com/flex/spark";
    @namespace mx "library://ns.adobe.com/flex/mx";

    mx|Alert {
        backgroundAlpha: 0.4;
        backgroundColor: #00ff00;
    }
</fx:Style>

<fx:Script>
    <![CDATA[
        import mx.controls.Alert;
    ]]>
</fx:Script>

</s:Application>

//结果

在此处输入图像描述

//编辑

如果您想使用自定义组件,它可以如下所示:

//MyAlert.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow 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="175" height="100">
<fx:Script>
    <![CDATA[
        import mx.managers.PopUpManager;

        protected function onOkClick(event:MouseEvent):void
        {
            PopUpManager.removePopUp(this);
        }
    ]]>
</fx:Script>

<s:Rect top="0" bottom="0" left="0" right="0">
    <s:fill>
        <s:SolidColor color="0x00ff00" alpha="0.4"/>
    </s:fill>
</s:Rect>

<s:VGroup horizontalAlign="center" width="100%" height="100%">
    <s:Spacer height="10"/>
    <s:Label text="Hello!"/>
    <s:Button label="Ok" click="onOkClick(event)"/>
</s:VGroup>
</s:TitleWindow>

从应用程序调用它:

var myAlert:MyAlert = new MyAlert();

PopUpManager.addPopUp(myAlert, this, true);
PopUpManager.centerPopUp(myAlert);

//结果

在此处输入图像描述

于 2013-04-11T17:31:41.233 回答