03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example<br />

The following example creates a text field called my_txt <strong>and</strong> assigns the text dog@house.net<br />

to the field. The indexOf() method is used to find the first occurrence of the specified<br />

symbol (@). If the symbol is found, the specified text (between the index of 0 <strong>and</strong> the symbol)<br />

replaces with the string bird. If the symbol is not found, an error message is displayed in the<br />

Output panel.<br />

this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320,<br />

22);<br />

my_txt.autoSize = true;<br />

my_txt.text = "dog@house.net";<br />

var symbol:String = "@";<br />

var symbolPos:Number = my_txt.text.indexOf(symbol);<br />

if (symbolPos>-1) {<br />

my_txt.replaceText(0, symbolPos, "bird");<br />

} else {<br />

trace("symbol '"+symbol+"' not found.");<br />

}<br />

If your SWF file includes a version 2 component, use the version 2 components'<br />

DepthManager class instead of the MovieClip.getNextHighestDepth() method, which is<br />

used in this example.<br />

restrict (TextField.restrict property)<br />

public restrict : String<br />

Indicates the set of characters that a user may enter into the text field. If the value of the<br />

restrict property is null, you can enter any character. If the value of the restrict property<br />

is an empty string, you cannot enter any character. If the value of the restrict property is a<br />

string of characters, you can enter only characters in the string into the text field. The string is<br />

scanned from left to right. A range may be specified using the dash (-). This only restricts user<br />

interaction; a script may put any text into the text field. This property does not synchronize<br />

with the Embed Font Outlines check boxes in the Property inspector.<br />

If the string begins with ^, all characters are initially accepted <strong>and</strong> succeeding characters in the<br />

string are excluded from the set of accepted characters. If the string does not begin with ^, no<br />

characters are initially accepted <strong>and</strong> succeeding characters in the string are included in the set<br />

of accepted characters.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 6<br />

TextField 1223

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!