5
votes

I would like to preface this wall of text by saying, I am very new at this. I may be missing something obvious.

I'm working in Flash CS5 with Actionscript 3. I'm trying to use actionscript to create a textfield, and populate it with text. I've embedded my font in my project using the "Font Embedding" window. However, when the code to create the textfield is run, if "embedFont = true;", the font is invisible. The cursor still changes when hovering over it, so I know it's there. Or at least its text box is, I guess. Dynamic textfields with embedded text which are already on the stage seem to be unaffected.

I've tried changing the embedded fonts outline format, neither work. I've tried directly embedding the font with the "embed" tag via actionscript, but it doesn't seem to work with CS5, or I don't know what I'm doing. As you can see in the code provided, I've tried "registering" the font, with no success. I've tried using:

var font:Font = new screenfont(); //"screenfont" is the name from Embedding Fonts    

var format:TextFormat = new TextFormat();

format.font = screenfont.fontName;

No dice.

I've followed some different tutorials about embedding, and come across a wealth of conflicted, confusing information. I've read a few different posts pertaining to this subject, but haven't found any viable solutions as of yet.

Here's a simple version of my code, where "screenfont" is the name I specified in the Embedding Fonts window:

Font.registerFont(screenfont);

            //TextFormat
var listformat:TextFormat = new TextFormat();

listformat.align = TextFormatAlign.LEFT;
listformat.size = 20.8;
listformat.color = 0x0DAC54;
listformat.font="Fixedsys Excelsior 3.01";


           //TextField
var photolist:TextField = new TextField();
    photolist.x = photos_x;
    photolist.y = tempY;
    photolist.width = photos_wdth;
    photolist.height = photos_hght;
    photolist.text = photoname;

    photolist.embedFonts = true; //<--- This freakin' guy!

    photolist.antiAliasType = AntiAliasType.ADVANCED;
    photolist.defaultTextFormat=listformat;
    photolist.selectable = false;
    photolist.wordWrap =  true;

    mediapage.photos.addChild(photolist);

I hope this provides a clear picture.

So, how exactly is embedding accomplished in CS5?

1
Have you declared your chosen font in your swf's library? If so, have you selected the glyphs to embed as well?ToddBFisher
Yes, and yes. I've checked 'export for actionscript' and 'export in frame 1' as well.TeaCake
There's nothing wrong with the code. Have you tried using another font?Pixel Elephant
That would probably be a smart thing to do... Okay, I just tried a couple of different fonts, with no luck. I've noticed that with "embedFont=false", the size specified in my TextFormat is completely ignored. I don't know if that's normal or not though. Also with "embedFont=false", the font doesn't show up at all, despite being installed on my computer. I just get some default 'Times' looking affair. Maybe that's a clue?TeaCake
@TeaCake Yeah that was a clue - looks like I read your code too fast the first time and missed what was causing the problem.Pixel Elephant

1 Answers

4
votes

You should set the text as the last thing you do. So this line photolist.text = photoname; should be after everything else.

var photolist:TextField = new TextField();
photolist.x = photos_x;
photolist.y = tempY;
photolist.width = photos_wdth;
photolist.height = photos_hght;

photolist.embedFonts = true; 
photolist.antiAliasType = AntiAliasType.ADVANCED;
photolist.defaultTextFormat=listformat;
photolist.selectable = false;
photolist.wordWrap =  true;
photolist.text = photoname;//<-- set text only after applying all formatting and embedding

mediapage.photos.addChild(photolist);