I’m pulling stuff from a MYSQL database with PHP and attaching thumbnails which when clicked load larger images/videos into another flash window.
this is going great but for some reason when i pass my array index variable
into a function I get the wrong stuff popping up for each thumbnail.
I can get it to work by using the index variable minus 1 (see my code below) but the very last thumbnail is returning undefined values and therefore not loading the correct stuff.
anybody experienced this? I’m sure it’s because the array starts with zero. I just can’t figure out how to do it and still have the last item in the array work!! argggh!!! here’s the section of my code that has the index variable, the looping and all that jazz…
//loop through childnodes of array
for (var i=0; i<totalModels.length; i++) {
//assign an index variable to use in other functions/scope
//LOOK HERE IS WHERE I USE THE INDEX MINUS 1 item.index = i-1;
//attach clips for each model node
item = _root.holder.attachMovie("thumbClip", "thumbClip" + i, i);
item._x = (i%columns)*85;
item._y = Math.floor(i/columns)*thumb_spacing;
//assign variables to xml attributes
var firstName = totalModels*.attributes.First_Name;
var ModelWire = totalModels*.attributes.Modelwire
var lastName = totalModels*.attributes.Last_Name;
var thumbToLoad = "http://www.mywebsite.com/media/images/thumbs/"+totalModels*.attributes.Filename;
//load thumbs & assign first/lastname
item.thumbHolder.loadMovie(thumbToLoad);
item.largeviewtoload=largeviewtoload;
item.thumbFirstName.text=firstName;
item.thumbLastName.text=lastName;
//create a function for thumbnail button
item.ThumbButton.onRelease=function(){
_root.detailsClip.gotoAndPlay("in");
_root.holder._alpha=20;
_root.detailsClip.firstName = totalModels[this._parent.index].attributes.First_Name;
_root.detailsClip.lastName = totalModels[this._parent.index].attributes.Last_Name;
_root.detailsClip.ModelWire = totalModels[this._parent.index].attributes.ModelWire;
_root.detailsClip.waist = totalModels[this._parent.index].attributes.Waist;
_root.detailsClip.inseam = totalModels[this._parent.index].attributes.Inseam;
_root.detailsClip.hair = totalModels[this._parent.index].attributes.Hair;