# Loading Images from an array?

**URL:** <https://forum.kirupa.com/t/loading-images-from-an-array/301909>\
**Category:** flash\
**Created:** [December 17, 2009, 5:15pm UTC](https://forum.kirupa.com/t/loading-images-from-an-array/301909 "2009-12-17T17:15:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dawood77](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@dawood77](https://forum.kirupa.com/u/dawood77)\
**Post date:** [December 17, 2009, 5:15pm UTC](https://forum.kirupa.com/t/loading-images-from-an-array/301909/1 "2009-12-17T17:15:14Z")

</div>

I know there are tons of tutorials out there about loading images from an xml file and creating a slide show. I can plug and play with those pretty good. However I would prefer it if I could start writing code myself. I am starting basic and each day working on adding code to a project.

Here is a made up app. Basically I have created three loaders that add an image to each one which I put into an array, cause why not. I have two event listeners one for an on stage click to load an image, and one a timer to load an image. The next thing I would like to try and do is load one image for a period of time, then load another etc.

So would I need a loop that loops through the array somehow connected with a timer?

public class array extends Sprite  
{  
//Create Loaders  
private var imageOne:Loader= new Loader;  
private var imageTwo:Loader= new Loader;  
private var imageThree:Loader= new Loader;  
private var images:Array = new Array(imageOne,imageTwo,imageThree);

```
    public function array()
    {
        //var imageOne:int=1;
        //var imageTwo:int=2;
        //var imageThree:int=3;
            
         imageOne.load(new URLRequest ("http://img.ffffound.com/static-data/assets/6/dd5e19de0ea063af8acb4a9e5ab86a3f02aff655_m.jpg"));
        imageTwo.load(new URLRequest ("http://img.ffffound.com/static-data/assets/6/f420968697dce9fb1dc8a5122c22c45266d1c4a1_m.jpg"));
        imageThree.load(new URLRequest ("http://img.ffffound.com/static-data/assets/6/ac7f15a5a22619ddda08e68ce2e99cd2d7190fdf_m.jpg"));
                    
        //add listener
        stage.addEventListener(MouseEvent.CLICK, onClick);
        
        //create timer
        var tTimer:Timer = new Timer (8000, 0);            
        
        //add listener.
        tTimer.addEventListener(TimerEvent.TIMER, onTimer);
                    
        //astart timer
        tTimer.start();
        
    }     
            //This loads the image once the stage is clicked.
            private function onClick (event:MouseEvent):void{
                addChild (imageOne);
            }    
            
    //Timer function
    
    private function onTimer (event:TimerEvent):void{
        addChild (imageOne);
        
    }                                     

```

}  
}
