# Invalid BitmapData error - Why?

**URL:** https://forum.kirupa.com/t/invalid-bitmapdata-error-why/245766
**Category:** flash
**Created:** [December 3, 2007, 8:27pm UTC](https://forum.kirupa.com/t/invalid-bitmapdata-error-why/245766 "2007-12-03T20:27:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Dark\_Viper](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dark_viper/32/3568_2.png) [@Dark\_Viper](https://forum.kirupa.com/u/Dark_Viper)
#### Post date: [December 3, 2007, 8:27pm UTC](https://forum.kirupa.com/t/invalid-bitmapdata-error-why/245766/1 "2007-12-03T20:27:48Z")

</div>

I have created a document class with this code:

```auto
package {
    //
    import flash.display.Sprite
    import flash.display.BitmapData;
    //
    public class main extends Sprite {
        //
        var allData:Array = new Array();
        //
        public function main() {
            var n:int;
            for (n=0;n<9000;n++) {
                var colour:int = Math.round(Math.random()*0xFFFFFF);
                var myBD:BitmapData = new BitmapData(2, 2, false, colour);
                allData[n] = myBD;
            }
        }
    }
}

```

This works fine and creates 9000 BitmapData objects.

However, if you change the loop size to 10000, you will get an Invalid BitmapData error and sometimes (for me anyway) Flash will continually display dialog boxes the content of which I cannot actually see (might be a Vista thing).

Note:all of the code is important - if you comment out the line which assigns the data to the array everything seems to work fine. I’ve never been more confused…

Anyone got any ideas?
