1 Reply Latest reply on May 29, 2010 12:03 PM by Korkia

    actionScript3 = true not working

    Korkia

      Hi all

       

      I know this is getting awful close to a support question, but I can't figure out if it's me that is doing something wrong or if there is a bug in the SDK

       

      I'm trying to make some swf's containg only fonts from my Java backend for use in my Flash frontend and they need to be generated using AS3. While digging through the source, I came across the FileAttributes class, which contained a boolean attribute called actionScript3. I figured this was the much needed solution I was looking for, but after creating a FileAttributes, setting actionScript3 to true and adding it to the TagEncoder, nothing changes. The swf I generate is still made using AS2.

       

      Here is the test code I'm currently working on:

       

      public class FontTest {
      
           /**
            * @param args
            */
           public static void main(String[] args) throws Throwable {
                
              FontDescription fontDescription = new FontDescription();
              fontDescription.advancedAntiAliasing = true;
              fontDescription.alias = "font heavy";
              fontDescription.compactFontFormat = true;
              try {
                  fontDescription.source = new URL("file:///D://ikssschv.ttf");
              } catch (MalformedURLException e) {
                  e.printStackTrace();
              }
              fontDescription.style = 0;
              fontDescription.unicodeRanges = "U+0020-U+007F,U+0080-U+00FF,U+0020,U+0021,U+0022,U+0023,U+0024,U+0025,U+0026,U+0027,U+0028,U+0029,U+002a,U+002c,U+002d,U+00b7,U+002e,U+002f,U+003a,U+003b,U+003c,U+003d,U+003e,U+003f,U+0040,U+005b,U+005d,U+005e,U+005f,U+0060,U+007b,U+007c,U+007d,U+007e,U+20ac,U+201a,U+0192,U+201e,U+2026,U+2020,U+2021,U+02c6,U+2030,U+0161,U+2039,U+0153,U+017e,U+2018,U+2019,U+201c,U+201d,U+2022,U+2013,U+2014,U+02dc,U+2122,U+203a,U+00ff,U+00a1,U+00a2,U+00a3,U+00a4,U+00a5,U+00a6,U+00a7,U+00a8,U+00a9,U+00aa,U+00ab,U+00ac,U+00ad,U+00ae,U+00af,U+00b0,U+00b1,U+00b2,U+00b3,U+00b4,U+03bc,U+00b6,U+00b8,U+00b9,U+00ba,U+00bb,U+00bc,U+00bd,U+00be,U+00bf,U+00e0,U+00e1,U+00e2,U+00e3,U+00e4,U+00e5,U+00e6,U+00e7,U+00e8,U+00e9,U+00ea,U+00eb,U+00ec,U+00ed,U+00ee,U+00ef,U+00f0,U+00f1,U+00f2,U+00f3,U+00f4,U+00f5,U+00f6,U+00d7,U+00f8,U+00f9,U+00fa,U+00fb,U+00fc,U+00fd,U+00fe,U+00df,U+00f7,U+0092,U+0105,U+0107,U+0119,U+0142,U+0144,U+015b,U+017a,U+017c,U+0151,U+0171,U+0430,U+0431,U+0432,U+0433,U+0434,U+0435,U+0451,U+0436,U+0437,U+0438,U+0439,U+043a,U+043b,U+043c,U+043d,U+043e,U+043f,U+0440,U+0441,U+0442,U+0443,U+0444,U+0445,U+0446,U+0447,U+0448,U+0449,U+044a,U+044b,U+044c,U+044d,U+044e,U+044f,U+0061,U+0062,U+0063,U+010d,U+0064,U+010f,U+0065,U+011b,U+0066,U+0067,U+0068,U+0191,U+0160,U+0152,U+017d,U+0178,U+00b5,U+00c0,U+00c1,U+00c2,U+00c3,U+00c4,U+00c5,U+00c6,U+00c7,U+00c8,U+00c9,U+00ca,U+00cb,U+00cc,U+00cd,U+00ce,U+00cf,U+00d0,U+00d1,U+00d2,U+00d3,U+00d4,U+00d5,U+00d6,U+00d8,U+00d9,U+00da,U+00db,U+00dc,U+00dd,U+00de,U+0053,U+0104,U+0106,U+0118,U+0141,U+0143,U+015a,U+0179,U+017b,U+0150,U+0170,U+0410,U+0411,U+0412,U+0413,U+0414,U+0415,U+0401,U+0416,U+0417,U+0418,U+0419,U+041a,U+041b,U+041c,U+041d,U+041e,U+041f,U+0420,U+0421,U+0422,U+0423,U+0424,U+0425,U+0426,U+0427,U+0428,U+0429,U+042a,U+042b,U+042c,U+042d,U+042e,U+042f,U+0041,U+0042,U+0043,U+010c,U+0044,U+010e,U+0045,U+011a,U+0046,U+0047,U+0048,U+039c,U+0069,U+006f,U+0079,U+0075,U+0072,U+0155,U+006c,U+013a,U+007a,U+006a,U+006b,U+013e,U+006d,U+006e,U+0148,U+0070,U+0071,U+0073,U+0074,U+0165,U+0076,U+0077,U+0078,U+0049,U+004f,U+0059,U+0055,U+0052,U+0154,U+004c,U+0139,U+005a,U+004a,U+004b,U+013d,U+004d,U+004e,U+0147,U+0050,U+0051,U+0054,U+0164,U+0056,U+0057,U+0058";
      
      
                File localFile = new File("D:/myflashfont.swf");
                if (!(localFile.exists()))
                {
                  localFile.getParentFile().mkdir();
                  localFile.createNewFile();
                }
      
                FontTest fontTest =  new FontTest();
                
                fontTest.transcode(fontDescription, new FileOutputStream(localFile));
           }
           
             protected static final int TWIPS_PER_PIXEL = 20;
            protected int flashVersion = 10;
             protected int framerate = 24;
             protected int height = 400;
             protected int width = 550;
             protected int background_red = 255;
             protected int background_green = 255;
             protected int background_blue = 255;
             protected boolean compressed = true;
      
             public void transcode(FontDescription paramFontDescription, OutputStream paramOutputStream)
               throws FontTranscoderException
             {
                 FileAttributes attributes = new FileAttributes();
                 attributes.actionScript3 = true;
                 attributes.hasMetadata = true;
      
               Movie localMovie = new Movie();
               
               localMovie.version = this.flashVersion;
               localMovie.framerate = this.framerate;
               localMovie.size = new Rect(this.width * 20, this.height * 20);
               localMovie.bgcolor = new SetBackgroundColor(SwfUtils.colorToInt(this.background_red, this.background_green, this.background_blue));
               ArrayList localArrayList = new ArrayList(1);
               Frame localFrame = new Frame();
               localArrayList.add(localFrame);
               localMovie.frames = localArrayList;
               Header localHeader = new Header();
               localHeader.version = localMovie.version;
               localHeader.size = localMovie.size;
               localHeader.rate = localMovie.framerate;
               localHeader.compressed = this.compressed;
               TagEncoder localTagEncoder = new TagEncoder();
               localTagEncoder.header(localHeader);
               localTagEncoder.fileAttributes(attributes);
               DefineFont localDefineFont = null;
               try
               {
                 localDefineFont = createDefineFont(paramFontDescription);
                 if (localDefineFont == null) {
                   throw new FontTranscoderException("Failed to create font for " + paramFontDescription.source);
                 }
                 if (localDefineFont.name == null) {
                   localDefineFont.name = localDefineFont.getFontName();
                 }
                            
                 localFrame.addExport(localDefineFont);
                 localFrame.addFont(localDefineFont);
                 MovieEncoder localMovieEncoder = new MovieEncoder(localTagEncoder);
                 
                 
                 localMovieEncoder.export(localMovie);
                 localTagEncoder.writeTo(paramOutputStream);
               }
               catch (Exception localException)
               {
                 throw new FontTranscoderException(localException);
               }
             }
             
             protected DefineFont createDefineFont(FontDescription paramFontDescription)
             {
               AFEFontManager localAFEFontManager = new AFEFontManager();
               DefineFont localDefineFont = localAFEFontManager.createDefineFont(75, paramFontDescription);
               return localDefineFont;
             }
      }
      

       

      Everything compiles nicely and it even generates a nice swf containing fonts, the only problem is, that the swf is made using AS2 and not AS3. Can anybody point out what I'm doing wrong or if something isn't working as it is supposed too?