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

by Peter deHaan on August 14, 2007

in Alert

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.

{ 1 comment… read it below or add one }

1 Campbell August 15, 2007 at 12:01 am

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 :(

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can 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

Previous post:

Next post: