As2 jpg预加载器从xml中拉出来

时间:2010-09-06 13:02:50

标签: xml flash preloader actionscript-2

我正在尝试构建一个简单的预加载器。我在舞台上有4个动画片段,每一个我都在添加一个来自xml文件的图像

theMap = new XML();
theMap.ignoreWhite = true;

theMap.onLoad = function(success){
    if (success) {
        theNodes = theMap.firstChild.childNodes;
        for (i=0;i < theNodes.length;i++) {
            theSrc      = theNodes[i].attributes.src; //the jpg
            theClip     = theNodes[i].attributes.clip; //the movieclip
            _root[theClip].loadMovie(theSrc); // adding the jpg to the movieclip
        }
    }
    else {
        trace('Cannot Load XML file.');
    }
}
theMap.load("map.xml");

一切正常,但由于jpgs有点重,我想加载它们。那可能吗?

1 个答案:

答案 0 :(得分:0)

        var mcLoader:MovieClipLoader = new MovieClipLoader();
        mcLoader.addListener(this);
        this.onLoadProgress = function(target_mc:MovieClip,bytesLoaded:Number,bytesTotal:Number){
            var percentage:Number = int(bytesLoaded/bytesTotal*100);
            trace(percentage);
            if (percentage >= 100) { _root.waiting._visible = false; }
        }

        mcLoader.loadClip(theSrc,theClip);