Quick question, bitmapdata invalid : console & new world


(Enzo M) #1

Hi again guys, sorry about the number of messages, but I don’t see any question like this already asked :confused:

So, I am working on a levels-based game, so, when the player hit esc. during his game, a pausemenu appears. In this one, he can chose to restart the level. To do this, I just added :

 if (collidePoint("pauserestart", this.mouseX, this.mouseY)) {
				
       if (Input.mouseReleased) {
					
            GameVariables.paused = false;
					
            FP.world = new GameWorld;
	}
}

Thing is, when I click, an error appears : [Fault] exception, information=ArgumentError: Error #2015: BitmapData non valide.

But I don’t have any BitmapData in my program. I never used this oO

Moreover, this error also appears, sometimes, when I am in game (and only in game, it doesn’t appear when I do this in MENUWORLD or even SETTINGSWORLD), this error appears when I click “ù” to open the console :confused:

Thanks in advance guys,

Regards, Enzo


(Ultima2876) #2

Could you build and run in debug mode, and post the full error message including file and line numbers? :slight_smile:


(Bora Kasap) #3

also, i’m curious about why "mouseX mouseY is addressing from “this”, i’m used to see it Input.mouseX, Input.mouseY :smiley: also i’m curious about is there any difference between “new Array;” and “new Array( );” or “new GameWorld” and “new GameWorld( )” can somebody write me about that by private msg


(Enzo M) #4

Hi guys,

When I have the error, the only messages I got are :

In the output box : [Fault] exception, information=ArgumentError: Error #2015: BitmapData non valide.

When I stop the program, a box is opening with :

ArgumentError: Error #2015: BitmapData non valide.

at flash.display::BitmapData/ctor()

at flash.display::BitmapData()

at net.flashpunk.graphics::Image/createBuffer()[C:\Users\msi\Documents\ICAN\Dropbox\Projet 1er semestre\Protos\FlashPunk-1.7.2\net\flashpunk\graphics\Image.as:100]

at net.flashpunk.graphics::Image()[C:\Users\msi\Documents\ICAN\Dropbox\Projet 1er semestre\Protos\FlashPunk-1.7.2\net\flashpunk\graphics\Image.as:89]

at LevelWalls_1()[C:\Users\msi\Documents\ICAN\Dropbox\Projet 1er semestre\Programmation\Polaris_v5\src\LevelWalls_1.as:16]

at GameWorld()[C:\Users\msi\Documents\ICAN\Dropbox\Projet 1er semestre\Programmation\Polaris_v5\src\GameWorld.as:27]

at Menuscreen_play/update()[C:\Users\msi\Documents\ICAN\Dropbox\Projet 1er semestre\Programmation\Polaris_v5\src\Menuscreen_play.as:30]

at net.flashpunk::World/update()[C:\Users\msi\Documents\ICAN\Dropbox\Projet 1er semestre\Protos\FlashPunk-1.7.2\net\flashpunk\World.as:60]

at MenuWorld/update()[C:\Users\msi\Documents\ICAN\Dropbox\Projet 1er semestre\Programmation\Polaris_v5\src\MenuWorld.as:40]

at net.flashpunk::Engine/update()[C:\Users\msi\Documents\ICAN\Dropbox\Projet 1er semestre\Protos\FlashPunk-1.7.2\net\flashpunk\Engine.as:96]

at net.flashpunk::Engine/onEnterFrame()[C:\Users\msi\Documents\ICAN\Dropbox\Projet 1er semestre\Protos\FlashPunk-1.7.2\net\flashpunk\Engine.as:211]


(Jacob Albano) #5
  • The reason for this.mouseY/mouseX is most likely because this code is being run from a World class, which has variables of its own.
  • In as3, there is no difference between calling a zero-parameter constructor with parentheses or without.

(Jacob Albano) #6

If you’re using embedded assets, you’re using BitmapData. That’s what embedded images are stored as.

Are you passing null or a BitmapData instance of size {0, 0} into the constructor of Image? What image formats are you using? You might have trouble with formats that aren’t PNG.


(Enzo M) #7

All my images are PNG and one is JPG, but this last one is in the option screen and it doesn’t change anything, even without it, the bug appears.

I don’t understand the question about Image’s constructor ? Is it the thing that appears when clicking : gotodeclaration of Image’s class ? Because I didn’t change anything there. (or maybe an error, so I would need to remplace it by a new ??)

Moreover, I only embed assets and create graphic Image OR spritemaps that I add in my gameworld. That’s why I thought doing a FP.world = new gameworld(); would be enough to restart the level ? (changing the pause boolean since it’s no longer in pause).


(Jacob Albano) #8

What I meant was, when you call new Image(source), is it possible that source is null or otherwise malformed?

What happens on LevelWalls line 16? Somewhere along the way, Image is getting a bad image. Usually that error is because a BitmapData was initialized with a width or height of zero. Are you using Image.createRect() and passing it zero for one of its arguments possibly?


(Enzo M) #9

Na, i don’t use any createRect() etc.

Well… I think I resolved it. Looking at my two Level1Walls classes (I had two : _1 and _2), I added two graphic images. The first is my level collision map, which I add in my GameWorld and works properly. The second was my level background, which I didn’t add in my GameWorld (I only created a var of type Level1Walls_2).

I deleted the second class and I don’t have any problem now. I guess it’s because I didn’t add it to my scene.

Btw, how did you know about the line ? Is it the “:16” at the end ?


How to tile without addGraphic(), or addGraphic is cool for my situation? [SOLVED]
(Jacob Albano) #10

Yep. :smiley: I’m glad you fixed it, but I’m not sure why the object not being in the scene would make a difference, Hopefully the bug doesn’t resurface later.