I found this code to create dynamic hover captions from a text file, here is the original code:
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.
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.