# Using mx.controls.Loader

**URL:** <https://forum.kirupa.com/t/using-mx-controls-loader/216584>\
**Category:** flash\
**Created:** [February 18, 2007, 2:37pm UTC](https://forum.kirupa.com/t/using-mx-controls-loader/216584 "2007-02-18T14:37:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![WearDark](https://avatars.discourse-cdn.com/v4/letter/w/48db29/32.png) [@WearDark](https://forum.kirupa.com/u/WearDark)\
**Post date:** [February 18, 2007, 2:37pm UTC](https://forum.kirupa.com/t/using-mx-controls-loader/216584/1 "2007-02-18T14:37:22Z")

</div>

Can I use an instance of this class to load images in a similar way to placing a Loader component on stage and setting its contentPath?

I want to place an instance of Loader inside a sublcass of MovieClip and then create a method in that class that gets called when I want to load a picture into an instance of the subclass…

This code is in the subclass and \_imageLoader is an instance of mx.controls.loader:

```auto

function loadImage(path:String){
        trace("Loading: " + path);
        _imageLoader.contentPath = path;
}

```

Then in the actions I use in the .fla file I can use the following:

```auto

function addImages(){
    for(var i:Number = 0; i < tiles.length; i++){
        if(i < 10){
            var imagePath:String = "images//1_0" + i + ".jpg";
            tiles*.loadImage(imagePath);
        }
        else{
            var imagePath:String = "images//1_" + i + ".jpg";
            tiles*.loadImage(imagePath);
        }
    }
}

```

to load an image… will that work? Obviously it currently does not… but does my approach sound correct? Can the Loader class be used to accomplish this goal?

Cheers.
