Marcos Placona Blog

Programming, technology and the taming of the web.

Background colour in a label control in AS3

Reading time: 1 – 2 minutes

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;

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.

1 Comment

  1. It seems to be buggy, I tried to use in inside a condition and the colored cells which is the output isn’t at correct places. Also, when I scroll up/down the dataGrid, the colored cell just became transparent.

    override public function set data(value:Object):void{
    if(tonnage != 0 && nominal != 0 && tonnage > nominal){
    // Display results in light red.
    this.textField.background = true;
    this.textField.backgroundColor = 0xFF895C;

1 Pingback

  1. Background colour in a label control in AS3 | Digital blog

Leave a Reply

Your email address will not be published.