# Array variable scope problem I think?

**URL:** <https://forum.kirupa.com/t/array-variable-scope-problem-i-think/162347>\
**Category:** Uncategorized\
**Created:** [September 12, 2005, 12:46pm UTC](https://forum.kirupa.com/t/array-variable-scope-problem-i-think/162347 "2005-09-12T12:46:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![keitai](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@keitai](https://forum.kirupa.com/u/keitai)\
**Post date:** [September 12, 2005, 12:46pm UTC](https://forum.kirupa.com/t/array-variable-scope-problem-i-think/162347/1 "2005-09-12T12:46:50Z")

</div>

So I defined a global array by  
frame 5

```auto

_global.userMoods = new Array();

```

add some values with

```auto

function addMood(choice)
{
	
	userMoods.push(choice);
	trace ("Array add "+userMoods);

```

But when calling this function

```auto

function show() 
{
	for (i=0; i<userMoods.length; i++) {
		//_root.attachMovie(_root.userMoods*,"Show"+i,i);
		test = userMoods*;
		trace("WHTA" +test);
	}
	trace("Length " +userMoods.length);
	trace("Show " +userMoods);
}

```

I don’t get the expected array values (none returned) just the length is visible.

Where did I go wrong???
