1

我正在尝试一次将 3 个 swf 文件加载到父 swf 中。但是,其中两个加载第三个会产生问题。另外两个使用我的自定义预加载器,但第三个无法识别它并显示默认的闪存加载器(带有 5 个点)。但是加载栏正确加载。如果我在我的第三个 SWF 中跟踪 this.parent,它会显示为 null。

不确定我是否在这里遗漏了一些明显的东西,但它们的代码都是相同的。

package  
{

import flash.display.Loader;
import flash.net.URLRequest;
import flash.display.MovieClip;
import flash.events.ProgressEvent;
import flash.events.IOErrorEvent;
import flash.events.Event;
import flash.system.Security;

public class PreloaderMain extends MovieClip
{
    private var l:Loader = new Loader();

    public function PreloaderMain() 
    {
        LoadGame3(); //THIS DOES NOT LOAD UP
    }   


    private function LoaderIOErrorHandler(i:IOErrorEvent):void
    {
        trace("IOErrorHandler: " + i.toString());
    }

    private function loop(e:ProgressEvent):void
    {
        var perc:Number = e.bytesLoaded / e.bytesTotal;
        mLoadingScreen.percent.text = (Math.ceil(perc * 100) + "%").toString();
    }

    private function done(e:Event):void
    {
        addChild(l);
    }


    private function LoadGame1():void // THIS LOADS FINE
    {
        l.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, LoaderIOErrorHandler);
        l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
        l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
        l.load(new URLRequest("SWF1.swf"));
        l.x = 20;
        l.y = 100;
    }

    private function LoadGame2():void //THIS LOADS FINE
    {
        l.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, LoaderIOErrorHandler);
        l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
        l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
        l.load(new URLRequest("SWF2.swf"));
        l.x = 20;
        l.y = 100;
    }

    private function LoadGame3():void //THIS GIVES A PROBLEM!!
    {
        l.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, LoaderIOErrorHandler);
        l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
        l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
        l.load(new URLRequest("SWF3.swf"));
        l.x = 20;
        l.y = 100;
    }
}

}

4

0 回答 0