Skip to main content
oluc
Known Participant
April 12, 2010
Question

text not showing up when publishing

  • April 12, 2010
  • 3 replies
  • 1986 views

Hello.

I cant for the life of me figure out why text is not showing up when I publish. I get no errors. And I DO have the font exported for AS in the FLA file.

Do you see what I am doing wrong?

package asFiles.stageElements{
    
     import flash.display.*;
     import flash.text.*;
    
     public class Titles extends Sprite {
         
          public var titleHolder:Sprite;
         
          public var titleFormat:TextFormat;
          public var titleField:TextField;
         
          public var textTitle:String = new String ("TITLE");

         
          public function Titles() {
               setFormat();
          }
         
          public function setFormat():void {
              
               titleFormat = new TextFormat();
               titleFormat.color = 0xffffff;
               titleFormat.font = "Helvetica";
               titleFormat.letterSpacing = 4;
               titleFormat.size = 12;
               titleFormat.align = TextFormatAlign.CENTER;
              
               createTitle();
          }
         
          public function createTitle():void {
              
               titleField = new TextField();
               titleField.text = textTitle;
               titleField.setTextFormat(titleFormat);
               titleField.autoSize = TextFieldAutoSize.CENTER;
               titleField.selectable = false;
               titleField.antiAliasType = AntiAliasType.ADVANCED;
               titleField.embedFonts = true;
               titleField.width = 900;

                        titleField.x -= titleField.width/2;
              
               titleHolder = new Sprite;
               titleHolder.y = 190;
               titleHolder.x = 640;
               titleHolder.addChild(titleField);
               addChild(titleHolder);
          }
         
     }
}

If you take a look at this I appreciate it! and if you are able to help me I appreciate it even more!  : )

This topic has been closed for replies.

3 replies

Inspiring
April 12, 2010

What is the class name for the font you embedded into the library?

oluc
olucAuthor
Known Participant
April 12, 2010

Helvetica

Inspiring
April 12, 2010

First, I think you should rename class to something else. Say, _helvetica. Try to instantiate the font first to put it to the list of fonts (the mere presence in the library doesn't make font available to Flash):

So, in the class library you need to write:

var usedFont:Font = new Helvetica(); // (or new _helvetica() if you follow my advice);

For the text format:

titleFormat.font = usedFont.fontName;

Inspiring
April 12, 2010

Just out of curiousity try titleField.defaultTextFormat(titleFormat); as opposed titleField.setTextFormat(titleFormat);

oluc
olucAuthor
Known Participant
April 12, 2010

okay, so I tried titleField.defaultTextFormat = titleFormat;

and still no result and no error.

April 12, 2010

Hi!

You didn't emed Helvetica font. To do it, type the following code above variable definitions:

[Embed(source="c:/windows/fonts/helvetica.ttf", fontFamily="Helvetica")]
private var helvetica:Class;

Of course in source put the actual path to your font file.

Additionaly put

titleField.embedFonts = true;

before

titleField.setTextFormat(titleFormat);

Regards,

gc

oluc
olucAuthor
Known Participant
April 12, 2010

Hey thanks.

Well, I embed' the font in the fla file and exported it for use as a class.

Thanks for the tip on putting embedFont before setTextFormat.

I am still not able to get it to work though. But the funny thing is that I basically copied the code from an another .as file I programmed which added text. and that other file works totally fine. : (

anyother ideas or knowlege as to why this is not working?

tks.