Recipe 9.4. Making a Password Input Field


Problem

You want to create a password-style text field that hides the characters as asterisks. You also want to disable copying from the text field.

Solution

Set the text field's password property to true.

Discussion

When a user enters a password into a field, you generally want to make it so others aren't 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 she is successfully entering a value without anyone else being able to easily read what she's just typed.

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

field.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:

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

Password text fields also disable copying from the text field. That prevents a user from being able to copy passwords or similar data and then paste it into a plain text document.

Password text fields are most commonly also input text fields; however, you can set the password property to TRue for a dynamic text field as well.

Although password text fields hide the data from the display, they do not encrypt the data or make it more secure for sending over a network. If data security is important to your application, you must use technologies that make data secure as it is transferred over a network. If you send data from Flash using standard HTTP, then the data is sent in an unsecured fashion. Use a technology such as SSL if you must send data in a secure fashion.





ActionScript 3. 0 Cookbook
ActionScript 3.0 Cookbook: Solutions for Flash Platform and Flex Application Developers
ISBN: 0596526954
EAN: 2147483647
Year: 2007
Pages: 351

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