The following example shows how you can style a flex alert control using the static
Stylemanager. getstyledeclaration ()
Method, and
Setstyle ()
Method <? XML version = "1.0" encoding = "UTF-8" ?>
<! -- Http://blog.flexexamples.com/2008/02/29/styling-alert-controls-in-flex-using-the-stylemanager-class-and-setstyle-methods/ -->
< MX: Application Xmlns: MX = "Http://www.adobe.com/2006/mxml"
Layout = "Vertical"
Verticalalign = "Middle"
Backgroundcolor = "White"
Creationcomplete = "Init ();" >
<MX: script>
<! [CDATA [
Import MX. Controls. Alert;
Import MX. Styles. stylemanager;
Private var alert: alert;
Private var alertcss: cssstyledeclaration;
Private function Init (): void {
Alertcss = stylemanager. getstyledeclaration ("alert ");
}
Private function showalert (color: Object): void {
Alertcss. setstyle ("modaltransparencycolor", color );
Alertcss. setstyle ("themecolor", color );
Alert = alert. Show ("The quick brown fox ");
}
]>
</ MX: script >
< MX: applicationcontrolbar Dock = "True" >
< MX: button Label = "Red"
Themecolor = "Red"
Click = "Showalert ('red ');" />
< MX: button Label = "Orange"
Themecolor = "Haloorange"
Click = "Showalert ('haloorange ');" />
< MX: button Label = "Yellow"
Themecolor = "Yellow"
Click = "Showalert ('yellow ');" />
< MX: button Label = "Green"
Themecolor = "Halogreen"
Click = "Showalert ('halogre ');" />
< MX: button Label = "Blue"
Themecolor = "Haloblue"
Click = "Showalert ('haloblue ');" />
</ MX: applicationcontrolbar >
</MX: Application>