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.

length (TextField.length property)<br />

public length : Number [read-only]<br />

Indicates the number of characters in a text field. This property returns the same value as<br />

text.length, but is faster. A character such as tab (\t) counts as one character.<br />

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

Example<br />

The following example outputs the number of characters in the date_txt text field, which<br />

displays the current date.<br />

var today:Date = new Date();<br />

this.createTextField("date_txt", this.getNextHighestDepth(), 10, 10, 100,<br />

22);<br />

date_txt.autoSize = true;<br />

date_txt.text = today.toString();<br />

trace(date_txt.length);<br />

The MovieClip.getNextHighestDepth() method used in this example requires Flash Player<br />

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

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

maxChars (TextField.maxChars property)<br />

public maxChars : Number<br />

Indicates the maximum number of characters that the text field can contain. A script may<br />

insert more text than maxChars allows; the maxChars property indicates only how much text<br />

a user can enter. If the value of this property is null, there is no limit on the amount of text a<br />

user can enter.<br />

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

Example<br />

The following example creates a text field called age_txt that only lets users enter up to two<br />

numbers in the field.<br />

this.createTextField("age_txt", this.getNextHighestDepth(), 10, 10, 30,<br />

22);<br />

age_txt.type = "input";<br />

age_txt.border = true;<br />

age_txt.maxChars = 2;<br />

age_txt.restrict = "0-9";<br />

1208 <strong>ActionScript</strong> classes

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

Saved successfully!

Ooh no, something went wrong!