# Reusable Preloader Using MovieClipLoader

**URL:** <https://forum.kirupa.com/t/reusable-preloader-using-moviecliploader/226423>\
**Category:** Uncategorized\
**Created:** [May 21, 2007, 1:03pm UTC](https://forum.kirupa.com/t/reusable-preloader-using-moviecliploader/226423 "2007-05-21T13:03:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikising](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@nikising](https://forum.kirupa.com/u/nikising)\
**Post date:** [May 21, 2007, 1:03pm UTC](https://forum.kirupa.com/t/reusable-preloader-using-moviecliploader/226423/1 "2007-05-21T13:03:17Z")

</div>

Hi ,

I have used this wonderful tutorial and it is actually working in my swf! I am so happy because it’s been terrible trying to find a preloading solution for my image gallery which has a script that must be kept on the first frame. The only thing now is that my buttons are in a sliding menu and so the external jpgs being loaded are sliding as well. I am wondering , is there any way with this script to place the “container” or empty mc and the loading bar etc. in a different mc than the buttons? That is the container where the images are loading into and the loading bar be in a different place to the buttons?

Tutorial :  
[http://www.kirupa.com/developer/acti...cliploader.htm](http://www.kirupa.com/developer/acti...cliploader.htm)

The code is:

```auto
MovieClip.prototype.fadeIn = function() {
    this.onEnterFrame = function() {
        if (this._alpha<100) {
            this._alpha += 10;
        } else {
            delete this.onEnterFrame;
        }
    };
};
bar._visible = false;
border._visible = false;
var empty = this.createEmptyMovieClip("container", "100");
empty._x = 447;
empty._y = -250;
my_mc = new MovieClipLoader();
preload = new Object();
my_mc.addListener(preload);
preload.onLoadStart = function(targetMC) {
    trace("started loading "+targetMC);
    container._alpha = 0;
    bar._visible = true;
    border._visible = true;
    pText._visible = true;
};
preload.onLoadProgress = function(targetMC, lBytes, tBytes) {
    bar._width = (lBytes/tBytes)*100;
    pText.text = "% "+Math.round((lBytes/tBytes)*100);
};
preload.onLoadComplete = function(targetMC) {
    container.fadeIn();
    border._visible = false;
    bar._visible = false;
    dText._visible = false;
    trace(targetMC+" finished");
};
//default image
my_mc.loadClip("movieClipLoader/picture1.jpg", "container");
//buttons
button1.onPress = function() {
    my_mc.loadClip("picture1.jpg", "container");
};
button2.onPress = function() {
    my_mc.loadClip("picture2.jpg", "container");
};
button3.onPress = function() {
    my_mc.loadClip("picture3.jpg", "container");
};

```

Can anyone help me modify the code so that the container and loadbar is on the main stage ( or another mc on the main stage) outside of the sliding menu where the buttons are?

Thanks I really appreciate the help,

Niki
