Preload af alle filer
Det er sikkert en for stor mundfuld af vise på en gang. Men jeg loader X antal filer fra et xml document og vil gerne have dem alle preloaded på en gang, men de bliver preloaded en af gangen. Altså min preloader bar loader et billede starter så forfra med næste.Jeg vil gerne have at alle billeder bliver loaded sammen som var de en stor fil.
Se: ######## Her går det galt #############
preloader._visible = false;
var iTotal;
var k;
var container:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth())
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
on_thumbnails = [];
off_thumbnails = [];
total = xmlNode.childNodes.length;
_level0.iTotal = total;
for(i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
on_thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
off_thumbnails[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
thumbnails_fn(i);
}
//firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("imagesAG.xml");
p = 0;
var filesize = 0;
var q = 0;
_root.onEnterFrame = function()
{
if(image != undefined && q != image.length)
{
this.createEmptyMovieClip("container"+q, this.getNextHighestDepth());//this.getNextHighestDepth()
q++;
}
else if(q == image.length) { pre(); }
}
function pre()
{
if(loaded == undefined || filesize == undefined)
{
preloader._visible = true;
preNext(q);
}
q=0;
j=0;
iTotal = (image.length-1);
preNext(q);
var append = 0;
var iTotalBytesToLoad;
######## Her går det galt #############
this.onEnterFrame = function()
{
if(this["container"+q].getBytesTotal() > 0 && this["container"+q].getBytesTotal() <= this["container"+q].getBytesLoaded())
{
q++;
preNext(q);
}
else
{
filesize = this["container"+q].getBytesTotal();
loaded = this["container"+q].getBytesLoaded();
preloader._visible = true;
if(loaded != filesize)
{
preloader.preload_bar._xscale = 100*loaded/filesize;
}
else
{
preloader._visible = false;
if(picture._alpha<100)
{
picture._alpha += 10;
}
}
if(q == iTotal)
{
trace("færdig");
shiftImages();
firstImage();
}
}
}
}
function preNext(q)
{
removeMovieClip(this["container"+(q-1)]);
this["container"+q].loadMovie(image[q]);
}
function shiftImages()
{
this.onEnterFrame = function()
{
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = false;
if(loaded != filesize)
{
//preloader.preload_bar._xscale = 100*loaded/filesize;
}
else
{
preloader._visible = false;
if(picture._alpha<100)
{
picture._alpha += 10;
}
}
}
}
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
//desc_txt.text = description[p];
picture_num();
}
}
}
function firstImage() {
removeMovieClip(this["container"+q]);
picture._alpha = 0;
picture.loadMovie(image[0], 1);
//desc_txt.text = description[0];
picture_num();
}
