Recipe 8.4. Accepting Password Input


Problem

You want to accept text input from the user, but you want it to display on the screen as asterisks rather than the actual characters to ensure that other users won't be able to read it.

Solution

If you are using a text input component, set the password parameter to TRue.

If you are using an input text field, choose Password from the Line type menu in the Property inspector. Or, alternatively, assign a value of TRue to the instance's password property using ActionScript.

Discussion

Regular input text fields and text input components display all the entered text in plain view of anyone who can view the computer monitor. This is not always a good idea for fields into which the user is supposed to enter information relating to securityinformation such as passwords or credit card numbers. Password fields can be used for any kind of information you don't want to make visible to all people in the same room as the user. Instead of displaying the actual character that the user inputs, a password field displays asterisks to correspond to each character. This way the user can see how many characters they have entered, but not the actual value. This affects only the display of the value, not the actual value itself as it is processed within your Flash movie.

How you create a password field depends on what type of input control you are using. If you are using an input text field, you can make it a password field by selecting the password option from the Line type menu in the Property inspector. Password fields can be only single-line fields.

If you created the input text field at runtime with ActionScript code (or even if you didn't), you can use code to make it a password field. All you need to do is set the password property to true:

 tInputField.password = true; 

You can also make text input component instances into password fields. To do so, select the instance, open the Component Inspector panel, and set the password parameter to true.




Flash 8 Cookbook
Flash 8 Cookbook (Cookbooks (OReilly))
ISBN: 0596102402
EAN: 2147483647
Year: 2007
Pages: 336
Authors: Joey Lott

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net