# Looping gallery problem

**URL:** https://forum.kirupa.com/t/looping-gallery-problem/304525
**Category:** flash
**Created:** [February 9, 2010, 12:15pm UTC](https://forum.kirupa.com/t/looping-gallery-problem/304525 "2010-02-09T12:15:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![satup](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@satup](https://forum.kirupa.com/u/satup)
#### Post date: [February 9, 2010, 12:15pm UTC](https://forum.kirupa.com/t/looping-gallery-problem/304525/1 "2010-02-09T12:15:52Z")

</div>

Hi,

I have little problem, I am creating a vertical scrolling gallery with two buttons but I would like to make it looping, so when you get to the last photo and you press the “forward” button it jumps to the first image. I have gotten this done, but it’s now stopped to the last image and you have to scroll back to get to the first image…

So here goes:

speed = 2;  
photo\_width = 600;  
photo\_total = 10;  
photo\_num = 0;

photo\_mc.onEnterFrame = function() {  
photo\_mc.\_x += (final\_x - photo\_mc.\_x) / speed;  
};  
b1.onRelease = function() {  
(–photo\_num \< 0) ? photo\_num = 0 : null;  
final\_x = -photo\_width \* photo\_num;  
};  
b2.onRelease = function() {  
(++photo\_num \> photo\_total-1) ? photo\_num = photo\_total-1 : null;  
final\_x = -photo\_width \* photo\_num;  
};

I would appreciate any help, thanks!

-S
