简体   繁体   中英

how to change background color of PopUp window in flex

I have developed a application where it contains few PopUp windows. whenever popup comes the background of the popup is little brighter, is there any way that i can make PopUP Background little darker.

Thanks in Advance..

If you mean the Alert component, you can do something like this:

<?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>

//the result

在此处输入图片说明

//EDIT

If you want to use a custom component, it can look like this:

//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>

call it from the application:

var myAlert:MyAlert = new MyAlert();

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

//the result

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM