Combined Code
movieClip 2 m2ID {
}
frame 1 {
m1Mass = 5;
distx = 0;
disty = 0;
distJx = 0;
distJy = 0;
dist = 0;
a = 0;
b = 0;
c = 0;
distJ = 0;
aJ = 0;
bJ = 0;
cJ = 0;
n = 0;
s = 0;
G = 8;
force = 0;
forceJ = 0;
m2Array = new Array();
wPer = 0;
hPer = 0;
randMass = 0;
randPosx = 0;
randPosy = 0;
Mouse.hide();
startDrag(m1, true);
m1._width = m1Mass;
m1._height = m1Mass;
onEnterFrame = function () {
wPer = m1._width / cam._width;
if (wPer > 0.15) {
cam._width += 4 * (m1Mass / 100);
cam._height += 3 * (m1Mass / 100);
}
if (wPer < 0.02) {
cam._width -= 4 * m1Mass;
cam._height -= 3 * m1Mass;
}
randMass = random(m1Mass * 1.2);
randPosx = Math.floor(Math.random() * (1 + (cam._x + cam._width / 2))) + (cam._x - cam._width / 2);
randPosy = Math.floor(Math.random() * (1 + (cam._y + cam._height / 2))) + (cam._y - cam._height / 2);
m1Mass = m1._width;
m1Mass = m1._height;
++n;
if (n > 3) {
n = 0;
if (m2Array.length < 25) {
s += 1;
newClip = _root.attachMovie('m2ID', 'm2' + s, s, {'_x': randPosx, '_y': randPosy, '_width': randMass, '_height': randMass});
m2Array.push(newClip);
}
}
i = 0;
while (i < m2Array.length) {
m2Array[i]._width = m2Mass;
m2Array[i]._height = m2Mass;
distx = m1._x - m2Array[i]._x;
disty = m1._y - m2Array[i]._y;
a = distx * distx;
b = disty * disty;
c = a + b;
dist = Math.sqrt(c);
force = G * (m1Mass * m2Array[i]._width) / dist * dist;
if (distx > 0) {
m2Array[i]._x += force * (0.01 * distx);
} else {
m2Array[i]._x -= force * (0.01 * -distx);
}
if (disty > 0) {
m2Array[i]._y += force * (0.01 * disty);
} else {
m2Array[i]._y -= force * (0.01 * -disty);
}
if (m1.hitTest(m2Array[i])) {
if (m1Mass > m2Array[i]._width) {
m1._width += m2Array[i]._width / 2;
m1._height += m2Array[i]._width / 2;
loadMovie('', m2Array[i]);
m2Array.splice(i, 1);
} else {
m1._width -= m2Array[i]._width / 2;
m1._height -= m2Array[i]._width / 2;
loadMovie('', m2Array[i]);
m2Array.splice(i, 1);
}
}
j = 0;
while (j < m2Array.length) {
distJx = m2Array[i]._x - m2Array[j]._x;
distJy = m2Array[i]._y - m2Array[j]._y;
aJ = distJx * distJx;
bJ = distJy * distJy;
cJ = aJ + bJ;
distJ = Math.sqrt(cJ);
forceJ = G * (m2Array[j]._width * m2Array[i]._width) / distJ * distJ;
if (distJx > 0) {
m2Array[j]._x += forceJ * (0.01 * distJx);
} else {
m2Array[j]._x -= forceJ * (0.01 * -distJx);
}
if (distJy > 0) {
m2Array[j]._y += forceJ * (0.01 * distJy);
} else {
m2Array[j]._y -= forceJ * (0.01 * -distJy);
}
if (m2Array[i] != m2Array[j]) {
if (m2Array[i].hitTest(m2Array[j])) {
if (m2Array[j]._width < m2Array[i]._width) {
loadMovie('', m2Array[j]);
m2Array.splice(j, 1);
m2Array[i]._width += m2Array[j]._width / 2;
m2Array[i]._height += m2Array[j]._width / 2;
} else {
loadMovie('', m2Array[i]);
m2Array.splice(i, 1);
m2Array[j]._width += m2Array[i]._width / 2;
m2Array[j]._height += m2Array[i]._width / 2;
}
}
}
++j;
}
++i;
}
};
}
movieClip 4 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
// unknown tag 88 length 63
movieClip 9 {
frame 1 {
function camControl() {
parentColor.setTransform(camColor.getTransform());
var v3 = sX / this._width;
var v4 = sY / this._height;
_parent._x = cX - this._x * v3;
_parent._y = cY - this._y * v4;
_parent._xscale = 100 * v3;
_parent._yscale = 100 * v4;
}
function resetStage() {
var v2 = {'ra': 100, 'rb': 0, 'ga': 100, 'gb': 0, 'ba': 100, 'bb': 0, 'aa': 100, 'ab': 0};
parentColor.setTransform(v2);
_parent._xscale = 100;
_parent._yscale = 100;
_parent._x = 0;
_parent._y = 0;
}
this._visible = true;
var oldMode = Stage.scaleMode;
Stage.scaleMode = 'exactFit';
var cX = Stage.width / 2;
var cY = Stage.height / 2;
var sX = Stage.width;
var sY = Stage.height;
Stage.scaleMode = oldMode;
var camColor = new Color(this);
var parentColor = new Color(_parent);
this.onEnterFrame = camControl;
this.onUnload = resetStage;
onMouseMove = function () {
txt_mass.text = _root.m1._width;
};
}
}
instance cam of movieClip 9 {
onClipEvent (enterFrame) {
_x = _x + (_root.m1._x - _x) / 20;
_y = _y + (_root.m1._y - _y) / 20;
}
}