XML and/or Actionscript

i’m creating a photo gallery which has 10 photos viewed through XML. I’ve got next and previous buttons aswell. How can I do to detect if its on the 10th photo the next button disappears and if its viewing the first button the previous button disappears? help pls help! 10x