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 security—information 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 ...

Get Flash 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.