Frame 1
function slide(angle, speed) {
angle = (Math.PI/180) * angle;
var _local4 = Math.cos(angle) * speed;
var _local3 = Math.sin(angle) * speed;
this.fly._x = this.fly._x + _local4;
this.fly._y = this.fly._y - _local3;
}
function rotate(angleVar) {
angle = angle + angleVar;
}
function accelerate(accVar) {
speed = speed + accVar;
}
function decelerate(decVar) {
speed = speed - decVar;
}
function wait() {
waitTime = waitTime - 1;
if (waitTime == 0) {
setHalt = 0;
angle = Math.random() * 360;
if (this.fly._x > 750) {
angle = parseInt(115 + (Math.random() * 90));
}
if (this.fly._x < 50) {
angle = parseInt(315 + (Math.random() * 90));
}
if (this.fly._y > 550) {
angle = parseInt(45 + (Math.random() * 90));
}
if (this.fly._y < 50) {
angle = parseInt(225 + (Math.random() * 90));
}
waitTime = parseInt(10 + (Math.random() * 50));
}
}
function moveStop() {
var _local1 = Math.random() * 0.8;
if (movevar < 11) {
accelerate(_local1);
movevar = movevar + 1;
}
if ((movevar > 10) && (movevar < 20)) {
movevar = movevar + 1;
}
if ((movevar >= 20) && (movevar < 30)) {
decelerate(_local1);
movevar = movevar + 1;
}
if (movevar == 30) {
speed = 0;
movevar = 0;
setHalt = 1;
}
}
function wiggle() {
xWiggle = Math.sin(getTimer() * 0.02) * (2 + Math.random(2));
xWiggle2 = Math.sin(getTimer() * 0.03) * (2 + Math.random(2));
this.fly._x = (this.fly._x - xWiggle) + xWiggle2;
yWiggle = Math.sin(getTimer() * 0.03) * (2 + Math.random(2));
yWiggle2 = Math.sin(getTimer() * 0.03) * (1 + Math.random(3));
this.fly._y = (this.fly._y - yWiggle) + yWiggle2;
}
function sethitzone() {
this.hitzone._x = _root._xmouse - 50;
this.hitzone._y = _root._ymouse - 50;
}
function compareAngle() {
if (((_root._xmouse - this.fly._x) >= 0) && ((_root._ymouse - this.fly._y) >= 0)) {
angle = parseInt(90 + (Math.random() * 90));
}
if (((_root._xmouse - this.fly._x) <= 0) && ((_root._ymouse - this.fly._y) >= 0)) {
angle = parseInt(0 + (Math.random() * 90));
}
if (((_root._xmouse - this.fly._x) <= 0) && ((_root._ymouse - this.fly._y) <= 0)) {
angle = parseInt(270 + (Math.random() * 90));
}
if (((_root._xmouse - this.fly._x) >= 0) && ((_root._ymouse - this.fly._y) <= 0)) {
angle = parseInt(180 + (Math.random() * 90));
}
}
var angle = (Math.random() * 360);
var speed = 0;
var movevar = 0;
var setHalt = 0;
var waitTime = 50;
var xWiggle = 0;
var xWiggle2 = 0;
var yWiggle = 0;
var yWiggle2 = 0;
this.onEnterFrame = function () {
sethitzone();
wiggle();
if (setHalt == 0) {
moveStop();
}
if (setHalt == 1) {
wait();
}
if (this.fly.hitTest(this.hitzone)) {
sethalt = 1;
waitTime = 10;
speed = 4;
compareAngle();
}
slide(angle, speed);
};