-
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.
-
Senior Member
hi paul manlove! you can use movieclip loader class for that.
-
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
-
Senior Member
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.
-
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.
-
Senior Member
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.
-
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
-
Senior Member
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.
-
Works like a charm!
Thank you for your time and patience.
Best, Paul
-
Senior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|