Ok, so I have a sidescroller I’m trying to dynamically load images and text into. So I setup a single movieclip with movieclips I’m loading into inside my main arrayed moviclip. Like I have srollerMovie, then inside that I have picture(mc), title_txt (mc) and desc_txt . I can get the info I need loaded from my xml into the first 2 scrollerMovie, using my Image and nextImage functions, but how do I load it into the whole array with just the one function? Attached is my flashfile, and xml and images and below is my code. I also need to know how to set the depth below my buttons and how to attach my bounce to this arrayed moviclip, and set the distance dynamically so I don’t go too far when I have 5 or 10 images loaded. I’ve used a few tutorials (well pieces of the tutorials to get this far. and I guess I really don’t understand where the “p” comes from, I kind of understand the new, as the array makes new movieClips called new, and p is the arrayed number like i in the loop, but I don’t it set anywhere, it just works, maybe someone can explain this to me as I can’t find any explanations on it.
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
title = [];
link = [];
btn = [];
total = xmlNode.childNodes.length;
var xPos = 90;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
title* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
link* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
btn* = xmlNode.childNodes*.firstChild.nodeValue;
var scrollerMovie = attachMovie("scrollerMovie", "new"+i, i, {_x:xPos, _y:42});
xPos += scrollerMovie._width+20;
}
firstImage();
nextImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
p = 0;
function firstImage() {
this["new"+p].picture.loadMovie(image[0], 1);
this["new"+p].desc_txt.text = description[0];
this["new"+p].title_txt.text = title[0];
}
function nextImage() {
p++;
this["new"+p].picture.loadMovie(image[p], 1);
this["new"+p].desc_txt.text = description[p];
this["new"+p].title_txt.text = title[p];
}
leftBtn.onRelease = function(){
easeType = mx.transitions.easing.Bounce.easeOut;
var begin = 45;
var end = 270;
var time = 2.5;
var mc = scrollerMovie;
scrollerMovie = new mx.transitions.Tween(mc, "_X", easeType, begin, end, time, true);
}
rightBtn.onRelease = function(){
easeType = mx.transitions.easing.Bounce.easeOut;
var begin = 270;
var end = 45;
var time = 2.5;
var mc = scrollerMovie;
scrollerMovie = new mx.transitions.Tween(mc, "_X", easeType, begin, end, time, true);
}