Frame 1
function init(option) {
var _local2 = 0;
while (_local2 < nMax) {
_root["e" + _local2].removeMovieClip();
_local2++;
}
onResize();
x = [];
y = [];
vx = [];
vy = [];
r = [];
vrot = [];
rot = [];
touch = [];
x0 = [];
y0 = [];
movx = [];
movy = [];
ymin = 0;
rmax0 = 0;
generateCommand = false;
firstGenerate = true;
n = 0;
rollID = 0;
rgrow = 0;
growVector = 1;
if (option == "generateAll") {
_local2 = 0;
while (_local2 < nMax) {
generateCell(_local2);
setCellProperty(_local2, "first");
n++;
_local2++;
}
rollID = n - 1;
firstGenerate = false;
updateRmax0();
}
draw();
xindex = [];
yindex = [];
gridArray = [];
setGrid();
}
function loop() {
move();
rotate();
if (generateCommand) {
generateCell(n);
if (isGrowth) {
setCellGrowth(n);
dragStart(n);
growthID = n;
} else {
setCellProperty(n);
}
generateCommand = false;
n++;
}
if (isGrowth) {
grow(growthID);
}
draw();
setGrid();
}
function generateCell(i) {
var _local2 = _root.attachMovie("element", "e" + i, i + 10);
}
function setCellProperty(i, option) {
if (option == "first") {
var _local4 = 0;
while (_local4 < 100) {
r[i] = (rmin * 1.5) + (Math.random() * (rmax - (rmin * 1.5)));
x[i] = (margin + (r[i] / 2)) + (Math.random() * ((sw - r[i]) - (margin * 2)));
y[i] = (((-r[i]) / 2) - 200) - (Math.random() * ((3 * sh) - (r[i] / 2)));
var _local9 = _local4;
_local4 = 1000;
var _local3 = 0;
while (_local3 < nMax) {
if ((r[_local3] != undefined) && (i != _local3)) {
var _local6 = x[i] - x[_local3];
var _local5 = y[i] - y[_local3];
var _local7 = Math.sqrt((_local6 * _local6) + (_local5 * _local5));
var _local8 = (r[i] + r[_local3]) / 2;
if (_local7 < (_local8 + 2)) {
_local4 = _local9;
}
}
_local3++;
}
_local4++;
}
vx[i] = (Math.random() * 10) - 5;
vy[i] = Math.random() * 0;
} else {
r[i] = rmin + (Math.random() * (rmax - rmin));
x[i] = (margin + (r[i] / 2)) + (Math.random() * ((sw - r[i]) - (margin * 2)));
y[i] = ymin - (r[i] / 2);
vx[i] = (Math.random() * 60) - 30;
vy[i] = Math.random() * 0;
}
_root["e" + i]._xscale = r[i];
_root["e" + i]._yscale = r[i];
_root["e" + i].txtarea._xscale = (_root["e" + i].txtarea._yscale = 30000 / r[i]);
_root["e" + i].cross1._xscale = (_root["e" + i].cross1._yscale = 30000 / r[i]);
_root["e" + i].cross2._xscale = (_root["e" + i].cross2._yscale = 30000 / r[i]);
_root["e" + i].id = i;
vrot[i] = (Math.random() * 20) - 10;
rot[i] = 0;
touch[i] = [];
x0[i] = x[i];
y0[i] = y[i];
}
function setCellGrowth(i) {
r[i] = rmin;
x[i] = _root._xmouse;
y[i] = _root._ymouse;
vx[i] = 0;
vy[i] = 0;
_root["e" + i]._xscale = r[i];
_root["e" + i]._yscale = r[i];
_root["e" + i].txtarea._xscale = (_root["e" + i].txtarea._yscale = 30000 / r[i]);
_root["e" + i].cross1._xscale = (_root["e" + i].cross1._yscale = 30000 / r[i]);
_root["e" + i].cross2._xscale = (_root["e" + i].cross2._yscale = 30000 / r[i]);
_root["e" + i].id = i;
vrot[i] = 0;
rot[i] = 0;
touch[i] = [];
x0[i] = x[i];
y0[i] = y[i];
}
function grow(i) {
if (growVector == 1) {
r[i] = r[i] * agrow;
if (r[i] >= rmax) {
r[i] = rmax;
growVector = -1;
}
} else {
r[i] = r[i] / agrow;
if (r[i] <= rming) {
r[i] = rming;
growVector = 1;
}
}
_root["e" + i]._xscale = r[i];
_root["e" + i]._yscale = r[i];
_root["e" + i].txtarea._xscale = (_root["e" + i].txtarea._yscale = 30000 / r[i]);
_root["e" + i].cross1._xscale = (_root["e" + i].cross1._yscale = 30000 / r[i]);
_root["e" + i].cross2._xscale = (_root["e" + i].cross2._yscale = 30000 / r[i]);
_root["e" + i].id = i;
vrot[i] = 5;
updateRmax0();
}
function move() {
count = 0;
ymin = 0;
var _local2 = 0;
while (_local2 < n) {
if (_local2 == dragID) {
vx[_local2] = (vx[_local2] + (((_root._xmouse - dragshiftx) - x[_local2]) / da)) / db;
vy[_local2] = (vy[_local2] + (((_root._ymouse - dragshifty) - y[_local2]) / da)) / db;
} else {
var _local13 = xindex[_local2] - 1;
while (_local13 <= (xindex[_local2] + 1)) {
var _local12 = yindex[_local2] - 1;
while (_local12 <= (yindex[_local2] + 1)) {
var _local10 = gridArray[_local13][_local12];
if (_local10 != undefined) {
var _local14 = _local10.length;
var _local5 = 0;
while (_local5 < _local14) {
var _local3 = _local10[_local5];
if (_local2 != _local3) {
var _local7 = x[_local2] - x[_local3];
var _local6 = y[_local2] - y[_local3];
var _local4 = Math.sqrt((_local7 * _local7) + (_local6 * _local6));
count++;
var _local9 = (r[_local2] + r[_local3]) / 2;
if (_local4 < _local9) {
var _local11 = Math.abs(((_local9 - _local4) / 2) * k);
var _local8 = r[_local3] / r[_local2];
vx[_local2] = (vx[_local2] + (((_local11 * _local7) / _local4) * _local8)) / bref;
vy[_local2] = (vy[_local2] + (((_local11 * _local6) / _local4) * _local8)) / bref;
touch[_local2].push(_local3);
}
}
_local5++;
}
}
_local12++;
}
_local13++;
}
vx[_local2] = vx[_local2] / b;
vy[_local2] = (vy[_local2] + gravity) / b;
}
x[_local2] = x[_local2] + vx[_local2];
y[_local2] = y[_local2] + vy[_local2];
ymin = Math.min(ymin, y[_local2]);
if (x[_local2] < ((r[_local2] / 2) + margin)) {
x[_local2] = x[_local2] - (vx[_local2] * (1 + (Math.random() / 100)));
vx[_local2] = vx[_local2] / (-breff);
touch[_local2].push("L");
}
if (x[_local2] > ((sw - (r[_local2] / 2)) - margin)) {
x[_local2] = x[_local2] - (vx[_local2] * (1 + (Math.random() / 100)));
vx[_local2] = vx[_local2] / (-breff);
touch[_local2].push("R");
}
if (y[_local2] > (sh - (r[_local2] / 2))) {
y[_local2] = y[_local2] - vy[_local2];
vy[_local2] = vy[_local2] / (-breff);
touch[_local2].push("B");
}
_local2++;
}
}
function rotate() {
var _local1 = 0;
while (_local1 < n) {
movx[_local1] = x[_local1] - x0[_local1];
movy[_local1] = y[_local1] - y0[_local1];
x0[_local1] = x[_local1];
y0[_local1] = y[_local1];
_local1++;
}
_local1 = 0;
while (_local1 < n) {
if (_local1 == dragID) {
vrot[_local1] = vrot[_local1] / brot;
} else if (touch[_local1] != undefined) {
var _local7 = 0;
while (_local7 < touch[_local1].length) {
var _local4 = touch[_local1][_local7];
switch (_local4) {
case "L" :
vrot[_local1] = (vrot[_local1] + (movy[_local1] / arot)) / brot;
break;
case "R" :
vrot[_local1] = (vrot[_local1] - (movy[_local1] / arot)) / brot;
break;
case "B" :
vrot[_local1] = (vrot[_local1] + (movx[_local1] / arot)) / brot;
break;
default :
var _local3 = movx[_local1] - movx[_local4];
var _local2 = movy[_local1] - movy[_local4];
var _local8 = Math.max(Math.sqrt((_local3 * _local3) + (_local2 * _local2)), 0.0001);
var _local6 = x[_local1] - x[_local4];
var _local5 = y[_local1] - y[_local4];
var _local10 = Math.sqrt((_local6 * _local6) + (_local5 * _local5));
var _local12 = ((_local3 * _local6) + (_local2 * _local5)) / (_local8 * _local10);
var _local9 = Math.acos(_local12);
if ((_local6 * _local5) > 0) {
if (((_local3 > 0) && (_local2 > 0)) || ((_local3 < 0) && (_local2 > 0))) {
var _local11 = -1;
} else {
var _local11 = 1;
}
} else if (((_local3 > 0) && (_local2 > 0)) || ((_local3 < 0) && (_local2 > 0))) {
var _local11 = 1;
} else {
var _local11 = -1;
}
vrot[_local1] = (vrot[_local1] + (((((_local11 * _local8) * Math.sin(_local9)) / arot) * 300) / r[_local1])) / brot;
vrot[_local1] = vrot[_local1] - (vrot[_local4] / arot_rel);
}
_local7++;
}
}
rot[_local1] = rot[_local1] + vrot[_local1];
touch[_local1] = [];
_local1++;
}
}
function draw() {
var _local2 = 0;
while (_local2 < n) {
_root["e" + _local2]._x = x[_local2];
_root["e" + _local2]._y = y[_local2];
_root["e" + _local2]._rotation = rot[_local2] % 360;
_local2++;
}
}
function setGrid() {
gridArray = [];
var _local1 = 0;
while (_local1 < n) {
xindex[_local1] = Math.floor(x[_local1] / grid);
yindex[_local1] = Math.floor(y[_local1] / grid) + 50;
if (gridArray[xindex[_local1]][yindex[_local1]].length > 0) {
gridArray[xindex[_local1]][yindex[_local1]].push(_local1);
} else if (gridArray[xindex[_local1]].length > 0) {
gridArray[xindex[_local1]][yindex[_local1]] = [_local1];
} else {
gridArray[xindex[_local1]] = [];
gridArray[xindex[_local1]][yindex[_local1]] = [_local1];
}
_local1++;
}
}
function dragStart(id) {
dragID = id;
dragshiftx = _root._xmouse - x[id];
dragshifty = _root._ymouse - y[id];
}
function dragStop(id) {
dragID = null;
}
function onResize() {
sw = Stage.width;
sh = Stage.height - hfloor;
var _local2 = 0;
while (_local2 < n) {
if (x[_local2] > ((sw - (r[_local2] / 2)) - margin)) {
vx[_local2] = (((sw - (r[_local2] / 2)) - margin) - 1) - x[_local2];
x[_local2] = x[_local2] + vx[_local2];
}
_local2++;
}
_local2 = 0;
while (_local2 < n) {
if (x[_local2] < ((r[_local2] / 2) + margin)) {
vx[_local2] = (((r[_local2] / 2) + margin) + 1) - x[_local2];
x[_local2] = x[_local2] + vx[_local2];
}
_local2++;
}
_local2 = 0;
while (_local2 < n) {
if (y[_local2] > (sh - (r[_local2] / 2))) {
vy[_local2] = ((sh - (r[_local2] / 2)) - 1) - y[_local2];
y[_local2] = y[_local2] + vy[_local2];
}
_local2++;
}
_root.floor._y = sh;
updateRscale();
}
function updateRscale() {
var _local1 = sw * sh;
rmax = Math.round(Math.sqrt(_local1 / nMax)) * 1.5;
rmin = Math.round(rmax / 4);
rming = Math.round(rmin * 1);
trace((((("scale updated - R:" + rmax) + ",") + rmin) + ",") + rming);
}
function updateRmax0() {
rmax0 = 0;
var _local1 = 0;
while (_local1 < n) {
rmax0 = Math.max(rmax0, r[_local1]);
_local1++;
}
grid = Math.round(rmax0);
}
function rollCell(option) {
if (firstGenerate) {
generateCommand = true;
} else if (rollID != dragID) {
vanishMC = _root.attachMovie("vanish", "vanish", 1);
vanishMC._x = _root["e" + rollID]._x;
vanishMC._y = _root["e" + rollID]._y;
vanishMC._xscale = (vanishMC._yscale = _root["e" + rollID]._xscale);
vanishMC.gotoAndPlay(2);
if (option == "byClick") {
setCellGrowth(rollID);
dragStart(rollID);
growthID = rollID;
} else {
setCellProperty(rollID);
}
}
rollID++;
if (rollID >= nMax) {
firstGenerate = false;
rollID = 0;
}
updateRmax0();
}
function onClickGenerateStart() {
_root.sound.ring(2);
isGrowth = true;
rgrow = 0;
growVector = 1;
rollCell("byClick");
}
function onClickGenerateEnd() {
isGrowth = false;
vx[dragID] = vx[dragID] + ((Math.random() * 2) - 1);
dragStop();
onResize();
trace("end");
}
nMax = 16;
k1 = 1;
k2 = 1.2;
b = 1.01;
bref1 = 1.135;
bref2 = 1.13;
breff = 1.13;
gravity1 = 1.8;
gravity2 = 1.8;
bref = bref1;
k = k1;
rmin = 70;
rming = rmin * 0.7;
rmax = 300;
gravity = 1.2;
arot = 10;
brot = 1.1;
arot_rel = 30;
da = 3;
db = 1.5;
grid = rmax;
hfloor = 0;
margin = 10;
agrow = 1.05;
Frame 7
_root.attachMovie("bset", "bset", 10000);
Frame 10
_quality = "LOW";
Stage.align = "LT";
Stage.scaleMode = "noScale";
myListener = new Object();
myListener.onResize = function () {
_root.onResize();
};
Stage.addListener(myListener);
stop();
function startTick() {
IntervalID = setInterval(_root.tickAction, 1000);
clearInterval(metaInterval);
}
function tickAction() {
_root.rollCell();
_root.sound.ring(1);
}
bref = bref1;
k = k1;
gravity = gravity1;
init("generateAll");
_root.onEnterFrame = loop;
metaInterval = setInterval(startTick, 4000);
stop();
Frame 25
clearInterval(IntervalID);
clearInterval(metaInterval);
btarea.useHandCursor = false;
delete _root.onEnterFrame;
bref = bref2;
k = k2;
gravity = gravity2;
init();
_root.onEnterFrame = loop;
stop();
Symbol 3 MovieClip [vanish] Frame 14
this.removeMovieClip();
Symbol 4 Button
on (press) {
_parent.dragStart(this.id);
gotoAndPlay ("press");
}
on (release, releaseOutside) {
_parent.dragStop(this.id);
gotoAndPlay ("release");
}
Symbol 5 MovieClip Frame 1
Symbol 8 MovieClip [element] Frame 1
bt.useHandCursor = false;
Symbol 8 MovieClip [element] Frame 5
stop();
Symbol 8 MovieClip [element] Frame 10
play();
Symbol 8 MovieClip [element] Frame 14
stop();
Symbol 8 MovieClip [element] Frame 17
gotoAndStop ("def");
Symbol 8 MovieClip [element] Frame 25
stop();
Symbol 8 MovieClip [element] Frame 26
play();
Symbol 8 MovieClip [element] Frame 30
stop();
Symbol 14 Button
on (rollOver, dragOver) {
this.gotoAndPlay("in");
}
on (rollOut, dragOut) {
this.gotoAndPlay("out");
}
on (release) {
_parent.onClickAction();
}
Symbol 17 MovieClip Frame 1
stop();
Symbol 19 MovieClip [buttonBg] Frame 1
stop();
Symbol 19 MovieClip [buttonBg] Frame 14
stop();
this.showDescription();
Symbol 19 MovieClip [buttonBg] Frame 30
stop();
this.hideDescription();
Symbol 19 MovieClip [buttonBg] Frame 44
stop();
_global.URLjump();
Instance of Symbol 20 MovieClip "bt1" in Symbol 21 MovieClip [bset] Frame 33
onClipEvent (load) {
this.title = "AUTOMATIC";
this.bg._width = 60;
this.bg.gotoAndStop("select");
onClickAction = function () {
this.bg.gotoAndStop("select");
_parent.bt2.bg.gotoAndStop("def");
_root.gotoAndPlay("auto");
};
}
Instance of Symbol 20 MovieClip "bt2" in Symbol 21 MovieClip [bset] Frame 33
onClipEvent (load) {
this.title = "SEMI-AUTOMATIC";
onClickAction = function () {
this.bg.gotoAndStop("select");
_parent.bt1.bg.gotoAndStop("def");
_root.gotoAndStop("semi-auto");
};
}
Symbol 21 MovieClip [bset] Frame 40
stop();
Symbol 23 MovieClip Frame 1
function ring(f) {
gotoAndPlay(f + 1);
}
stop();
Symbol 23 MovieClip Frame 2
gotoAndStop (1);
Symbol 25 Button
on (press) {
_root.onClickGenerateStart();
}
on (release, releaseOutside) {
_root.onClickGenerateEnd();
}