Skip to main content
markerline
Inspiring
January 14, 2010
Question

rows and columns of rectangles part 2 (random vs. ordered, exponential)

  • January 14, 2010
  • 1 reply
  • 3314 views

Dear Community:

In a previous post I was stuck creating a grid of rectangles.  Now with the help of a community expert I have figured out what was wrong with my action script.  However I would like to build on the AS file with the following attachments.  I have a FLA and a AS file which can be Ctrl+Enter for the SWF but I have a PNG which displays what I would like to accomplish via Math.random() or some sort of Array declaration to create a mathematically ordered and mathematically random array of duplicated addChild's .

This topic has been closed for replies.

1 reply

markerline
Inspiring
January 14, 2010
markerline
Inspiring
January 20, 2010

No takers on this topic?  I need help on it soon as I am trying to prepare the file for a presentation in a class.  Someone, anyone, please help.

Sincerely,

markerline

markerline
Inspiring
January 20, 2010

This is the ActionScript I came up with so far.  Brick is referring to a rectangle symbol with Export:Brick for actionscript in my Library.


var bricks:Array;
var myBrick:Brick;
makeBricks();
function makeBricks(){

bricks=new Array();
for (var i:uint=1;i<6;i++){
  for(var j:uint=1;j<4;j++){
   for(var h:uint=1;h<5;h++){
    var scale:Number=Math.ceil(h*Math.random());
  
   myBrick=new Brick();
   addChild(myBrick);
   myBrick.x=i*myBrick.width*scale;
   myBrick.width=h*20;
   myBrick.height=h*20;
  
   myBrick.y=j*myBrick.height*scale;
  
   trace(scale);
  
   bricks.push(myBrick);
   }
  }
}
}