|
-
Unexplainable Invalid BitmapData error
I have created a document class with this code:
Code:
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?
-
a.k.a gltovar
yeah that stuff was starting to crash my stuff. I tried many different ways to see if I could massage out the glitch but it was a no go. I also kept throwing invalid data at different times ( around 9873 for me )
I don't know if you view this as a possible solution though:
Code:
package {
//
import flash.display.Sprite
import flash.display.BitmapData;
//
public class bitmap10000 extends Sprite {
//
var allData:Array = new Array();
//
public function bitmap10000() {
var n:Number;
while(allData.length <= 10000)
{
try
{
var colour:Number = Math.round(Math.random()*0xFFFFFF);
var myBD:BitmapData = new BitmapData(2, 2, false, colour);
allData.push(myBD);
}catch (err:Error)
{
trace("doh, it crapped out at: " + allData.length);
try
{
var randomness:int = Math.round(Math.random()*(allData.length-1));
allData.push(allData[randomness]);
}
catch (err2:Error)
{
trace("boooooo cant even do this, screw this im out");
break;
}
}
}
}
}
}
but it does make it to the end that way ^_^
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|