Class com.sekati.utils.TextUtils

Description

Static class wrapping various Text utilities.

Method Index

antiAlias(), caret(), chop(), create(), excerpt(), focusToggle(), format(), select(), simpleChop(), style()

Method Detail

create

static public function create(scope:MovieClip, instanceName:String, x:Number, y:Number, w:Number, h:Number, props:Object, fprops:Object, css:String):TextField

createTextField wrapper

Parameters

scope(MovieClip) target movieclip scope
instanceName(String) created TextField instance name
x(Number) x pos
y(Number) y pos
w(Number) width
props(Object) object populated with extra props to apply to TextField
fprops(Object) object populated with TextFormat properties to apply to TextField
css(String) CSS Stylesheet to apply; may be either inline css or an external stylesheet url

Return

TextField

 Usage:
 TextUtils.create(_root, "tf", 10, 10, 100, 20, {antiAliasType:"advanced", autoSize:true, embedFonts:false, html:true, htmlText:"hello world", multiline:true, mouseWheelEnabled:true, selectable:false, type:"dynamic", wordWrap:true}, {font:"Verdana",size:9,color:0x000000});
 

format

static public function format(tf:TextField, props:Object, css:String):Void

TextFormat wrapper

Parameters

tf(TextField) target TextField
props(Object) object populated with TextFormat props to apply to TextField

Return

Void

 Usage:
 TextUtils.format(tf, {font:"Verdana",size:9,color:0x000000});
 

style

static public function style(tf:TextField, css:String):Void

TextField.StyleSheet wrapper

Parameters

tf(TextField) target TextField
css(String) CSS Stylesheet to apply; may be either inline css or an external stylesheet url

Return

Void

 Usage:
 TextUtils.style(tf, "css/styles.css");
 TextUtils.style(tf, "a:link{color:#c20b10; text-decoration:none; font-style:italic;} a:hover{color:#363636; text-decoration:underline; font-style:italic;}");
 

focusToggle

static public function focusToggle(tf:TextField):Void

empty a TextField.onSetFocus, restore to default if blank onKillFocus on input textfield

Parameters

tf(TextField) target TextField

Return

Void

 Usage:
 tf.onSetFocus = tf.onKillFocus = function ():Void { TextUtils.focusToggle (tf); };
 

caret

static public function caret(tf:TextField, index:Number):Void

place cursor caret at index of text in textfield

Parameters

tf(TextField) target TextField
index(Number) character number to place caret

Return

Void

 Usage:
 TextUtils.caret (tf, 5);
 

select

static public function select(tf:TextField, sIndex:Number, eIndex:Number):Void

select an area of text with cursor within text

Parameters

tf(TextField) target TextField
sIndex(Number) start character index of selection
eIndex(Number) end character index of selection

Return

Void

 Usage:
 TextUtils.select (tf, 5, 10);
 

antiAlias

static public function antiAlias(tf:TextField, thick:Number, sharp:Number, gridFitType:Number, isAdvanced:Boolean):Void

antiAlias settings for textfield

Parameters

tf(TextField) target TextField
thick(Number) set thickness of antialias [-200 to 200, default:0]
sharp(Number) set sharpness of antialias [-400 to 400, default:0]
gridFitType(Number) 0:["none"-for large fonts & anim] 1:["pixel"-for legibility of left-aligned text] 2:["subpixel"-for right-aligned or centered text] [default: 1]
isAdvanced(Boolean) type of antialias: should be true for anything <48pts [default: true]

Return

Void

 Usage:
 TextUtils.antiAlias (tf, 200, -200, 1, true);
 

excerpt

static public function excerpt(tf:TextField, n:Number, ellipseLine:Boolean):Void

ellipse text after the defined number of lines

Parameters

tf(TextField) target TextField
n(Number) number of lines of text desired
ellipseLine(Boolean) ellipse at exact end of line [true] or after the last full word [false]

Return

Void

chop

static public function chop(tf:TextField, cutW:Number, ellipse:Boolean, longEllipse:Boolean):Void

chop single-line text to width, use optional ellipse

Parameters

tf(TextField) target text
cutW(Number) desired text width
ellipse(Boolean) add ...
longEllipse(Boolean) add ... to end of textField (currently not working)

Return

Void

simpleChop

static public function simpleChop(tf:TextField, maxW:Number, ellipse:Boolean):Void

simple chop single-line text to width, use optional ellipse (unoptimized version of above)

Parameters

tf(TextField) target text
maxW(Number) desired text width
ellipse(Boolean) add ...

Return

Void