6 Replies Latest reply on Jun 28, 2007 3:26 PM by SymTsb

    Embedding Fonts in AS3

    SymTsb Level 2
      Maybe someone here can help me understand this a bit better.....

      These questions are based on the AS3 Cookbook recipe 9.17 (Embedding Fonts)...

      According to the cookbook, embedding fonts in AS3 requires using the [Embed] metatag "inside an AS file outside the class declaration". I can't figure out (based on the cookbook), what I'm doing wrong... I've attached my entire class so go ahead and see what I'm doing wrong...or not understanding here...

      It's the entire class at this point.... still migrating my stuff from AS2 to AS3....
        • 1. Re: Embedding Fonts in AS3
          SymTsb Level 2
          This is a temp fix but I still would prefer an AS based way of doing it....

          I put a text field off the stage of my shell and embedded the font i needed into my swf that way but I'd like to know how it works just from AS3....
          • 2. Re: Embedding Fonts in AS3
            kglad Adobe Community Professional & MVP
            add a font to your library per usual. assign it a class name, say _arialBold. you can then use:

            • 3. Re: Embedding Fonts in AS3
              SymTsb Level 2
              wow. as usual, thanks k. sometimes I really wish that the people writing these cookbooks were doing so with a final release and not a candidate release of the language. I'm assuming that [Embed] is the metatag used by Flex.... anyways, I now have it working from your code. much appreciated.
              • 4. Re: Embedding Fonts in AS3
                kglad Adobe Community Professional & MVP
                i've never been able to get font embedding to work with the metatag stuff. i assume it works for flex because i see it all over when discussing embedding fonts for as3.
                • 5. Re: Embedding Fonts in AS3
                  vDiaz761
                  SymTsb,

                  Can you provide a working AS and Fla? If not, do you mind posting your code? I'm having similar problems and have been searching for a solution for days now. I tried copying the code above and applying KGlad's suggestion, but it still doesn't work.

                  I went to the library panel and added a new Font. In the name field I added "_arialBold". Then I hit OK. I then right clicked and selected linkage. I checked off "Export for AS"and "Export in first frame". In the class field I put "_arialBold". The base class was "flash.text.Font". In the class you created, I replaced every instance of the word "Vivacious" with "_arialBold". I added KGlads code one line after you defined the TextFormat.

                  In my fla, I imported your class and then created a new instance of your class. I ran the file... blank screen...

                  Help
                  V
                  • 6. Re: Embedding Fonts in AS3
                    SymTsb Level 2
                    The updated code that is working.....