explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!

bug? exception thrown by getter – BitmapData

Leave a comment

Interesting little issue I am having here.

Basically I have a method that gets called on ENTER_FRAME. I have some vars that are getting accessed each time and so to save on fetching from the related object (a big performance saver I would think), when I set the related object during initialization I simple set the local vars to those props on the related object.


Problem solved – I forgot that in the relatedObject anytime a resize occurs, the canvas object gets disposed of:

canvas = null;

//later on in the resize logic
canvas = new BitmapData(targetWidth, targetHeight, true, 0x00FF00FF);

The rendering class had an old and disposed reference to a bitmapData object.  Due to the debugger freaking out I didn’t even really think to inspect if the local bitmapData object was the same object in the relatedObject.  So what can you take from all this?  If you encounter a similar problem, you might check to see if you are calling dispose() on any bitmapData objects.

Has anyone run into this before?  I will post more findings as they come.  Here is some code to help visualize:



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s