A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Font embed

  1. #1
    Member
    Join Date
    Aug 2000
    Posts
    80

    Font embed

    Hi I am using CS4 and AS2. I have created a font library item and would like to apply it to several dynamic fields. The dynamic fields load HTML formatted text files. I don't know how to make the text appear in my font. Does anyone have any ideas? Thanks in advance...

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    Define a TextFormat and apply that format to the TextField.

  3. #3
    Member
    Join Date
    Aug 2000
    Posts
    80

    Exclamation

    Hi there. That's the problem, I don't know how to do that bit and can't find a simple explanation or sample actionscript. I created a library item called it 'ComingUp', but don't know what to do after that, even if it needs things setting in the linkage, etc.

    Thanks

  4. #4
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    Ok...

    In the Library, right-click on the Font and select Properties. Make sure you have the characters selected you want to embed. Then go to Actionscript, and then Linkage and select "Export for Actionscript" and "Export in frame 1". Give it an identifier of ComingUp.

    Let's say you have a textfield on the stage with an instance name of myText. You'd add this ActionScript:

    Code:
    myFormat=new TextFormat();
    myFormat.font="ComingUp";
    
    myText.text="blah blah blah";
    myText.embedFonts=true;
    myText.setTextFormat(myFormat);

  5. #5
    Member
    Join Date
    Aug 2000
    Posts
    80

    Thumbs up

    Thanks very much. Where you've put 'blah blah...' can I specify an external txt file? Much appreciated

  6. #6
    Member
    Join Date
    Aug 2000
    Posts
    80
    Thanks for your help so far, but I am still really stuck. The font embed works well, but I need to apply it to some text that is loaded dynamically and it won't work. Please could somebody have a look at the code:

    myLoadVars = new LoadVars();
    myLoadVars.onLoad = function() {
    // the data is loaded in the myLoadVars object as a property of the object
    myText.htmlText = myLoadVars.topHTMLdata;
    }
    myLoadVars.load("text1.txt");
    {
    }
    myFormat=new TextFormat();
    myFormat.font="ComingUp";

    myText.text="";
    myText.embedFonts=true;
    myText.setTextFormat(myFormat);

    Thanks again.

  7. #7
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    This line:

    Code:
    myText.text="";
    is erasing any text in the field. Remove that line.

  8. #8
    Member
    Join Date
    Aug 2000
    Posts
    80
    Thanks, but it's doesn't display. I have tried another method, but it won't allow the HTML to display, please take a look at the attached if you have a spare minute.
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center