0

我已经为 ios 和 android 创建了一个应用程序。它将从本地目录动态加载一些图像并显示在屏幕上。但我意识到几个小时后应用程序会自动崩溃。请帮忙。下面的代码是我的代码

timer = new Timer(AppSetting.SCREENSAVER_INTERVAL * 1000);
timer.addEventListener(TimerEvent.TIMER, loadNewImage);
timer.start();

private function loadNewImage(e:TimerEvent):void {
    //timer.
    //timer.removeEventListener(TimerEvent.TIMER, loadNewImage);
    //var f_Index:int = int(Math.random() * images.length);

    var f_Loader:Loader =  new Loader();

    f_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void {
        //trace(System.totalMemory / 1024);
        f_Loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, arguments.callee);
        f_Loader = null;

        if (screensaver) {
            removeChild(screensaver);
            screensaver.bitmapData.dispose();
            screensaver = null;
            //System.gc();
        }

        screensaver = Bitmap(f_Loader.content);
        addChild(screensaver);
        screensaver.width = AppSetting.STAGE.stageWidth;
        screensaver.height = AppSetting.STAGE.stageHeight;
    });

    f_Loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void {
        trace("load screensavers image error!");
    },false);

    try {
        f_Loader.load(new URLRequest(File.applicationStorageDirectory.resolvePath(AppSetting.SC REENSAVER_PATH + images[f_Index]).url));
        f_Index = f_Index + 1;

        if (f_Index == images.length)
        {
            f_Index = 0;
        }
    } catch (e:Error) {
        trace("load screensavers image error!");
    }

    //timer.addEventListener(TimerEvent.TIMER, loadNewImage);
    //trace(System.totalMemory / 1024);
    dispatchEvent(new Event(LOADED));
}

我已将所有 var 设置为 null,但它仍然崩溃。

4

0 回答 0