
TextField.restrict Property
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
861
// If a text field was the last object focused...
if (eval(oldFocus) instanceof TextField) {
// ...focus it
Selection.setFocus(oldFocus);
// Then set the selection and insert the new text
Selection.setSelection(oldBegin, oldEnd);
eval(oldFocus).replaceSel("text to insert");
}
}
Example
Example R-6 adds an appendText() method to all TextField objects. The method inserts
new text at the end of the field, using replaceSel().
Reader Exercise: Adapt the appendText() handler from Example R-6, or use the example
from this entry’s Description, to create a custom replaceText() function that accepts
starting and ending character indexes to specify the character span to be replaced.
See Also
Selection.setFocus(), Selection.setSelection(), TextField.setNewTextFormat(), TextField.text
TextField.restrict Property
limit text entry to a series of characters
Flash 6
read/write
theField.restrict = restrictedChars;
Arguments
restrictedChars
Although not strictly an argument,
restrictedChars is a string containing the
allowable characters for the field.
Example R-6. Custom appendText() function using replaceSel()
/*
* Method: TextField.appendText
* Desc: A convenient method for appending text to a
* text field without disturbing its formatting.