Recipe 8.6 Making a Password Input Field

8.6.1 Problem

You want to create an input text field so that characters entered into it are displayed as asterisks?a feature commonly used on password input fields.

8.6.2 Solution

Set the text field's password property to true.

8.6.3 Discussion

When a user enters a password into a field, you generally do not want observers to be able to read the password. This is a basic security precaution. The common convention is to display only asterisks in the field as the user types. This way, the user can see that he is successfully entering a value without observers being able to easily read the password.

To create an input field that is automatically masked with asterisks, you only need to set the TextField.password property to true:

myTextField.password = true;

When you set the password property to true, all text entered into the text field, either programmatically or by user input, displays as asterisks:

myTextField.password = true;
myTextField.text = "some text";  // Text field displays: *********

8.6.4 See Also

Recipe 8.5. Password text fields only obscure the display of the text; the value contained by the text property is unaltered. Therefore, when you send the password value across an Internet connection, it is not encrypted. If you need additional security when sending the password, you should use HTTPS or use an encryption technique such as a cryptographic hash algorithm, as Branden Hall discusses at Also, read Macromedia Flash Security whitepaper See Recipe 11.19 for information on transmitting data securely.

    Part I: Local Recipes
    Part II: Remote Recipes