# Loop through images - code correction required

**URL:** <https://forum.kirupa.com/t/loop-through-images-code-correction-required/316344>\
**Category:** flash\
**Created:** [November 18, 2010, 10:22pm UTC](https://forum.kirupa.com/t/loop-through-images-code-correction-required/316344 "2010-11-18T22:22:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisjacks](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@chrisjacks](https://forum.kirupa.com/u/chrisjacks)\
**Post date:** [November 18, 2010, 10:22pm UTC](https://forum.kirupa.com/t/loop-through-images-code-correction-required/316344/1 "2010-11-18T22:22:21Z")

</div>

Hi folks,  
I am new to AS, but have spent some time traversing these forums to teach myself.

I am trying to loop through a series of images in my library that are all linked as follows:  
image\_01  
image\_02  
image\_03  
image\_04  
etc

I want to loop through each of these images automatically. There are two parts I need help on.

**1) Can someone help me correct the code below?**

```auto
 
if (imagecounter = undefined)
{
imagecounter = 1;
} else {
imagecounter = imagecounter++
}
currentImage = "image_" + imagecounter;
currentImageNewName = currentImage + "playing";
holder1_mc.attachMovie(currentImage,currentImageNewName,1);

```

**2) How do I check if a linked movie exists?**  
ie:  
if (currentImage = exists) ?  
Any help is very much appreciated! Thanks!

Kind Regards,  
Chris
