Skip to main content
Known Participant
July 14, 2009
Question

Am I trying the impossible?

  • July 14, 2009
  • 2 replies
  • 749 views

I wish to format the text that appear in a List component as shown below and it's not working.

var lb = new TextFormat();

     lb.bold = true;
     lb.align = TextFieldAutoSize.CENTER
     lb.color = 0x000066;

var anHeading = new Label()

     anHeading.text = "Answers"
     anHeading.setSize(200,22)
    anHeading.setStyle("textFormat",lb);
     anHeading.move(10,78);
     addChild(anHeading)

This topic has been closed for replies.

2 replies

Craig Grummitt
Inspiring
July 14, 2009

Describe 'not working'.

I just created a new flash file, dragged a Label component to the library, pasted your code and added import statements at the beginning and it works as expected.

import fl.controls.Label;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
MwalimoAuthor
Known Participant
July 14, 2009

Craig, I made a mistake. Sorry. The code I meant to send is given below. With the Label component, the formating works, but I am not sure whether it works on a List component.

var lb:TextFormat = new TextFormat();
     lb.bold = true;
     lb.align = TextFieldAutoSize.CENTER
     lb.color = 0x000066;

//Apply formating on a List component

var sqsL:List = new List();
     sqsL.rowHeight = 44;
     sqsL.setSize(200,22);
     sqsL.setStyle("textFormat",lb);
     sqsL.move(10,300);

     addChild(sqsL)

MwalimoAuthor
Known Participant
July 14, 2009

Ok, here is the solution. For a List it's is setRendererStyle as opposed to setStyle. Thanks all for listening.

myTileList.setRendererStyle("textFormat", tf);

Ned Murphy
Legend
July 14, 2009

You may have to set the text foirmatting on the textField property of the Label.