SWCGenerator Eclipse Plugin

Posted: May 28th, 2009 | Categories: Actionscript 3.0, Tools | 10 Comments

There are several possibilities to create swc libraries or assets. You can use embed tags wihing as-classes to force the compiler to include assets directly into your physical swf or you can use the flash IDE to link your assets in the library and publish them afterwards or at least use the flex oem compiler to compile your assets from the console.

There is a catch with all of these possibilities (in my opinion). The flash IDE is not open source, I always forget the syntax of the embed tags and using the console is failure prone.

The SWCGenerator plugin is able to create swc libraries with direct access to Bitmaps, Fonts, Sounds and ByteArrays. You can choose a specific linkage which matches the project structure.

In addition you can choose different unicode ranges and even included characters to make sure not to include unnecessary charsets. Figure 1 shows the add font dialog.

Add Font dialog
Figure 1: add font dialog

All added assets are stored in a table in a specific eclipse view.
SWCGenerator
Figure 2: SWCGenerator view

Also it is possible to save and load project settings.

There are two ways to load a project settings file:
1. by a single-click on the file in an eclipse project
2. by a single-click on the "Open Project"-Action in the toolbar.

Installation:

  1. download SWCGenerator
  2. put the .jar files in the plugins folder of your eclipse installation directory
  3. if eclipse is running restart it
  4. Window -> Show View -> Other -> Addicted2Flash -> SWCGenerator

Please drop me a comment for feature requests or bugs.


10 Comments on “SWCGenerator Eclipse Plugin”

  1. 1 Trevor said at 21:41 on May 28th, 2009:

    sweet! can’t wait to try it out

  2. 2 tim said at 12:46 on June 3rd, 2009:

    There is a bug in the flex_config path. I will fix it. Be patient.
    The bug has been fixed.

  3. 3 Mohammed Khan said at 14:33 on June 30th, 2009:

    Hi Tim,

    Is it possible to get the source code, as i plan to use it for an open source project where we need to generate an asset swc at runtime of he flex application. We dont intend to use it use it as eclipse plugin but more as a servlet. Any help would be great and thanks agian.

  4. 4 tim said at 20:52 on July 19th, 2009:

    Hi Mohammed,

    there is a little problem with this issue, because the swc generator need a couple of files from the flex sdk to work properly. The only way to get rid of an included sdk is the possiblity to put an executable jar in a directory relative to the sdk directory. Drop me a comment if this could be a possible solution.

  5. 5 David said at 15:19 on August 18th, 2009:

    Hi Tim,

    first of all I would like to compliment you on your idea of building this Eclipse Plugin. I think it could be very helpful on a daily basis if you are not dependent on FLA-file which can be edited by a designer.

    So I just had my first test run of your SWCGenerator on my Mac. But I ran into some problems. First of all there seems to be error saving the project. When I choose a destination the path looks like this: /Users/db/DesktopTestAssets/.lib. Even when I change it to this: /Users/db/Desktop/TestAssets.lib, it fails: “Exception occurred. No such file or directory”.

    The other problem is related to adding fonts to the SWC. When I try to add a TTF-font which works with the [Embed()] compiler statement it fails with this message: “Exception occurred. java.lang.ClassCastException: java.lang.Integer”.

    May these be Mac-specific problems? I’m using the latest version (1.0.0) which I got from your Google Code downloads. By the way the download link on this page is leading to a non existing file. At least this is easy to fix. ;)

    David

  6. 6 tim said at 23:21 on August 18th, 2009:

    Hi David,

    thank you for your comment. Seems to be a problem with compiling .otf-fonts. I updated the source. The other bug with the project file is also fixed. I am sorry for that.

  7. 7 tim said at 09:52 on August 20th, 2009:

    It seems that the flex compiler has problems with fonts that uses specific font weight or font style. The swcgenerator is now able to parse .ttf/.otf font files to get specific information.

  8. 8 David said at 00:56 on August 25th, 2009:

    Hi Tim,

    yes, I had the same problem some time ago. Back then the feature of embedding fonts wasn’t even documented. Since then nothing has changed: http://livedocs.adobe.com/flex/3/html/help.html?content=04_OO_Programming_09.html

    I fixed my problems by consulting several web sources and identified the following attributes which can/must be used to embed a font:
    - fontFamily
    - fontName
    - fontWeight (i.e. “bold”)
    - fontStyle (i.e. “normal” or “italic”)
    - mimeType (i.e. “application/x-font-truetype”)
    - advancedAntiAliasing (i.e. “true”)

    In my case it was a lot of trial and error to find out, that for example you can set fontWeight to “medium” although you have a medium font face. This needed to be “bold” instead. All attributes except fontName are optional. If not used the compiler will spit out a specific warning. The other attributes “fontFamily”, “fontWeight” and “fontStyle” can be helpful if you want to work with embed fonts and css styles.

    Maybe this can be of any help to improve your generator. If you have a question about I’ld be glad to help you.

    Just checked your latest release. Saving and exporting projects now works like a charme. When I get to it I’ll try to make a test with with css styles and see if this works too with your automatic font detection.

    Thx.David

  9. 9 tim said at 11:43 on August 25th, 2009:

    Hi David,

    thanks again for your comment. The main problem by embedding fonts is the “macStyle” tag of the font. This attribute holds information about the fontWeight and the fontStyle. To handle this automatically, I had to parse the font file header to get these informations.

    Hope you enjoy the plugin.

  10. 10 tim said at 16:38 on September 7th, 2009:

    * Fixed color highliting within table
    * Font detecting is more reliable now

    Have fun!



Leave a Reply