FORUMS: list search recent posts

AS3, dynamic textfields, CSS and embeding fonts

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
David Snyder
AS3, dynamic textfields, CSS and embeding fonts
on Aug 20, 2009 at 4:42:33 pm

If this has been asked and answered, my apologies. I haven't seen an exact reference or example with all these combinations at play.

Roughly, I have one SWF loading a CSS file, onComplete it loads another SWF with my embed fonts. When this is complete, textfields are dynamically created, assigned a stylesheet, embed fonts set to true, and populated with HTML.

I am missing something for this to click in my head. Sometimes it works, sometimes like now it fails and I haven't a clue.

When enbedFonts = false, it renders.
When embedFonts = true, the textfields are empty.

Any suggestions? A code snipette after the CSS is loaded and after the font SWF is loaded:

theHeaderLabel = new TextField();
theHeaderLabel.antiAliasType= AntiAliasType.ADVANCED;
theHeaderLabel.embedFonts = true;
theHeaderLabel.autoSize = TextFieldAutoSize.LEFT;
theHeaderLabel.multiline = true;
theHeaderLabel.styleSheet= theCSS.styles;
theHeaderLabel.htmlText =theLabelText ;

theLabelText is equal to the cdata content here:

<header><![CDATA[<p><span class="headers">SOME CONTENT HERE</span></p>]]></header>


Return to posts index

demetri tashie
Re: AS3, dynamic textfields, CSS and embeding fonts
on Aug 22, 2009 at 8:43:37 pm

you will need to make sure that the embedded font is actually a 'font symbol' in your Library for it to
be recognized.

go to your library, and right click to get the menu. use " New Font" and it will take you through the easy steps. choose the font, give it a name . once it is created, choose it in the Library list, and give it a linkage name/class for export ( export for ActionScript).

you then need to do this ( let's say the font's linkage/class was named MyFontName )

var myFont: MyFontName = new MyFontName();
var myTextFormatter:TextFormat = new TextFormat();
var theHeaderLabel:TextField = new TextField();
myTextFormatter.font = myFont.fontName
theHeaderLabel.embedFonts = true;
theHeaderLabel.defaultTextFormat= myTextFormatter;;

then add all the formatting rukles you want.

sorry- i am not anywhere where i can test this - but you should at least get the idea from this.

let us know how it turns out for you.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved