# Problem(I think...) accessing instance objects

**URL:** https://forum.kirupa.com/t/problem-i-think-accessing-instance-objects/276055
**Category:** Uncategorized
**Created:** [November 21, 2008, 8:28pm UTC](https://forum.kirupa.com/t/problem-i-think-accessing-instance-objects/276055 "2008-11-21T20:28:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Radik782](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@Radik782](https://forum.kirupa.com/u/Radik782)
#### Post date: [November 21, 2008, 8:28pm UTC](https://forum.kirupa.com/t/problem-i-think-accessing-instance-objects/276055/1 "2008-11-21T20:28:41Z")

</div>

First up, my first post here, so hi to all. =)

Ok the problem I’ve got isn’t really a bug, I mean the code does what I want so far, but I think I might going about it the wrong way. Simple game, a breakout clone in AS3, although this time I was messing about splitting it up into classes, but was having trouble accessing instances of those classes…

Way I got around it was to… add them to arrays… example, creating an instance of a menu…

```auto

var menuItem = new MainMenu();
menuArray.push({aButton:addChild(menuItem.createStartBtn())});
menuArray.push({aButton:addChild(menuItem.createOptionBtn())});

// some time later

menuArray[0].aButton.x = 10;

```

That cant be right though can it? I mean I was ok with it when I was sticking instances of blocks and player paddle etc into arrays, but now sticking the menu screen into an array? :-/  
Is there a better way of accessing them, other then adding them to an array like that?Or am I just worrying about nothing? :blah:

**EDIT:** Well, doesn’t look like I’m going to get a reply to this thread… but no worries, I found a better solution, for anyone else who might suffer a brain fart like I did and finds this, make the external class return an object, and in the main class be sure to have an object variable handy ( var bla:Object; ), just assign the returned object to that, no need for arrays. If object variable has scope, no problems accessing it form anywhere else.
