使用AS2预加载外部swfs

时间:2011-04-15 10:05:57

标签: flash external preloader actionscript-2

我找到了这段代码,它可以在我做了一段时间的旧AS2项目中预加载我的单个'Q1.swf'。如何调整它以预加载5个swf?我可以将它们全部加载到同一目标mc,还是必须将它们加载到不同的级别或不同的目标上。 我不想将项目更改为AS3,因为预算不允许。当从CD和在线查看项目时,这也能工作吗?

stop();
preloader._visible = false;
preloader.bar._xscale = 0;
var mclListener:Object = new Object();
mclListener.onLoadInit = function(container:MovieClip) {
trace('initialized');
};
mclListener.onLoadStart = function(container:MovieClip) {
preloader._visible = true;
trace('started');
};
mclListener.onLoadProgress = function(mc, w, t) {
trace('progress: '+w+", "+t);
var w = container.getBytesLoaded();
var t = container.getBytesTotal();
preloader.percent = Math.round(w/t*100)+"%";
preloader.bar._xscale = Math.round(w/t*100);
};
mclListener.onLoadComplete = function(container:MovieClip) {
trace("loaded");
preloader._visible = false;
_root.play();
};
mclListener.onLoadError = function(container:MovieClip, errorCode:String) {
preloader._visible = false;
trace('not loaded');
};
var container1:MovieClipLoader = new MovieClipLoader();
container1.addListener(mclListener);
container1.loadClip("Q1.swf", container);

1 个答案:

答案 0 :(得分:0)

我这样做:

function loadSection() {
    ext_mc.loadMovie("01.swf");
    bg_mc.loadMovie("bg.swf");  

    _root.createEmptyMovieClip("ctrl_mc",_root.getNextHighestDepth());
    _root.ctrl_mc.onEnterFrame = function() {
        vbt = ext_mc.getBytesTotal() + bg_mc.getBytesTotal()
        vbl = ext_mc.getBytesLoaded() + bg_mc.getBytesLoaded()
        if (vbl >= vbt && vbl > 200) {

            delete _root.ctrl_mc.onEnterFrame;              
             trace("do something")
        }
    };
}