Frame 1
function move() {
_root.vxr = (Math.random() * 1) + 3;
_root.vyr = 0;
var _local7 = magnet._x - this._x;
var _local6 = magnet._y - this._y;
var _local11 = (_local7 * _local7) + (_local6 * _local6);
var _local13 = Math.sqrt(_local11);
var _local4 = 2000 / _local11;
_local4 = Math.min(_local4, 2);
var _local16 = (_local4 * _local7) / _local13;
var _local14 = (_local4 * _local6) / _local13;
var _local9 = magnet2._x - this._x;
var _local8 = magnet2._y - this._y;
var _local12 = (_local9 * _local9) + (_local8 * _local8);
var _local10 = Math.sqrt(_local12);
var _local3 = 2000 / _local12;
_local3 = Math.min(_local3, 2);
var _local17 = (_local3 * _local9) / _local10;
var _local15 = (_local3 * _local8) / _local10;
this.vx = this.vx + (_local16 + _local17);
this.vy = this.vy + (_local14 + _local15);
this.vy = this.vy + grav;
this._x = this._x + this.vx;
this._y = this._y + this.vy;
check(this, l0);
check(this, l1);
if (this._y > 450) {
this._x = (this.oldx = 20);
this._y = (this.oldy = 80);
this.vx = vxr;
this.vy = vyr;
}
var _local5 = createEmptyMovieClip("t" + count, count++);
if (count > 1000) {
count = 100;
}
_local5.lineStyle(1, 0, 10);
_local5.moveTo(this.oldx, this.oldy);
_local5.lineTo(this._x, this._y);
this.oldx = this._x;
this.oldy = this._y;
}
function check(dot, line) {
var _local10 = line.getBounds(_root);
if ((dot._x > _local10.xMin) && (dot._x < _local10.xMax)) {
var _local7 = line._x - dot._x;
var _local6 = line._y - dot._y;
var _local12 = (line._rotation * Math.PI) / 180;
var _local4 = Math.cos(_local12);
var _local3 = Math.sin(_local12);
var _local5 = (_local4 * _local6) - (_local3 * _local7);
var _local9 = (_local4 * dot.vy) - (_local3 * dot.vx);
if ((_local5 < 1) && (_local5 > (-_local9))) {
var _local11 = (_local4 * _local7) + (_local3 * _local6);
_local5 = 1;
var _local13 = (_local4 * dot.vx) + (_local3 * dot.vy);
_local9 = _local9 * bounce;
dot.vx = (_local4 * _local13) - (_local3 * _local9);
dot.vy = (_local4 * _local9) + (_local3 * _local13);
_local7 = (_local4 * _local11) - (_local3 * _local5);
_local6 = (_local4 * _local5) + (_local3 * _local11);
dot._x = line._x - _local7;
dot._y = line._y - _local6;
}
}
}
numdots = 20;
bounce = -0.5;
grav = 0.4;
count = 100;
pressing = false;
magnet.onPress = function () {
startDrag (this);
};
magnet.onRelease = function () {
stopDrag();
};
magnet2.onPress = function () {
startDrag (this);
};
magnet2.onRelease = function () {
stopDrag();
};
l0.onPress = function () {
if (l0.myDial.hitTest(_root._xmouse, _root._ymouse)) {
pressing0 = true;
} else {
startDrag (this);
}
};
l0.onRelease = (l0.onReleaseOutside = function () {
stopDrag();
pressing0 = false;
});
l0.onEnterFrame = function () {
if (pressing0 == true) {
myRadians = Math.atan2(_ymouse - _root.l0._y, _xmouse - _root.l0._x);
myDegrees = Math.round((myRadians * 180) / Math.PI);
_root.l0._rotation = myDegrees - 90;
}
};
Mouse.addListener(_root);
_root.onMouseDown = function () {
};
l1.onPress = function () {
if (l1.myDial.hitTest(_root._xmouse, _root._ymouse)) {
pressing = true;
} else {
startDrag (this);
}
};
l1.onRelease = (l1.onReleaseOutside = function () {
stopDrag();
pressing = false;
});
l1.onEnterFrame = function () {
if (pressing == true) {
myRadians = Math.atan2(_ymouse - _root.l1._y, _xmouse - _root.l1._x);
myDegrees = Math.round((myRadians * 180) / Math.PI);
_root.l1._rotation = myDegrees - 90;
}
};
i = 0;
while (i < numdots) {
dot = attachMovie("dot", "d" + i, i);
dot._x = (dot.oldx = 20);
dot._y = (dot.oldy = 80);
dot.vx = (Math.random() * 1) + 3;
dot.vy = 0;
dot.onEnterFrame = move;
i++;
}