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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

In the following example, the text field focuses on the username_txt text field when it is<br />

running in a browser window. If the user does not fill in one of the required text fields<br />

(username_txt <strong>and</strong> password_txt), the cursor automatically focuses in the text field that's<br />

missing data. For example, if the user does not type anything into the username_txt text<br />

field <strong>and</strong> clicks the submit button, an error message appears <strong>and</strong> the cursor focuses in the<br />

username_txt text field.<br />

this.createTextField("status_txt", this.getNextHighestDepth(), 100, 70,<br />

100, 22);<br />

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

100, 22);<br />

this.createTextField("password_txt", this.getNextHighestDepth(), 100, 130,<br />

100, 22);<br />

this.createEmptyMovieClip("submit_mc", this.getNextHighestDepth());<br />

submit_mc.createTextField("submit_txt", this.getNextHighestDepth(), 100,<br />

160, 100, 22);<br />

submit_mc.submit_txt.autoSize = "center";<br />

submit_mc.submit_txt.text = "Submit";<br />

submit_mc.submit_txt.border = true;<br />

submit_mc.onRelease = checkForm;<br />

username_txt.border = true;<br />

password_txt.border = true;<br />

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

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

password_txt.password = true;<br />

Selection.setFocus("username_txt");<br />

//<br />

function checkForm():Boolean {<br />

if (username_txt.text.length == 0) {<br />

status_txt.text = "fill in username";<br />

Selection.setFocus("username_txt");<br />

return false;<br />

}<br />

if (password_txt.text.length == 0) {<br />

status_txt.text = "fill in password";<br />

Selection.setFocus("password_txt");<br />

return false;<br />

}<br />

status_txt.text = "success!";<br />

Selection.setFocus(null);<br />

return true;<br />

}<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 />

Selection 1093

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

Saved successfully!

Ooh no, something went wrong!