Prototype preloader, use it

How about a good prototype preloader?
U just type

holder.loadhere(x,y,"somemovie.swf","nameofmovie");

It will show a loading bar and preload your movie into holder movieclip.
Just copy-paste this code to your first frame, first scene.
Then use in root or in an instance.
eg. mc1.loadhere(0,0,“pic1.jpg”,“pic1”)
then the path of the loaded movie is _root.mc1.pic1

Maybe the code is a little bit dirty :x
If you have a question or suggestion… post it!

movieClip.prototype.loadhere=function(x,y,path,name) {

   // creates and positions clip, bar and text
   var containerText=name+"text";
   var containerBar=name+"bar";
   this.createEmptyMovieClip(name,1);
   this.createEmptyMovieClip(containerText,2);
   this.createEmptyMovieClip(containerBar,3);
   this[name]._x=x;
   this[name]._y=y;
   this[containerText]._x=x;
   this[containerText]._y=y;
   this[containerBar]._x=x;
   this[containerBar]._y=y;

   // draws the bar
   with (this[containerBar]){
      beginFill (0xDDDDDD, 50);
      lineStyle (1, 0x000000, 100);
      moveTo (0, 0);
      lineTo (80, 0);
      lineTo (80, 20);
      lineTo (0, 20);
      lineTo (0,0);
      endFill();
   }

   // loads movie
   this[name].loadMovie(path);
   var movie=this[name];
   var prelText=this[containerText];
   var prelBar=this[containerBar];

   // sets new text format
   var formtext=new TextFormat();
   formtext.color="0x000000";
   formtext.font="_sans";
   formtext.align="center";
   prelText.createTextField("loadtext",50,0,0,80,20);
   prelText.loadtext.border=false;

   // defines text display
   prelText.onEnterFrame=function() {
      if(this.percent!=100) {
         this.percent=int((movie.getBytesLoaded()/movie.getBytesTotal())*100)
         this.loadtext.text="Loading "+this.percent+"%";
         this.loadtext.setTextFormat(formtext);
         prelBar._xscale=this.percent;
      }
      if(this.percent==100) {
         delete this.onEnterFrame;
         this.removeMovieClip();
         prelBar.removeMovieClip();
      }
   }
} 
//end prototype

Make sure you run it in server enviroment just to see preloader, or using xat.com WebSpeed simulator (not advertising it)

Nice :slight_smile:

I’m putting this in the best of Kirupa if you don’t mind.

pom :asian:

joyhost, if it’s possible can you post the fla for the preloader plz ?! :smiley: thanx

It’s all-code!! What do you need a fla for? :stuck_out_tongue: :stuck_out_tongue:

pom :asian:

i’m missing something to make it play… :frowning:
can anyone HELP C:-)

What are you talking about? Are you saying that your externally loaded movie stops at your first frame…

what i mean is i don’t know how make this preloader play to use it. :frowning:
if you did it before, it’ll be greate if you send me .fla file =)
thanx

Here is a .fla http://www.danalu.com/proto_loader.fla

isnt the beauty of prototypes, classes, and the like that they can be used in any situation in any fla and get the same result - hmmm :smirk:

No offense, just playin’

Peace

Could you post the fla again so that I can see where the code actually resides please… it sound great

yea, I’d love to see this code too.

One quick question, is it possible to reference embeded fonts for the text, instead of using system fonts?