Looping gallery problem

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