A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: using embedded fonts loaded from swf

  1. #1
    Senior Member
    Join Date
    Feb 2000
    Posts
    226

    using embedded fonts loaded from swf

    I searched around, tried several things but I cannot get this to work.

    My current approach:

    - Created a seperate swf with 2 fonts in the library, linkage "_Arial" and "_ArialBold". "_ArialBold" has the style set to "bold". On the first frame I have:

    Font.registerFont(_Arial);
    Font.registerFont(_ArialBold);

    When I load the swf in my main application and itterate through the list of available fonts the 2 new fonts are returned, but fontName outputs "Arial" in both cases not the linkage name.

    textformat.font = "Arial";

    This works fine, but I can't figure out how to assign the embedded font "_ArialBold" to a textfield. How is this done?

    Thanks,
    Raoul

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    I normally use TextFormat objects to decorate text. TextFields properties really aren't suited for it.

    First you have to create a new instance of your font, then assign it to the .font property of a new text format.

    I would change the linkage class name to proper class name format like Arial and ArialBold

    Then create the instances

    Actionscript Code:
    var _arial = new Arial();
    var _arialBold = new ArialBold();

    Then create the textformats:

    Actionscript Code:
    var arialFormat:TextFormat = new TextFormat();
    arialFormat.font = _arial.fontName;

    ]var arialBoldFormat:TextFormat = new TextFormat();
    arialBoldFormat.font = _arialBold.fontName;

    Then assign them to text fields

    Actionscript Code:
    myTextField:TextField = new TextField();
    myTextField.text = "Some Text";
    myTextField.defaultTextFormat = arialFormat;

  3. #3
    Senior Member
    Join Date
    Feb 2000
    Posts
    226
    Thanks jAQUAN!

    Is the setup of my swf correct if I use this approach?

    Because now I get the error:

    "1180: Call to a possibly undefined method ArialClass"

    on the line:

    var _arial = new ArialClass();

    (I changed the class names to ArialClass and ArialBoldClass)

    On the other hand this class is not available yet as it is part of the at runtime loaded swf so I understand why this error is raised. But how do you avoid this and have the swf correctly compiled?

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