Using variables as part of object names

Hey everyone!

I’m a new member of the forums, but I’ve been browsing this website for a while now, reading posts and tutorials,
and I wanted to say that I really like it here. Everybody are very helpful and websites such as this one really make it
easier to learn flash. (I like learning stuff by myself, I already managed to make myself a portfolio website thanks to such tutorials)

I need your help; I’m making a menu which has 5 dynamic texts instance-named buttontxt1, buttontxt2… buttontxt5.
I’m using a code in order to take information from a .txt file and put it in these texts’ text fields.
This worked fine, but instead of writing:

buttontxt1.text=e.target.data.ArtistName1;
buttontxt2.text=e.target.data.ArtistName2;

buttontxt5.text=e.target.data.ArtistName5;

I wanted to make it more elegant, so I wrote:

for (var i:Number = 1; i <= 5; i++){
this[“buttontxt”+i].text=e.target.data.target[“ArtistName”+i];
trace(“buttontxt”+i);
}

However, theres a syntax error regarding —> target[“ArtistName”+i];

Could you please tell me the right way to phrase this?

THANKS in advance!

Cat