Add background for the title of the Alert component

Source: Internet
Author: User
After searching for a long time, I did not know how to add a background to the title of the Alert component. Later I found a method. Maybe it is not the best method, but it can always be implemented. I 'd like to share it with you.

First, create a MovieClip named titleBack. Then, you can add the style you want in this MovieClip. If you just want to add a background color, you can draw a rectangle, fill in the color you want and convert it to MovieClip. You can set this name by yourself (labBack is defined here). Then we need to set the size of Alert based on the size of Alert, to fill the title part of the entire Alert. because the background color I set is blue, the original words are not clear. How can I set the title Font color?

Alert does not seem to provide such a method, so I added a Label component in titleBack so that I can set the font style at will. Then I added the following code in titleBackground:

Lab. color = 0 xFFFFFF;
Lab. text = _ root. labText;
LabBack. _ width = _ root. labWidth;
LabBack. _ height = 25;

Among them, _ root. labText and _ root. labWidth are variables in the main scenario. Then we only need to add the following code to the main scenario.

Import mx. controls. Alert; Alert. titleBackground = "titleBack"; var myAlert = Alert. show ("Hello World ");
LabText = "Hello !!! "
LabWidth = myAlert. _ width-8;

This. style. width = (this. offsetWidth & gt; 740 )? '740px ': 'auto'} "src =" http://www.85flash.com/Files/BeyondPic/2006-4/1/064115485332499.gif "border =" 0 "> click to browse this file
This. style. width = (this. offsetWidth & gt; 740 )? '740px ': 'auto'} "src =" http://www.85flash.com/Files/BeyondPic/2006-4/1/064115485324187.gif "border =" 0 "> click to browse this file

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.