I'm still pretty novice when it comes to as3 and am trying to use modulus to loop 14 thumbnails in an array.
i have a property called firstThumb that keeps track of the first thumbnail being displayed and a forward and back function that looks like this
PHP Code:private function reverseThumbs(e:MouseEvent):void
{
trace("moving back");
displayThumbs(firstThumb-1, DISPLAYED);
//update our pointer to the first thumb to display
firstThumb--;
}
PHP Code:private function advanceThumbs(e:MouseEvent):void
{
trace("moving forward");
displayThumbs(firstThumb+1, DISPLAYED);;
//update our pointer to the first thumb to display
firstThumb++;
}
i also have a position counter to keep track of the thumbnails being displayed
if anyone has any suggestions for how i can go about using modulus to loop the images through, itd be greatPHP Code://display some of the thumbs in the thumbarray
private function displayThumbs (aStart,howMany:int):void
{
//13%14 modulus
//get rid any thumbs already displayed
for (var n = firstThumb; n < firstThumb+DISPLAYED; n++)
{
//remove the thumb if it is in the displaylist
if (this.contains(thumbArray[n])) removeChild(thumbArray[n]);
}
//then display the current four
var posCounter:int =0;
for (var i = aStart; i < aStart+howMany; i++)
{
addChild( thumbArray[i] );
thumbArray[i].y = 45;
thumbArray[i].x = 150 +posCounter*(thumbArray[i].width + MARGIN);
posCounter++;
}
}




Reply With Quote
