0
我想知道如何在此代碼中將文本格式更改爲Arial或Futura?在ActionScript 3.0中更改TextField的文本格式
在舞臺上有一個名爲my_text的動態文本框,但試圖從屬性面板更改文本不起作用。
這裏是我的代碼:
//SCROLLING SPEED
var scrolling_speed:int = 10;
//TEXT TO SCROLL
var text_to_scroll:String = "This is my text";
//establish the field
var my_text:TextField = new TextField();
//add the field to stage
addChild(my_text);
//set the text
my_text.text = text_to_scroll;
//set the x coord off right side of stage
my_text.x = stage.stageWidth;
//set y coord in middle of stage (about)
my_text.y = (stage.stageHeight/2)-(my_text.height/2);
//not selectable
my_text.selectable = false;
//no border
my_text.border = false;
//field scales with more text
my_text.autoSize = TextFieldAutoSize.LEFT;
//set a format
var my_text_format:TextFormat = new TextFormat();
//set the color to the hex
my_text_format.color = 0x000000;
//set the font size
my_text_format.size = 24;
//apply formatting
my_text.setTextFormat(my_text_format);
//add the listener to scroll
my_text.addEventListener(Event.ENTER_FRAME,move_text);
//scroll function
function move_text(myevent:Event):void {
my_text.x-=scrolling_speed;
if(my_text.x<(0-my_text.width)){
my_text.x=stage.stageWidth;
}
}
感謝:ActionScript TextFormat.font values - Erik’s Brain
更多關於
defaultTextFormat
和setTextFormat()
我需要的。你知道也許這是一個XML函數,所以我可以從XML文件或TXT文件中獲取文本數據? – user3391599@ user3391599,不幸的是,我還沒有得到答案。你的意思是從外部XML文件中獲取一些文本格式數據,以便以後用它來格式化AS3 TextField? –
不只是基本的信息文本,所以我可以很容易地編輯它 – user3391599