Clone wiki

FlexORM / Faq

Error #1065: Variable XYZ is not defined. at global/flash.utils::getDefinitionByName()

ReferenceError: Error #1065: Variable B is not defined.
   at global/flash.utils::getDefinitionByName()

It's not a bug it's a feature ;) The problem here is the SWF compiler in Flex Builder is optimizing out any imports that don’t get instantiated, so at run-time, the class really doesn’t exist in the SWF.

Basically when you try to use a class that you have included in your SWC using //getDefinitionByName(“MyClassName”) as Class//, the compiler throws an error message saying it can’t find them – variable not defined etc. Even though you think that those classes are in your SWC and therefore in your project, the compiler still doesn’t know about them so you need to tell it to include them when compiling.


There are several ways to achieve this. The most basic way is just to reference them in your code. Even a trace(MyClass) message will work or defining a dummy variable like var foo:MyClass;. The problem with this method is that you have to write a lot of dummy code to include a bunch of classes. There's another (dirty) workaround for now to use the EntityIntrospector and preload the class metadata before loading the list of As: em.introspector.loadMetadata(MyClassName);

Flash Develop

The correct way to do it in FD is actually to add the SWC that the class is in to the project via //Project Properties > Compiler Options > SWC Include Libraries// list. This way all classes in the SWC you specify are compiled.

However the problem with this method is that this it includes ALL the classes in that SWC you define.

Flash Builder

The correct way to do it in FB is to add compiler flags via //Project > Properties > Flex Compiler > Additional compiler arguments// and to add the class or whole library. Same as above.

includes class [...]
include-libraries library [...]