开发者

AS3 try/catch out of memory

开发者 https://www.devze.com 2022-12-10 18:48 出处:网络
I\'m loading a few huge images on my flex/as3 app, but I can\'t manage to catch the error when the flash player runs out of memory.

I'm loading a few huge images on my flex/as3 app, but I can't manage to catch the error when the flash player runs out of memory.

Here is the what I was thinking might work (I use ???? because i dont know what to catc开发者_开发知识库h):

try{
    images = new Array(frames);
    for (var i:uint = 0; i < frames; i++){
         imagesBA[i] = new BitmapData(width, height, false, 0x000000FF);
    }
 }
catch(error:????){
     Alert.show("Out of memory!");
}

Any idea what ???? can be?

Or does anyone knows how to catch when there is no memory for a variable?


No there is no catch for it....

Saying that I can always catch all the errror in 10.1 using:

if(this.loaderInfo.hasOwnProperty("uncaughtErrorEvents"))
            {
                IEventDispatcher(loaderInfo["uncaughtErrorEvents"]).addEventListener("uncaughtError", global_error_handler);
            }


Have you tried flash.errors.MemoryError. I haven't check if it works, but the asdoc seems to say that's the way to go.

0

精彩评论

暂无评论...
验证码 换一张
取 消