RESOLVED: Console gives Error #2015: Invalid BitmapData


(John Heigns) #1

Hi everyone,

I have been slowly toying around with AS3 and Flashpunk and I was trying to view the hitboxes of my entities through the console. Without the console I receive no errors, but when I use FP.console.enable() it gives me this when I try to start the game:

ArgumentError: Error #2015: Invalid BitmapData. at flash.display::BitmapData/ctor() at flash.display::BitmapData() at net.flashpunk.debug::Console/enable() at Main()

Any help would be greatly appreciated.


(TaylorAnderson) #2

Where are you calling FP.console.enable()?


(John Heigns) #3

Located in main.as:

package 
{
    import net.flashpunk.Engine;
    import net.flashpunk.FP;

    public class Main extends Engine 
    {
	
	    public function Main()
	    {
		    super(1000, 600, 60, false);
		    FP.world = new MyWorld;
		    FP.screen.scale = 7;
		    FP.console.enable();
    	    }
	
	    override public function init():void
	    {
		    trace("Flashpunk has started successfully!");
		    FP.screen.color = 0x333333;
	    }
    }
}

(TaylorAnderson) #4

Thats weird. Have you tried commenting out the screen.scale line to see if thats the issue? Thats a rather large screen scale, it might mess up the console. Other than that I have no clue what the issue could be.


(John Heigns) #5

Yup, that completely worked. Thanks so much for the help!


(TaylorAnderson) #6

Awesome! Glad my shot in the dark turned out to be accurate :stuck_out_tongue:


(Zachary Lewis) #7

The reason that it fails when scaling is because the resulting BitmapData is too large.

In AIR 1.5 and Flash Player 10, the maximum size for a BitmapData object is 8,191 pixels in width or height, and the total number of pixels cannot exceed 16,777,215 pixels.

BitmapData - Adobe ActionScript® 3 (AS3 ) API Reference

With a screen resolution of 1,000x600, scaling it by 7 results in a screen resolution of 7,000x4,200 (within the size limit of a BitmapData) with a screen area of 29,400,000 pixels, exceeding the size limit of a BitmapData. The console (which isn’t scaled) draws onto the upscaled BitmapData, making the screen itself invalid and throwing runtime error #2015.