Random arrangement

Code Actionscript 2.0

Frame action

for (i = 1; i < 64; i = i + 1) {
square0.duplicateMovieClip("square" + i, i);
this["square" + i]._x = random(400);
this["square" + i]._y = random(400);
}

Code Actionscript 3.0

var i=1; var Squares: Array = new Array(); for (i = 1; i < 64; i = i + 1) { //important: square has to be exported for actionscript //go to "linkage" in library menu Squares[i] = new squareObject(); Squares[i].x = int(Math.random()*400); Squares[i].y = int(Math.random()*400); addChild(Squares[i]); }

Description

The instance named square0 is duplicated 64 times. In Actionscript 2, each instance is given a unique name from square1 to square64, with the help of the loop-variable i. In Actionscript 3, there is an array of squares. The squares are numbered with an index i. All squares are then given a random position on the stage.

Download

Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File


Share