Transparent
Flash Player 6 begins to support text field (TextField) Transparency Properties (alpha), but Textfield._alpha only supports text fields that are rendered using embedded font outlines (Textfield.embedfonts = true). The text field rendered for the default device font is not valid.
Here's how Textfield._alpha is implemented, and the following code sets the transparency of my_txt text to 20%. Click the library-> new font option, create a font symbol, and then set the font symbol link identifier to "my font."
var my_fmt:textformat = new TextFormat ();
My_fmt.font = "my font";//' My font ' is the link identifier for the font symbol in the library
This.createtextfield ("My_txt", This.getnexthighestdepth (), 10, 10, 100, 22);
My_txt.border = true;
My_txt.embedfonts = true;//Renders a text field with an embedded font outline
My_txt.text = "Hello World";
My_txt.settextformat (MY_FMT);
My_txt._alpha = 20;
The above method uses the font components, is not very convenient to use, and as a result of the packaging of fonts at the time the SWF file is relatively large. To learn more about font components, see Flash technotes:using font symbols,creating font symbols.
The following two methods discard Textfield._alpha and simulate the transparency of the text field.
One, by setting the color simulation
function Setalpha (obj, Alpha) {
var rgb = "0x" + (255* (100-alpha)/100). toString (16);
RGB = RGB << 16 | RGB << 8 | Rgb
Obj.backgroundcolor |= RGB;
Obj.bordercolor |= RGB;
Obj.textcolor |= RGB;
}
Second, by creating a film clip composition of the Mongolian layer
function Setalpha (obj, Alpha) {
var tmp_mc_name:string = obj._name+ "_ALPHAMASK_MC";
var tmp_mc:movieclip = eval (tmp_mc_name);
if (!TMP_MC) {
TMP_MC = This.createemptymovieclip (Tmp_mc_name,this.getnexthighestdepth ());
Tmp_mc.beginfill (0xFFFFFF);
Tmp_mc.moveto (0, 0);
Tmp_mc.lineto (20, 0);
Tmp_mc.lineto (20, 10);
Tmp_mc.lineto (0, 10);
Tmp_mc.lineto (0, 0);
Tmp_mc.endfill ();
}
tmp_mc._x = obj._x;
tmp_mc._y = obj._y;
Tmp_mc._width = (obj.border)? Obj._width+1:obj._width;
Tmp_mc._height = (obj.border)? Obj._height+1:obj._height;
Tmp_mc._alpha = 100-alpha;
}
How to use:
This.createtextfield ("My_txt", This.getnexthighestdepth (), 10, 10, 100, 22);
My_txt.text = "Hello World";
Setalpha (my_txt,50)//Set My_txt text transparency to 50%