0

我已经用几个不同的 SWF 文件进行了尝试,以确保它与我真正想要加载的文件无关

package 
{
import flash.automation.ActionGenerator;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.net.URLRequest;

/**
 * ...
 * @author Megan Morgan Games
 */
public class Main extends Sprite 
{

    private var myLoader:Loader = new Loader();

    public function Main():void 
    {
        if (stage) init();
        else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init(e:Event = null):void 
    {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        var url:URLRequest = new URLRequest("CandyFactory.swf");
        myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, stillLoading);
        myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, doneLoading);

        myLoader.load(url);
    }

    private function stillLoading(e:ProgressEvent):void
    {
        trace("Still Loading");
    }

    private function doneLoading(e:Event):void
    {
        trace("Done Loading");
        myLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, doneLoading);
        addChild(e.currentTarget.content);
    }

}

}

最终产品是一款免费的在线游戏,我无法单独加载不同的“场景”,因此我不会嵌入当时不需要的资产。

当我运行它时,无论我插入什么 SWF,它都会重复跟踪已完成的加载并且没有任何显示(我假设是因为它无法同时处理十几个不同的游戏实例)。

4

0 回答 0