Changing dynamic font via XML data

Hello, wondered if anyone might be able to help…

I am trying to create dynamic text fields in a movie that get their font information from an attribute in an XML document, i.e.


<fontInfo>buttonFont="C:/WINDOWS/Fonts/GOUDYSTO.TTF"</fontInfo>

I want to embed the fonts so that they can be antialiased. I’ve presumed that I need to go down the route of Embedding the font info, using the XML attribute as the value of the ‘source’ variable. The problems are that a) nothing is currently displaying in the dynamic text field and b) I’m not 100% that this is the correct method to use.

This is what I’m doing in my AS, as it stands (inside the Document Class):

[Embed(source="C:/WINDOWS/Fonts/GOUDYSTO.TTF", fontFamily="EmbeddedFont")] 
var EmbeddedFont:Class;
var embeddedFont:Font;
embeddedFont = new EmbeddedFont();
				
var format:TextFormat = new TextFormat();
format.font = embeddedFont.fontName;
format.color = 0x0000FF;
format.size = 32;
				  
var label1:TextField = new TextField();
label1.autoSize = TextFieldAutoSize.LEFT;
label1.wordWrap = true;
label1.defaultTextFormat = format;
label1.embedFonts = true;

label1.text = "Text Label";
myMovieClip.addChild(label1);

I guess the questions are, then:

  • am I barking up completely the wrong tree?

and,

  • what no I need to change if I am on the right lines?

It’s all a little frustrating! Especially as it’s part of a bigger AS3 project that seemed to be going along quite smoothly.

Any advice welcomed…