PDA

View Full Version : text formatting not working...


colfaxrev
07-23-2008, 11:17 PM
:confused:


package com.Objects
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;

public class Text extends Sprite
{
private var p_myText:TextField;


public function Text()
{
p_myText = new TextField();
}
public function setWidth(w:int):void
{
p_myText.width = w;
}
public function setHeight(h:int):void
{
p_myText.height = h;
}
public function setText(str:String, font:String, color, size:int):void
{
trace('setText() str['+str+'] font['+font+'] color['+color+'] size['+size+']');
p_myText.text = str;
p_myText.autoSize = TextFieldAutoSize.LEFT;
p_myText.background = false;
p_myText.multiline = true;
p_myText.wordWrap = true;
p_myText.border = false;

var format:TextFormat = new TextFormat();
format.font = str;
format.color = color;
format.size = size;
//format.underline = true;

p_myText.defaultTextFormat = format;

addChild(p_myText);
}
}
}


for some reason none of my text formatting is being applied to the text... it's like the TextFormat object does nothing...

what am i doing wrong...?

bloodstyle
07-24-2008, 12:02 AM
Put in a setTextFormat(format) after the defaultTextFormat line, or replace with that depending on what you want. defaultTextFormat doesn't change the formatting of any text in the field already.