package { import flash.display.*; import flash.display.Sprite; import flash.text.*; public class TitleTest extends Sprite { // Colour Constants private var C_GREY1:uint = 0xCCCCCC; private var C_GREY2:uint = 0xEEEEEE; private var C_WHITE:uint = 0xFFFFFF; private var C_BLACK:uint = 0x000000; // Stage objects public var txf_title:TextField; public function TitleTest():void { SetupStage(); CreateChildren(); } private function SetupStage():void { // Sets 0,0 of coordinate system to TOP/CENTER of stage stage.align = StageAlign.TOP; stage.stageWidth = 800; stage.stageHeight = 600; stage.scaleMode = StageScaleMode.NO_SCALE; } private function CreateChildren():void { var tf:TextFormat; // Title txf_title = new TextField(); txf_title.htmlText = "Title Test - My First TextField"; txf_title.width = 500; txf_title.autoSize = TextFieldAutoSize.CENTER; tf = txf_title.getTextFormat(); tf.font = "Arial"; tf.size = 14; txf_title.setTextFormat(tf); addChild(txf_title); // Background to title graphics.lineStyle(1, C_GREY1); graphics.beginFill(C_GREY2); graphics.drawRect(0, 0, 500, 30); } } }