Error with debugging


(Teun) #1

Hello,

I’m trying to make ogmo levels work in my game but when I debug it i’m getting this error: [Fault] exception, information=TypeError: Error #1007: Instantiation attempted on a non-constructor.

This is my Level.as where I load the ogmo level(s).

package 

{

import net.flashpunk.Entity;
import net.flashpunk.FP;
import net.flashpunk.World;
import net.flashpunk.Sfx;
import flash.utils.ByteArray;


public class Level extends Entity 
{
	[Embed(source = 'Level1.oel', mimeType = 'application/octet-stream')]
    public static const LEVEL1:Class;

	
	public static var levelarray:Array = [LEVEL1];
	public static var current_level:Number = 1;

  
 public function Level()
  {
    super()
	loadlevel(levelarray[current_level]);	
 }	


	public static function loadlevel(map:Class):void
	{
		var xmL:XML = FP.getXML(map);
		var o:XML;

		
		
        for each (o in xmL.Objects.Player)
		{
			FP.world.add(new MyPlayer(o.@x, o.@y));

		}
        
        for each (o in xmL.Objects.Wall)
		{
			FP.world.add(new MyWall(o.@x, o.@y));

		}
		
		
		
	}
}

}


(Jacob Albano) #2

What line does the error come from? The only thing I can see that might be a problem is the calll to new MyPlayer(), if MyPlayer isn’t a valid class.


(Teun) #3

The error is coming from FP.as, from this line:

		public static function getXML(file:Class):XML
	{
		var bytes:ByteArray = new file;
		return XML(bytes.readUTFBytes(bytes.length));
	}

EDIT:

Oops the loadlevel variable was wrong, thanks for the help!