# Collection of shape in an array

**URL:** <https://forum.kirupa.com/t/collection-of-shape-in-an-array/239577>\
**Category:** Uncategorized\
**Created:** [September 23, 2007, 6:55pm UTC](https://forum.kirupa.com/t/collection-of-shape-in-an-array/239577 "2007-09-23T18:55:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![qpixo](https://avatars.discourse-cdn.com/v4/letter/q/c4cdca/32.png) [@qpixo](https://forum.kirupa.com/u/qpixo)\
**Post date:** [September 23, 2007, 6:55pm UTC](https://forum.kirupa.com/t/collection-of-shape-in-an-array/239577/1 "2007-09-23T18:55:08Z")

</div>

Is there a way to declare a collection of shapes in an array?

red, green, blue and gray are shape

my current code:

package {

public class rectangle extend Sprite {

import flash.display.\*;

private var \_tabRectangle:Array = [\_red, \_green, \_blue, \_gray];

public function rectangle() {  
\_createRectangles();

}

private function \_createRectangles():void {

```
        for(var i:int=0;i&lt;_tabRectangle.length;i++) {
            _tabRectangle* = new Shape();
            _tabRectangle*.graphics.beginFill(0xFF0000);
            _tabRectangle*.graphics.drawRect(0, 10*i, 50, 20);
            _tabRectangle*.endFill();
        
        }

```

}

}
