This code will not render text to the screen. Changing,
drawText.embedFonts = false;
Renders text, but font size doesn't modify or the color.
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.*;
public class DrawText extends Sprite {
private var drawText:TextField;
private var myFormat:TextFormat;
[Embed(source="c:/windows/fonts/verdana.ttf", fontFamily="Verdana", embedAsCFF="false")]
private var verdana:Class;
public function DrawText(mX:int,mY:int){
myFormat = new TextFormat("Verdana");
myFormat.size = 32;
myFormat.color = 0x00FFFF;
drawText = new TextField();
drawText.embedFonts = true;
drawText.autoSize = TextFieldAutoSize.LEFT;
drawText.selectable = false;
drawText.type = "dynamic";
drawText.multiline=true;
drawText.wordWrap=true;
drawText.x = 128;
drawText.y = 128;
drawText.text = "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST";
drawText.defaultTextFormat = myFormat;
addChild(drawText);
}//END constructor
}//END class
}//END package
It's really frustrating any help would be greatly appreciated. I'm using Flash Builder 4.6.
You should apply defaultTextFormat
before the setting of the text
or use TextField.setTextFormat
for the existed text
UPD:
As for the embedFonts
you have to register font class before using:
Font.registerFont(verdana);
UPD2:
Example (modify code in the topic):
//set defaultTextFormat before set text
//and use setTextFormat to format existed text
drawText.defaultTextFormat = myFormat;
drawText.setTextFormat(myFormat);
drawText.text = "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST";