Skip to main content
Participant
March 21, 2007
Question

Preloading pictures through XML.

  • March 21, 2007
  • 1 reply
  • 143 views
Hello,

I am building a dynamic photogallery which load pictures out of an XML-file in a movieclip.
The problem is that my preload script not work proper. The preloader stops by picture 2. Is there anybody here who has the experience to help me? Any improvements or suggestions for my script are very welcome.
This is my script:

var xml:XML = new XML();
xml.ignoreWhite = true;
var mcl:MovieClipLoader = new MovieClipLoader;
var bronnen:Array = new Array();
var nodes:Array = new Array();
xml.onLoad = function() {
nodes = xml.firstChild.childNodes;
for(var i=0;i<nodes.length;i++) {
bronnen.push(nodes .attributes.bron);
var foto:MovieClip = houder.createEmptyMovieClip("foto"+i,houder.getNextHighestDepth());
mcl.loadClip(bronnen
,foto);
var mclL:Object = new Object();
mclL.onLoadProgress = function(doel:MovieClip,geladen:Number,totaal:Number):Void {
var procent:Number = geladen/totaal;
if(procent==1) {
g++;
if(g==nodes.length*nodes.length) {
trace("Alle foto's zijn geladen.");
}
}
}
mcl.addListener(mclL);
}
var i:Number = new Number();
mclL.onLoadInit = function() {
foto_b.push(houder["foto"+i]._width);
foto_l.push(houder["foto"+i]._height);
foto_x.push(foto_b *i);
foto_y.push((houder._height - foto_l
)/2);
if(i==0) {
foto_x = 0;
} else {
foto_x
= foto_x[i-1] + foto_b[i-1];
}

houder["foto"+i]._x = foto_x ;
houder["foto"+i]._y = foto_y
;

if(i>nodes.length-(nodes.length-1)) {
var hoogsteNummer:Number = zoekHoogsteNummer(foto_l);
masker.lineTo(foto_b[0],0);
masker.lineTo(foto_b[0],foto_l[0]);
masker.lineTo(0,foto_l[0]);
masker.endFill();
masker._x = (Stage.width/2) - (masker._width/2);// + (foto_b /2);
masker._y = foto_y[0];
}
i++;
houder_x = Stage.width/2 - foto_b[i-nodes.length]/2;
houder_y = Stage.height/2 - foto_l[hoogsteNummer]/2;
houder._x = houder_x;
houder._y = houder_y;

masker._y += houder_y;
}
}
xml.load("zonder_zon.xml");


Greetings,
Albus
This topic has been closed for replies.

1 reply

RenifiusAuthor
Participant
March 22, 2007
Does nobody has any suggestions?