/ Published in: ActionScript 3
URL: http://www.adobe.com/devnet/flash/quickstart/label_component_as3/#section7
I borrowed this example from the link above
Expand |
Embed | Plain Text
// Import the required component classes. import fl.controls.Label; // Create a new instance of the Font1 symbol from the document's library. var myFont:Font = new MyFont(); // Create a new TextFormat object, and set the font and size properties. var myTextFormat:TextFormat = new TextFormat(); myTextFormat.font = myFont.fontName; myTextFormat.size = 8; /* Create a new Label component instance, set the textField.antiAliasType property, set the embedFonts and textFormat styles, and add the label to the display list. */ var myLabel:Label = new Label(); myLabel.text = "The quick brown fox jumped over the lazy dog"; myLabel.autoSize = TextFieldAutoSize.LEFT; myLabel.move(10, 10); myLabel.textField.antiAliasType = AntiAliasType.ADVANCED; myLabel.setStyle("embedFonts", true); myLabel.setStyle("textFormat", myTextFormat); addChild(myLabel);
Comments
Subscribe to comments
You need to login to post a comment.

ooh man... you saved my frickin live!!! had a specific problem with the textfield class that could not be solved...
shouldn't this line: var myFont:Font = new MyFont();
be: var myFont:Font = new Font()
?
Not exaclty. MyFont() is name you assigned the font after importing it into the Library.
Hi I have tried this but my label text disappeared !!
Please, a little hint ??
Many thanks !!
Hi I have tried this but my label text disappeared !!
Please, a little hint ??
Many thanks !!
crmedinar: You'll have to be more specific. I suspect you're having problems with a particular Font but you'll have to give me more information. I'd suggest first trying a basic font like Verdana.