O'Reilly logo

Actionscript Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.4. Creating a Background for a Text Field

Problem

You want to make a visible background behind the text in a text field.

Solution

Set the text field’s background property to true. Additionally, you can change the color of the background by setting the object’s backgroundColor property.

Discussion

Text fields lack a visible background by default (in other words, the background is transparent). However, you can create a background for a text field by setting the background property to true for that object:

myTextField.background = true;

By default, the background for a text field is white (if made visible). You can, however, assign the background color by setting the value of the object’s backgroundColor property, which accepts a hex RGB value corresponding to the desired color:

myTextField.backgroundColor = 0x00FFFF; // Set the background to light blue.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required