FLASH中怎么用代码改变文本字体颜色

来源:百度知道 编辑:UC知道 时间:2024/06/16 01:29:20
例如on(press){
a.text="字体颜色"}
我想让输入“字体”为红色“颜色”为蓝色。应该怎么写?

有3种方式,如下:
1.char_txt.textColor = 0xff0000; 这个得用在char_txt.setTextFormat(textFormat); 下一行才行。
2.textFormat.color = 0xff0000;
3.使用htmlText,更方便控制大小、格式、颜色、加图片等。
var txt:textField = new textField();
txt.html = "<font color = '#ff0000'>需要的文本</font>"

建立两个文本框,“字体”为txt1,“颜色”为txt2;
txt1.text="字体";
txt2.text="颜色";
//建立两个文本格式设置变量
var myTextFormat1:TextFormat=new TextFormat();
myTextFormat1.color=0xFF3333;
var myTextFormat2:TextFormat=new TextFormat();
myTextFormat2.color=0x214AEF;
//“字体”为红色
txt1.setTextFormat(myTextFormat1);
//“颜色”为蓝色
txt2.setTextFormat(myTextFormat2);

我只知道 字体代码 都是 #000000 这样的格式 #666666 是灰色 #FF0000 是红色 #0000FF 是蓝色 字母和数字随便写 就是一种颜色 到ps里 可以找合适的颜色

你可以试着用html
如下:
on(press){
a.html=true;
a.htmlText="<font color='#ff0000'>字体</font><font color='#ff00ff'>颜色<