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.

 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

8 Responses to Customizing the background alpha and background color of the Alert control in Flex

  1. coco says:

    very useful!

  2. Bendz says:

    thanks. this is just what i need

  3. romulus says:

    Hi,
    Is it possible to change this white ‘blurred’ whole app background color?
    Best regards,
    Romulus

  4. Peter deHaan says:

    romulus,

    Sure, look into the modalTransparencyBlur, modalTransparency, modalTransparencyColor, and modalTransparencyDuration styles.
    There are a few examples at “Changing a modal Alert control’s blur, transparency and transparency color”, “Globally setting modal styles in a Flex application”, and modalTransparencyColor tag archive, or use the search box on the right.

    Peter

  5. romulus says:

    Thank You very much Peter!
    Romulus

  6. AS says:

    Thankyou very much…..exactly what was needed…… :)

  7. ntaka says:

    very useful. i have a similar post but mine is for customizing an alert and adding icons on the buttons

    • nancy says:

      Is it possible to remove white ‘blurred’ whole app background color for alerts and just show the alert popup window

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree