# AS3 Classes, hard to explain. please read and help

**URL:** <https://forum.kirupa.com/t/as3-classes-hard-to-explain-please-read-and-help/330288>\
**Category:** Uncategorized\
**Created:** [December 26, 2012, 6:24am UTC](https://forum.kirupa.com/t/as3-classes-hard-to-explain-please-read-and-help/330288 "2012-12-26T06:24:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeekTweak\_0](https://avatars.discourse-cdn.com/v4/letter/g/b5ac83/32.png) [@GeekTweak\_0](https://forum.kirupa.com/u/GeekTweak_0)\
**Post date:** [December 26, 2012, 6:24am UTC](https://forum.kirupa.com/t/as3-classes-hard-to-explain-please-read-and-help/330288/1 "2012-12-26T06:24:39Z")

</div>

[SIZE=2]So at one point in my life i thought i was pretty good at AS3, but then classes got involved. This is a bit more to take in so bear with me here:

I have \*x \*amount of sprites on the screen, all with different heights, and i want to place them equal distances from each other across the y-axis. I was able to accomplish this. but i want to be able to use it with the use of a class, both for practice and easy reuse. Not entirely sure how to go about this.

Here is what i had originally and it worked fine:

```auto
for (var i=0; i<obj.length; i++) {
    totalHeight += obj*.height;
}

var temp2 = 0;

function separate():void {
    dist = (stageHeight-totalHeight)/obj.length+1;
    for (var j=0; j<obj.length; j++) {
        obj[j].y = temp2+dist/2;
        temp2 += obj[j].height+dist;
    }
}

```

Any help with [SIZE=2]how to use [SIZE=2]th[SIZE=2]is[SIZE=2] concept with [SIZE=2]a class[SIZE=2]? [SIZE=2]Thanks[SIZE=2]! (and merry [SIZE=2]Christmas for those to whom[SIZE=2] it may apply) :P[/SIZE][/SIZE][/SIZE][/SIZE][/SIZE][/SIZE][/SIZE][/SIZE][/SIZE][/SIZE]  
[/SIZE]
