Question: I get an annoying error:
I try to use the type Size in the below actionscript code.
But I always get this error:
1046: Type was not found or was not a compile-time constant: Size.
But no matter what I try, it seems to break when I add
public function get Size():Size
Somehow it doesn’t like the return type Size, but what am I doing wrong ?
package BaseTypes
{
public class StockData
{
private var size:Size;
public function get Size():Size
{
return this.size;
}
public function set Size(value:Size):void
{
this.size = value;
}
} // End Class
}// End Package
I have the bellow code in folder BaseTypes, and it is in the AS3 class path.
package BaseTypes
{
public class Size
{
private var width:Number;
private var height:Number;
public function Size(width:Number, height:Number)
{
this.width = width;
this.height = height;
}
public function get Width():Number
{
return this.width;
}
public function set Width(value:Number):void
{
this.width = value;
}
public function get Height():Number
{
return this.height;
}
public function set Height(value:Number):void
{
this.height = value;
}
public function toString():String
{
return "{width: " +this.width.toString()+ " height: " +this.height.toString() + "}";
}
} // End Class
} // End package
You have named your getter function the same as the class you imported, I think this is the source of your error.
in your StockData class you have the definition
you should rename “Size” to either “size” or something that is not the same name as the class you imported.