Joshua Maerten
Joshua Maerten

Reputation: 183

TextFormat doesn't do anything

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;
    }
}

For who dont know

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

Upvotes: 0

Views: 1134

Answers (1)

Steven Mercatante
Steven Mercatante

Reputation: 25295

Instead of my_text.setTextFormat(format);, try my_text.defaultTextFormat = format;

Upvotes: 3

Related Questions