# Photo gallery modify

**URL:** <https://forum.kirupa.com/t/photo-gallery-modify/11277>\
**Category:** Uncategorized\
**Created:** [January 14, 2003, 10:48pm UTC](https://forum.kirupa.com/t/photo-gallery-modify/11277 "2003-01-14T22:48:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![victim](https://avatars.discourse-cdn.com/v4/letter/v/7bcc69/32.png) [@victim](https://forum.kirupa.com/u/victim)\
**Post date:** [January 14, 2003, 10:48pm UTC](https://forum.kirupa.com/t/photo-gallery-modify/11277/1 "2003-01-14T22:48:21Z")

</div>

hi all,  
i’m modifying the photo gallery tutorial on this sit to suit me and i’ve got some questions on how best to modify it and also on how it works.

1. Firstly if I’m using the ten images supplied in the tutorial and i activate the SWF to load tutorial, do the images load 1 at at time or will i wait for the ten to load at once?

2. in either case, if say images load 1 by 1 and the image is 50K  
how can i add a pre-loader to each image so I’m not staring at a blank screen waiting for each image to pop up?

3. also, how can I modify the code to make it go to image 4 first,  
for eg, I have 10 thumbnail images in my main SWF, i want to click on thumb 5 button so it goes to image 5 in the gallery SWF instead of image 1 which it is doing, and then have the forward button go to image 6 etc, and the back button go to image 5 etc…

code…that’s used

/\*  
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 = “animation/”;  
// fill this array with your pics  
this.pArray = [“image0.jpg”, “image1.jpg”, “image2.jpg”, “image3.jpg”, “image4.jpg”, “image5.jpg”, “image6.jpg”, “image7.jpg”, “image8.jpg”, “image9.jpg”, “image10.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:** [January 15, 2003, 12:26am UTC](https://forum.kirupa.com/t/photo-gallery-modify/11277/2 "2003-01-15T00:26:07Z")

</div>

gallery doesn’t work when I upload it…

\_in the photo gallery SWF,

this.pathToPics = “[http://www.switchstudio.net/httpdocs/images/](http://www.switchstudio.net/httpdocs/images/)”;

all i get is the SWF with no images, is the above code correct,  
do I need an ‘index html’ page with the photo gallery SWF even though it’s loaded externally from my main SWF?

all help appreciated, thanks.

---

<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:** [January 21, 2003, 3:10pm UTC](https://forum.kirupa.com/t/photo-gallery-modify/11277/3 "2003-01-21T15:10:46Z")

</div>

Would any one know how to format the flash code to load the image names from a external PHP or Text file so that the Image Gallery project will become more flexible?

The code use in the modified code is like:  
this.pArray = [“image0.jpg”, “image1.jpg”, “image2.jpg”];

How can I modify the code to load names from a external file as an array?
