actionscript-3flash-cs4flashflash-cs5

Alternative for getDefinitionByName


In the past, there was a simple trick, to include the mxmlc module by adding the following line to the makefile:

-include-libraries “/absolute/path/to/my/assets/assets.swc” 

This gave you the ability to use getDefinitionByName, an helper function to access the embedded swc asset-library (instead of creating hand-written classes all assets).

Unfortunately, this has stopped working since . Does anybody know another solution?


Solution

  • Unfortunately, the only workaround I have found is to explicitly refer each of asset classes somewhere in the code. You may create dummy class like this:

    public class AssetsExporter extends Sprite
    {   
      public static function export()
      {
        AssetClass1;
        AssetClass2;
        //etc
    
        trace( "DEBUG AssetsExporter.export()" );
      }
    }
    

    Specify this class as Document class in Flash IDE, so it will be compiled into the resulting swc. Then in the main code of your application call

    AssetsExporter.export();
    

    After doing this you will be able to use getDefinitionByName().