# Script for photo gallery

**URL:** https://forum.kirupa.com/t/script-for-photo-gallery/29098
**Category:** Uncategorized
**Created:** [August 22, 2003, 5:34am UTC](https://forum.kirupa.com/t/script-for-photo-gallery/29098 "2003-08-22T05:34:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![holePUNCHED](https://avatars.discourse-cdn.com/v4/letter/h/c67d28/32.png) [@holePUNCHED](https://forum.kirupa.com/u/holePUNCHED)
#### Post date: [August 22, 2003, 5:34am UTC](https://forum.kirupa.com/t/script-for-photo-gallery/29098/1 "2003-08-22T05:34:09Z")

</div>

OK no one answered my question…which is kinda good I guess cuz it made me puzzle it out. N E way, I am trying to get this dang photogallery to load into another movie. so I use \_root.contents.loadMovie(“portfolio.swf”); and it should load right? I don’t know. All my other swf’s loaded fine, just not this one. one pic shows up, and that’s it. No forward or back buttons, nothing. why would only one pic show up, and not have buttons? I open the swf, and everything is fine. It’s just not loading into my movie clip (contents). Could someone PLEEEZE help me???  
Thanks to everyone that has helped…you have been awesome.  
Here is the code for my folio that I got off the tut. Do any of the variables need to be changed in order to allow for dynamic loading?

// Code written by sbeener (suprabeener)  
//  
// i wrote this code, but you can use and abuse it however you like.  
// the methods are defined in the order which they occur to make it  
// easier to understand.  
//  
// variables ------------------------------------------  
// put the path to your pics here, include the slashes (ie. “pics/”)  
// leave it blank if they’re in the same directory  
this.pathToPics = “pics/”;  
// fill this array with your pics  
this.pArray = [“ad1.jpg”, “ad2.jpg”, “ad3.jpg”, “ad4.jpg”, “ad5.jpg”, “ad6.jpg”, “ad7.jpg”, “ad8.jpg”, “ad9.jpg”, “ad10.jpg”, “ad11.jpg”, “ad12.jpg”, “ad13.jpg”, “ad14.jpg”, “ad15.jpg”, “hand1.jpg”, “hand2.jpg”, “hand3.jpg”, “hand4.jpg”, “hand5.jpg”, “hand6.jpg”, “hand7.jpg”, “hand8.jpg”, “hand9.jpg”, “hand10.jpg”, “hand11.jpg”, “hand12.jpg”, “hand13.jpg”, “hand14.jpg”, “id1.jpg”, “id2.jpg”, “id3.jpg”, “id4.jpg”, “id5.jpg”, “id6.jpg”, “id7.jpg”, “id8.jpg”, “id9.jpg”, “id10.jpg”, “photo1.jpg”, “photo2.jpg”, “photo3.jpg”, “photo4.jpg”, “photo5.jpg”, “photo6.jpg”, “photo7.jpg”, “photo8.jpg”, “photo9.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);

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 22, 2003, 5:44am UTC](https://forum.kirupa.com/t/script-for-photo-gallery/29098/2 "2003-08-22T05:44:06Z")

</div>

> MovieClip.prototype.loadPhoto = function() {  
> // specify the movieclip to load images into  
> var p = \_root.photo;

This is just a guess from looking at the code quickly; but if your movie’s loaded in a different movie, \_root.photo should be changed too, right?

I have a photo gallery on one of my sites that’s a loaded movie into a movie, but I don’t remember what I changed in the code. I’ll look it up later if you still have problems.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 22, 2003, 5:48am UTC](https://forum.kirupa.com/t/script-for-photo-gallery/29098/3 "2003-08-22T05:48:42Z")

</div>

I have no idea  
I can give links to my fla files if you have some time to look at them.

[www.holepunched.com/ext\_index.fla](http://www.holepunched.com/ext_index.fla)  
[www.holepunched.com/ext\_portfolio.fla](http://www.holepunched.com/ext_portfolio.fla)

thanks in advance
