# Dynamic AS Grid - works but ...\>

**URL:** <https://forum.kirupa.com/t/dynamic-as-grid-works-but/250865>\
**Category:** flash\
**Created:** [February 2, 2008, 12:49pm UTC](https://forum.kirupa.com/t/dynamic-as-grid-works-but/250865 "2008-02-02T12:49:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)\
**Post date:** [February 2, 2008, 12:49pm UTC](https://forum.kirupa.com/t/dynamic-as-grid-works-but/250865/1 "2008-02-02T12:49:27Z")

</div>

Hi, Ive written some code to create a grid out of dynamically placed blocks from the library, which has a random colour assigned to each one on creation.

The Code is simple … But Takes my browser - ages to load up, as if the script is super inefficient… Is it the tween engine that is buggering it up?

```auto

#include "mc_tween2.as"
var colours:Array = new Array("006699","01354B","001E2B","0172A0","0289C1","02A6EC","1CBAFD","3EC4FD","78D7FE","ABE6FE");
var ALength:Number = colours.length;                              

blocks = 30; //no. of blocks in row
bwidth = 20; //block width
bheight = 20; //block height
row = 30; // no. of rows
for(r=0;r<row;r++){
    for(i=0;i<blocks;i++){
        var Num:Number = Math.floor(Math.random()*ALength);
        _root.attachMovie("block","row"+r+"block"+i,this.getNextHighestDepth(),{_x:(i*bwidth),_y:(r*bheight)});
        _root["row"+r+"block"+i].colorTo(("0x"+colours[Num]));
    }
}

```
