# Next previous button help \[flash 4, AC 2 \]

**URL:** <https://forum.kirupa.com/t/next-previous-button-help-flash-4-ac-2/281825>\
**Category:** Uncategorized\
**Created:** [February 13, 2009, 3:50pm UTC](https://forum.kirupa.com/t/next-previous-button-help-flash-4-ac-2/281825 "2009-02-13T15:50:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![markrob](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@markrob](https://forum.kirupa.com/u/markrob)\
**Post date:** [February 13, 2009, 3:50pm UTC](https://forum.kirupa.com/t/next-previous-button-help-flash-4-ac-2/281825/1 "2009-02-13T15:50:25Z")

</div>

hi, i’m trying to add some previous and next buttons to a gallery flash file i modified. i’d like to add buttons to the right and left of the large images so the user can advance the images without having to use the thumbnail bar. any help would be appreciated! the website is [http://jameegidwitz.com](http://jameegidwitz.com). here’s my current actionscript:

//set stage background color  
myColor = new Color(bgColor);  
myColor.setRGB(“0xffffff”);  
bg.\_alpha=0;

//The following is for general settings:  
\_root.originThumbnailX = mc\_thumbnail.\_x;  
var generalXML:XML = new XML();  
generalXML.ignoreWhite = true;  
generalXML.load(“general.xml”);  
generalXML.onLoad = loadGeneralXML;  
function loadGeneralXML(loaded) {  
if (loaded) {  
theRootNode = this.firstChild;  
\_root.largeImageEffect = theRootNode.childNodes[0].childNodes[0].nodeValue;  
var backgroundImage:String = theRootNode.childNodes[1].childNodes[0].nodeValue;  
if (backgroundImage.toUpperCase() == “ON”) {  
bg.\_alpha=100;  
}

var backgroundColor:String = theRootNode.childNodes[2].childNodes[0].nodeValue;  
//set stage background color  
myColor = new Color(bgColor);  
myColor.setRGB(“0x”+backgroundColor);

}  
}  
// The following is for the categories:  
var myXML:XML = new XML();  
myXML.ignoreWhite = true;  
myXML.load(“category.xml”);  
myXML.onLoad = loadXML;  
var catBtns:Array = Array();  
function loadXML(loaded) {  
if (loaded) {  
rootNode = this.firstChild;  
\_root.numberOfItem = rootNode.firstChild.childNodes.length;  
verticalDistance = rootNode.lastChild.childNodes[0].firstChild.nodeValue;  
for (var i = 0; i\<\_root.numberOfItem; i++) {  
menuList.categoryAll.m\_category.btn.duplicateMovieClip(“btn”+i, i);  
\_root.main.menuList.categoryAll.m\_category[“btn”+i].theText = rootNode.firstChild.childNodes\*.childNodes[0].firstChild.nodeValue;  
\_root.main.menuList.categoryAll.m\_category[“btn”+i].theID = rootNode.firstChild.childNodes\*.childNodes[1].firstChild.nodeValue;  
\_root.main.menuList.categoryAll.m\_category[“btn”+i].\_y = \_root.main.menuList.categoryAll.m\_category.btn0.\_y+(i_verticalDistance);  
\_root.main.menuList.categoryAll.m\_category[“btn”+i].btnNumber = i;  
catBtns.push(\_root.main.menuList.categoryAll.m\_category[“btn”+i]);  
}  
//catBtns[0].gotoAndStop(“2”);  
\_root.currentBtn = “”;  
}  
}  
function resetAllButtons() {  
catBtns[\_root.currentBtn].gotoAndPlay(“1”);  
}  
// The following is for the thumbnails and big image  
var myXML2:XML = new XML();  
myXML2.ignoreWhite = true;  
myXML2.load(“gallery\_bty.xml”);  
var Name:Array = Array();  
var ImgWidth:Array = Array();  
var ImgHeight:Array = Array();  
var thumbPath:Array = Array();  
var picPath:Array = Array();  
var linkURL:Array = Array();  
\_root.currentCatID = 1;  
\_root.gapH = 7;  
// horizontal space  
myXML2.onLoad = function(success) {  
displayPage();  
};  
function displayPage() {  
mc\_thumbnail.\_x = \_root.originThumbnailX;  
delete rightBtn.onEnterFrame;  
delete leftBtn.onEnterFrame;  
//remove existing thumbnails  
for (var i = 0; i\<\_root.numberOfItems; i++) {  
removeMovieClip(mc\_thumbnail[“img”+i]);  
}  
xml = myXML2.firstChild;  
\_root.numberOfItems = xml.childNodes.length;  
\_root.numberInCategory = 0;  
var itemsInThisCat:Array = Array();  
for (var i = 0; i\<\_root.numberOfItems; i++) {  
if (xml.childNodes_.childNodes[6].childNodes[0].nodeValue == \_root.currentCatID) {  
\_root.numberInCategory++;  
itemsInThisCat.push(i);  
}  
}  
var numberOfImgs:Number = itemsInThisCat.length;  
var integer:Number = Math.floor(numberOfImgs/7);  
var remainder:Number = numberOfImgs%7;  
var maxRightClickTime:Number = 0;  
//if total imgs over 7  
if (remainder == 0) {  
maxRightClickTime = integer-1;  
} else {  
maxRightClickTime = integer;  
}  
var leftClickTime:Number = 0;  
var rightClickTime:Number = 0;  
var currentTarget:Number = 0;  
leftBtn.\_visible = false;  
//if total imgs less than 7 or equal 7  
if (numberOfImgs\<7) {  
rightBtn.\_visible = false;  
} else {  
rightBtn.\_visible = true;  
}  
var originX:Number = mc\_thumbnail.\_x;  
currentTarget = 0;  
rightBtn.onRelease = function() {  
leftBtn.\_visible = true;  
rightClickTime++;  
if (rightClickTime == maxRightClickTime) {  
rightBtn.\_visible = false;  
}  
currentTarget = originX-(mc\_thumbnail.img.\_width+\_root.gapH)_7_rightClickTime;  
this.onEnterFrame = function() {  
diff = currentTarget-mc\_thumbnail.\_x;  
mc\_thumbnail.\_x += diff/4;  
};  
};  
leftBtn.onRelease = function() {  
rightBtn.\_visible = true;  
rightClickTime–;  
leftClickTime++;  
if (rightClickTime == 0) {  
leftBtn.\_visible = false;  
}  
currentTarget = originX-(mc\_thumbnail.img.\_width+\_root.gapH)_7_rightClickTime;  
this.onEnterFrame = function() {  
diff = currentTarget-mc\_thumbnail.\_x;  
mc\_thumbnail.\_x += diff/4;  
};  
};  
for (var i = 0; i\<itemsInThisCat.length; i++) {  
Name\* = xml.childNodes[itemsInThisCat\*].childNodes[0].childNodes[0].nodeValue;  
ImgWidth\* = xml.childNodes[itemsInThisCat\*].childNodes[1].childNodes[0].nodeValue;  
ImgHeight\* = xml.childNodes[itemsInThisCat\*].childNodes[2].childNodes[0].nodeValue;  
thumbPath\* = xml.childNodes[itemsInThisCat\*].childNodes[3].childNodes[0].nodeValue;  
picPath\* = xml.childNodes[itemsInThisCat\*].childNodes[4].childNodes[0].nodeValue;  
linkURL\* = xml.childNodes[itemsInThisCat\*].childNodes[5].childNodes[0].nodeValue;  
mc\_thumbnail.img.duplicateMovieClip(“img”+i, i);  
mc\_thumbnail[“img”+i].\_x = mc\_thumbnail.img.\_x+i\*(95+\_root.gapH);  
mc\_thumbnail.img0.\_x = 0;  
if (thumbPath\* == “undefined”) {  
mc\_thumbnail[“img”+i].enabled = false;  
} else {  
mc\_thumbnail[“img”+i].enabled = true;  
mc\_thumbnail[“img”+i].img\_mc.loadMovie(thumbPath\*);  
}  
mc\_thumbnail[“img”+i].theImageName = Name\*;  
mc\_thumbnail[“img”+i].theLinkURL = linkURL\*;  
mc\_thumbnail[“img”+i].thePicPath = picPath\*;  
mc\_thumbnail[“img”+i].theWidth = ImgWidth\*;  
mc\_thumbnail[“img”+i].theHeight = ImgHeight\*;  
}  
//load the first big image  
showLargeImg(ImgWidth[0], ImgHeight[0], picPath[0], linkURL[0], Name[0]);  
}  
function showLargeImg(theWidth:Number, theHeight:Number, thePicPath:String, theLinkURL:String, theImageName:String) {  
\_root.main.big\_mc.big\_mc\_image.container.\_alpha = 0;  
var theImageWidth:Number = theWidth;  
theImageHeight = theHeight;  
theDisplayAreaWidth = 735;  
theDisplayAreaHeight = mask.\_y+7;  
//trace(theDisplayAreaHeight+" "+mask.\_y);  
\_root.main.big\_mc.\_x = (theDisplayAreaWidth-theImageWidth)/2;  
\_root.main.big\_mc.\_y = (theDisplayAreaHeight-theImageHeight)/2;  
\_root.targetX = \_root.main.big\_mc.\_x-4;  
\_root.targetY = \_root.main.big\_mc.\_y-6;  
\_root.targetWidth = theImageWidth_1+7;  
\_root.targetHeight = theImageHeight_1+7;  
\_root.targetY2 = \_root.targetY-txtImageTitle.\_height;  
//define empty movieclip, my\_mc and preloader object  
var empty = \_root.main.big\_mc.big\_mc\_image.createEmptyMovieClip(“container”, “100”);  
\_root.main.big\_mc.big\_mc\_image.my\_mc = new MovieClipLoader();  
preload = new Object();  
\_root.main.big\_mc.big\_mc\_image.my\_mc.addListener(preload);  
preload.onLoadComplete = function(targetMC) {  
if (\_root.largeImageEffect.toUpperCase() == “ON”) {  
\_root.main.big\_mc.big\_mc\_image.container.\_alpha = 100;  
} else {  
\_root.main.big\_mc.big\_mc\_image.container.\_alpha = 0;  
}  
changeColor();  
};  
\_parent.onEnterFrame = function() {  
diffX = \_root.targetX-\_root.main.mc\_bigImageBg.\_x;  
\_root.main.mc\_bigImageBg.\_x += diffX/2.5;  
diffY = \_root.targetY-\_root.main.mc\_bigImageBg.\_y;  
\_root.main.mc\_bigImageBg.\_y += diffY/2.5;  
diffX2 = \_root.targetX-txtImageTitle.\_x;  
txtImageTitle.\_x += diffX2/2.5;  
diffY2 = \_root.targetY2-txtImageTitle.\_y;  
txtImageTitle.\_y += diffY2/2.5;  
diffWidth = \_root.targetWidth-\_root.main.mc\_bigImageBg.\_width;  
diffHeight = \_root.targetHeight-\_root.main.mc\_bigImageBg.\_height;  
\_root.main.mc\_bigImageBg.\_width += diffWidth/2.5;  
\_root.main.mc\_bigImageBg.\_height += diffHeight/2.5;  
if (Math.abs(diffX)\<1 && Math.abs(diffY)\<1) {  
delete \_parent.onEnterFrame;  
//load image  
\_root.main.big\_mc.big\_mc\_image.my\_mc.loadClip(thePicPath, “\_root.main.big\_mc.big\_mc\_image.container”);  
}  
};

//\_root.main.big\_mc.onRelease = function() {  
// getURL(theLinkURL, “\_blank”);  
// };

var alfa:Number = 0;  
var percentage:Number = 0;  
var amountLoaded:Number = 0;  
if (theImageName != undefined) {  
\_root.main.txtImageTitle.text = theImageName;  
} else {  
\_root.main.txtImageTitle.text = “”;  
}  
}  
function changeColor():Void {  
var colorComponent:Number = 500;  
onEnterFrame = function () {  
if (\_root.largeImageEffect.toUpperCase() == “ON”) {  
myColor = new Color(\_root.main.big\_mc.big\_mc\_image.container);  
myColTr = new Object();  
colorComponent += (100-colorComponent)/10;  
myColTr = {ra:colorComponent, ga:colorComponent, ba:colorComponent};  
myColor.setTransform(myColTr);  
if (Math.round(colorComponent) == 100) {  
delete this.onEnterFrame;  
colorComponent = 500;  
}  
} else {  
\_root.main.big\_mc.big\_mc\_image.container.\_alpha += 7;  
if (\_root.main.big\_mc.big\_mc\_image.container.\_alpha\>=100) {  
delete this.onEnterFrame;  
\_root.main.big\_mc.big\_mc\_image.container.\_alpha = 100;  
}  
}  
};  
}
