加载AS3的问题

时间:2012-06-18 11:10:08

标签: actionscript-3 flash actionscript

我正在尝试一次将3个swf文件加载到父swf文件中。但是,其中两个加载第三个出现了问题。另外两个使用我的自定义预加载器,但第三个无法识别它并显示默认的Flash加载器(带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;
    }
}

}

0 个答案:

没有答案