A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Change text properties of Checkbox component

  1. #1
    Junior Member
    Join Date
    Apr 2003
    Posts
    3

    Change text properties of Checkbox component

    I am trying to change the text properties(font, color, size) of the text appears next to the checkbox component. I am not interested in doing a global change to the component. I've read the flash tutorials, and tried a few things, but haven't got it to work yet. Thanks for the help!

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    you have two options.
    1)
    in the Library, open the FLabel component and change the textfield instance - labelField to your color, size, .....

    2) use a styleFormat and add a Listener to your checkbox
    code:


    uiStyle0 = new FStyleFormat;
    uiStyle0.textColor = 0x660066;
    uiStyle0.textSize = 16;
    uiStyle0.textFont = "Arial Black";
    uiStyle0.textBold = true;
    uiStyle0.addListener(checkbox1,checkbox2);
    uiStyle0.applyChanges();


  3. #3
    Junior Member
    Join Date
    Feb 2008
    Posts
    7
    I'm really struggling with this also.

    Are you able to use either of these 2 methods in Flash v9?

    I've tried using the styleFormat method you suggested, but the font and text colour do not change. I couldn't find the FLabel component in my library either.

    Can you please provide the full code you used so I can see what I'm doing wrong.

    Thanks in advance!

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    code above is for MX version 6
    i do not have version 9 so cannot comment.

  5. #5
    Junior Member
    Join Date
    Feb 2008
    Posts
    7
    Okay, thanks modified dog.

    Does anyone have a solution to this problem for Flash v9?

  6. #6
    Junior Member
    Join Date
    Feb 2008
    Posts
    7
    Anyone pro's use Flash version 9 out there?

  7. #7
    Junior Member
    Join Date
    May 2009
    Posts
    1
    I'm sure you've already received tons of answers to this question, but in Flash 9 you can change the fl.controls.CheckBox control in this manner with Actionscript 3:

    // This is one of my drop shadow check boxes. I change the label to
    // appear on the left hand side. Additionally, I register my embedded
    // fonts in the main application file using the Flash API's Font.registerFont
    // method after exporting the fonts in my asset FLA.

    var dsCb:CheckBox = new CheckBox();
    dsCb.label = 'Drop Shadow';
    dsCb.labelPlacement = 'left';
    dsCb.setStyle('embedFonts', true);
    dsCb.setStyle('textFormat', new TextFormat('Trebuchet MS Bold', 16, 0xFFFFFFF));
    dsCb.width = 120; // Note: this will change the textfield width, which allows the text field to be fully displayed. Otherwise it truncates if the width is exceeded.
    dsCb.addEventListener(Event.CHANGE, useDropShadow);

    So I know I added some extra code in there, but to change the size and color, simply set the textFormat style of the check box with a new TextFormat object with the desired color and size. Although this reply occurred over a year later, hope this helps someone!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center