Right here we go, firstly I’m no coder by any stretch of the imagination and thus have a little problem. I have some basterdised gallery code which displays the type of gallery, once the user chooses a gallery all the relevent thumbnails are displayed, the user can then click the thumbnails to show a more hi-res image. My problem is I’m struggling to develop next and previous buttons to cycle through the large images within the chosen gallery. Here is the code guys, any pointers would be great.
var firstLook:Boolean = true;
var menuButtons:MovieClip = galleryMenu_mc.buttonsHolder_mc;
var imagesHolder:MovieClip = imagesHolder_mc;
var descText:TextField = desc_mc.desc_txt;
var imagesInGallery:Array = new Array();
var galleryNames:Array = new Array();
var galleryIntros:Array = new Array();
var descriptions:Array = new Array();
var tracker:Number = new Number();
var whatIsLoading:String = new String();
var galleryBtnLeftMargin:Number = 10;
var galleryBtnUpperMargin:Number = 60;
var galleryBtnVSpace:Number = 112;
var thumbMarginX:Number = 112;
var thumbMarginY:Number = 100;
var radioadButtons:MovieClip = radioad_mc.radioadHolder_mc;
/* -------------------- Aligning and positioning imagesHolder_mc, the logo and the description text field -------------------- */
imagesHolder._x = 45;
imagesHolder._y = 205;
/* -------------------- The welcome text -------------------- */
descText.text = "yak, yak, yak.";
/* -------------------- MovieClipLoader & Listener -------------------- */
var loader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
loader.addListener(myListener);
myListener.onLoadInit = function(target:MovieClip) {
if (whatIsLoading == "thumb") {
currentThumbnail.percent_txt._visible = false;
thumbClickable();
tracker++;
if (tracker<howManyImages) {
loadThumbnail();
} else {
enableThumbs();
}
} else if (whatIsLoading == "big") {
target._alpha = 0;
displayBigImage.percent_txt._visible = false;
bigClickable();
fadeIn();
}
};
myListener.onLoadProgress = function(target:MovieClip, loaded:Number, total:Number) {
percent = Math.floor(loaded/total*100);
if (whatIsLoading == "thumb") {
currentThumbnail.percent_txt._visible = true;
currentThumbnail.percent_txt.text = percent+"%";
} else if (whatIsLoading == "big") {
displayBigImage.percent_txt._visible = true;
displayBigImage.percent_txt.text = percent+"%";
}
};
///////////////////////////////////////////////////////////
var imageGallery:XML = new XML();
imageGallery.ignoreWhite = true;
imageGallery.onLoad = function(success) {
if (success) {
parseGalleries();
} else {
descText.text = "Sorry the image data just didn't load.";
}
};
imageGallery.load("gallery.xml");
/* -------------------- parsing XML -------------------- */
function parseGalleries():Void {
if (imageGallery.firstChild.nodeName == "galleries") {
var rootNode:XMLNode = imageGallery.firstChild;
for (i=0; i<rootNode.childNodes.length; i++) {
if (rootNode.childNodes*.nodeName == "gallery") {
currentGallery = rootNode.childNodes*;
imagesInGallery.push(currentGallery.childNodes.length);
galleryNames.push(currentGallery.attributes.title);
galleryIntros.push(currentGallery.attributes.intro);
currentGalleryTitle = rootNode.childNodes*.attributes.title;
currentGalleryButton = galleryMenu_mc.buttonsHolder_mc.attachMovie("gallery section button", "galleryButton"+i, galleryMenu_mc.buttonsHolder_mc.getNextHighestDepth());
currentGalleryButton._x = galleryBtnVSpace*i;
currentGalleryButton._y = 0;
currentGalleryButton.sectionTitle_txt.text = +currentGalleryTitle.toUpperCase();
for (j=0; j<currentGallery.childNodes.length; j++) {
if (currentGallery.childNodes[j].nodeName == "image") {
currentDescription = currentGallery.childNodes[j].firstChild.toString();
descriptions.push(currentDescription);
}
}
}
}
}
numberOfGalleries = i;
enableButtons(numberOfGalleries);
}
///////////////////////////////////////////////////////////////////
function enableButtons(numberOfGalleries:Number):Void {
for (i=0; i<numberOfGalleries; i++) {
pressedButton = galleryMenu_mc.buttonsHolder_mc["galleryButton"+i];
pressedButton.onRollOver = function():Void {
this.gotoAndPlay("on");
//this.sectionTitle_txt.colorTo(0xfff315, 0.1);
};
pressedButton.onRollOut = function():Void {
this.gotoAndPlay("off");
//this.sectionTitle_txt.colorTo(0xff0000, 0.1);
};
pressedButton.onPress = function():Void {
removeMovieClip(thumbsDisplayer);
removeMovieClip(displayBigImage);
tracker = 0;
thumbsDisplayer = imagesHolder.createEmptyMovieClip("thumbsDisplayer_mc", imagesHolder.getNextHighestDepth());
clickedGallery = Number(this._name.substr(13));
howManyImages = imagesInGallery[clickedGallery];
whichGallery = galleryNames[clickedGallery];
descText.text = galleryIntros[clickedGallery];
currentRow = 0;
currentColumn = 0;
loadThumbnail();
};
}
enableGalleryNavigation();
}
///////////////////////////////////////////////////////////////////
function loadThumbnail() {
currentThumbnail = thumbsDisplayer.attachMovie("thumbnail holder", "thumbnail"+(tracker+1), thumbsDisplayer.getNextHighestDepth());
target = currentThumbnail.thumbImage_mc;
if ((tracker%5) == 0 && tracker != 0) {
currentRow += 1;
}
if (currentColumn>3) {
currentColumn = 0;
} else if (tracker == 0) {
currentColumn = 0;
} else {
currentColumn += 1;
}
currentThumbnail._x = currentColumn*thumbMarginX;
currentThumbnail._y = currentRow*thumbMarginY;
currentThumbnail.percent_txt._visible = true;
thumbNumber = currentThumbnail._name.substr(9);
thumbPath = "gallery/"+whichGallery+"/thumbs/"+thumbNumber+".jpg";
whatIsLoading = "thumb";
loader.loadClip(thumbPath, target);
//
//
if (whichGallery == imageGallery.firstChild.childNodes[3].attributes.title) {
this.FSMP3Player._visible = true;
this.attachMovie("FSMP3Player1", "FSMP3Player1", this.getNextHighestDepth());
this.FSMP3Player._x = 170;
this.FSMP3Player._y = 250;
}else {
this.FSMP3Player._visible = false;
}
//
//
}
////////////////////////////////////////////////////////////////////////
function thumbClickable():Void {
currentThumbnail.onPress = function() {
bigNumber = this._name.substr(9);
displayBigImage = imagesHolder.attachMovie("big image holder", "bigImage_mc", imagesHolder.getNextHighestDepth());
target = displayBigImage.imageHolder_mc;
bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
whatIsLoading = "big";
disableThumbs();
loader.loadClip(bigImagePath, target);
if (clickedGallery>0) {
var descPosition:Number = 0;
for (i=0; i<clickedGallery; i++) {
descPosition += imagesInGallery*;
}
descPosition = descPosition+Number(bigNumber)-1;
imageDesc = descriptions[descPosition];
} else {
imageDesc = descriptions[Number(bigNumber)-1];
}
descText.text = imageDesc;
};
currentThumbnail.enabled = false;
///
/*Next & Previous buttons*/
///
/*img_next.onRelease = function() {
//
bigNumber = clickedGallery;
p=imagesInGallery;
displayBigImage = imagesHolder.attachMovie("big image holder", "bigImage_mc", imagesHolder.getNextHighestDepth());
target = displayBigImage.imageHolder_mc;
bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
whatIsLoading = "big";
if (whatIsLoading == "big") {
//
trace("Gallery " + clickedGallery); //bigImagePath
trace("There are " + howManyImages + " images in this gallery");
trace("Image Number " + thumbNumber);
trace("There are " + currentGallery); //bigImagePath
//
disableThumbs();
loader.loadClip(bigImagePath, target);
if (clickedGallery<0) {
var bigNumber:Number = 0;
for (i=0; i<clickedGallery; i++) {
bigNumber ++;
}}
} else {
this.enabled = false;
}
//
}; */
img_next.onRelease = function() {
//
bigNumber = howManyImages;
p=imagesInGallery;
displayBigImage = this.attachMovie("big image holder", "bigImage_mc", this.getNextHighestDepth());
target = displayBigImage;
bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
whatIsLoading = "big";
if (whatIsLoading == "big") {
//
trace("Gallery " + clickedGallery); //bigImagePath
trace("There are " + howManyImages + " images in this gallery");
trace("Image Number " + thumbNumber);
trace("There are " + currentGallery); //bigImagePath
//
disableThumbs();
loader.loadClip(bigImagePath, target);
if (clickedGallery<0) {
var bigNumber:Number = 0;
for (i=0; i<howManyImages; i++) {
bigNumber ++;
}}
} else {
this.enabled = false;
}
//
};
///
/*End Next & Previous buttons*/
///
}
img_prev.onRelease = function() {
//
//
};
/////////////////////////////////////////////////////
Thanks in advace guys…