This content has been marked as final. Show 4 replies
Read the documentation on getDefinitionByName()
Thanks. I'll take a look.
Theres a gotcha here.... Flex Builder will only include a class in the build if it is referenced from somewhere, and getDefinitionByName() will only return a definition if the class is included in the build. So for getDefinitionByName() you have to reference the class from somewhere. IMO this renders getDefinitionByName() pretty useless....
I've already had a rant about this here:
FlexBuilder not checking for errors in AS files
Thanks for the heads up Ed!
One way to be ableto get around your issue (not that this exists in AS 3.0) is to be able to "register" a class so the compiler/linker can link it into the swf and you get compile time checking.
This is the way Delphi allows for this. The C# complier is kind of in between in that you are still liable to get a runtime error in the case that you creat an instance of a class using (say) Activator.CreateInstance() which is the equivalent.
One way to get around this in AS 3.0 (I think) would be to simply declare a variables of the types you intend to create instances of dynamically. This should force the linker to link in the class definition.
Of course in both C# and Delphi you can create instances of classes unknown to you at complie time. From the looks of it, AS 3.0 can't do this.