I have 25 animated movieclips dragged on the stage and they have similar instance names for easier manipulation purposes inside programming using loops. The instance names look like this: image0, image1, image2 and so on.
Each time I go mouseover on one of these unique images I want to show the unique title of that image using for all titles just one dynamic text container named imageTitle.
I have succeeded to make this work image by image but this would require me to copy paste and modify for each image the following code.
[FONT=arial]image0.onRollOver = function() {
imageTitle.text = "First image title";
imageTitle.textColor = 0x000000; // setting the text color here
};
image0.onRollOut = function() {
imageTitle.text = "Choose an image";
imageTitle.textColor = 0x000000;
}; [/FONT]
Question: The above code would work but seems redundant to me. Since I have similar instance names (image0, image1, …,image24), how can I put this code inside a loop or something in order to work for all images without repeating this code 25 times.
Update: I have added an array to the project that contains all the titles:
var imagesTitles = new Array("First image title", "Second image title", ....);