Need Help with a Preloader Problem

I have the buttons load movie clips into a small area underneath them but I want to have a preloader that will load the movie instead of just opening it… What can I do?

Place the following on contents mc:

onClipEvent (enterFrame) {
        if (this._url != _root._url) {
                _root.preload(this);
        }
}

Now the following code on main timeline. Note that you must have a textfield with an instance name of percent and a loadbar (check the preloader tutorials on kirupa) with an instance name of loadBar. Both on root.

buttons_array = ["Home", "Downloads", "Events", "Speak Your Mind"];//your buttons INSTANCE names
function enableButton() {
        this.enabled = false;
        this._parent.contents.loadMovie(new String(this).substring(8, this.length)+".swf");
        for (var i in buttons_array) {
                if (this._parent[buttons_array*]._name != this._name) {
                        this._parent[buttons_array*].enabled = true;
                }
        }
}
for (var j in buttons_array) {
        this[buttons_array[j]].onPress = enableButton;
}
function preload(clip) {
        if (!loaded) {
                if (clip.getBytesLoaded>0 && clip.getBytesLoaded>=clip.getBytesTotal) {
                        loaded = true;
                }
                var percent = Math.round((clip.getBytesLoaded()/clip.getBytesTotal())*100);
                loadBar._width = 100*percent; //replace 100 for your loadbar width
        }
}

Untested though :-\

Now do I put the preload bar in the movie clip that will be loaded or in the whole thing itself…?

On the main movie
You can set its visibility to false by default and when you need it, set it visible again.

Ok…I’m just trying this test but it doesn’t seem to show the preloader when I preview it… :m:

And here is the first content it loads…

I dont get it… you are using a totally different code and you have no preloading actions on your code.

Get the second attachment I put there…that one has the preloader code in it.