A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: pre-loader needed?

  1. #1
    Member
    Join Date
    Oct 2005
    Posts
    59

    pre-loader needed?

    Have a portfolio page www.paulmanlove.com, and am loading photo's externally, although with the script that I am using there is no pre-loader between photo's. How would I set up the file to have a pre-loader between each photo?

    Thanks for the help!

    Here is the script:

    this.pathToPics = "animation/";
    // fill this array with your pics
    this.pArray = ["history1.jpg", "history2.jpg", "history3.jpg", "downtown.gwash.one.jpg", "downtown.gwash.two.jpg", "downtown.oil.one.jpg", "Downtown.oil.two.jpg"];
    this.fadeSpeed = 20;
    this.pIndex = 0;
    // MovieClip methods ----------------------------------
    // d=direction; should 1 or -1 but can be any number
    //loads an image automatically when you run animation
    loadMovie(this.pathToPics+this.pArray[0], _root.photo);
    MovieClip.prototype.changePhoto = function(d) {
    // make sure pIndex falls within pArray.length
    this.pIndex = (this.pIndex+d)%this.pArray.length;
    if (this.pIndex<0) {
    this.pIndex += this.pArray.length;
    }
    this.onEnterFrame = fadeOut;
    };
    MovieClip.prototype.fadeOut = function() {
    if (this.photo._alpha>this.fadeSpeed) {
    this.photo._alpha -= this.fadeSpeed;
    } else {
    this.loadPhoto();
    }
    };
    MovieClip.prototype.loadPhoto = function() {
    // specify the movieclip to load images into
    var p = _root.photo;
    //------------------------------------------
    p._alpha = 0;
    p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
    this.onEnterFrame = loadMeter;
    };
    MovieClip.prototype.loadMeter = function() {
    var i, l, t;
    l = this.photo.getBytesLoaded();
    t = this.photo.getBytesTotal();
    if (t>0 && t == l) {
    this.onEnterFrame = fadeIn;
    } else {
    trace(l/t);
    }
    };
    MovieClip.prototype.fadeIn = function() {
    if (this.photo._alpha<100-this.fadeSpeed) {
    this.photo._alpha += this.fadeSpeed;
    } else {
    this.photo._alpha = 100;
    this.onEnterFrame = null;
    }
    };
    // Actions -----------------------------------------
    // these aren't necessary, just an example implementation
    this.onKeyDown = function() {
    if (Key.getCode() == Key.LEFT) {
    this.changePhoto(-1);
    } else if (Key.getCode() == Key.RIGHT) {
    this.changePhoto(1);
    }
    };
    Key.addListener(this);
    Last edited by Paul Manlove; 05-26-2008 at 06:17 PM.

  2. #2
    Senior Member ilive's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    195
    hi paul manlove! you can use movieclip loader class for that.

  3. #3
    Member
    Join Date
    Oct 2005
    Posts
    59
    Thanks Ilive, Can anyone tell me what a "movieclip loader" is? Is this a pre-loader on a movieclip? How would this be set up?

    Best, Paul

  4. #4
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    Hi Paul.here is a sample for you to take a look at. i does what yours does on the your site. it uses the MovieClipLoader and a listener to preload each image before showing it. let me know if it's good for you or not.
    Last edited by EQFlash; 07-26-2008 at 06:02 PM.

  5. #5
    Member
    Join Date
    Oct 2005
    Posts
    59
    Hi EQFlash,

    This code works great, although I would like to load the images into a MovieClip(mine is called "photo"). This allows me to control the layout, and location of images. Is it possible to use the new code and have the photo's load into a MovieClip? Or show I try to adjust the X and y coordinates on this code? Which would be fine, but I'm too much of a moron to know how and where to do that within this code. Ahhh

    Thanks! Paul
    Last edited by Paul Manlove; 06-01-2008 at 11:14 AM.

  6. #6
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    here is the same fla, only it's created inside a movieclip named = photo. on the stage is the textfield, the preloader bar and the photo movieclip in the top-left hand corner. the photo movieclip contains the script to load the images. you can now place the photo movieclip anywhere you want it. hope this helps. let me know
    Last edited by EQFlash; 07-26-2008 at 06:02 PM.

  7. #7
    Member
    Join Date
    Oct 2005
    Posts
    59
    Thanks EQFlash,

    Genius! Works great!, I only have one more question. With my previous set up when one moved to a new page the first image of that page would load automatically. With this new setup, it seems that one most click on the advance button to show the first image. How would one have the this image load automatically?

    Great work! Thanks,

    Paul

  8. #8
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    ok. in the script that loads the images you will see the lines that start like this. the script is obviously located in the photo movieclip. just click on it to edit it's script.
    PHP Code:
    listener.onLoadComplete = function(){

    right under this function put this;
    PHP Code:
    //load the first image in the array
    mcLoader.loadClip(path+pArray[0], container); 
    change where it says changeImage = -1 to changeImage = 0. the reason for this is because the first image is now loaded at runtime and the changeImage variable is set to zero for the buttons. everything else stays the same as before.
    let me know
    Last edited by EQFlash; 06-01-2008 at 02:53 PM.

  9. #9
    Member
    Join Date
    Oct 2005
    Posts
    59
    Works like a charm!

    Thank you for your time and patience.

    Best, Paul

  10. #10
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    my pleasure

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