【AS3代码】设置动态文本格式(颜色,大小等等)
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat; //文字格式类
public class Main extends Sprite
{
public function Main():void
{
var format:TextFormat = new TextFormat();
format.bold = true;
format.color = 0xff0000;
format.size = 40;
format.underline = true; //带下划线
format.url = "http://www.baidu.com";
format.target = "_blank";
var txt:TextField = new TextField();
txt.text = "AS3开发";
txt.setTextFormat(format); //格式绑定下
txt.width = 300;
txt.height = 300;
this.addChild(txt);
}
}
}
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat; //文字格式类
public class Main extends Sprite
{
public function Main():void
{
var format:TextFormat = new TextFormat();
format.bold = true;
format.color = 0xff0000;
format.size = 40;
format.underline = true; //带下划线
format.url = "http://www.baidu.com";
format.target = "_blank";
var txt:TextField = new TextField();
txt.text = "AS3开发";
txt.setTextFormat(format); //格式绑定下
txt.width = 300;
txt.height = 300;
this.addChild(txt);
}
}
}