# Help with tweening photo gallery

**URL:** <https://forum.kirupa.com/t/help-with-tweening-photo-gallery/327381>\
**Category:** flash\
**Created:** [February 25, 2012, 10:58pm UTC](https://forum.kirupa.com/t/help-with-tweening-photo-gallery/327381 "2012-02-25T22:58:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sputnik1977](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@Sputnik1977](https://forum.kirupa.com/u/Sputnik1977)\
**Post date:** [February 25, 2012, 10:58pm UTC](https://forum.kirupa.com/t/help-with-tweening-photo-gallery/327381/1 "2012-02-25T22:58:29Z")

</div>

Hi everyone, I’m really stuck with this problem. I have a sliding photo gallery that uses thumbnails on the left side, and next and previous buttons to scroll through the images.

I have the next and prev btns functionality working. The problem is I can’t get the thumbnails working so when you click on them the main image slides into place. Please any help would be so appreciated!!!

There are 6 images in total. I’ve created instances of the first one (thumb1Press). Ideally it should slide the gallery back into place based on its relative position.

You can see the SWF here: [http://www.media77.ca/flashtest/image\_slideshow.swf](http://www.media77.ca/flashtest/image_slideshow.swf)

Here is the code:

import fl.transitions.easing._;  
import fl.transitions._;

//know what image to play  
var count :Number = 0;

//an array with the images x - coordinate  
var imagePos :Array = [115,-490,-1095,-1700,-2305,-2910];

var imgLength = imagePos.length-1;

//left button  
button\_left.buttonMode = true;  
button\_left.useHandCursor = true;  
button\_left.mouseChildren = true;  
button\_left.addEventListener(“mouseDown”,buttonLeftPress);  
button\_left.visible = true;

thumb1.buttonMode = true;  
thumb1.useHandCursor = true;  
thumb1.mouseChildren = true;  
thumb1.addEventListener(“mouseDown”,thumb1Press);  
thumb1.visible = true;

//right button  
button\_right.buttonMode = true;  
button\_right.useHandCursor = true;  
button\_right.mouseChildren = true;  
button\_right.addEventListener(“mouseDown”,buttonRightPress);  
button\_right.visible = true;

function leftStage(e:Event) {  
button\_left.visible = true;  
button\_right.visible = true;  
}  
function getPosition(e:MouseEvent) {  
if (mouseX \< stage.stageWidth/2) {  
button\_left.visible = true;  
button\_right.visible = false;  
} else {  
button\_left.visible = false;  
button\_right.visible = true;  
}

}  
//left button press  
function buttonLeftPress(e:MouseEvent) {  
count–;  
if (count \<0) {  
count = imgLength;  
}  
new Tween(mc,“x”,Regular.easeOut,mc.x,imagePos[count],1,true);  
}  
//right button press  
function buttonRightPress(e:MouseEvent) {  
count++;  
if (count \>imgLength) {  
count = 0;  
}

```
new Tween(mc,"x",Regular.easeOut,mc.x,imagePos[count],1,true);

```

}

//thumb 1  
function thumb1Press(e:MouseEvent) {  
new Tween(mc, “x”, Regular.easeOut, 0, 10, 1, true);  
}
