# Array problems in AS2

**URL:** <https://forum.kirupa.com/t/array-problems-in-as2/262308>\
**Category:** flash\
**Created:** [June 4, 2008, 10:03pm UTC](https://forum.kirupa.com/t/array-problems-in-as2/262308 "2008-06-04T22:03:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rick\_cope100\_ho](https://avatars.discourse-cdn.com/v4/letter/r/e19adc/32.png) [@rick\_cope100\_ho](https://forum.kirupa.com/u/rick_cope100_ho)\
**Post date:** [June 4, 2008, 10:03pm UTC](https://forum.kirupa.com/t/array-problems-in-as2/262308/1 "2008-06-04T22:03:49Z")

</div>

Hi anyone  
I’ve set up an array to store info. about land use in a farming game. There are 8 fields and I need to be able to store the changing land use for each one. So, my array is called “land\_use” and I’ve set land\_use[1] to land\_use[8] as zero to start with. No problems so far. However, when I try to change the land use in a field by using “land\_use[8] = 1;” and testing it using trace I get ‘undefined’. This is a mystery because it displayed perfectly before I changed it. It I add the code to a button it seems to work fine, but when used on a drag ’ n drop movie clip it doesn’t. All other code on the movie clip works perfectly.  
What am I doing wrong?:tired:

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [June 4, 2008, 10:30pm UTC](https://forum.kirupa.com/t/array-problems-in-as2/262308/2 "2008-06-04T22:30:17Z")

</div>

Probably a scoping issue. Because the code is attached to a movieclip, Flash expects to find an array called land\_use attached to the movieclip as well. When it doesn’t find it, it returns the undefined value. Try substituting \_root.land\_use[8] = 1; instead
