/* Create a new folder In that folder create and open a new FLash file (ActionScript 3.0). Select TimeLine --> Top Layer --> Frame 1 Select Window --> Actions (F9) Copy and paste this snippet then continue */ var hi:HelloWorld = new HelloWorld(); addChild(hi); /* Open a new Actionscript file (.as ). Copy and paste this snippet. Save the as file as HelloWorld.as into the folder you created. Execute with Observe the output on the movie player Make the substitutions you see in comments below please. */ package { import flash.display.*; import flash.text.*; public class HelloWorld extends Sprite { public function HelloWorld() { // Time to do some paragraph level formatting. var t:TextField = new TextField(); t.text = "Hello cold, cruel world. \nNo matter what I will not be intimidated. \nI will defeat every syntax error that comes my way. \nI will locate every syntax error. The compilier will not win."; t.wordWrap = true; t.autoSize = TextFieldAutoSize.LEFT; var alignFormat:TextFormat = new TextFormat(); alignFormat.align = TextFormatAlign.CENTER; t.setTextFormat(alignFormat, 0); addChild(t); } } } // From Essential ActionScript by Moock // Now alignment applies to the next paragraph as indicated by the new line (\n). // If we wanted to center the second line, we'd use: // t.setTextFormat(alignFormat, 27); // So that we could apply CENTER to the second paragraph. Counting these is a pain and we // often use dynamic text, so it would be hard to "know" where to align the text. So we // have to determine it programatically. The problem is the technique doesn't generalize well. // By the way, you can also use a beginning and end range but right now that's besides the point. // t.setTextFormat(alignFormat, 29, 123);