# Accessing a variable of an object stored in an Array

**URL:** <https://forum.kirupa.com/t/accessing-a-variable-of-an-object-stored-in-an-array/330299>\
**Category:** flash\
**Created:** [December 28, 2012, 10:03am UTC](https://forum.kirupa.com/t/accessing-a-variable-of-an-object-stored-in-an-array/330299 "2012-12-28T10:03:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![silverneo188](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@silverneo188](https://forum.kirupa.com/u/silverneo188)\
**Post date:** [December 28, 2012, 10:03am UTC](https://forum.kirupa.com/t/accessing-a-variable-of-an-object-stored-in-an-array/330299/1 "2012-12-28T10:03:28Z")

</div>

So as the title suggests I am dealing with objects in an array. Here is an example of what I am doing. (No they are not as static as I am writing them here. This is just an example to explain my situation)

```php

_global.heroVars.weapons = new Array();

weapon1 = new Object();
weapon1.labelName = "Iron Dagger";
weapon1.power = 1;
weapon1.frameName = "dagger_1";
_global.heroVars.weapons.push(weapon1);

weapon2 = new Object();
weapon2.labelName = "Iron Sword";
weapon2.power = 1;
weapon2.frameName = "sword_1";
_global.heroVars.weapons.push(weapon2);

weapon3 = new Object();
weapon3.labelName = "Staff";
weapon3.power = 1;
weapon3.frameName = "staff_1";
_global.heroVars.weapons.push(weapon3);

trace(_global.heroVars.weapons[1].labelName);

```

but it traces back **Undefinded**. How would I go about this?
