Styling alert controls in flex using the stylemanager class and setstyle () Methods

Source: Internet
Author: User
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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.