0 Replies Latest reply on Jul 14, 2016 7:23 AM by викторб82329482

    Output in view

    викторб82329482 Level 1

      I created rectangles in loop, but i don`t know how to show.

       

      <fx:Script>

          <![CDATA[

            private function createColors(n:int):Array

            {

              var colors:Array = [];       

              for( var i:int = 0; i < n ; i++ )

              {  

                var color:uint = 0xffffff * Math.random();

                colors[i] = color;

              }       

              return colors;

            }

           

            private function createRectangles():void

            {

              var colors:Array = createColors( 10 );

             

              for( var i:int = 0; i < colors.length ; i++ )

              {

                var rect:Sprite = new Sprite();

               

                var g:Graphics = rect.graphics;

                g.beginFill(colors[i]);

                g.drawRect(10 * i , 10 * i, 100, 150);

                g.endFill();

               

                this.addChild( rect );

              }

            }

          ]]>

        </fx:Script>