The following example shows how you can use an embedded font with the Flash ActionScript 3.0 CheckBox control by setting the textFormat and embedFonts styles.
Full code after the jump.
Note: The following example requires a CheckBox control in your Flash document’s library, as well as an embedded font with the linkage class set to “MyFont”.
// ActionScript 3.0 /* Requires: * - A CheckBox control in Flash library. * - An embedded font in Flash library with linkage class "MyFont". */ import fl.controls.CheckBox; var embeddedFont:Font = new MyFont(); var textFormat:TextFormat = new TextFormat(); textFormat.font = embeddedFont.fontName; textFormat.size = 24; var checkBox:CheckBox = new CheckBox(); checkBox.setStyle("textFormat", textFormat); checkBox.setStyle("embedFonts", true); checkBox.label = "The quick brown fox jumps over the lazy dog."; checkBox.textField.autoSize = TextFieldAutoSize.LEFT; checkBox.move(10, 10); checkBox.validateNow(); addChild(checkBox);
{ 6 comments… read them below or add one }
Hello, that’s good if I want to change the font and size of the text of the checkbox, but if I want to use the checkbox to change the font and size of the text in a textarea, how I’m suppose the write the code?
David,
Here’s some rough code (written in ActionScript 3.0).
To run this example, drag two CheckBox controls onto the Stage and give them instance names of ‘checkBox1′ and ‘checkBox2′. Next, drag a TextArea control onto the Stage and give it an instance name of ‘textArea’. Clicking the first CheckBox control should toggle the font family between “Times New Roman” and “Arial”. Clicking the second CheckBox control should toggle the font size between 12px and 20px.
Peter
My god, you are quick like hell…
Seems so easy…when it’s write.
Thank you, I will try to understand every part.
SENT ME THREE CHECK BOX FILE IN FLASH
THANKS
How we can change the font of check box in action script 2.0.
Please guide….