# Desperately trying to learn arrays -HELP!

**URL:** <https://forum.kirupa.com/t/desperately-trying-to-learn-arrays-help/19457>\
**Category:** Uncategorized\
**Created:** [April 28, 2003, 2:08pm UTC](https://forum.kirupa.com/t/desperately-trying-to-learn-arrays-help/19457 "2003-04-28T14:08:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveD](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@SteveD](https://forum.kirupa.com/u/SteveD)\
**Post date:** [April 28, 2003, 2:08pm UTC](https://forum.kirupa.com/t/desperately-trying-to-learn-arrays-help/19457/1 "2003-04-28T14:08:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 28, 2003, 2:40pm UTC](https://forum.kirupa.com/t/desperately-trying-to-learn-arrays-help/19457/2 "2003-04-28T14:40:21Z")

</div>

change this line

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

```

to

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

```

… =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 28, 2003, 2:57pm UTC](https://forum.kirupa.com/t/desperately-trying-to-learn-arrays-help/19457/3 "2003-04-28T14:57:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 28, 2003, 3:02pm UTC](https://forum.kirupa.com/t/desperately-trying-to-learn-arrays-help/19457/4 "2003-04-28T15:02:12Z")

</div>

did you change this line as well?

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

```

it should be

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

```

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 28, 2003, 3:26pm UTC](https://forum.kirupa.com/t/desperately-trying-to-learn-arrays-help/19457/5 "2003-04-28T15:26:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 28, 2003, 3:46pm UTC](https://forum.kirupa.com/t/desperately-trying-to-learn-arrays-help/19457/6 "2003-04-28T15:46:07Z")

</div>

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

SteveD

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 28, 2003, 3:50pm UTC](https://forum.kirupa.com/t/desperately-trying-to-learn-arrays-help/19457/7 "2003-04-28T15:50:26Z")

</div>

😛

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