Code:
Stage.scaleMode = 'noScale';
Stage.align = 'TL';
speed = 20;
maxspeed = 15;
minspeed = 5;
this.createEmptyMovieClip('flier_mc',2);
flier_mc.lineStyle(2,0x0000ff,100);
flier_mc.beginFill(0x00ffff,100);
flier_mc.moveTo(-15,15);
flier_mc.lineTo(-3,-5);
flier_mc.lineTo(0,-15);
flier_mc.lineTo(3,-5);
flier_mc.lineTo(15,15);
flier_mc.lineTo(0,10);
flier_mc.lineTo(-15,15);
flier_mc.endFill();
flier_mc._x = random(Stage.width);
flier_mc._y = random(Stage.height);
flier_mc.onEnterFrame = function() {
this.point = {x:target_mc._x, y:target_mc._y};
this.globalToLocal(this.point);
this.disx = -this.point.x;
this.disy = -this.point.y;
this.ang = -Math.atan2(this.disx, this.disy) / (Math.PI / 180);
if (Math.abs(this.ang) < 45) {
this._rotation += (this.ang / 4);
if (Math.abs(this.ang) < 15) {
laser();
}
speed = (speed < maxspeed) ? speed + 1 : maxspeed;
} else {
speed = (speed > minspeed) ? speed - .25 : minspeed;
}
this._rotation += (this.ang / (speed * 2));
trail();
this.rot2rad = this._rotation * (Math.PI / 180);
this._x += (Math.sin(this.rot2rad) * speed);
this._y -= (Math.cos(this.rot2rad) * speed);
movetrail();
};
var t:Number = 0;
this.createEmptyMovieClip('trail_mc',1);
function trail() {
trailed = trail_mc.createEmptyMovieClip('trail' + t, t);
trailed.lineStyle(5,0xff6600,100);
trailed.moveTo(flier_mc._x,flier_mc._y);
}
function movetrail() {
trailed.lineTo(flier_mc._x,flier_mc._y);
trailed.onEnterFrame = function() {
this._alpha -= 25;
if (this._alpha < 0) {
this.removeMovieClip();
}
};
t++;
}
this.createEmptyMovieClip('target_mc',0);
target_mc.lineStyle(2,0xff00ff,100);
target_mc.beginFill(0x660066,100);
target_mc.moveTo(-10,0);
target_mc.lineTo(-3,-3);
target_mc.lineTo(0,-10);
target_mc.lineTo(3,-3);
target_mc.lineTo(10,0);
target_mc.lineTo(3,3);
target_mc.lineTo(0,10);
target_mc.lineTo(-3,3);
target_mc.moveTo(-10,0);
target_mc.endFill();
target_mc._x = target_mc.tX = 50;
target_mc._y = target_mc.tY = 50;
target_mc.onEnterFrame = function() {
this._rotation += 25;
if (this._x < (this.tX + 5) and this._x > (this.tX - 5)) {
this.tX = 50 + Math.random() * (Stage.width - 50);
}
if (this._y < (this.tY + 5) and this._y > (this.tY - 5)) {
this.tY = 50 + Math.random() * (Stage.height - 50);
}
this._x += ((this.tX - this._x) / 20);
this._y += ((this.tY - this._y) / 20);
this._xscale = this._yscale = (this._yscale > 100) ? this._yscale - 25 : 100;
};
var las:Number = 0;
function laser() {
lsr = this.createEmptyMovieClip('laser' + las, 1000 + las);
lsr.lineStyle(3,0x00ffff,50);
lsr.moveTo(0,0);
lsr.lineTo(0,-10);
lsr.lineStyle(1,0x00ffff,100);
lsr.moveTo(0,-1);
lsr.lineTo(0,-9);
lsr._x = flier_mc._x + (5 - Math.random() * 10);
lsr._y = flier_mc._y + (5 - Math.random() * 10);
lsr._rotation = flier_mc._rotation + (5 - Math.random() * 10);
lsr.onEnterFrame = function() {
this.rot2rad = this._rotation * (Math.PI / 180);
this._x += (Math.sin(this.rot2rad) * 25);
this._y -= (Math.cos(this.rot2rad) * 25);
if (this.hitTest(target_mc)) {
target_mc._xscale = target_mc._yscale = 150;
this.removeMovieClip();
}
if (this._x < -50 or this._x > Stage.width + 50 or this._y < -50 or this._y > Stage.height + 50) {
this.removeMovieClip();
}
};
las++;
}