23
Dec
07

Customizing the background alpha and background color of the Alert control in Flex

The following example shows how you can customize the background alpha and background color of a Flex Alert control by setting the backgroundAlpha, backgroundColor, borderAlpha, and borderColor styles.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/23/customizing-the-background-alpha-and-background-color-of-the-alert-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="showAlert();">

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

            private var alert:Alert;

            private function showAlert():void {
                alert = Alert.show("The quick brown fox jumped over the lazy dog.", "title");
            }
        ]]>
    </mx:Script>

    <mx:Style>
        Alert {
            backgroundAlpha: 0.3;
            backgroundColor: red;
            borderAlpha: 0.3;
            borderColor: red;
            dropShadowEnabled: false;
        }
    </mx:Style>

    <mx:ApplicationControlBar dock="true">
        <mx:Button label="Show alert" click="showAlert();" />
    </mx:ApplicationControlBar>

</mx:Application>

View source is enabled in the following example.


2 Responses to “Customizing the background alpha and background color of the Alert control in Flex”


  1. 1 coco Dec 24th, 2007 at 5:02 pm

    very useful!

  2. 2 Bendz Feb 23rd, 2008 at 6:52 am

    thanks. this is just what i need

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".