Hi,
I am attempting to change a font in AS3 so that I can eventually
control it from an xml file. I have exported the font for actionscript
and given it the class Font1. The relevant part of my code is below -
it does not error in this state however the font does not change from
its original state. Any ideas? I am new to actionscript.
The larger code I have lifted from here: http://www.krazydad.com/bestiary/bestiary_xml_ticker.html
public function getTickerItem(n)
{
var myFont:Font = new Font1();
var myFormat:TextFormat = new TextFormat();
myFormat.font = myFont;
visible = true;
this.idx = n;
this.tstate = 0;
mc.ticker_txt.embedFonts = true;
mc.ticker_txt.setTextFormat(myFormat); // This is the part of the
code that should change the font??
mc.ticker_txt.htmlText = tickerItems[n].txt;
setupDebut(tickerItems[n].debut);
}
//UPDATE***//
Oop, UPDATE:
The text mc.ticker_txt was getting it’s format from HTML code in an external XML.
Therefore I embedded a standard HTML font:
[Embed(systemFont=‘Verdana’, fontName=“Verdana”, mimeType=“application/x-font-truetype”)]
public static const FONT_VERDANA:String;
Then got rid of some lines:
public function getTickerItem(n)
{
visible = true;
this.idx = n;
this.tstate = 0;
mc.ticker_txt.htmlText = tickerItems[n].txt; //This points to the external xml
setupDebut(tickerItems[n].debut);
}
In the XML I added Font Face Verdana:
<tickeritem >[font color="#FF0000" face=“Verdana”]This is the first item in the xml ticker.[/font]</tickeritem>
Hey presto, it now works! The drawback is it takes longer to load and I get a warning:
Warning: the embedded font ‘Verdana’ may shadow a device font of the same name. Use fontName to alias the font to a different name