Hey guys, Im trying to make a horizontal scroller, that pulls images from an XML document, and scrolls them infinitely.
I have 2 problems with this and I have been looking everywhere for a tutorial, or example that shows how to do this and I always find something that is close to what I want but not quite.
Here is what I have so far:
var mcLoader:MovieClipLoader = new MovieClipLoader();
var mcListener:Object = new Object();
for(i=0; i<main.length; i++){
var mainLoader = loader_mc.createEmptyMovieClip("loader"+i, i);
mcLoader.addListener(mcListener);
mcLoader.loadClip(main*.attributes.url, mainLoader);
mcListener.onLoadInit = function(target:MovieClip){
trace(mainLoader); //returns loader_mc.loader11, 11 times.
};
mainLoader._y = 225;
mainLoader._x = loader_mc["loader"+(i-1)]._x + [U]490[/U];
};
onEnterFrame = function(){
loader_mc._x = loader_mc._x - 3;
};
What I’m wanting to do is instead of using 490 (underlined), I want to be able to get the width of each loaded image so that I can line up the next image right up against it regardless of its width (490 just happens to be the width of all of them right now).
I’m trying to use the onLoadInit() function, but I know I’m doing something wrong. When I try and trace my mainLoader variable, it traces the right amount of times, but they are all the last object in the group.
What do I need to do to be able to get the widths of each image as it loads, then use that variable to position the next image right after it?
also (a semi unrelated help request), what I’m doing right now is loading them ALL in creating one giant line of images, then loading in another giant line of images and just alternating between the 2 each time one is almost to the end of its length. Is there a better way to do this so that only the right amount will load, and scroll, at the beginning adding the one right before it enters stage, and as they move off stage they are removed, then when it’s near the end it just adds the first one back to the end?
Sorry for the HUGE wall of text, but this problem is starting to frustrate me.
Thank you for all of your help.