Cant find any topics to suit my needs... Preloading external MC with loadbar in 2004!

Hi all. I have this major problem I hope someone can help me with.
I simply want to have a preloader with a loadbar to load my external movies in flash 2004… HOW can I do this? Ive been searching all over the net, but cant find anything I can use…

I found this code by “newhopekenny” in a topic, it works fine, but I was wondering if there is some way to adapt it to work in external movies. I’ve tried simply changing the paths but that didnt work out…
the code Im using is as follows:

 _root.stop();
// initialize the loadbar
_root.loadBarMC.onEnterFrame = function() {
        // stop the playhead
       
        // declare some variables
        var loaded = _root.getBytesLoaded();
        var total = _root.getBytesTotal();
        var totalPercent = Math.round((loaded/total)*100);
        // make the width of the loadbar
        // equal to the percent loaded
        _root.loadBarMC.loadBar_bar._xscale = totalPercent;
        // echo variables to output window
        trace("loaded = "+loaded);
        trace("total = "+total);
        trace("loadBar width = "+totalPercent);
        // if the movie is loaded, get the
        // playhead going again
        if (loaded == total) {
                _root.loadBarMC.gotoAndPlay("loaded");
                _root.gotoAndPlay(2);
                trace("Loaded!");
                // clear the onEnterFrame event
                // so that it's not still running
                // when it doesn't need to be
                delete this.onEnterFrame;
        }
};

Thx! :}

try the MovieClipLoader class !!
with this class you can load external .jpg and .swf into your movie
e.g.

myLoader = new MovieClipLoad();
myListener = new Object();

myListener.onLoadProgress = function(target_mc,loadedBytes,totalBytes){

target_mc.percentageLoader._xscale = loadedBytes/totalBytes*100;

}

myLoader.addListener(myListener);
myLoader.load(“myClip.swf”,myTarget_mc);

hope i could help you

Thx for replying Pete!
I’ll have a look at it!

Ok… I can’t get it to work! I need a little more info about the code!
Right now I have this, in the frame that holds my empty MC.

myLoader = new MovieClipLoad();
myListener = new Object();

myListener.onLoadProgress = function(MCholder,loadedBytes,totalBytes){

MCholder.LoadBar._xscale = loadedBytes/totalBytes*100;

}
myLoader.addListener(myListener);
myLoader.load(“myClip.swf”,MCholder);

-where “MCholder” is the name og my empty MC and “LoadBar” is the name of the percentence-loader (where should I place that one? right now I’ve put it in the first frame of the external movie, but that obiously doesn’t work! nothing gets loaded!

If u could just guide me a little bit, that would be great!
I appoligize for my stupiddity!!!

Thanks for your help! :smirk:

hey,
dont say that you are stupid !!
sorry if i let you think so
i made a little mistake in my script because the percentage movie should always be one level upper the movie in which it is loaded in.

here a .fla file for total clarity
i loaded in a picture (from blizzard) into an empty “container” which is in the _root level. there is also a preloader movie with the loadbar and textfield.
the reason why i load a picture from the internet and not from the local drive(and if you test it on the local drive for sure) is that i found out that if i load a pic or swf from local drive the onLoadProgress listener is not invoked( that is a little bit funny) !
but if you test in the web everything works properly.

Hi Pete!
This definetly cleared up some things for me about the movieClipLoader!
However, there is a “but”!! :h:
I tried making a flash from scratch, using your code, it works perfectly!
But, when I put the code in the movie im working with, it does not. I must be doing something wrong. I’ve even tried to copy-paste the frames from your flash, but nothing!
If u got time, could u try to take a look at my flash? I’ve stripped it down so the filesize isnt so big!
Thx for all your help!
:slight_smile:

okay,
just upload your file
or send it to my mail address

hmm thats wierd! thought I did!
I’ll try again! :slight_smile:

i had a smiliar problem…
If you find out what the problem was please post the fixed code/solution here.

okay
it would have been very helpful if you had said that you publish your movies in flash player 6 becaus MovieClipLoader class is first available in flash player 7.
but does not matter !!
here is the final .fla now it should work correctly :wink:

and here the final code:


loadin("http://www.blizzard.com/wow/images/screens/all/ss154.jpg");

function loadin(movie:String){
var BYTESTOTAL:Number = container.getBytesTotal();
container.loadMovie(movie);
preloader.loader._xscale = 0;
preloader.percText.text = "0%";
preloader.onEnterFrame = function(){
	if(container.getBytesTotal()>BYTESTOTAL){
	var perc:Number = Math.round(container.getBytesLoaded()/container.getBytesTotal()*100);
	this.loader._xscale = perc;
	this.percText.text = perc + "%";
		if(perc == 100){
			this.onEnterFrame = null;
		}
	}
}
} 

****! I knew it was for some lame reason it didn’t work! I never would have thought of tjecking my publish settings though!!
Thank u so much for helping me out! :smiley:

ohhh,
I know the moviecliploaded class first came out with flash player 7, but i didn’t know that it wouldn’t work if you published it to flash player 6, wouldn’t flash give you an error that some of the code isn’t compatible?