# If else else if

**URL:** <https://forum.kirupa.com/t/if-else-else-if/229564>\
**Category:** Uncategorized\
**Created:** [June 18, 2007, 4:33pm UTC](https://forum.kirupa.com/t/if-else-else-if/229564 "2007-06-18T16:33:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Multi\_Task](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@Multi\_Task](https://forum.kirupa.com/u/Multi_Task)\
**Post date:** [June 18, 2007, 4:33pm UTC](https://forum.kirupa.com/t/if-else-else-if/229564/1 "2007-06-18T16:33:43Z")

</div>

Hey yall question about an if else statement I am trying to write for a gallery. I want to have it so if picture is on last one to go to first set on xml. Heres what I am writing it as:

```auto

function nextImage() { 
if (p<(total-1)) { 
 p++; 
} else if (p==4) {
 p =0;
}
if (loaded == filesize) { 
picture._alpha = 0; 
picture.loadMovie(image[p], 1); 
wer.title_txt.text = title[p];
we.desc_txt.text = description[p];
picture.link = link[p];
picture_num();
}
}

```

I have it written on my next image function because many things refer to that so check here then proceed to first set if on last. The problem is it stays on 4 or last item in xml. Can someone hit me with some insight. Thanks in advance. mT
