This content has been marked as final. Show 4 replies
I have the same problem i have posted a new Topic without response. Regarding to your code, it works even if you dont intstantiate TestClass:
var bb:TestClass; // added this line
Simply by referencing the class you will use the Class definition or whatever its imported and the error its not throwed.
I use getDefinitionByName in functions in which I have not made static reference to the type, and have not encountered this problem. Other parts of my application, however do, and perhaps that's the difference.
What is the package of your TestClass? Is it in the default package? If not, do you get this problem when you specify its fully qualified class name? If, in your example (the working one), you query ClassReference.getQualifiedClassName(), what does it say?
After some further examination, yes - if I have declared a variable of this type anywhere in my application, I'm free to use getDefinitionByName(), but if I don't declare such a variable I get the same error. This is frustrating, and doesn't appear to get any mention in the docs. This suggests to be it's a bug?
The following is courtesy of Matt on the flexcoders group:
You need to make sure that the class gets linked into your SWF. You don't
need to instantiate it but you need to declare a variable with the type of
the class that you want. You can also use the –include-classes directive to
the compiler to force the class to be available. Check the docs for more