Call: (209) 560-6611

How to format a text area in AS3

Date: December 15, 2014 Author: ang Category: Tutorials Tags: , , , , Comments: 0

Below is a main project class that creates a text area instance, adds it to the stage, creates a text area style and applies it to the text area. Formatting a TextArea object is different than formatting a TextField object in AS3.

 Javascript |  copy code |? 
01
package  {
02
 
03
	import flash.display.MovieClip;
04
	import flash.text.TextFormat;
05
	import fl.controls.TextArea;
06
	import fl.managers.StyleManager;
07
 
08
	public class main extends MovieClip {
09
 
10
		//create vars
11
		//create text area object
12
		var myTextArea:TextArea = new TextArea();
13
		//create text area formatting style variable
14
		var myTextFormat:TextFormat = new TextFormat();
15
 
16
		public function main() {
17
			// constructor code
18
			addChild(myTextArea);
19
			myTextArea.x = 30;
20
			myTextArea.y = 30;
21
			myTextArea.setSize(400, 100);
22
			myTextArea.text = "Hello World";
23
			//set style formating variable
24
			myTextFormat.font = "Arial";
25
			myTextFormat.size = 18;
26
			myTextFormat.bold = true;
27
			myTextFormat.italic = true;
28
			myTextFormat.underline = true;
29
			myTextFormat.color = 0xef0000;
30
			//apply style to textarea variable
31
			myTextArea.setStyle("textFormat", myTextFormat);
32
 
33
		}
34
 
35
 
36
	}
37
}
38

Leave a Reply

Your email address will not be published. Required fields are marked *

Before you post, please prove you are sentient.

What do bees make?

Before you post, please prove you are sentient.

what is 2 + 3?