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