Simple Text Field – Code snippet

I find creating text fields a bit tedious at times especially when your setting numerous parameters.

So i created SimpleTextField, it extends TextField and takes up to four parameters, a TextFormat, autosize which is automatically set to left, selectable set to false and anitaliastype set to normal.

These parameters are usually the ones i need to modify on all text fields i create via code, so this class speeds up development quite a bit.

Download and modify to your liking, there are certainly more parameters to be used or removed like embed fonts or even the text to be displayed.

Download: SimpleTextField.as

Code:

package com.arcticcode.greenFlames.text
{
	import flash.text.TextField;
	import flash.text.TextFormat;
 
	public class SimpleTextField extends TextField
	{
		public function SimpleTextField(textFormat:TextFormat=null, autoSize:String = "left", selectable:Boolean = false, antiAliasType:String = "normal")
		{
			super();
			this.autoSize = autoSize;
			this.defaultTextFormat = textFormat;
			this.selectable = selectable;
			this.antiAliasType = antiAliasType;
		}
		public function move(x:Number, y:Number):void
		{
			super.x = x;
			super.y = y;
		}
	}
}
Vote in HexoSearch Vote for this on HexoSearch!

0 Responses to “Simple Text Field – Code snippet”


  • No Comments

Leave a Reply