# OOP class variables question

**URL:** <https://forum.kirupa.com/t/oop-class-variables-question/250405>\
**Category:** flash\
**Created:** [January 29, 2008, 9:49am UTC](https://forum.kirupa.com/t/oop-class-variables-question/250405 "2008-01-29T09:49:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dragy](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@Dragy](https://forum.kirupa.com/u/Dragy)\
**Post date:** [January 29, 2008, 9:49am UTC](https://forum.kirupa.com/t/oop-class-variables-question/250405/1 "2008-01-29T09:49:11Z")

</div>

Hey 😏

Not too long ago I started using Flash CS3 and AS3. OOP is completely new for me, but I’m getting the hang of it with time. But I have a question -

I have a class which extends a movieclip, that class is a unit. In my game, there’s a player unit and an enemy unit. I’m using the same class for both, the only difference is a boolean inside that tells if it’s an enemy or a player unit, which affects what array of units in the above class they should be looping and checking for foes nearby.

To create a unit, what I do, and I figured is wrong, is after creating the unit in a create unit function I have, only then I set the boolean, from the outside, for instance:  
unit = new unit\_mc;  
unit.isPlayer = true;

So ‘in the long run’ it plays fine, but when I create the class first, it already run loops and ifs regarding the isPlayer boolean, which wasn’t yet defined, but only a line after.

So my question is, is there a way to define a boolean from the outside in the same time of creation? If not, how else can I solve this issue?  
I thought about making a class that extends Unit, that only sets the boolean (using super.isPlayer, I believe?), but is it right to work that way?

Thanks a bunch!
