PDA

View Full Version : loadMovie() troubles


morghulis
03-01-2006, 10:15 PM
Well, I am new to actionscript, but hopefully this isnt a totally n00b question/problem. I am trying to create a dynamic endless thumbnail scroller. Unfortunately i cant get that far into it because I cant seem to get or set the properties for an empty movie clip that I am loading a jpeg into. I know this is a timing issue, that technically the jpeg hasnt been loaded into the empty MC by the time I am trying to get the _width (or anything else) of the MC. I tried using an onEnterFrame function and checking for the bytes loaded and then accessing the _width property...I must have not created the function correctly, cause that still didnt work. Anyway here is the code as I have it so far. Any help would be greatly appreciated.

var panel:MovieClip = _root.createEmptyMovieClip("panel", 10);

var blocksXML:XML = new XML();
blocksXML.ignoreWhite = true;
blocksXML.onLoad = function() {

for(i = 0; i < this.firstChild.childNodes.length; i++) {

var block:MovieClip = _root.panel.createEmptyMovieClip("block"+i, i);
block.loadMovie(this.firstChild.childNodes[i].attributes.src);


block._x = 15 + (15 * i) + (block._width * i); // this is the problem line
block._y = -((25/1000) * block._x) + 41;

}

}

blocksXML.load("XML/filmBlocks.xml");

Ricod
03-05-2006, 06:00 PM
You need to check wether or not the jpg is fully loaded yet. Only when this has been done, then the code should continue. Instead of using onEnterframe (which is frame dependant), you could check at a set interval. (see setInterval() in your help file for examples and an indepth explanation)

At the moment, I don't see anything in your code that checks wether or not all bytes have been loaded yet.