Alternative for getDefinitionByName

There was a simple trick in the past to enable flex mxmlc by adding the following line to makefile:

 -include-libraries "/absolute/path/to/my/assets/assets.swc" 

This gave you the option to use getDefinitionByName , a helper function to access the built-in library of swc properties (instead of creating manual classes for all assets).

Unfortunately, this has stopped working with . Does anyone know a different solution?

+4
source share
3 answers

Unfortunately, the only workaround I found was to explicitly reference each of the asset classes somewhere in the code. You can create a dummy class as follows:

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

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

 AssetsExporter.export(); 

After that, you can use getDefinitionByName ().

+4
source

You can add them to libraries in the publication settings.

Publish Settings

(Image from http://wiki.gigya.com/ via Google Images)

By the way, if you use SWC files, you can also do

 new somepackage.SomeClass(); 

instead

 new getDefinitionByName("somepackage.SomeClass") 

where applicable. This is because SWC files are included at compile time, and not at run time.

+1
source

Even if you can change the compiler settings manually, it is easy if you use FlashDevelop, since it is very easy to fix.

Right-click your included swc from the Project list. Select the "enable library (full library)" options.

.. now you can use getDefinitionByName to get an unregistered class from your swc file.

0
source

Source: https://habr.com/ru/post/1341780/


All Articles