Packagesekati.utils
Classpublic class TextUtil

Static class wrapping various Text utilities.



Public Methods
 MethodDefined by
  
TextUtil Static Constructor
TextUtil
  
clearFields(o:DisplayObject):void
[static] Clear a TextField text or to all TextField's texts in a DisplayObject.
TextUtil
  
createField(str:String, x:Number = 0, y:Number = 0, width:Number = 200, height:Number = 20, multiline:Boolean = false, font:String = "Verdana", size:Number = 9, color:uint = 0, autoSize:String = "left", embedFonts:Boolean = false, selectable:Boolean = false, css:StyleSheet = null):TextField
[static] Create a TextField instance and return it.
TextUtil
  
formatFields(o:DisplayObject, textFormat:TextFormat):void
[static] Apply a TextFormat to a TextField or to all TextField's in a DisplayObject.
TextUtil
  
getUsableFonts(desiredFontList:Array):Array
[static] Searches the client's available fonts to see if any of the Font from the desiredFontList are available.
TextUtil
  
hideFields(... args):void
[static] Hide a TextField or TextField's from display (visible false, alpha 0).
TextUtil
  
revealFields(... args):void
[static] Reveal a TextField or TextField's (visible true, alpha 1)
TextUtil
  
setFormattedText(tf:TextField, str:String, autoSize:Boolean = true):void
[static] Set the text of a TextField while preserving the formatting (leading, kerning, etc).
TextUtil
  
setStyledText(tf:TextField, str:String, stylesheet:StyleSheet = null):void
[static] Apply a StyleSheet to a TextField & set its contents.
TextUtil
  
setTextColor(tf:TextField, color:uint, backgroundColor:Number, borderColor:Number):void
[static] Set the TextField color formatting.
TextUtil
  
setTextFont(tf:TextField, fontName:String, fontSize:Number, isEmbedFont:Boolean = false, isBold:Boolean = false, isItalic:Boolean = false, isUnderline:Boolean = false):void
[static] Set the TextField font formatting.
TextUtil
  
setTextLeading(tf:TextField, space:Number = 0):void
[static] Set the TextField leading formatting.
TextUtil
  
setTextLetterSpacing(tf:TextField, spacing:Number = 0):void
[static] Set the TextField letter spacing formatting.
TextUtil
  
setTextSpaceWidth(tf:TextField, space:Number = 1):void
[static] Set the TextField's width for space characters.
TextUtil
  
styleFields(o:DisplayObject, stylesheet:StyleSheet = null):void
[static] Apply the application stylesheet to a TextField or to all TextField's in a DisplayObject.
TextUtil
  
truncateMultilineText(tf:TextField, numAlllowedLines:uint, isEllipsed:Boolean = true):void
[static] Truncate a multiline TextField after the defined number of lines of text.
TextUtil
  
truncateText(tf:TextField, maxWidth:Number, isEllipsed:Boolean = true, isLineEllipse:Boolean = false):void
[static] Truncate a single-line TextField to a specific width.
TextUtil
Constructor detail
TextUtil()constructor
public function TextUtil()

TextUtil Static Constructor

Method detail
clearFields()method
public static function clearFields(o:DisplayObject):void

Clear a TextField text or to all TextField's texts in a DisplayObject.

Parameters
o:DisplayObjectDisplayObject that either is or contains TextField's.
createField()method 
public static function createField(str:String, x:Number = 0, y:Number = 0, width:Number = 200, height:Number = 20, multiline:Boolean = false, font:String = "Verdana", size:Number = 9, color:uint = 0, autoSize:String = "left", embedFonts:Boolean = false, selectable:Boolean = false, css:StyleSheet = null):TextField

Create a TextField instance and return it.

Parameters
str:String
 
x:Number (default = 0)
 
y:Number (default = 0)
 
width:Number (default = 200)
 
height:Number (default = 20)
 
multiline:Boolean (default = false)
 
font:String (default = "Verdana")
 
size:Number (default = 9)
 
color:uint (default = 0)
 
autoSize:String (default = "left")
 
embedFonts:Boolean (default = false)
 
selectable:Boolean (default = false)
 
css:StyleSheet (default = null)

Returns
TextField
formatFields()method 
public static function formatFields(o:DisplayObject, textFormat:TextFormat):void

Apply a TextFormat to a TextField or to all TextField's in a DisplayObject.

Parameters
o:DisplayObjectDisplayObject that either is or contains TextField's.
 
textFormat:TextFormat — to apply to the TextField's.
getUsableFonts()method 
public static function getUsableFonts(desiredFontList:Array):Array

Searches the client's available fonts to see if any of the Font from the desiredFontList are available.

Parameters
desiredFontList:Array — array of desired fontName's.

Returns
Array — array of desired fonts which are available for use on the client's system.
hideFields()method 
public static function hideFields(... args):void

Hide a TextField or TextField's from display (visible false, alpha 0).

Parameters
... args

See also

revealFields()method 
public static function revealFields(... args):void

Reveal a TextField or TextField's (visible true, alpha 1)

Parameters
... args

See also

setFormattedText()method 
public static function setFormattedText(tf:TextField, str:String, autoSize:Boolean = true):void

Set the text of a TextField while preserving the formatting (leading, kerning, etc). XXX - Warning: htmlText and styles can break the formatting: no known fix as of yet.

Parameters
tf:TextField
 
str:String
 
autoSize:Boolean (default = true)
setStyledText()method 
public static function setStyledText(tf:TextField, str:String, stylesheet:StyleSheet = null):void

Apply a StyleSheet to a TextField & set its contents.

Parameters
tf:TextFieldTextField to display.
 
str:String — of text to apply.
 
stylesheet:StyleSheet (default = null) — to apply to the TextField's (Default: App.css).

See also

setTextColor()method 
public static function setTextColor(tf:TextField, color:uint, backgroundColor:Number, borderColor:Number):void

Set the TextField color formatting.

Parameters
tf:TextField
 
color:uint
 
backgroundColor:Number
 
borderColor:Number
setTextFont()method 
public static function setTextFont(tf:TextField, fontName:String, fontSize:Number, isEmbedFont:Boolean = false, isBold:Boolean = false, isItalic:Boolean = false, isUnderline:Boolean = false):void

Set the TextField font formatting.

Parameters
tf:TextField
 
fontName:String
 
fontSize:Number
 
isEmbedFont:Boolean (default = false)
 
isBold:Boolean (default = false)
 
isItalic:Boolean (default = false)
 
isUnderline:Boolean (default = false)
setTextLeading()method 
public static function setTextLeading(tf:TextField, space:Number = 0):void

Set the TextField leading formatting.

Parameters
tf:TextField
 
space:Number (default = 0)
setTextLetterSpacing()method 
public static function setTextLetterSpacing(tf:TextField, spacing:Number = 0):void

Set the TextField letter spacing formatting.

Parameters
tf:TextField
 
spacing:Number (default = 0)
setTextSpaceWidth()method 
public static function setTextSpaceWidth(tf:TextField, space:Number = 1):void

Set the TextField's width for space characters.

Parameters
tf:TextField
 
space:Number (default = 1)
styleFields()method 
public static function styleFields(o:DisplayObject, stylesheet:StyleSheet = null):void

Apply the application stylesheet to a TextField or to all TextField's in a DisplayObject.

Warning: Unlike formatFields you must reset your htmlText to have the style applied.

Parameters
o:DisplayObjectDisplayObject that either is or contains TextField's.
 
stylesheet:StyleSheet (default = null) — to apply to the TextField's (Default: App.css).

See also

truncateMultilineText()method 
public static function truncateMultilineText(tf:TextField, numAlllowedLines:uint, isEllipsed:Boolean = true):void

Truncate a multiline TextField after the defined number of lines of text.

Parameters
tf:TextFieldTextField to truncate.
 
numAlllowedLines:uint — before the remaining text is removed.
 
isEllipsed:Boolean (default = true) — determines whether the text is ended with "..." or not.
truncateText()method 
public static function truncateText(tf:TextField, maxWidth:Number, isEllipsed:Boolean = true, isLineEllipse:Boolean = false):void

Truncate a single-line TextField to a specific width.

Parameters
tf:TextField — the textfield to truncate.
 
maxWidth:Number — the desired text width to truncate at.
 
isEllipsed:Boolean (default = true) — denotes whether to truncate with the ellipse char "...".
 
isLineEllipse:Boolean (default = false) — gives the option to "ellipse" the entire width of the field.