Growing, Grid arrangement

Code Actionscript 2.0

Frame action

i = 1;
for (gx = 1; gx < 9; gx = gx + 1) {
for (gy = 1; gy < 9; gy = gy + 1) {
i = i + 1;
square0.duplicateMovieClip("square" + i, i);
this["square" + i]._width = 25;
this["square" + i]._height = 25;
this["square" + i]._x = 20 + gx * 40;
this["square" + i]._y = 20 + gy * 40;
}
}
square0._visible = 0;

Instance action

onClipEvent (enterFrame) {
this._width = this._width + 1;
this._height = this._height + 1;
}
on (rollOver) {
this._width = 10;
this._height = 10;
}

Code Actionscript 3.0

var Squares: Array = new Array(); var i=1; for (var gx = 1; gx < 9; gx = gx + 1) { for (var gy = 1; gy < 9; gy = gy + 1) { //important: square has to be exported for actionscript //go to "linkage" in library menu Squares[i] = new squareObject(); Squares[i].addEventListener( Event.ENTER_FRAME, enterFrame); Squares[i].addEventListener( MouseEvent.MOUSE_OVER, rollOver); Squares[i].width=25; Squares[i].height=25; Squares[i].x=20+gx*40; Squares[i].y=20+gy*40; addChild(Squares[i]); i=i+1; } } square0.visible=false; function enterFrame(e:Event) { e.target.width=e.target.width+1; e.target.height=e.target.height+1; } function rollOver(e:MouseEvent) { e.target.width=10; e.target.height=10; }

Description

The squares are arranged in a grid structure. They will grow until they are stopped by a rollover of the mouse. In Actionscript 2, "Grid arrangement" consists of a frame-action and "Growing" of an instance-action. The code from "Growing" is represented in enterFrame and rollOver, and the code from "Grid arrangement" is represented in the for-loop.

related to: Growing, Grid arrangement

Download

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


Share