Instance of Symbol 13 MovieClip [Blob] "ship" in Frame 1
//component parameters
onClipEvent (construct) {
varName = "defaultValue";
}
Symbol 9 MovieClip [Alien] Frame 1
#initclip 4
function AlienClass(nCreated) {
this.type = "one";
trace("Alien Started " + this._name);
}
AlienClass.prototype = new MovieClip();
AlienClass.prototype.setPos = function (nx, ny) {
this._x = nx;
this._y = ny;
};
Object.registerClass("Alien", AlienClass);
#endinitclip
Symbol 9 MovieClip [Alien] Frame 15
_root[this._name].removeMovieClip();
Symbol 11 MovieClip [bullet] Frame 1
#initclip 1
function bulletClass() {
this.vPos = 400;
this.speed = -10;
}
bulletClass.prototype = new MovieClip();
bulletClass.prototype.onEnterFrame = function () {
this.vPos = this.vPos + this.speed;
this._y = this.vPos;
if (this._y < 0) {
_root.control.killBullet(this._name);
this._y = 200;
this._x = -50;
this.vPos = 200;
this.speed = 0;
}
};
Object.registerClass("bullet", bulletClass);
#endinitclip
Symbol 13 MovieClip [Blob] Frame 1
#initclip 2
function BlobClass() {
_root.xPos = 250;
_root.speed = 3;
_root.bulletNum = 10;
this.myListener = new Object();
this.myListener.onKeyDown = function () {
switch (Key.getCode()) {
case 40 :
trace("down");
break;
case 39 :
trace("right");
_root.xPos = _root.xPos + _root.speed;
break;
case 38 :
trace("up");
_root.control.fire();
break;
case 37 :
trace("left");
_root.xPos = _root.xPos - _root.speed;
break;
default :
trace((("key" + Key.getCode()) + " ") + Key.getAscii());
}
};
this.myListener.onKeyUp = function () {
trace("keyUp");
};
Key.addListener(this.myListener);
}
BlobClass.prototype = new MovieClip();
BlobClass.prototype.onEnterFrame = function () {
this._x = _root.xPos;
};
Object.registerClass("Blob", BlobClass);
#endinitclip
Symbol 16 MovieClip [control] Frame 1
#initclip 3
function controlClass() {
this.alienArray = new Array();
this.bulletArray = new Array();
this.setupAliens();
_root.score = 0;
}
controlClass.prototype = new MovieClip();
controlClass.prototype.setupAliens = function () {
i = 0;
while (i < 5) {
_root.Alien.duplicateMovieClip("Alien" + i, i);
obj = eval ("_root.Alien" + i);
this.alienArray[i] = obj;
obj.setPos(i * 100, 100);
obj.gotoAndStop("one");
i++;
}
this.aMovX = 0;
this.aMovY = 100;
this.aDir = 2;
this.aFr = 0;
this.aFireDelay = 0;
};
controlClass.prototype.fire = function () {
_root.bulletNum = _root.bulletNum + 1;
if (this.aFireDelay <= 0) {
this.aFireDelay = 5;
if (this.bulletArray.length < 3) {
_root.bullet.duplicateMovieClip("bullet" + _root.bulletNum, _root.bulletNum);
obj = eval ("_root.bullet" + _root.bulletNum);
trace(this.bulletArray.length);
this.bulletArray[this.bulletArray.length] = obj;
obj._x = _root.ship._x;
obj.vPos = _root.ship._y;
}
}
};
controlClass.prototype.killBullet = function (nName) {
this.bulletArray.shift();
_root[nName].removeMovieClip();
};
controlClass.prototype.killAlien = function (nName) {
i = 0;
while (i < this.alienArray.length) {
obj = this.alienArray[i];
if (obj._name == nName) {
this.alienArray.splice(i, 1);
}
i++;
}
};
controlClass.prototype.onEnterFrame = function () {
this.aFireDelay = this.aFireDelay - 1;
this.aMovX = this.aMovX + this.aDir;
if ((this.aMovX < 0) || (this.aMovX > 100)) {
this.aDir = this.aDir * -1;
this.aMovY = this.aMovY + 10;
}
this.aFr++;
if (this.aFr > 5) {
this.aFr = 0;
}
i = 0;
while (i < this.alienArray.length) {
obj = this.alienArray[i];
obj.setPos((i * 100) + this.aMovX, this.aMovY);
j = 0;
while (j < this.bulletArray.length) {
if (obj.hitTest(this.bulletArray[j])) {
obj.gotoAndPlay("explode");
this.killAlien(obj._name);
this.killBullet(this.bulletArray[j]._name);
_root.score = _root.score + 1;
_root.scoreText.text = "score: " + _root.score;
}
j++;
}
switch (aFr) {
case 0 :
obj.gotoAndStop("one");
break;
case 1 :
obj.gotoAndStop("two");
}
i++;
}
if (this.alienArray.length <= 0) {
this.setupAliens();
}
};
Object.registerClass("control", controlClass);
#endinitclip