Ok, so I have a scroller, with buttons on eachside, when the buttons clicked it slides either way on the x direction to show another images (holder). Right now it just jumps from image to image, and I’ll put easing on it once I get this figured out. BUT, I can’t get it to stop at the constraints of my dynamic movie. Right now I have 10 images in and I can trace all the maxWidth etc, but my first one always comes up NaN, so I can’t find the beggining. Below is my code as well as some of the traces I have done to try to get this to work.
Traces:
totalClips I get 1,2,3,4,5,6,7,8,9,10 (I just want the last one tho, how do I get that?
w_clips I get Nan, 161.5 (9times sorry, not gonna type 161.5 and confuse ya)
**totalWidth **I get NaN, 323, 484.5, 646, 807.5, 969, 1130.5, 1292, 1453.5, 1615
maxleft I get 10 undefieneds.
and maxright, I get NaN then the distances. How do I set this up so I don’t get the NaNs and undefineds, and how do I stop my movie from moving on my left and right btns when it reaches these max widths??
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;
scrollerMovie.picture.loadMovie (image*, 1);
scrollerMovie.desc_txt.text = description*;
scrollerMovie.title_txt.text = title*;
var totalClips = scrollerMovie=i+1;
var clipBaseName = 'new';
var w_clips = _root[clipBaseName + '1']._width+2;
var totalWidth = (totalClips * w_clips);
var maxleft = ["new"+i]._x;
var maxright = (totalWidth/2);
trace(maxleft);
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
_root.leftBtn.swapDepths(99);
_root.rightBtn.swapDepths(109);
_root.lines.swapDepths(89);
leftBtn.onRelease = function(){
for (var i=0; i<total; i++) {
_root["new"+i]._x += 161.5;
if(_root["new"+i]._x <= maxleft){_root["new"+i]._x += totalWidth;}
}
}
rightBtn.onRelease = function(){
for (var i=0; i<total; i++){
_root["new"+i]._x -= 161.5;
if(_root["new"+i]._x >= maxright){_root["new"+i]._x -= totalWidth;}
}
}