# Hover Captions

**URL:** <https://forum.kirupa.com/t/hover-captions/169338>\
**Category:** Uncategorized\
**Created:** [November 15, 2005, 3:26pm UTC](https://forum.kirupa.com/t/hover-captions/169338 "2005-11-15T15:26:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lbeetles](https://avatars.discourse-cdn.com/v4/letter/l/2bfe46/32.png) [@lbeetles](https://forum.kirupa.com/u/lbeetles)\
**Post date:** [November 15, 2005, 3:26pm UTC](https://forum.kirupa.com/t/hover-captions/169338/1 "2005-11-15T15:26:21Z")

</div>

I found this code to create dynamic hover captions from a text file, here is the original code:

```auto
mv = new LoadVars();
mv.load("tooltip.txt");
mv.onLoad = function(success) {
	if (success) {
		trace("text loaded");
		for (i=1; i<=4; i++) {
			temp = _root["mc"+i];
			temp.onRollOver = function() {
				startDrag("_root.toolTip", true);
			 _root.toolTip.tip = _root.mv['tooltip'+this._name.substr(-1)];
				_root.toolTip.gotoAndStop(2);
			};
			temp.onRollOut = function() {
				stopDrag();
				toolTip.gotoAndStop(1);
			};
		}
	} else {
		trace("text not loaded");
	}
};

```

there is a text file in the same directory called tooltip.txt and it has vars in it:  
&tooltip1=No 1&  
&tooltip2=No 2&  
&tooltip3=No 3&

I have been trying to change this because i dont want to change all the names of my buttons to mc1, mc2 etc…

Does any one know how to change this to use an array so i can keep all my button names to what they are like, play\_mc, view\_mc etc…

this is what i chnaged the code to but only the last name in the array shows the caption.

```auto
toolTip.tipText_txt.autoSize = true;

mv = new LoadVars();
mv.load("tooltip.txt");
mv.onLoad = function(success) {
	if (success) {
		var my_array:Array = new Array(); 
		for (var i:Number = i=1; i<=4; i++) { 
			 my_array* = ("mc1", "mc2", "mc3"); 
			trace(my_array);
			temp = _root[my_array*];
			temp.onRollOver = function() {
				startDrag("_root.toolTip", true);
				toolTip.tipText_txt._visible = true;
			 _root.toolTip.tip = _root.mv['tooltip'+this._name.substr(-1)]; 		
			};
			temp.onRollOut = function() {
				stopDrag();
				toolTip.tipText_txt._visible = false;
				toolTip.tipText_txt.text = "";
			};
		}
	} else {
		trace("text not loaded");
	}
};

```

i have attached my fla for anyone to have a look at.
