# Having Trouble with an OOP Concept

**URL:** <https://forum.kirupa.com/t/having-trouble-with-an-oop-concept/288793>\
**Category:** flash\
**Created:** [May 21, 2009, 3:14am UTC](https://forum.kirupa.com/t/having-trouble-with-an-oop-concept/288793 "2009-05-21T03:14:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AceDecade](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@AceDecade](https://forum.kirupa.com/u/AceDecade)\
**Post date:** [May 21, 2009, 3:14am UTC](https://forum.kirupa.com/t/having-trouble-with-an-oop-concept/288793/1 "2009-05-21T03:14:40Z")

</div>

First of all, thanks for the help. I’m dabbling in OOP, but I’m nowhere near proficient yet.

I have two classes, house() and town(). In house’s constructor, I want to define an exit from the house to town. I’ve set up a Doors and Exits array in the base class, and in house, I add town to it:

Doors = new Array(new trigger());  
Exits = new Array(new town());

This way, I can check if the player is colliding with the trigger, and if so, I can set level to Exits\* or wherever it is.

My problem is, including Exits = new Array(new town()); in house’s constructor calls town’s constructor, and town has an array Exits, which leads back to house and so on.

So my question is: How would I get around this problem or structure my level class? Is it possible to use “town” to get to new town(); without manually checking if(“town”){ new town(); } etc. Basically, I want to tell flash to create a new town() WHEN I need it, not necessarily during the initial construction, but I don’t want to have to manually call “new town();”

Thanks again for the help!
