I’m new to the starling framework and am currently learning how to use it.
I’ve created textures from embedded PNG files with the starling framework that work perfectly and display on the screen, but I am trying to get a spritesheet (Texture Atlas) to work and it is giving me this:
“Error #1007: Instantiation attempted on a non-constructor.”
From all of the research I have done the code I have should work.
Here is the applicable code from my Assets class.
public class Assets
{
[Embed(source="assets/sky.png")]
private static var SKY_CLASS:Class;
public static var SKY:Texture;
[embed(source="assets/generalsheet.png")]
private static var GENERAL_SHEET_CLASS:Class;
[embed(source="assets/generalsheet.xml", mimeType="application/octet-stream")]
private static var GENERAL_ATLAS_CLASS:Class;
public static var GENERAL_SHEET:TextureAtlas;
public static function init():void
{
SKY = Texture.fromBitmap(new SKY_CLASS());
GENERAL_SHEET = new TextureAtlas(Texture.fromBitmap(new GENERAL_SHEET_CLASS()), XML(new GENERAL_ATLAS_CLASS())); // this is where Flash Builder tells me there is an error
}
You just need to write the
Embedtag in upper case, just change:to:
On a side note, class names are usually written in UpperCamelCase, and ALL_CAPITALIZED is reserved for constants. Variable names are usually written in lowerCamelCase or lowercase_separated_by_underscore. This is a convention followed by most ActionScript3 (and Java) programmers and if you stick to it your code will be more readable and thus it should be easier to help you next time 😉
So I recommend: