# Store objects in an array?

**URL:** https://forum.kirupa.com/t/store-objects-in-an-array/56625
**Category:** flash
**Created:** [July 6, 2004, 7:08am UTC](https://forum.kirupa.com/t/store-objects-in-an-array/56625 "2004-07-06T07:08:48Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Phreaky](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@Phreaky](https://forum.kirupa.com/u/Phreaky)
#### Post date: [July 6, 2004, 7:08am UTC](https://forum.kirupa.com/t/store-objects-in-an-array/56625/1 "2004-07-06T07:08:48Z")

</div>

Howdy!

Does anybody know if there is possible to store an object in an array? I have this class that I call Person and when I create an instance of that class, like:

[color=navy]var p:Person = new Person(“Josef”);[/color]

I would like to store it in an array. Is that possible? And if the answer is yes, how?

// phreaky

---

<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: [July 8, 2004, 7:18am UTC](https://forum.kirupa.com/t/store-objects-in-an-array/56625/2 "2004-07-08T07:18:30Z")

</div>

Yes it is possible , try this

var db:Array = []  
var person = new Person(“Josef”);  
db.push(person)

Ajo.K.Jose

---

<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: [July 8, 2004, 4:47pm UTC](https://forum.kirupa.com/t/store-objects-in-an-array/56625/3 "2004-07-08T16:47:31Z")

</div>

Well, I’ve tried that and it does work. But! What dosn’t seem to work is the question of how I can retrive that stored objekt later on.

---

<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: [July 8, 2004, 9:37pm UTC](https://forum.kirupa.com/t/store-objects-in-an-array/56625/4 "2004-07-08T21:37:57Z")

</div>

wouldn’t you just use db[index of object (ie 0)].property of object

---

<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: [July 9, 2004, 3:30am UTC](https://forum.kirupa.com/t/store-objects-in-an-array/56625/5 "2004-07-09T03:30:22Z")

</div>

Yes jerez\_z is Correct !! Thank you jerez

index of Object is a number, have a posible value 0 to db.length

---

<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: [July 9, 2004, 6:37am UTC](https://forum.kirupa.com/t/store-objects-in-an-array/56625/6 "2004-07-09T06:37:50Z")

</div>

…I’m sorry but that doesn’t seem to work. Let’s say that the class Person har a method called getAge();

Normaly I would do something like this to retrive its stored data:  
var numAge:Number = db[index].getAge();

But in this case it does not work.

---

<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: [July 9, 2004, 6:41am UTC](https://forum.kirupa.com/t/store-objects-in-an-array/56625/7 "2004-07-09T06:41:02Z")

</div>

Is it a public mathod which return Number ?? … Can you share the file???

---

<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: [July 9, 2004, 2:40pm UTC](https://forum.kirupa.com/t/store-objects-in-an-array/56625/8 "2004-07-09T14:40:49Z")

</div>

well, I can publish my fla for you to se, but I need some time…

---

<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: [July 13, 2004, 7:30am UTC](https://forum.kirupa.com/t/store-objects-in-an-array/56625/9 "2004-07-13T07:30:37Z")

</div>

…it works now!

It was like you said, don’t know what i did…

thanx
