# Photo gallery with text

**URL:** https://forum.kirupa.com/t/photo-gallery-with-text/38449
**Category:** Uncategorized
**Created:** [December 23, 2003, 12:28am UTC](https://forum.kirupa.com/t/photo-gallery-with-text/38449 "2003-12-23T00:28:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jturuc](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jturuc](https://forum.kirupa.com/u/jturuc)
#### Post date: [December 23, 2003, 12:28am UTC](https://forum.kirupa.com/t/photo-gallery-with-text/38449/1 "2003-12-23T00:28:39Z")

</div>

I was trying to use the photo gallery tutorial from this site the code was done by sbeener I wanted to use the same concept for adding external text for each image. So far I have only been able to figure out how to load the text but I have not figured out how to be able to change the text to correspond to the image. Can someone help me? Please!

Here is the code I was working on:  
stop();  
photo.\_width=550;  
photo.\_height=380;

//this is exactly what it said the location of your images  
this.pathToPics = “images/”;  
this.pathToText = “text/”;

//the file name for the images that will be used  
this.pArray = [“image01.jpg”, “image02.jpg”, “image03.jpg”, “image04.jpg”, “image05.jpg”, “image06.jpg”, “image07.jpg”, “image08.jpg”, “image09.jpg”, “image10.jpg”];  
this.txtArray = [“text01.txt”, “text02.txt”, “text03.txt”, “text04.txt”, “text05.txt”, “text06.txt”, “text07.txt”, “text08.txt”, “text09.txt”,“text10.txt”];

this.fadeSpeed = 20;  
this.pIndex = 0;  
this.txtIndex = 0;

```
loadText = new loadVars();
loadText.load(this.pathToText+this.txtArray[this.txtIndex]);

loadText.onLoad = function(success) {
	if (success) {
		// trace(success);
		artworkText.html = true;
		artworkText.htmlText = this.imageText;
	}
};

```

// d=direction; should 1 or -1 but can be any number  
//loads an image when you run animation  
loadMovie(this.pathToPics+this.pArray[0], \_root.photo);  
MovieClip.prototype.changePhoto = function(d) {

```
// make sure pIndex is within pArray.length
this.pIndex = (this.pIndex+d)%this.pArray.length;
if (this.pIndex&lt;0) {
	this.pIndex += this.pArray.length;
}

	// make sure txtIndex is within txtArray.length
this.txtIndex = (this.txtIndex+d)%this.txtArray.length;
if (this.txtIndex&lt;0) {
	this.txtIndex += this.txtArray.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;  
}  
};

this.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
this.changePhoto(-1);  
} else if (Key.getCode() == Key.RIGHT) {  
this.changePhoto(1);  
}  
};  
Key.addListener(this);

// This is the code on the + button------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

on (release) {  
\_root.changePhoto(1);  
}

---

<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: [December 23, 2003, 2:36am UTC](https://forum.kirupa.com/t/photo-gallery-with-text/38449/2 "2003-12-23T02:36:24Z")

</div>

try this code and be sure you don’t get any undefineds  
just say nope if that doesnt work 🙂  
[AS]  
loadText.onLoad = function(success) {  
if (success) {  
trace(success);  
trace(artworkText)  
trace(this.imageText)  
artworkText.html = true;  
artworkText.htmlText = this.imageText;  
}  
};  
[/AS]

---

<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: [December 23, 2003, 8:59am UTC](https://forum.kirupa.com/t/photo-gallery-with-text/38449/3 "2003-12-23T08:59:25Z")

</div>

[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=42070](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=42070)

scotty(-:

---

<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: [December 25, 2003, 5:01am UTC](https://forum.kirupa.com/t/photo-gallery-with-text/38449/4 "2003-12-25T05:01:23Z")

</div>

Thank you very much! I will give it a shot  
Thanks again
