PDA

View Full Version : collection of shape in an array



qpixo
September 23rd, 2007, 02:55 PM
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<_tabRectangle.length;i++) {
_tabRectangle[i] = new Shape();
_tabRectangle[i].graphics.beginFill(0xFF0000);
_tabRectangle[i].graphics.drawRect(0, 10*i, 50, 20);
_tabRectangle[i].endFill();

}
}


}