home *** CD-ROM | disk | FTP | other *** search
- _global.Timer = function(onChangeFunction, changeInterval, firstTick, clip)
- {
- this.initTime = getTimer();
- this.initClip(clip);
- this.killTime = null;
- this.milissec = 0;
- this.nextChange = 0;
- this.changeInterval = changeInterval;
- this.onChangeFunction = onChangeFunction;
- if(firstTick == undefined)
- {
- firstTick = false;
- }
- this.firstTick = firstTick;
- this.dead = false;
- };
- Timer.prototype.tick = function()
- {
- this.milissec = getTimer() - this.initTime;
- };
- Timer.prototype.updateTime = function(newTime)
- {
- this.changeInterval = newTime;
- };
- Timer.prototype.initClip = function(clip)
- {
- var _loc3_ = randomInt(0,1000000);
- var _loc4_ = "clock" + _loc3_;
- if(clip == undefined)
- {
- clip = "timer";
- }
- _root.attachMovie(clip,_loc4_,_loc3_);
- this.clip = _root[_loc4_];
- this.clip.obj = this;
- this.clip.onEnterFrame = function()
- {
- this.obj.enterFrame();
- };
- };
- Timer.prototype.addKill = function(num)
- {
- this.killTime = num;
- };
- Timer.prototype.kill = function()
- {
- if(this.killTime == null)
- {
- return undefined;
- }
- if(this.milissec >= this.killTime)
- {
- this.clip.removeMovieClip();
- this.dead = true;
- false;
- }
- };
- Timer.prototype.killNow = function()
- {
- this.clip.removeMovieClip();
- this.dead = true;
- false;
- };
- Timer.prototype.change = function()
- {
- if(this.changeInterval == undefined)
- {
- this.changeInterval = 1 * SEC;
- }
- if(this.milissec >= this.nextChange || this.nextChange == undefined)
- {
- if(this.nextChange == 0 && this.firstTick == false)
- {
- this.nextChange = this.milissec + this.changeInterval;
- return false;
- }
- this.nextChange = this.milissec + this.changeInterval;
- return true;
- }
- return false;
- };
- Timer.prototype.enterFrame = function()
- {
- this.tick();
- this.kill();
- if(this.change())
- {
- this.onChangeFunction();
- }
- };
- enemyCounter = 0;
- _global.releaseEnemy = function()
- {
- var _loc5_ = random(3);
- _root.enemyGenerator["enemy" + _loc5_].duplicateMovieClip("e" + enemyCounter,enemyCounter);
- var _loc3_ = random(2);
- if(_loc3_ > 0)
- {
- _loc3_ = -1;
- }
- else
- {
- _loc3_ = 1;
- }
- if(_loc3_ < 0)
- {
- _root.enemyGenerator["e" + enemyCounter]._x = 600 + _root.enemyGenerator["e" + enemyCounter]._width;
- }
- else
- {
- _root.enemyGenerator["e" + enemyCounter]._x = - _root.enemyGenerator["e" + enemyCounter]._width;
- }
- _root.enemyGenerator["e" + enemyCounter].dir = _loc3_;
- _root.enemyGenerator["e" + enemyCounter]._xscale *= _loc3_;
- _root.enemyGenerator["e" + enemyCounter].speed = _loc3_ * randomInt(3,5);
- var _loc4_ = random(4) + 1;
- _root.enemyGenerator["e" + enemyCounter]._y = _root["spot" + _loc4_]._y;
- enemyCounter++;
- };
-