Adding a caption to a Thumbnail?

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?


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);

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

Need to find a new board I think.

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

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.

Hi Guys

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

thanks

Just load a single textfile with all the captions.

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.


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…


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.