I am having a very strange issue with the flex compiler (using Flash Builder 4.5) that I have never come across before.
I am trying to create an instance of a class (that exists in the same package) and the compiler will not recognize the class as a compile-time constant, but only in instance methods. Class methods (static) will compile without issue.
This class is being used all over the place without issue. Just in this one place it will not compile in instance methods. Makes no sense.
I have tried everything I can think of...
- Added an import for UploadDate (even though the class is in the same package)
- Clean built the project (and all parent/sub projects)
- Deleted code model cache (.metadata/.plugins/com.adobe.flexbuilder.codemodel/*)
- Deleted all generated assets cache (.../com.adobe.flexide.editorcore/GeneratedAssets/*)
- Compiled with different flex sdk's (3.2, 3.5, 3.6)
Here is the code:
package classes
{
import classes.UploadDate;
[Bindable]
public class UserImages {
....
//this compiles with no errors
public static function classMethod():void {
var ud:UploadDate = new UploadDate();
}
//this will not compile
public function instanceMethod():void {
//1046: Type was not found or was not a compile-time constant: UploadDate
var obj:UploadDate = new UploadDate();
}
//this is the ugly workaround I am currently using (works fine at Runtime)
public function hackyMethod():void {
var Def:Class = getDefinitionByName("classes.UploadDate") as Class;
var obj:* = new Def();
}
}
}
And the UploadDate class:
package classes
{
[Bindable]
public class UploadDate {
public var date:String;
public var numImages:int;
public UploadDate() {
}
}
}
Has anyone seen this before?
Thanks, Matt
public UploadDate() {
is not valid and won't compile. But this is probably not the problem? – Kaken Bokclasses
to something else and do the same forUploadDate
– cmann