的TextFormat不会做任何事情 [英] TextFormat doesn't do anything

查看:155
本文介绍了的TextFormat不会做任何事情的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code是正确的,但无论如何,反正我的TextFormat不工作,检查后续code。 没有看到我做错了什么。

my code is correct, but anyhow, anyway my textformat does not work, examine follow code. Didnt see what i did wrong.

    //SCROLLING SPEED
var scrolling_speed:int = 2;
//TEXT TO SCROLL

var url:String = "tekst.txt";
var loadit:URLLoader = new URLLoader();
loadit.addEventListener(Event.COMPLETE, completeHandler);
loadit.load(new URLRequest(url));

var my_text:TextField = new TextField();
addChild(my_text);

function completeHandler(event:Event):void
{
    my_text.text = event.target.data as String;
}

//set a format
var format:TextFormat = new TextFormat();
//set the color to the hex
//set the font size
format.size = 24;
format.align = "center";
//apply formatting
my_text.setTextFormat(format);

my_text.x = stage.stageWidth = 50, 0;
//set y coord in middle of stage (about)
my_text.y = stage.stageHeight;
//not selectable
my_text.selectable = false;
//no border
my_text.border = false;
my_text.multiline = true;

my_text.textColor = 0xFFFFFF;
//field scales with more text
my_text.autoSize = TextFieldAutoSize.LEFT;



//add the listener to scroll;
my_text.addEventListener(Event.ENTER_FRAME,move_text);

//scroll function;
function move_text(myevent:Event):void
{
    my_text.y -=  scrolling_speed;
    if (my_text.y<(0-my_text.height))
    {
        my_text.y = stage.stageHeight;
    }
}

对于谁不知道

的字体大小保持小或相同。 而对齐不起作用。 任何帮助将是完美的事情,

The fontsize stays little or the same. and the align doesn't work. Any help would be wonderfull

推荐答案

而不是 my_text.setTextFormat(格式); ,试试 my_text.defaultTextFormat =格式;

这篇关于的TextFormat不会做任何事情的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆