Return to Snippet

Revision: 40550
at April 22, 2011 08:56 by burnandbass


Updated Code
package {
 
	import flash.text.TextField;
	import flash.text.AntiAliasType;
	import flash.text.Font;
	import flash.text.GridFitType;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
 
	public class TextHandle extends TextField{
 
		private var _format:TextFormat;
 
		public function TextHandle(_label:String, _size:uint = 11, _color:uint = 0xFFFFFF) {
 
			_format = new TextFormat();
			_format.font = "Verdana";
			_format.color = _color;
			_format.size = _size;
			_format.align = TextFormatAlign.LEFT;
			
			this.embedFonts = false;
			this.antiAliasType = AntiAliasType.ADVANCED;
			this.autoSize = TextFieldAutoSize.LEFT;
			this.multiline = false;
			this.cacheAsBitmap = true;
			this.selectable = false;
			this.text = _label;
			this.defaultTextFormat = _format;
			this.setTextFormat(_format);
		}
		
		public function get format():TextFormat{
			return _format;
		}
		
		public function refresh():void{
			this.setTextFormat(_format);
		}
 
	}//end
}

Revision: 40549
at February 3, 2011 16:06 by burnandbass


Updated Code
package display {
	/*
	Author: Bassta (Chrysto Panayotov);
	Date: 3 feb 2011
	This is simple textfield handling util
	*/
	
	import flash.text.TextField;
	import flash.text.AntiAliasType;
	import flash.text.Font;
	import flash.text.GridFitType;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	public class TextHandle extends TextField{
		
		private var _format:TextFormat;
		
		public function TextHandle(_label:String, _size:uint = 22, _color:uint = 0x000000) {
			
			_format = new TextFormat();
			_format.font = "Helvetica";
			_format.color = _color;
			_format.size = _size;
			//_format.letterSpacing = 10;
			
			this.embedFonts = false;
			this.antiAliasType = AntiAliasType.ADVANCED;
			this.autoSize = TextFieldAutoSize.LEFT;
			this.selectable = false;
			this.text = _label;
			this.defaultTextFormat = _format;
			this.setTextFormat(_format);
		}

	}//end
}

Revision: 40548
at February 3, 2011 15:16 by burnandbass


Initial Code
package display {
	/*
	Author: Bassta (Chrysto Panayotov);
	Date: 3 feb 2011
	This is simple textfield handling util
	*/
	
	import flash.text.TextField;
	import flash.text.AntiAliasType;
	import flash.text.Font;
	import flash.text.GridFitType;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	public class TextHandle extends TextField{
		
		private var _format:TextFormat;
		
		public function TextHandle(_label:String, _size:uint = 22, _color:uint = 0x000000) {
			
			_format = new TextFormat();
			_format.font = "Helvetica";
			_format.color = _color;
			_format.size = _size;
			//_format.letterSpacing = 10;
			
			this.embedFonts = false;
			this.antiAliasType = AntiAliasType.ADVANCED;
			this.autoSize = TextFieldAutoSize.LEFT;
			this.selectable = false;
			this.text = _label;
			this.setTextFormat(_format);
		}

	}//end
}

Initial URL

                                

Initial Description
Very simple and basic TextHandle class, extends TextField... You can extend to fit your needs.

Basic usage:

var a:TextHandle = new TextHandle("some text");
addChild(a)

Optional params:
 
_size: uint ( default 22 ) - size of the textfiled

_color: uint ( default 0x000000, black ) - the color of the textfield

Initial Title
AS3 TextHandle Util - TextField made easy

Initial Tags
format, text

Initial Language
ActionScript 3