Marcos Placona
Marcos Placona
Developer evangelist at Twilio, GDE and in ❤️ with Open Source
1 min read

Categories

  • Adobe

This is just a quick example of how to add a background colour to a label control in AS3.

Most people don’t know, but the label component has a TextField inside of it. What that means is that you can basically use all of the available methods within the TextField in a label. Here’s an example of how to add a background colour to a label.

import fl.controls.Label;
// If you were doing Playbook development
// import qnx.ui.text.Label;
 
var lblName:Label = new Label();
lblName.textField.background = true;
lblName.textField.backgroundColor = 0xFFFFFF;
addChild(lblName);

And that’s it. You now have a label with a white background. Seems pretty simple, but what is cool here, is the fact that your label can have pretty much the same behaviour as a text field, and you can modify it as you would in a text field.