dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Preloader for jpg....any working code out there?

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    118

    Preloader for jpg....any working code out there?

    Im after a working .jpg preloader for a 100% dynamic site, ie nothing on the stage except the AS in frame 1 of _root.

    Something i can take apart and learn how it works, just the basic code will do, any ideas where i can get it people?

    Thanx in advance!

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try this code, hope it helps

    MovieClip.prototype.preloadJPG = function(yourImage) {
    this.createEmptyMovieClip("imagerTargetMC", 1);
    this.createTextField("preloadDisplay", 2, 5, 5, 300, 30);
    this.imagerTargetMC.loadMovie(yourImage);
    this.onEnterFrame = function() {
    this.preloadDisplay.text =
    this.imagerTargetMC.getBytesLoaded()/1024 + "KB LOADED" +
    this.imagerTargetMC.getBytesTotal();
    trace(this.preloadDisplay.text);
    if (this.imagerTargetMC.getBytesLoaded() > 1 && this.imagerTargetMC.getBytesLoaded() >= this.imagerTargetMC.getBytesTotal()) {
    this.preloadDisplay.removeTextField();
    delete this.onEnterFrame;
    this.onComplete();
    }
    }
    };

    this.createEmptyMovieClip("loadTarget", 1);
    loadTarget.preloadJPG("image01.jpg");

    function loadAnother (){
    imageLoaded = Number(imageLoaded)+2;
    if (imageLoaded < 6) {
    loadTarget.preloadJPG("image0"+imageLoaded+".jpg") ;
    } else {
    loadTarget.preloadJPG("image01.jpg");
    imageLoaded = 1;
    }
    };

    buttonNext.onRelease = function (){
    loadAnother();
    };

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Posts
    118
    Thanx for your speedy reply--------a_modified_dog--------- Your code works fine, i have spent the entire day trying out all sorts of different code but yours is the only one that works;-)

    I find it always helps to have working code when you are trying to understand how it works, once again thanx for your help... your a star!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center