Frame 1
stop();
Frame 2
function loadBlank() {
for (i in _root) {
mesh.destroyn(_root[i]);
removeMovieClip(_root[i]);
}
mesh.nodes.splice(0, mesh.nodes.length);
mesh.springs.splice(0, mesh.springs.length);
_root.nmbr = 0;
}
function loadPerson() {
for (i in _root) {
mesh.destroyn(_root[i]);
removeMovieClip(_root[i]);
}
mesh.nodes.splice(0, mesh.nodes.length);
mesh.springs.splice(0, mesh.springs.length);
_root.nmbr = 15;
_root.attachMovie("node2", "n0", 0);
n0.NodeInit(600, 300, true, 100);
_root.attachMovie("node", "n1", 1);
n1.NodeInit(600, 500, false, 500);
_root.attachMovie("node", "n2", 2);
n2.NodeInit(500, 600, false, 100);
_root.attachMovie("node", "n3", 3);
n3.NodeInit(700, 600, false, 100);
_root.attachMovie("node", "n4", 4);
n4.NodeInit(500, 800, false, 100);
_root.attachMovie("node", "n5", 5);
n5.NodeInit(700, 800, false, 100);
_root.attachMovie("node2", "n6", 6);
n6.NodeInit(600, 700, true, 100);
_root.attachMovie("node", "n7", 7);
n7.NodeInit(400, 500, false, 100);
_root.attachMovie("node", "n8", 8);
n8.NodeInit(300, 600, false, 100);
_root.attachMovie("node", "n9", 9);
n9.NodeInit(800, 500, false, 100);
_root.attachMovie("node", "n10", 10);
n10.NodeInit(900, 600, false, 100);
_root.attachMovie("node", "n11", 11);
n11.NodeInit(400, 900, false, 100);
_root.attachMovie("node", "n12", 12);
n12.NodeInit(350, 1000, false, 100);
_root.attachMovie("node", "n13", 13);
n13.NodeInit(800, 900, false, 100);
_root.attachMovie("node", "n14", 14);
n14.NodeInit(850, 1000, false, 100);
_root.mesh.addNode(n0);
_root.mesh.addNode(n1);
_root.mesh.addNode(n2);
_root.mesh.addNode(n3);
_root.mesh.addNode(n4);
_root.mesh.addNode(n5);
_root.mesh.addNode(n6);
_root.mesh.addNode(n7);
_root.mesh.addNode(n8);
_root.mesh.addNode(n9);
_root.mesh.addNode(n10);
_root.mesh.addNode(n11);
_root.mesh.addNode(n12);
_root.mesh.addNode(n13);
_root.mesh.addNode(n14);
mesh.addSpring(n0, n1, 100, 100, 250, 1, 11184810, 1);
mesh.addSpring(n1, n2, 50, 100, 250, 3, 0, 10);
mesh.addSpring(n1, n3, 50, 100, 250, 3, 0, 10);
mesh.addSpring(n2, n3, 50, 200, 250, 3, 0, 10);
mesh.addSpring(n3, n5, 50, 200, 250, 3, 0, 10);
mesh.addSpring(n4, n5, 50, 200, 250, 3, 0, 10);
mesh.addSpring(n2, n4, 50, 200, 250, 3, 0, 10);
mesh.addSpring(n2, n6, 50, 100, 250, 3, 11184810, 1);
mesh.addSpring(n3, n6, 50, 100, 250, 3, 11184810, 1);
mesh.addSpring(n4, n6, 50, 100, 250, 3, 11184810, 1);
mesh.addSpring(n5, n6, 50, 100, 250, 3, 11184810, 1);
mesh.addSpring(n2, n5, 50, 200, 250, 2, 11184810, 1);
mesh.addSpring(n3, n4, 50, 200, 250, 2, 11184810, 1);
mesh.addSpring(n2, n7, 50, 150, 250, 3, 0, 10);
mesh.addSpring(n7, n8, 50, 150, 250, 3, 0, 10);
mesh.addSpring(n3, n9, 50, 150, 250, 3, 0, 10);
mesh.addSpring(n9, n10, 50, 150, 250, 3, 0, 10);
mesh.addSpring(n4, n11, 50, 150, 250, 3, 0, 10);
mesh.addSpring(n11, n12, 50, 150, 250, 3, 0, 10);
mesh.addSpring(n5, n13, 50, 150, 250, 3, 0, 10);
mesh.addSpring(n13, n14, 50, 150, 250, 3, 0, 10);
mesh.addSpring(n2, n7, 50, 150, 250, 3, 0, 10);
mesh.addSpring(n7, n8, 50, 150, 250, 3, 0, 10);
mesh.addSpring(n3, n9, 50, 150, 250, 3, 0, 10);
mesh.addSpring(n7, n3, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n7, n4, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n8, n2, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n9, n2, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n9, n5, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n10, n3, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n11, n2, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n11, n5, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n12, n4, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n13, n4, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n13, n3, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n14, n5, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n12, n14, 50, 300, 250, 2, 11184810, 1);
mesh.addSpring(n11, n13, 50, 200, 250, 2, 11184810, 1);
}
function loadWheel() {
for (i in _root) {
mesh.destroyn(_root[i]);
removeMovieClip(_root[i]);
}
mesh.nodes.splice(0, mesh.nodes.length);
mesh.springs.splice(0, mesh.springs.length);
_root.nmbr = 9;
_root.attachMovie("node2", "n0", 0);
n0.NodeInit(600, 600, true, 100);
_root.attachMovie("node", "n1", 1);
n1.NodeInit(400, 600, false, 100);
_root.attachMovie("node", "n2", 2);
n2.NodeInit(450, 450, false, 100);
_root.attachMovie("node", "n3", 3);
n3.NodeInit(600, 400, false, 100);
_root.attachMovie("node", "n4", 4);
n4.NodeInit(750, 450, false, 100);
_root.attachMovie("node", "n5", 5);
n5.NodeInit(800, 600, false, 100);
_root.attachMovie("node", "n6", 6);
n6.NodeInit(750, 750, false, 100);
_root.attachMovie("node", "n7", 7);
n7.NodeInit(600, 800, false, 100);
_root.attachMovie("node", "n8", 8);
n8.NodeInit(450, 750, false, 100);
_root.mesh.addNode(n0);
_root.mesh.addNode(n1);
_root.mesh.addNode(n2);
_root.mesh.addNode(n3);
_root.mesh.addNode(n4);
_root.mesh.addNode(n5);
_root.mesh.addNode(n6);
_root.mesh.addNode(n7);
_root.mesh.addNode(n8);
mesh.addSpring(n0, n1, 50, 200, 350, 3, 0, 1);
mesh.addSpring(n0, n2, 50, 200, 350, 3, 0, 1);
mesh.addSpring(n0, n3, 50, 200, 350, 3, 0, 1);
mesh.addSpring(n0, n4, 50, 200, 350, 3, 0, 1);
mesh.addSpring(n0, n5, 50, 200, 350, 3, 0, 1);
mesh.addSpring(n0, n6, 50, 200, 350, 3, 0, 1);
mesh.addSpring(n0, n7, 50, 200, 350, 3, 0, 1);
mesh.addSpring(n0, n8, 50, 200, 350, 3, 0, 1);
mesh.addSpring(n1, n2, 50, 100, 150, 3, 0, 1);
mesh.addSpring(n2, n3, 50, 100, 150, 3, 0, 1);
mesh.addSpring(n3, n4, 50, 100, 150, 3, 0, 1);
mesh.addSpring(n4, n5, 50, 100, 150, 3, 0, 1);
mesh.addSpring(n5, n6, 50, 100, 150, 3, 0, 1);
mesh.addSpring(n6, n7, 50, 100, 150, 3, 0, 1);
mesh.addSpring(n7, n8, 50, 100, 150, 3, 0, 1);
mesh.addSpring(n8, n1, 50, 100, 150, 3, 0, 1);
}
_xscale = 50;
_yscale = 50;
space = false;
go = false;
spr = -1;
nmbr = 0;
drag = 0;
spring = new Array();
spring = [0, 0];
nam = 3;
stat = "hand";
stop();
var col = "000000";
var frict = 5;
var gravity = 10;
var colo = 0;
var thi = 2;
var mass = 100;
var typ = 1;
var k = 10;
var len = 300;
var elim = 450;
var mod = 1;
var mesh = new elasticMesh();
_root.attachMovie("node2", "n" + _root.nmbr, _root.nmbr);
_root["n" + _root.nmbr].NodeInit(600, 600, true, 100);
_root.mesh.addNode(_root["n" + _root.nmbr]);
_root.nmbr++;
_root.onEnterFrame = function () {
if (go) {
stat = "hand";
spr = -1;
mesh.update();
} else {
mesh.nodeDrag();
}
frict = Number(fbox.text);
thi = Number(box.thibox.text);
colo = Number("0x" + box.colbox.text);
mass = Number(box.massbox.text);
k = Number(box.tbox.kbox.text);
len = Number(box.tbox.lbox.text);
elim = Number(box.tbox.elbox.text);
gravity = Number(gbox.text);
(isNaN(gravity) ? ((gravity = 0)) : 0);
(isNaN(frict) ? ((frict = 0)) : 0);
(isNaN(thi) ? ((thi = 0)) : 0);
(isNaN(colo) ? ((colo = 0)) : 0);
(isNaN(mass) ? ((mass = 0)) : 0);
(isNaN(k) ? ((k = 0)) : 0);
(isNaN(len) ? ((len = 0)) : 0);
(isNaN(elim) ? ((elim = 0)) : 0);
};
_root.onMouseDown = function () {
clickable = true;
if ((stat == "hand") || (stat == "spring")) {
mesh.down();
} else if (!box.hitTest(_xmouse, _ymouse, true)) {
if (stat == "node_m") {
_root.attachMovie("node", "n" + _root.nmbr, _root.nmbr);
_root["n" + _root.nmbr].NodeInit(_xmouse, _ymouse, false, mass);
_root.mesh.addNode(_root["n" + _root.nmbr]);
_root.nmbr++;
}
if (stat == "node_f") {
_root.attachMovie("node2", "n" + _root.nmbr, _root.nmbr);
_root["n" + _root.nmbr].NodeInit(_xmouse, _ymouse, true, mass);
_root.mesh.addNode(_root["n" + _root.nmbr]);
_root.nmbr++;
}
}
};
_root.onMouseUp = function () {
space = Key.isDown(32);
mesh.up();
};
Symbol 2 MovieClip [pt] Frame 1
#initclip 7
Object.registerClass("pt", Node);
#endinitclip
Symbol 5 MovieClip [node2] Frame 1
#initclip 5
Object.registerClass("node2", Node);
#endinitclip
Symbol 8 MovieClip [node] Frame 1
#initclip 6
Object.registerClass("node", Node);
#endinitclip
Symbol 13 Button
on (release) {
_root.play();
}
Symbol 86 MovieClip [__Packages.Node] Frame 0
class Node extends MovieClip
{
var _x, _y, gravity, freeze, blue, speed, oldpos, net, mass, _xscale, _yscale, origpos, hitTest;
function Node () {
super();
}
function NodeInit(x, y, frozen, mas) {
_x = x;
_y = y;
gravity = 1;
freeze = frozen;
blue = frozen;
speed = new Vector(0, 0);
oldpos = new Vector(0, 0);
net = new Vector(0, 0);
mass = mas;
_xscale = mass;
_yscale = mass;
origpos = new Vector(_x, _y);
}
function update() {
_xscale = mass;
_yscale = mass;
if ((!freeze) && (_root.go)) {
speed.y = speed.y + ((_root.gravity / 10) * (mass / 100));
speed.x = speed.x * (1 - (_root.frict / 100));
speed.y = speed.y * (1 - (_root.frict / 100));
_x = _x + (speed.x / (mass / 100));
_y = _y + (speed.y / (mass / 100));
} else if (_root.drag == this) {
oldpos.x = _x;
oldpos.y = _y;
(_x = _root._xmouse);
(_y = _root._ymouse);
}
net.x = 0;
net.y = 0;
net.add(new Vector(speed.x, speed.y));
}
function onDown() {
if (hitTest(_root._xmouse, _root._ymouse)) {
if (_root.go) {
freeze = true;
}
speed.x = 0;
speed.y = 0;
if (_root.spr == -1) {
_root.drag = this;
} else if (_root.spr == -2) {
_root.mesh.destroyn(this);
} else if ((_root.clickable = true)) {
_root.clickable = false;
if (_root.spring[0] != this) {
_root.spring[_root.spr] = this;
_root.spr++;
}
if (_root.spr == 2) {
_root.spr = 0;
_root.mesh.addSpring(_root.spring[0], _root.spring[1], _root.k, _root.len, _root.elim, _root.typ, _root.colo, _root.thi);
if (_root.mod == 1) {
_root.mesh.springs[_root.mesh.springs.length - 1].adjust();
}
_root.spring = [0, 0];
}
}
}
}
function onUp() {
if (((!_root.space) && (_root.drag == this)) && (_root.go)) {
freeze = false;
(blue ? ((freeze = !freeze)) : 0);
speed.x = _x - oldpos.x;
speed.y = _y - oldpos.y;
} else {
if ((blue && (_root.drag == this)) && (_root.go)) {
freeze = false;
speed.x = _x - oldpos.x;
speed.y = _y - oldpos.y;
}
if (!_root.go) {
origpos.x = _x;
origpos.y = _y;
}
}
if (_root.drag == this) {
_root.drag = null;
}
}
}
Symbol 87 MovieClip [__Packages.Vector] Frame 0
class Vector
{
var x, y;
function Vector (xpos, ypos) {
x = xpos;
y = ypos;
}
function norm() {
var _local2 = vLength();
((_local2 == 0) ? (_local2 = 1) : 0);
x = x / _local2;
y = y / _local2;
}
function vLength() {
return(Math.sqrt((x * x) + (y * y)));
}
function add(v) {
x = x + v.x;
y = y + v.y;
}
function add2(v, v2) {
return(new Vector(v.x + v2.x, v.y + v2.y));
}
function scale(v) {
x = x * v;
y = y * v;
}
}
Symbol 88 MovieClip [__Packages.elasticMesh] Frame 0
class elasticMesh
{
var nodes, springs, gravity;
function elasticMesh () {
nodes = new Array();
springs = new Array();
gravity = 1;
}
function addNode(node) {
var _local2 = nodes.length;
nodes[_local2] = new Node();
nodes[_local2] = node;
}
function addSpring(n1, n2, k, len, elim, typ, col, thi) {
var _local2 = springs.length;
springs[_local2] = new Spring(n1, n2, k, len, elim, typ, col, thi);
}
function update() {
var _local2 = 0;
while (_local2 < springs.length) {
springs[_local2].update();
_local2++;
}
_local2 = 0;
while (_local2 < nodes.length) {
nodes[_local2].update();
_local2++;
}
draw();
}
function nodeDrag() {
var _local2 = 0;
while (_local2 < nodes.length) {
nodes[_local2].update();
_local2++;
}
draw();
}
function down() {
var _local2 = 0;
while (_local2 < nodes.length) {
nodes[_local2].onDown();
_local2++;
}
}
function reset() {
var _local2 = 0;
while (_local2 < nodes.length) {
nodes[_local2]._x = nodes[_local2].origpos.x;
nodes[_local2]._y = nodes[_local2].origpos.y;
nodes[_local2].freeze = nodes[_local2].blue;
nodes[_local2].speed.x = 0;
nodes[_local2].speed.y = 0;
_local2++;
}
}
function destroy(tgt) {
var _local3 = -1;
var _local2 = 0;
while (_local2 < springs.length) {
((springs[_local2] == tgt) ? (_local3 = _local2) : 0);
_local2++;
}
springs.splice(_local3, 1);
}
function destroyn(tgt) {
var _local3 = -1;
var _local2 = 0;
while (_local2 < nodes.length) {
((nodes[_local2] == tgt) ? (_local3 = _local2) : 0);
_local2++;
}
removeMovieClip(nodes[_local3]);
nodes.splice(_local3, 1);
}
function draw() {
_root.clear();
_root.lineStyle(2, 0, 100);
var _local3 = 0;
while (_local3 < springs.length) {
springs[_local3].draw(_root);
_local3++;
}
}
function adjust() {
var _local2 = 0;
while (_local2 < springs.length) {
springs[_local2].adjust();
_local2++;
}
}
function up() {
var _local2 = 0;
while (_local2 < nodes.length) {
nodes[_local2].onUp();
_local2++;
}
}
}
Symbol 89 MovieClip [__Packages.Spring] Frame 0
class Spring
{
var n1, n2, k, length, elimit, type, color, thick;
function Spring (p1, p2, kconst, len, elim, typ, col, thi) {
n1 = p1;
n2 = p2;
k = kconst / 300;
length = len;
elimit = elim + len;
type = typ;
color = col;
thick = thi;
}
function update() {
var _local2 = new Vector(n2._x - n1._x, n2._y - n1._y);
var _local3 = _local2.vLength();
((_local3 == 0) ? (_local3 = 0.1) : 0);
if ((((_local3 > length) && (type == 1)) || ((_local3 < length) && (type == 2))) || (type == 3)) {
_local2.norm();
var _local4 = (k + ((_local3 > elimit) * k)) * (_local3 - length);
_local2.scale(_local4);
if ((!n1.freeze) || (!n2.freeze)) {
if (!n1.freeze) {
n1.speed.add(new Vector(_local2.x / (n1.mass / 100), _local2.y / (n1.mass / 100)));
} else {
_local2.scale(-1);
n2.speed.add(new Vector(_local2.x / (n2.mass / 100), _local2.y / (n2.mass / 100)));
_local2.scale(-1);
}
if (!n2.freeze) {
_local2.scale(-1);
n2.speed.add(new Vector(_local2.x / (n2.mass / 100), _local2.y / (n2.mass / 100)));
_local2.scale(-1);
} else {
n1.speed.add(new Vector(_local2.x / (n1.mass / 100), _local2.y / (n1.mass / 100)));
}
}
}
}
function adjust() {
var _local2 = new Vector(n2._x - n1._x, n2._y - n1._y);
length = _local2.vLength();
elimit = (length * 1.5) + length;
}
function draw(tgt) {
if ((n1._x == undefined) || (n2._x == undefined)) {
_root.mesh.destroy(this);
} else {
tgt.lineStyle(thick, color, 100);
tgt.moveTo(n1._x, n1._y);
tgt.lineTo(n2._x, n2._y);
}
}
}
Symbol 39 MovieClip Frame 1
stop();
Symbol 39 MovieClip Frame 2
stop();
Symbol 46 MovieClip Frame 1
stop();
Symbol 46 MovieClip Frame 2
stop();
Symbol 46 MovieClip Frame 3
stop();
Symbol 52 MovieClip Frame 1
stop();
Symbol 52 MovieClip Frame 2
stop();
Instance of Symbol 46 MovieClip "typ" in Symbol 52 MovieClip Frame 2
on (release) {
play();
}
onClipEvent (load) {
this.gotoAndPlay(_root.typ);
}
onClipEvent (enterFrame) {
_root.typ = this._currentframe;
}
Instance of Symbol 39 MovieClip "tbox" in Symbol 52 MovieClip Frame 2
onClipEvent (mouseUp) {
if (box1.hitTest(_root._xmouse, _root._ymouse, true)) {
play();
}
}
onClipEvent (load) {
this.gotoAndPlay(_root.mod);
}
onClipEvent (enterFrame) {
_root.mod = this._currentframe;
}
Symbol 54 Button
on (release) {
_root.stat = "node_m";
_root.spr = -1;
_root.box.gotoAndStop(1);
}
Symbol 56 Button
on (release) {
_root.stat = "hand";
_root.spr = 0;
_root.box.gotoAndStop(2);
}
Symbol 59 Button
on (release) {
_root.stat = "spring";
_root.spr = -1;
}
Symbol 60 Button
on (release) {
_root.stat = "hand";
_root.go = true;
_root.spr = -1;
_root.box._visible = false;
}
Symbol 62 Button
on (release) {
_root.stat = "node_f";
_root.spr = -1;
_root.box.gotoAndStop(1);
}
Symbol 65 Button
on (release) {
mesh.nodes[mesh.nodes.length - 1].removeMovieClip();
mesh.nodes.pop();
}
Symbol 67 Button
on (release) {
_root.mesh.springs.pop();
}
Symbol 68 Button
on (release) {
_root.go = false;
_root.mesh.reset();
_root.box._visible = true;
}
Symbol 71 Button
on (release) {
_root.stat = "hand";
_root.spr = -2;
}
Symbol 73 Button
on (release) {
mesh.adjust();
}
Symbol 77 Button
on (release) {
_root.loadPerson();
}
Symbol 79 Button
on (release) {
_root.loadWheel();
}
Symbol 81 Button
on (release) {
_root.loadBlank();
}