appendHtml() static method
public function appendHtml(textField:TextField, newHtml:String) : void
Scaleform version: 4.0.12
Appends the HTML specified by the newHtml parameter to the end of the text of the text field. This method is more efficient than an addition assignment (+=) on an htmlText property (such as txt.htmlText += moreHtml). The regular += on an htmlText property generates the HTML string, appends the new HTML portion and then parses the entire HTML from scratch. This function does incremental HTML parsing, i.e., it parses only the HTML from the newHtml string parameter (that is why the HTML in the newHtml parameter should be well-formed, which is not necessary for the += operator). It is particularly important for a text field that contains a large amount of content.
Note: This method will not work if a style sheet is applied to the text field.
Parameters
textField:TextField – A textfield to append HTML to.
newHtml:String - The string with HTML to append to the existing text.
setIMEEnabled() static method
static public function setIMEEnabled(textField:TextField, isEnabled:Boolean): void
Scaleform version: 4.0.12
Enables/disables IME for the specified textfield. If isEnabled is set to false, then IME is prevented from being activated in this text field. By default IME is enabled.
Parameters
textField : TextField – A textfield to work with. isEnabled : Boolean – If true – IME enabled; disabled otherwise.
setVerticalAlign() static method
public function setVerticalAlign(textField:TextField, valign:String) : void
Scaleform version: 4.0.12
Sets the vertical alignment of the text inside the text box. Valid values for the property are the following constants declared in TextFieldEx class:
public static const VALIGN_TOP:String = "top"; public static const VALIGN_CENTER:String = "center"; public static const VALIGN_BOTTOM:String = "bottom";
If the property is set to center then text is centered inside the text box, if set to bottom, then text is at the bottom of the text box (see picture below):
The default value is top
Parameters
textField:TextField - A textfield to set vertical alignment
valign:String - Alignment value ("top", "center", "bottom").
getVerticalAlign() static method
static public function getVerticalAlign(textField:TextField) : String
Scaleform version: 4.0.12
Returns the vertical alignment of the text inside the text box.
setImageSubstitutions() static method
public function setImageSubstitutions(textField:TextField, substInfo:Object) : void {}
Scaleform version: 4.0.17
Sets image substitutions for substrings to the text field. Strings substitution works only with images embedded into a SWF; these images also should have assigned linkage in order to have an export name. To embed image into a SWF you need to:
After the image is imported and linkage identifier is assigned, it is necessary to create a BitmapData instance. Here is the example of ActionScript code:
import flash.display.BitmapData; var imageBmp:BitmapData = new myImage;
If more than one image to be used as a substitution you need to repeat these steps for each image, giving different linkage IDs.
The descriptor of the single substitution is the Object with the following members set:
subString:String Specifies the sub-string that will be replaced by image; this member is mandatory. The maximum length of this sub-string is 15 characters.
image : BitmapData Specifies the image; this is mandatory.
width : Number Specifies the width of image on the screen, in pixels. Optional.
height : Number Specifies the height of image on the screen, in pixels. Optional.
baseLineY : Number Specifies the Y-offset of base line in the image, in pixels of original image (without transformation). Optional. By default, this value is equal to image's height; thus, the bottom of the image appears on a baseline.
id : String Specifies the id of the substitution to use as a first parameter for the "updateImageSubstitution" call. Optional.
It is not necessary to keep a reference to the single descriptor object in ActionScript code after setImageSubstitutions is called; however, keep it if it is necessary to refer it somewhere in the ActionScript code, since there is no way to get the array of substitutions back from the text field.
Parameters
textField:TextField- The text field for image substitution.
substInfo:Object – A single substitution descriptor object (see above).
See also: updateImageSubstitution()
Example:
var b1:BitmapData = new smile1; var b2:BitmapData = new smile2; var b3:BitmapData = new smile3; var a = new Array; a[0] = { subString:"=)", image:b1, baseLineY:35, width:20, height:20, id:"sm=)" }; a[1] = { subString:":-)", image:b2, baseLineY:20, id:"sm:-)" }; a[2] = { subString:":\\", image:b3, baseLineY:35, height:100 }; a[3] = { subString:":-\\", image:b1 }; TextFieldEx.setImageSubstitutions(t, a);
As soon as a text field contains a substring "=)", without quotes, this substring will be replaced by the image with "smile1" linkage identifier.
updateImageSubstitution () static method
public function updateImageSubstitution(textField:TextField, id:String, image:BitmapData) : void
Scaleform version: 4.0.17
Replaces or removes the image for the text substitution previously created by the setImageSubstitutions function.
Parameters
textField:TextField- The text field for image substitution.
id:String – An ID of the substitution, same as id member of the descriptor object used for the setImageSubstitutions call.
image:BitmapData – Specifies the new image; if null then the substitution will be removed completely.
See also: setImageSubstitutions()
Example:
TextFieldEx.updateImageSubstitution(t, "sm=)", b3
The following is an example of animation of embedded images. Update may be done in the onEnterFrame handler or using setInterval. Note, no text reformatting occurs when updateImageSubstitution is called; thus, the size of new image should be the same as the old ones.
var phase = 0; var b1a:BitmapData = new smile1a; var b2a:BitmapData = new smile2a; addEventListener(Event.ENTER_FRAME, function() { if (phase % 10 == 0) { if (phase % 20 == 0) { TextFieldEx.updateImageSubstitution(t, "sm=)", b1); TextFieldEx.updateImageSubstitution(t, "sm:-)", b2); } else { TextFieldEx.updateImageSubstitution(t, "sm=)", b1a); TextFieldEx..updateImageSubstitution(t, "sm:-)",b2a); } } ++phase; });
setTextAutoSize() static method
static public function setTextAutoSize(textField:TextField, autoSz:String) : void
Scaleform version: 4.0.12
Enables automatic resizing of the text's font size to shrink or fit the textfield. Valid values for the property are the following constants declared in TextFieldEx class:
public static const TEXTAUTOSZ_NONE:String = "none"; public static const TEXTAUTOSZ_SHRINK:String = "shrink"; public static const TEXTAUTOSZ_FIT:String = "fit";
If the automatic text resize value is shrink or fit and if text doesn’t fit in a text field then size of the text will be decreased proportionally to fit whole text in the text field, thus, no scrolling is necessary. If text size becomes too small (font size is about 5 pt) then the default scrolling logic is still used and no further font size decrease is performed.
Setting the text resize value to fit mode will enable increasing of the font size until the text field is filled with text. Shrink mode can only decrease the font size when text doesn’t fit in the text field; the original font size is not increased.
Parameters
textField:TextField - A textfield to resize the text font size.
autoSz:String - Automatic text resize value ("none", "shrink", "fit").
getTextAutoSize() static method
static public function getTextAutoSize(textField:TextField) : String
Scaleform version: 4.0.12
Returns the value set for automatic resizing of the text's font size to shrink or fit the textfield. Valid values are "none", "shrink", and "fit".
setNoTranslate() static method
static public function setNoTranslate(textField:TextField, noTranslate:Boolean) : void
Scaleform version: 4.0.12
Set a Boolean value to disable auto-translation support for the target textfield (see GFx::Translator). If set to true, prevents Scaleform::GFx::Translator::Translate callback from being called for the text field.
Parameters
textField:TextField - A textfield to resize the text font size.
noTranslate:Boolean - A Boolean value to disable/enable auto-translation.
getNoTranslate() static method
static public function getNoTranslate(textField:TextField) : Boolean
Scaleform version: 4.0.12
Returns the Boolean value to determine whether auto-translation support for the target textfield is disabled or not.
setBidirectionalTextEnabled() static method
static public function setBidirectionalTextEnabled(textField:TextField, en:Boolean) : void
Scaleform version: 4.3.26
Set a Boolean value to enable bidirectional support for the text in the textfield.
Parameters
textField:TextField - A textfield containing the text.
noTranslate:Boolean - A Boolean value to enable/disable bidirectional text support.
getBidirectionalTextEnabled() static method
static public function getBidirectionalTextEnabled(textField:TextField) : Boolean
Scaleform version: 4.3.26
Returns the Boolean value to determine whether enable bidirectional text support is enabled or not.
setSelectionTextColor() static method
static public function setSelectionTextColor(textField:TextField, selColor :uint) : void
Scaleform version: 4.3.26
Set the active selection color of the text.
Parameters textField:TextField - A textfield containing the text. selColor:uint - The color of the text when selected.
getSelectionTextColor() static method
static public function getSelectionTextColor(textField:TextField) : uint
Scaleform version: 4.3.26
Returns the active selection color of the text.
setSelectionBkgColor() static method
static public function setSelectionBkgColor(textField:TextField, selColor:uint) : void
Scaleform version: 4.3.26
Sets the selection background color of the text field.
Parameters
textField:TextField - A textfield containing the text.
selColor:uint - The background color of the textfield when selected.
getSelectionBkgColor () static method
static public function getSelectionBkgColor(textField:TextField) : uint
Scaleform version: 4.3.26
Returns the selection background color of the text field.
setInactiveSelectionTextColor() static method
static public function setInactiveSelectionTextColor (textField:TextField, selColor :uint) : void
Scaleform version: 4.3.26
Set the inactive selection color of the text.
Parameters
textField:TextField - A textfield containing the text.
selColor:uint - The color of the text.
getInactiveSelectionTextColor() static method
static public function getInactiveSelectionTextColor(textField:TextField) : uint
Scaleform version: 4.3.26
Return the inactive selection color of the text.
setInactiveSelectionBkgColor() static method
static public function setInactiveSelectionBkgColor(textField:TextField, selColor:uint) : void
Scaleform version: 4.3.26
Sets the inactive selection background color of the text field.
Parameters textField:TextField - A textfield containing the text.
selColor:uint - The background color of the textfield.
getSelectionBkgColor () static method
static public function getInactiveSelectionBkgColor(textField:TextField) : uint
Scaleform version: 4.3.26
Returns the inactive selection background color of the text field.
setForceVector() static method
static public function setForceVector(textField:TextField, forceVector:Boolean) : void
Scaleform version: 4.3.28
This method allows forcing a certain textfield to be vector text (ie. not rasterized). This is useful, for example in Asian language input text fields, where the user can enter any number of glyphs that would generally not be in the glyph cache.
Parameters
textField:TextField - A textfield that can be forced to be vector text.
noTranslate:Boolean - A Boolean value to enable conversion to vector text.
getForceVector() static method
static public function getForceVector(textField:TextField) : uint
Scaleform version: 4.3.28
Returns whether the textfield is forced to use vector text rendering.