1
votes

Ok so I have game data parser that creates a game out of data file basically, it is using extensively getDefinitionByName which has one problem if the class is not loading somewhere else it throw variable not defined error information=ReferenceError: Error #1065: Variable {MyClass} is not defined. to workaround it I am using a class that holds all the list of components and instantiate it to make these classes available to the compiler. Ok the question part is there any more efficient way to do that or playing with compiler argument or something ? Is there something like export in first frame in flash professional as a compiler argument ?

1
I haven't heard of a compiler option for that. That easiest way I've used is to simply write something like this inside your file (must be inside package): myClass;. Simply as that. Do not instantiate it, but just write it's name and the compiler will know that it should be compiled for usage.Andrey Popov
I use an array of classes that are intended to be used as getDefinitionByName targets. For me it was [Gem01,Gem02,...] array, and then I was using "Gem" and two digits to get the required gem image. In short, you need to have a hard reference somewhere in the compiled area for getDefinitionByName to return something.Vesper
I have Class with all classes declared in there so I have central place to define all the dynamically created classes and then i instantiate it in the parser so the compiler can get all the reference from this giant classKhaled Garbaya

1 Answers

1
votes

I think what you want is to have a library project with all those "callable" classes, and then reference that library project in your game.

In flash builder, for a library project, you can check which classes are compiled (and so available to getDefinitionByName). (info here)