Network structure 1

Code Actionscript 2.0

Frame action

// duplicate nodes
for (node = 1; node <= 8; node = node + 1) {
square0.duplicateMovieClip("square" + node, node);
_root["square" + node]._x = random(350);
_root["square" + node]._y = random(350);
}
square0._visible = 0;

// connect nodes
createEmptyMovieClip("lines", 100);
lines.lineStyle(0, 0x000000, 100);
lines.moveTo(square1._x, square1._y);
for (node = 2; node <= 8; node = node + 1) {
lines.lineTo(_root["square" + node ]._x, _root["square" + node ]._y);
}

Code Actionscript 3.0

var Squares:Array = new Array(); // duplicate nodes for (var node = 1; node <= 8; node = node + 1) { //important: square has to be exported for actionscript //go to "linkage" in library menu Squares[node] = new squareObject(); Squares[node].x = int(Math.random()*350); Squares[node].y = int(Math.random()*350); addChild(Squares[node]); } square0.visible = false; // connect nodes var lines = new MovieClip(); lines.graphics.lineStyle(1, 0x000000, 1); lines.graphics.moveTo(Squares[1].x, Squares[1].y); for (node = 2; node <= 8; node = node + 1) { lines.graphics.lineTo(Squares[node].x, Squares[node].y); } addChild(lines);

Description

This script randomly arranges the nodes of a network within the stage, while each is connected with a line.

related to: Random arrangement, Line

Download

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


Share