Wwwebber's Blog

Bitmapdata .disose()

Posted in actionscript 3, bitmapdata, fraction games, math games by wwwebber on November 30, 2008

This is just some venting…I am working a fraction game..i’ve tentatively called “Fraction Wars”..basically you blast up equivalent fractions. Anyway, I’m using a fair amount of blitting ala 8 bit rocket style. I decide to create and cache some text animations that use this blitting technique. The logic is that I would cache all the text animations that were likely to occur during the more intense parts of the game and then just blit them to the main canvas, a single bitmapdata object that spans most of the screen. (for in between levels when not much action was occuring, I used regular old text fields and transitionmanagers).

The morale of my wasted time is that bitmapdata’s dispose() method is DESTRUCTIVE. Only use it if you don’t need ANY reference that given bitmapdata. I knew this before today , just didn’t see how it

I wasted more time than I care to share over the following embarrising fact that I had a timer loop that

1) created new bitmapdata by drawing from a text field
2) store bitmapdata in a slot in an array
3) before moving on to the next iteration of the timer, I called .dispose() on the new bitmapdata

I know it seems obviuos now

Advertisements

Comments Off on Bitmapdata .disose()