Desperately trying to learn arrays -HELP!

Hi,
I have been helping out a few members here with arrays in an effort to finally get my head around them. I think that arrays are probably one of the more powerful tools available in flash, but… I got myself stuck and need some help. I feel sure it just a syntax issue. here goes:

mc with instance name but0
inside mc is a text box var name label , code is
[AS]label = _name;[/AS]

mc on main timeline code in frame 1 is:
[AS]
subjects = new Array(“page1”,“page2”,“page4”,“page4”,“page5”)
butHeight = but0._height+5;
butNumber = subjects.length
if (i<butNumber) {
but0.duplicateMovieClip(“subjects”+i,i);
with(this[“subjects”+i]) {
_y= butHeight*i;
}
i++
}
but0._visible = 0;[/AS]

What this code does is produce 5 buttons appearing one after the other, like a cascade effect, so far so good, I then want to insert the array elements into text box label, but all I get is subject, subject1, subject2 and so on.
So, what do I need to do so that my buttons are called page1, page2 and so on.

Cheers

SteveD

change this line

but0.duplicateMovieClip("subjects"+i, i);

to

but0.duplicateMovieClip(subjects[Number(i)], i);

… =)

Thanks kax
But sort of, not quite, I get an error message, with action failed etc etc, but the one button that does appear has “page5” in it, think they are duplicating OK but not spacing out. ?
I’ll keep trying, any other ideas welcome

Cheers

SteveD

did you change this line as well?

with (this["subjects"+i]) {

it should be

with (this[subjects[Number(i)]]) {

that’s all i can think of… :-\

Hi,
again, not quite, this time the buttons are cascading, but something is awry with the order - I have posted my fla if you ( or anyone else) has the time to take a quick peek

Cheers

SteveD

Hi kax,
Solved it, there was a typo in the array, everything working OK now, thanks for your help
Cheers

SteveD

:stuck_out_tongue:

yeah… usually the easy problems are the hardest to solve. :-\