Quick question about the XML photo gallery tutorial

Hi guys, I’m a flash newbie so please forgive me :wink:

Just wanted to ask how to make the “next” button loop back to the first image when it reaches the end? And the “previous” button loop to the end when at the beginning?

The tutorial I am referring to is this one: here