title: embedding a font in a swf using as3
body: <p>I have a project using flash (and AIR for android and eventuall iOS) for translating some phrases. Although most fonts are fine there are some that I have to load after the user has chosen the languages. Over a year ago I generated a couple of swf files (Bengali and Urdu) and put them on my web server. The flash application then loads them when required and everything is OK...
    However as I am nearing implementing the project I thought I should generate the swf files for the other languages that are in the pipeline and for some reason I can't manage it! Needless to say I have misplaced (tidied) the original AS3 source for the two fonts I have done.</p>
  
  <pre><code>package   
  {  
      import flash.display.Sprite;  
      import flash.events.Event;  
      public class ArabicF extends Sprite   
      {       
          [Embed(source = "trado.ttf",
          fontName = "ArabicX",
          fontFamily = "ArabicY",
          fontWeight = "normal",
          fontStyle = "normal",
          mimeType = "application/x-font",
          advancedAntiAliasing="true",
          embedAsCFF="true")]  
          public static const ArabicZ:Class;  
      }   
  }  
  </code></pre>
  
  <p>This has expanded from a much simpler form as I added things to get it to work and I must have tried all permutations of true and false. I load the swf ok but then can't extract the class. With the two fonts I embedded before the swf class and the parameter all have the same name and they work fine (i.e. 
      Urdu.swf 
  then later: 
      var FontClass:Class = evt.target.applicationDomain.getDefinition("Urdu") as Class; 
  and then
      Font.registerFont(FontClass.Urdu);<br>
  in the calling .as application with the above Arabic.swf I try</p>
  
  <pre><code>trace("1 Arabic "+evt.target.applicationDomain.hasDefinition("ArabicF"));  
  trace("2 Arabic "+evt.target.applicationDomain.hasDefinition("Arabic"));  
  trace("3 ArabicX "+evt.target.applicationDomain.hasDefinition("ArabicX"));  
  trace("4 ArabicY "+evt.target.applicationDomain.hasDefinition("ArabicY"));  
  trace("5 ArabicZ "+evt.target.applicationDomain.hasDefinition("ArabicZ"));  
  </code></pre>
  
  <p>but all return false </p>
  
  <p>PS also tried generating the Arabic.swf using fontswf.bat which again seems to make a very similar swf file which is loaded but I can't extract the class from it</p>
  
  <p>PPS I'm using flashdevelop and the font swf are set up as AS3 standard project compiler options.</p>