Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Checkbox and radio button text colour

New Here ,
Feb 05, 2014 Feb 05, 2014

Hi

This might be a really simple question but I can't find the answer anywhere?!

How can I change the colour of the labels on checkboxes and radio buttons?

I tried this:

a1.setStyleProperty("textColor",0x990000);

but I get this error:

1061: Call to a possibly undefined method setStyleProperty through a reference with static type fl.controls:RadioButtonGroup.

can anyone help?

Thank you! : )

TOPICS
ActionScript
685
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 05, 2014 Feb 05, 2014

You should use TextFormat class to assign text formatting...

var newFormat:TextFormat = new TextFormat();
// whatever font styles you want to apply

newFormat.color = 0xFF0000;

a1.setStyle("textFormat", newFormat);

Translate
Guru ,
Feb 05, 2014 Feb 05, 2014

you wrote as2, try this one:

a1.setStyle("color",0x990000);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 05, 2014 Feb 05, 2014

You should use TextFormat class to assign text formatting...

var newFormat:TextFormat = new TextFormat();
// whatever font styles you want to apply

newFormat.color = 0xFF0000;

a1.setStyle("textFormat", newFormat);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 05, 2014 Feb 05, 2014

Many thanks - thats worked perfectly.

Is there a way to target all the checkboxes and radiobuttons rather than indvidually?

Thank you so much

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 05, 2014 Feb 05, 2014

You're welcome.

The only way I know of targeting all checkboxes is to use a loop.  You could name them in a manner that allows you to use bracket notation to target them.  For instance, if you were to name them... a1, a2, a3, etc....

for(var i:int=1; i<=numCheckboxes; i++){

     this["a"+String(i)].setStyle("textFormat", newFormat);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 05, 2014 Feb 05, 2014
LATEST

Brilliant! - thanks once again!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines