Question

When i press a button it will display text, but how would i add style? such as position and color.

import flash.text.TextField;

var tf:TextField= new TextField();


convob.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{

tf.text="hello world";


addChild(tf);

}
Was it helpful?

Solution

Something like this:

var format:TextFormat = new TextFormat();
format.color = 0x555555;
format.size = 18;
format.align = TextFormatAlign.CENTER;
format.bold = false;
tf.setTextFormat(format);

Check class reference for TextFormat: http://help.adobe.com/en_GB/FlashPlatform/reference/actionscript/3/flash/text/TextFormat.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top