The following example allows you to use Cascading Style Sheets (CSS) to control a Flex Alert control’s modalTransparencyBlur, modalTransparency, modalTransparencyColor, and modalTransparencyDuration styles.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/08/14/changing-a-modal-alert-controls-blur-transparency-and-transparency-color/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="showAlert()">

    <mx:Style>
        Alert {
            modalTransparencyBlur: 5;
            modalTransparency: 0.6;
            modalTransparencyColor: #FF0000;
            modalTransparencyDuration: 1000;
        }
    </mx:Style>

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

            private var a:Alert;

            private function showAlert():void {
                a = Alert.show("text", "title", Alert.OK);
            }
        ]]>
    </mx:Script>

    <mx:Button label="Show Alert" click="showAlert()" />

</mx:Application>

View source is enabled in the following example.

 
Tagged with:
 
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.

One Response to Changing a modal Alert control’s blur, transparency and transparency color

  1. Campbell says:

    Or change the class:

    // Setup new mofdal window class for popupManager
    protected function setupOverlay(type:Class):void{
    var ipm:IPopUpManager =Singleton.getInstance(“mx.managers::IPopUpManager”) as PopUpManager;
    var o:Object = ipm;
    var p:QName = new QName(mx_internal, “modalWindowClass”);
    o[p] = type;
    }

    Just make sure the type class reference extends UIComponent :)

    I have been Doing quite a bit with the PopUpManager, and found it way too locked down, which is why I have to step into mx_internal namespace :(

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