# Adding a caption to a Thumbnail?

**URL:** https://forum.kirupa.com/t/adding-a-caption-to-a-thumbnail/31846
**Category:** flash
**Created:** [September 28, 2003, 5:56am UTC](https://forum.kirupa.com/t/adding-a-caption-to-a-thumbnail/31846 "2003-09-28T05:56:00Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Dethroner](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@Dethroner](https://forum.kirupa.com/u/Dethroner)
#### Post date: [September 28, 2003, 5:56am UTC](https://forum.kirupa.com/t/adding-a-caption-to-a-thumbnail/31846/1 "2003-09-28T05:56:00Z")

</div>

Does anyone know a simple way to add to the following AS a caption into a dynamic text box from a text file to go along with each jpeg?

```auto

stop();
/
// 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 = "news pics/";
// fill this array with your pics
this.pArray = ["01.jpg", "02.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: [July 13, 2004, 5:24am UTC](https://forum.kirupa.com/t/adding-a-caption-to-a-thumbnail/31846/2 "2004-07-13T05:24:09Z")

</div>

i’ve asked exactly the same question, but never get any answers.

Need to find a new board I think.

---

<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: [July 13, 2004, 1:54pm UTC](https://forum.kirupa.com/t/adding-a-caption-to-a-thumbnail/31846/3 "2004-07-13T13:54:58Z")

</div>

Try searching the forums, this question has been answered before, using textfile or XML.

---

<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: [July 13, 2004, 1:56pm UTC](https://forum.kirupa.com/t/adding-a-caption-to-a-thumbnail/31846/4 "2004-07-13T13:56:47Z")

</div>

well when you click on an image (such as in your load image function), make it load a text file, for example a textfile “01.txt” would be for “01.jpg”, that way it would be easy to do it dynamically. Set a variable with to contain your textfile and get the textbox to read it.

I’ll try to make a fla later on, post If you don’t get what I mean, No time to do actionscript now sorry.

---

<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: [July 13, 2004, 2:00pm UTC](https://forum.kirupa.com/t/adding-a-caption-to-a-thumbnail/31846/5 "2004-07-13T14:00:00Z")

</div>

Hi Guys

I’m using the supabeener slideshow without any buttons as a rolling slideshow, so how would this work???

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: [July 13, 2004, 2:04pm UTC](https://forum.kirupa.com/t/adding-a-caption-to-a-thumbnail/31846/6 "2004-07-13T14:04:44Z")

</div>

> [@dinner dog](#):
>
> well when you click on an image, make it load a text file, for example a textfile “01.txt” would be for “01.jpg”, that way it would be easy to do it dynamically. Set a variable with to contain your textfile and get the textbox to read it.
> 
> I’ll try to make a fla later on, post If you don’t get what I mean, No time to do actionscript now sorry.

Just load a single textfile with all the captions.

---

<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: [July 13, 2004, 3:03pm UTC](https://forum.kirupa.com/t/adding-a-caption-to-a-thumbnail/31846/7 "2004-07-13T15:03:38Z")

</div>

sorry sprite but I’m unfamiliar with that script… link?

claudio: Yeah, ok so I didn’t think too much.  
Dethroner : revised using claudio’s suggestion, It _should_ work…  
replace function you have now with this, be sure to back up.

```auto

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]);
             // added - dinner dog - simple enough--------
             loadVariablesNum("captions.txt", 0)
	_root.cap.variable = this.pArray[this.pIndex];
             // end - dinner dog--------------------------
	this.onEnterFrame = loadMeter;
};

```

captions.txt stores the captions in this manor…

```auto

01=picture 1 caption &02=picture 2 caption&03=picture 3 caption&04=picture 4 caption

```

etc, etc (I know naming a variable as a number isn’t good/ shouldn’t work, but it was easier and worked for me off a variable).

and cap is a dynamic textfeild on the root of your movie.
