AS3 try/catch out of memory

落花浮王杯 提交于 2020-01-05 13:24:19

问题


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 catch):

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?


回答1:


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);
            }



回答2:


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.



来源:https://stackoverflow.com/questions/1702753/as3-try-catch-out-of-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!