# Failing to change font of dynamic text AS3

**URL:** <https://forum.kirupa.com/t/failing-to-change-font-of-dynamic-text-as3/321253>\
**Category:** flash\
**Created:** [April 14, 2011, 10:09am UTC](https://forum.kirupa.com/t/failing-to-change-font-of-dynamic-text-as3/321253 "2011-04-14T10:09:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andyjr75](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@Andyjr75](https://forum.kirupa.com/u/Andyjr75)\
**Post date:** [April 14, 2011, 10:09am UTC](https://forum.kirupa.com/t/failing-to-change-font-of-dynamic-text-as3/321253/1 "2011-04-14T10:09:31Z")

</div>

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](http://www.google.com/url?sa=D&q=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
