BitmapData Limit
Hi,
I'm getting a flash error when creating many BitmapDatas (I'm not talking about one bitmap that is too big).
I created for you a copy-paste class that reproduces the error.
Simply create an Issue class file and copy paste that code, then instantiate that class in your main class (new Issue()).
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.events.Event;
public class Issue extends MovieClip
{
private var mc:MovieClip;
public function Issue():void
{
addEventListener(Event.ENTER_FRAME, eachFrame);
mc = new MovieClip();
}
private function eachFrame(e:Event):void
{
for (var i:uint = 0; i < 100; i++)
{
createBitmap();
}
}
private function createBitmap():void
{
var bm:Bitmap = getBitmap();
mc.addChild(bm);
}
private function getBitmap():Bitmap
{
var bmd:BitmapData = new BitmapData(500, 500);
return new Bitmap(bmd);
}
}
}
The error I'm getting:
ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData/ctor()
at flash.display::BitmapData()
Something I noticed is when reducing the bitmap size flash will produce more bitmaps before throwing the error.
When multiplying:
Bitmaps Created before error was thrown x each BitampData size (example BitmapData size: 500x500), the overall amount of pixels generated before the error was thrown is very similar: more than 400000000.
Amount of bitmaps generated before the error was thrown, in bulks of 100:
1600: 500x500
2600: 400x400
4800: 300x300
Creating in smaller bulks will lead to more accurate numbers, but I think I'm onto something here - deliberate flash limit?
