As3: Adding a font to a Label component (fl.controls.Label)


/ Published in: ActionScript 3
Save to your folder(s)

I borrowed this example from the link above


Copy this code and paste it in your HTML
  1. // Import the required component classes.
  2. import fl.controls.Label;
  3.  
  4. // Create a new instance of the Font1 symbol from the document's library.
  5. var myFont:Font = new MyFont();
  6.  
  7. // Create a new TextFormat object, and set the font and size properties.
  8. var myTextFormat:TextFormat = new TextFormat();
  9. myTextFormat.font = myFont.fontName;
  10. myTextFormat.size = 8;
  11.  
  12. /* Create a new Label component instance, set the textField.antiAliasType property,
  13.   set the embedFonts and textFormat styles, and add the label to the display list. */
  14. var myLabel:Label = new Label();
  15. myLabel.text = "The quick brown fox jumped over the lazy dog";
  16. myLabel.autoSize = TextFieldAutoSize.LEFT;
  17. myLabel.move(10, 10);
  18. myLabel.textField.antiAliasType = AntiAliasType.ADVANCED;
  19. myLabel.setStyle("embedFonts", true);
  20. myLabel.setStyle("textFormat", myTextFormat);
  21. addChild(myLabel);

URL: http://www.adobe.com/devnet/flash/quickstart/label_component_as3/#section7

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.