Section 1
//AbstractController (com.mvc.AbstractController)
package com.mvc {
public class AbstractController implements Controller {
protected var view:View;
protected var model:AbstractModel;
public function setView(_arg1:View):void{
this.view = _arg1;
}
public function getModel():AbstractModel{
return (this.model);
}
public function getView():View{
return (this.view);
}
public function setModel(_arg1:AbstractModel):void{
this.model = _arg1;
}
}
}//package com.mvc
Section 2
//AbstractModel (com.mvc.AbstractModel)
package com.mvc {
import flash.events.*;
public class AbstractModel extends EventDispatcher implements Model {
public function notifyOfChanges():void{
this.dispatchEvent(new Event(Event.CHANGE));
}
}
}//package com.mvc
Section 3
//AbstractView (com.mvc.AbstractView)
package com.mvc {
import flash.events.*;
import flash.display.*;
public class AbstractView extends Sprite implements View {
protected var model:AbstractModel;
public function getModel():AbstractModel{
return (this.model);
}
public function update(_arg1:Event):void{
}
public function setModel(_arg1:AbstractModel):void{
this.model = _arg1;
this.model.addEventListener(Event.CHANGE, this.update);
}
}
}//package com.mvc
Section 4
//Controller (com.mvc.Controller)
package com.mvc {
public interface Controller {
function getModel():AbstractModel;
function setView(_arg1:View):void;
function getView():View;
function setModel(_arg1:AbstractModel):void;
}
}//package com.mvc
Section 5
//Model (com.mvc.Model)
package com.mvc {
public interface Model {
function notifyOfChanges():void;
}
}//package com.mvc
Section 6
//View (com.mvc.View)
package com.mvc {
import com.mvc.*;
import flash.events.*;
interface View {
function getModel():AbstractModel;
function setModel(_arg1:AbstractModel):void;
function update(_arg1:Event):void;
}
}//package com.mvc
Section 7
//Explosion (com.welcometoearth.game.explosion.Explosion)
package com.welcometoearth.game.explosion {
import flash.events.*;
import flash.display.*;
public class Explosion extends EventDispatcher {
private var t_particles:Array;
private var c_particles:Array;
private var energie:Number;
private static const X_SPEED_MULTIPLIER:Number = 1.2;
private static const EXPLOSION_MAX_VELOCITY:Number = 1;
private static const EXPLOSION_RADIUS:int = 10;
private static const PARTICLE_DAMP_ENERGIE:Number = 0.965;
private static const GRAVITY:Number = 0;
private static const EXPLOSION_MAX_HEAT:Number = 0;
private static const PARTICLE_COUNT:int = 150;
private static const PARTICLE_DAMP_MOVE:Number = 0.99;
private static const PARTICLE_CHAOTIC_MOVE:Number = 0.09;
private static const PARTICLE_COUNT_EACH_FRAME:int = 25;
public function Explosion(_arg1:Number, _arg2:Number){
init(_arg1, _arg2);
}
private function init(_arg1:Number, _arg2:Number):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Particle;
var _local7:int;
this.t_particles = new Array();
this.c_particles = new Array();
this.energie = 1;
_local7 = 0;
while (_local7 < PARTICLE_COUNT) {
_local3 = ((Math.random() * Math.PI) * 2);
_local4 = (Math.random() * EXPLOSION_MAX_VELOCITY);
_local5 = (Math.random() * EXPLOSION_RADIUS);
_local6 = new Particle((_arg1 + (Math.sin(_local3) * _local5)), (_arg2 + (Math.cos(_local3) * _local5)), ((Math.sin(_local3) * _local4) * X_SPEED_MULTIPLIER), ((Math.cos(_local3) * _local4) - (Math.random() * EXPLOSION_MAX_HEAT)), 1, PARTICLE_DAMP_ENERGIE);
this.t_particles.push(_local6);
_local7++;
};
}
public function render(_arg1:BitmapData):void{
var _local2:Particle;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:int;
var _local8:Number;
if (this.t_particles.length >= PARTICLE_COUNT_EACH_FRAME){
this.c_particles = this.c_particles.concat(this.t_particles.splice(-(PARTICLE_COUNT_EACH_FRAME)));
} else {
if (this.t_particles.length > 0){
this.c_particles = this.t_particles.splice();
};
};
_local7 = this.c_particles.length;
_local8 = 0;
while (--_local7 > -1) {
_local2 = this.c_particles[_local7];
_local3 = _local2.sx;
_local4 = _local2.sy;
_local5 = _local2.vx;
_local6 = _local2.vy;
_local5 = (_local5 + ((Math.random() / (0.5 / PARTICLE_CHAOTIC_MOVE)) - PARTICLE_CHAOTIC_MOVE));
_local6 = (_local6 + ((Math.random() / (0.5 / PARTICLE_CHAOTIC_MOVE)) - PARTICLE_CHAOTIC_MOVE));
if (_local2.energie < 0.1){
this.c_particles.splice(_local7, 1);
};
_local8 = (_local8 + _local2.energie);
_local2.energie = (_local2.energie * _local2.energieDamp);
_arg1.setPixel(_local3, _local4, int((_local2.energie * 0xFF)));
_local3 = (_local3 + _local5);
_local4 = (_local4 + _local6);
_local5 = (_local5 * PARTICLE_DAMP_MOVE);
_local6 = (_local6 * PARTICLE_DAMP_MOVE);
_local6 = (_local6 + GRAVITY);
_local2.sx = _local3;
_local2.sy = _local4;
_local2.vx = _local5;
_local2.vy = _local6;
};
if (_local8 == 0){
this.dispatchEvent(new Event(Event.COMPLETE));
};
}
}
}//package com.welcometoearth.game.explosion
Section 8
//ExplosionContainer (com.welcometoearth.game.explosion.ExplosionContainer)
package com.welcometoearth.game.explosion {
import flash.events.*;
import gs.*;
import flash.display.*;
import fl.transitions.easing.*;
import com.welcometoearth.*;
import flash.filters.*;
import flash.geom.*;
public class ExplosionContainer extends Sprite {
private var output:BitmapData;
private var explosion:Explosion;
private var buffer:BitmapData;
private var blur:BlurFilter;
private var fireColors:Array;
private var outputBitmap:Bitmap;
private static const ORIGIN:Point = new Point();
private static const EXPLOSION_BLUR_QUALITY:int = 1;
private static const REMOVE_EXPLOSION_DURATION:Number = 0.8;
private static const EXPLOSION_BLUR_STRENGTH:int = 2;
public function ExplosionContainer(){
this.initialize();
}
private function onExplosionComplete(_arg1:Event):void{
this.explosion.removeEventListener(Event.COMPLETE, this.onExplosionComplete);
TweenLite.to(this.outputBitmap, REMOVE_EXPLOSION_DURATION, {alpha:0, ease:Strong.easeIn, onComplete:this.onExplosionHidden});
}
public function createExplosion(_arg1:Number, _arg2:Number):void{
if (this.explosion == null){
this.buffer = new BitmapData(Main.STAGE_WIDTH, Main.STAGE_HEIGHT, false, 0);
this.output = new BitmapData(Main.STAGE_WIDTH, Main.STAGE_HEIGHT, false, 0);
this.outputBitmap = (this.addChild(new Bitmap(this.output)) as Bitmap);
this.outputBitmap.alpha = 1;
this.explosion = new Explosion(_arg1, _arg2);
this.explosion.addEventListener(Event.COMPLETE, this.onExplosionComplete);
this.stage.addEventListener(Event.ENTER_FRAME, this.render);
};
}
private function render(_arg1:Event):void{
if (this.explosion != null){
this.explosion.render(this.buffer);
this.buffer.applyFilter(this.buffer, this.buffer.rect, ORIGIN, blur);
this.output.copyPixels(this.buffer, this.buffer.rect, ORIGIN);
this.output.paletteMap(this.output, this.output.rect, ORIGIN, [], [], this.fireColors, []);
};
}
private function initialize():void{
var _local1:Array;
var _local2:Array;
var _local3:Array;
this.blur = new BlurFilter(EXPLOSION_BLUR_STRENGTH, EXPLOSION_BLUR_STRENGTH, EXPLOSION_BLUR_QUALITY);
_local1 = [0, 0, 13253435, 16764194, 0xFFFFFF, 0xFFFFFF];
_local2 = [0, 0, 1, 1, 1, 1];
_local3 = [0, 17, 102, 153, 187, 0xFF];
this.fireColors = Gradient.getArray(_local1, _local2, _local3);
}
private function onExplosionHidden():void{
this.stage.removeEventListener(Event.ENTER_FRAME, this.render);
this.explosion = null;
this.removeChild(this.outputBitmap);
this.buffer.dispose();
this.output.dispose();
}
}
}//package com.welcometoearth.game.explosion
Section 9
//Gradient (com.welcometoearth.game.explosion.Gradient)
package com.welcometoearth.game.explosion {
import flash.display.*;
import flash.geom.*;
public class Gradient {
private static const IDENTITY:Matrix = new Matrix();
public static function getArray(_arg1:Array, _arg2:Array, _arg3:Array):Array{
var _local4:Array;
var _local5:Shape;
var _local6:Matrix;
var _local7:BitmapData;
var _local8:Graphics;
var _local9:uint;
var _local10:int;
_local4 = new Array();
_local5 = new Shape();
_local6 = new Matrix();
_local7 = new BitmapData(0x0100, 1, true, 0);
_local8 = _local5.graphics;
_local6.createGradientBox(0x0100, 0x0100, 0, 0, 0);
_local8.clear();
_local8.beginGradientFill("linear", _arg1, _arg2, _arg3, _local6);
_local8.drawRect(0, 0, 0x0100, 0x0100);
_local8.endFill();
_local7.draw(_local5, IDENTITY);
_local10 = 0;
while (_local10 < 0x0100) {
_local9 = _local7.getPixel32(_local10, 0);
_local4.push(_local9);
_local10++;
};
return (_local4);
}
}
}//package com.welcometoearth.game.explosion
Section 10
//Particle (com.welcometoearth.game.explosion.Particle)
package com.welcometoearth.game.explosion {
public class Particle {
public var vx:Number;
public var vy:Number;
public var sx:Number;
public var sy:Number;
public var energie:Number;
public var energieDamp:Number;
public function Particle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number){
this.sx = _arg1;
this.sy = _arg2;
this.vx = _arg3;
this.vy = _arg4;
this.energie = _arg5;
this.energieDamp = _arg6;
}
}
}//package com.welcometoearth.game.explosion
Section 11
//Shockwave (com.welcometoearth.game.explosion.Shockwave)
package com.welcometoearth.game.explosion {
import com.welcometoearth.game.shield.*;
public class Shockwave extends Shield {
private static const TWEEN_DURATION:Number = 2;
private static const MAX_RADIUS:Number = 200;
public function Shockwave(_arg1:Number, _arg2:Number){
super(_arg1, _arg2);
this.tweenDuration = TWEEN_DURATION;
this.maxRadius = MAX_RADIUS;
this.initialize();
}
}
}//package com.welcometoearth.game.explosion
Section 12
//Missile (com.welcometoearth.game.missile.Missile)
package com.welcometoearth.game.missile {
import flash.events.*;
import flash.display.*;
import com.welcometoearth.game.*;
import com.welcometoearth.*;
public class Missile extends EventDispatcher {
private var speed:Number;
private var angle:Number;
private var ySpeed:Number;
private var game:Game;
private var missileView:MissileView;
private var xSpeed:Number;
public var x:Number;
public var y:Number;
private static const DECELLERATION:Number = 0.9;
public static const MIN_SPEED:Number = 2;
public static const REMOVED_ON_WRAP:String = "removedOnWrap";
public static const MAX_SPEED:Number = 4;
public function Missile(_arg1:Game){
this.game = _arg1;
this.speed = (MIN_SPEED + ((MAX_SPEED - MIN_SPEED) * Math.random()));
this.angle = 0;
}
public function hide():void{
this.x = 0;
this.y = 0;
this.xSpeed = 0;
this.ySpeed = 0;
this.missileView.x = this.x;
this.missileView.y = this.y;
}
public function setSpeed(_arg1:Number):void{
this.speed = _arg1;
}
public function updatePosition():void{
this.x = (this.x + this.xSpeed);
this.y = (this.y + this.ySpeed);
if (!this.checkGameOverAndRemoved()){
this.x = (this.x + Main.STAGE_WIDTH);
this.x = (this.x % Main.STAGE_WIDTH);
this.y = (this.y + Main.STAGE_HEIGHT);
this.y = (this.y % Main.STAGE_HEIGHT);
};
this.missileView.x = this.x;
this.missileView.y = this.y;
}
public function isCollidingWith(_arg1:DisplayObject):Boolean{
return (_arg1.hitTestPoint(this.x, this.y, true));
}
public function attractToPoint(_arg1:Number, _arg2:Number):void{
this.repelFromPoint(_arg1, _arg2);
this.setAngle((this.angle + Math.PI));
}
private function setAngle(_arg1:Number):void{
this.angle = _arg1;
this.missileView.rotation = (((Math.PI - _arg1) / Math.PI) * 180);
}
public function repelFromPoint(_arg1:Number, _arg2:Number):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local3 = (this.x - _arg1);
_local4 = (this.y - _arg2);
_local5 = Math.atan((_local3 / _local4));
if ((((_local4 < 0)) && ((_local3 < 0)))){
_local5 = (_local5 + Math.PI);
} else {
if (_local4 < 0){
_local5 = ((Math.PI / 2) - _local5);
};
};
this.setAngle(_local5);
}
public function setView(_arg1:MissileView):void{
this.missileView = _arg1;
}
public function updateVelocity():void{
this.xSpeed = (Math.sin(this.angle) * this.speed);
this.ySpeed = (Math.cos(this.angle) * this.speed);
}
private function checkGameOverAndRemoved():Boolean{
if (((this.game.getGameOver()) && ((((((((this.x < 0)) || ((this.x > Main.STAGE_WIDTH)))) || ((this.y < 0)))) || ((this.y > Main.STAGE_HEIGHT)))))){
this.setSpeed(0);
this.dispatchEvent(new Event(REMOVED_ON_WRAP));
return (true);
};
return (false);
}
public function updateSpeed():void{
if (this.speed > MAX_SPEED){
this.speed = (this.speed * DECELLERATION);
};
this.updateVelocity();
}
}
}//package com.welcometoearth.game.missile
Section 13
//MissileContainer (com.welcometoearth.game.missile.MissileContainer)
package com.welcometoearth.game.missile {
import flash.events.*;
import flash.display.*;
import com.welcometoearth.game.*;
import com.welcometoearth.game.shield.*;
import com.welcometoearth.*;
public class MissileContainer extends Sprite {
private var missiles:Array;
private var missile:Missile;
private var shield:Shield;
private var i:uint;
private var missileCount:int;
private var missilesRemoved:int;
private var missileViews:Array;
private var game:Game;
private static const MISSILE_SPAWN_DELAY:uint = 5;
private static const MISSILE_COUNT:uint = 100;
public function createMissileViews():void{
var _local1:uint;
var _local2:MissileView;
this.missileViews = new Array(MISSILE_COUNT);
_local1 = 0;
while (_local1 < MISSILE_COUNT) {
_local2 = new MissileView();
this.addChild(_local2);
this.missileViews[_local1] = _local2;
_local1++;
};
}
private function onMissileRemovedOnWrap(_arg1:Event):void{
var _local2:Missile;
_local2 = (_arg1.target as Missile);
_local2.removeEventListener(Missile.REMOVED_ON_WRAP, this.onMissileRemovedOnWrap);
this.missilesRemoved++;
if (this.missilesRemoved == this.missileCount){
};
}
public function reset():void{
this.resetMissileViews();
this.resetMissiles();
}
public function setShield(_arg1:Shield):void{
this.shield = _arg1;
}
public function setGame(_arg1:Game):void{
this.game = _arg1;
}
private function resetMissiles():void{
this.missiles = new Array(MISSILE_COUNT);
this.missileCount = 0;
}
public function createMissile(_arg1:int):void{
var _local2:Missile;
if (((((((_arg1 % MISSILE_SPAWN_DELAY) == 0)) && (!(this.game.getGameOver())))) && ((this.missileCount < MISSILE_COUNT)))){
_local2 = new Missile(this.game);
_local2.setView(this.missileViews[this.missileCount]);
this.moveToRandomEdgePosition(_local2);
_local2.attractToPoint(this.game.getPlayer().getModel().getX(), this.game.getPlayer().getModel().getY());
_local2.updateVelocity();
_local2.addEventListener(Missile.REMOVED_ON_WRAP, this.onMissileRemovedOnWrap);
this.missiles[this.missileCount] = _local2;
this.missileCount++;
};
}
public function checkCollisions():void{
this.i = 0;
while (this.i < this.missileCount) {
this.missile = (this.missiles[this.i] as Missile);
this.missile.updateSpeed();
this.missile.updatePosition();
if (this.missile.isCollidingWith(this.game.playerView)){
this.game.setGameOver(true);
this.missile.hide();
this.missilesRemoved = 0;
};
if (this.shield != null){
if (this.missile.isCollidingWith(this.shield)){
this.missile.setSpeed(Math.max(this.shield.getSpeed(), Missile.MIN_SPEED));
this.missile.repelFromPoint(this.shield.x, this.shield.y);
this.missile.updateVelocity();
};
};
this.i++;
};
}
private function moveToRandomEdgePosition(_arg1:Missile):void{
if (Math.random() > 0.5){
_arg1.x = (Math.random() * Main.STAGE_WIDTH);
if (Math.random() > 0.5){
_arg1.y = 0;
} else {
_arg1.y = Main.STAGE_HEIGHT;
};
} else {
_arg1.y = (Math.random() * Main.STAGE_HEIGHT);
if (Math.random() > 0.5){
_arg1.x = 0;
} else {
_arg1.x = Main.STAGE_WIDTH;
};
};
}
private function resetMissileViews():void{
var _local1:uint;
_local1 = 0;
while (_local1 < this.missileViews.length) {
this.missileViews[_local1].reset();
_local1++;
};
}
}
}//package com.welcometoearth.game.missile
Section 14
//MissileView (com.welcometoearth.game.missile.MissileView)
package com.welcometoearth.game.missile {
import flash.events.*;
import flash.display.*;
public class MissileView extends Sprite {
public var trail:Sprite;
private static const MAX_TRAIL_ALPHA:Number = 0.5;
public function MissileView(){
this.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
}
public function reset():void{
this.x = 0;
this.y = 0;
}
private function onEnterFrame(_arg1:Event):void{
this.trail.alpha = (Math.random() * MAX_TRAIL_ALPHA);
}
}
}//package com.welcometoearth.game.missile
Section 15
//Player (com.welcometoearth.game.player.Player)
package com.welcometoearth.game.player {
import flash.events.*;
import com.welcometoearth.game.ui.*;
public class Player {
private var view:PlayerView;
private var model:PlayerModel;
private var controller:PlayerController;
public function Player(_arg1:PlayerView, _arg2:KeyboardListener){
this.model = new PlayerModel(_arg1.x, _arg1.y);
this.controller = new PlayerController(_arg2);
this.controller.setView(_arg1);
this.controller.setModel(this.model);
this.view = _arg1;
this.view.setModel(this.model);
}
public function getModel():PlayerModel{
return (this.model);
}
public function step(_arg1:Event):void{
this.controller.step(_arg1);
}
}
}//package com.welcometoearth.game.player
Section 16
//PlayerController (com.welcometoearth.game.player.PlayerController)
package com.welcometoearth.game.player {
import com.mvc.*;
import flash.events.*;
import com.welcometoearth.game.ui.*;
import flash.ui.*;
public class PlayerController extends AbstractController {
private var keyboardListener:KeyboardListener;
private static const ACCELERATION:Number = 2;
private static const FRICTION:Number = 0.75;
public function PlayerController(_arg1:KeyboardListener){
this.keyboardListener = _arg1;
}
public function step(_arg1:Event):void{
var _local2:PlayerModel;
_local2 = (this.model as PlayerModel);
if (this.keyboardListener.getKeyDown(Keyboard.LEFT)){
_local2.setXSpeed((_local2.getXSpeed() - ACCELERATION));
};
if (this.keyboardListener.getKeyDown(Keyboard.RIGHT)){
_local2.setXSpeed((_local2.getXSpeed() + ACCELERATION));
};
if (this.keyboardListener.getKeyDown(Keyboard.UP)){
_local2.setYSpeed((_local2.getYSpeed() - ACCELERATION));
};
if (this.keyboardListener.getKeyDown(Keyboard.DOWN)){
_local2.setYSpeed((_local2.getYSpeed() + ACCELERATION));
};
_local2.setXSpeed((_local2.getXSpeed() * FRICTION));
_local2.setYSpeed((_local2.getYSpeed() * FRICTION));
_local2.setX((_local2.getX() + _local2.getXSpeed()));
_local2.setY((_local2.getY() + _local2.getYSpeed()));
}
}
}//package com.welcometoearth.game.player
Section 17
//PlayerModel (com.welcometoearth.game.player.PlayerModel)
package com.welcometoearth.game.player {
import com.mvc.*;
import com.welcometoearth.*;
public class PlayerModel extends AbstractModel {
private var ySpeed:Number;
private var xSpeed:Number;
private var x:Number;
private var y:Number;
public function PlayerModel(_arg1:Number, _arg2:Number){
this.x = _arg1;
this.y = _arg2;
this.xSpeed = 0;
this.ySpeed = 0;
}
public function getX():Number{
return (this.x);
}
public function getY():Number{
return (this.y);
}
public function getYSpeed():Number{
return (this.ySpeed);
}
public function setYSpeed(_arg1:Number):void{
this.ySpeed = _arg1;
}
public function setXSpeed(_arg1:Number):void{
this.xSpeed = _arg1;
}
public function setX(_arg1:Number):void{
this.x = Math.min(Math.max(_arg1, 0), Main.STAGE_WIDTH);
this.notifyOfChanges();
}
public function setY(_arg1:Number):void{
this.y = Math.min(Math.max(_arg1, 0), Main.STAGE_HEIGHT);
this.notifyOfChanges();
}
public function getXSpeed():Number{
return (this.xSpeed);
}
}
}//package com.welcometoearth.game.player
Section 18
//PlayerView (com.welcometoearth.game.player.PlayerView)
package com.welcometoearth.game.player {
import com.mvc.*;
import flash.events.*;
import gs.*;
import flash.display.*;
import fl.transitions.easing.*;
public class PlayerView extends AbstractView {
public var revealLine:Sprite;
public var maskSprite:Sprite;
private static const REVEAL_LINE_OFFSET:Number = -3;
private static const MASK_END_Y:Number = -9;
public static const REVEAL_DURATION:Number = 1;
private static const MASK_START_Y:Number = -36;
public static const REVEAL:String = "reveal";
private function updateRevealLine():void{
this.revealLine.y = ((this.maskSprite.y + this.maskSprite.height) + REVEAL_LINE_OFFSET);
}
public function hide():void{
this.maskSprite.y = MASK_START_Y;
this.updateRevealLine();
}
private function onRevealUpdate():void{
this.updateRevealLine();
}
override public function update(_arg1:Event):void{
var _local2:PlayerModel;
_local2 = (this.model as PlayerModel);
this.x = _local2.getX();
this.y = _local2.getY();
}
public function reveal(_arg1:Number=0):void{
if (_arg1 > 0){
TweenLite.to(this.maskSprite, _arg1, {y:MASK_END_Y, ease:Strong.easeIn, onUpdate:this.onRevealUpdate, onComplete:this.onRevealComplete});
} else {
this.maskSprite.y = MASK_END_Y;
};
}
private function onRevealComplete():void{
this.dispatchEvent(new Event(REVEAL));
}
}
}//package com.welcometoearth.game.player
Section 19
//Score (com.welcometoearth.game.score.Score)
package com.welcometoearth.game.score {
import flash.events.*;
import gs.*;
import flash.display.*;
import fl.transitions.easing.*;
import flash.net.*;
public class Score extends Sprite {
private var sharedObject:SharedObject;
public var stopwatch:Stopwatch;
private var highScore:int;
private var blinkCount:uint;
private var isNewHighScore:Boolean;
private var lastScore:int;
public var scoreText:ScoreText;
private static const BLINK_DELAY:Number = 0.2;
private static const SHARED_OBJECT_ID:String = "welcome_to_earth";
private static const HIGH_SCORE_ID:String = "high_score";
private static const REVEAL_DURATION:Number = 0.4;
private static const HIDE_DURATION:Number = 0.4;
private static const BLINK_COUNT:uint = 4;
private static const BLINK_DURATION:Number = 0.2;
private static const MIN_DISK_SPACE:uint = 10000;
public function Score(){
this.alpha = 0;
this.highScore = 0;
this.sharedObject = SharedObject.getLocal(SHARED_OBJECT_ID);
if (this.sharedObject.data[HIGH_SCORE_ID] != null){
this.highScore = this.sharedObject.data[HIGH_SCORE_ID];
};
}
private function storeHighScore(_arg1:int):void{
var highScore = _arg1;
this.sharedObject.data[HIGH_SCORE_ID] = highScore;
try {
this.sharedObject.flush(MIN_DISK_SPACE);
} catch(error:Error) {
trace(error.message);
};
}
public function hide():void{
this.blinkCount = 0;
this.blink();
}
private function updateHighScore(_arg1:int):void{
this.isNewHighScore = (this.lastScore > this.highScore);
this.highScore = Math.max(this.highScore, _arg1);
this.storeHighScore(this.highScore);
}
private function blink():void{
TweenLite.to(this.scoreText, BLINK_DURATION, {tint:0xFF0000, ease:None.easeNone, onComplete:this.onBlinkUpComplete, delay:BLINK_DELAY});
}
public function setFrameIndex(_arg1:int):void{
this.lastScore = _arg1;
this.updateHighScore(_arg1);
this.scoreText.textField.text = this.formatScore(_arg1);
this.stopwatch.setTime((_arg1 / this.stage.frameRate));
}
public function getHighScore():String{
return (this.formatScore(this.highScore));
}
private function onBlinkDownComplete():void{
this.blinkCount++;
if (this.blinkCount < BLINK_COUNT){
this.blink();
} else {
TweenLite.to(this, HIDE_DURATION, {alpha:0, delay:BLINK_DELAY, onComplete:this.onHide});
};
}
public function getIsNewHighScore():Boolean{
return (this.isNewHighScore);
}
private function onBlinkUpComplete():void{
TweenLite.to(this.scoreText, BLINK_DURATION, {tint:null, ease:None.easeNone, onComplete:this.onBlinkDownComplete, delay:BLINK_DELAY});
}
private function formatSeconds(_arg1:Number):String{
var _local2:String;
_local2 = _arg1.toString();
if (_local2.indexOf(".") == -1){
_local2 = (_local2 + ".00");
};
if (_local2.indexOf(".") == 1){
_local2 = ("0" + _local2);
};
_local2 = _local2.substr(0, Math.min(5, _local2.length));
while (_local2.length < 5) {
_local2 = (_local2 + "0");
};
return (_local2);
}
private function onHide():void{
this.dispatchEvent(new Event(Event.COMPLETE));
}
public function reveal():void{
TweenLite.to(this, REVEAL_DURATION, {alpha:1});
}
private function formatScore(_arg1:int):String{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local2 = (_arg1 / this.stage.frameRate);
_local3 = Math.floor((_local2 / 60));
_local4 = (_local2 % 60);
return (((this.formatMinutes(_local3) + ":") + this.formatSeconds(_local4)));
}
private function formatMinutes(_arg1:Number):String{
var _local2:String;
_local2 = _arg1.toString();
if (_local2.length == 1){
_local2 = ("0" + _local2);
};
return (_local2);
}
public function getLastScore():String{
return (this.formatScore(this.lastScore));
}
}
}//package com.welcometoearth.game.score
Section 20
//ScoreText (com.welcometoearth.game.score.ScoreText)
package com.welcometoearth.game.score {
import flash.display.*;
import flash.text.*;
public class ScoreText extends Sprite {
public var textField:TextField;
}
}//package com.welcometoearth.game.score
Section 21
//Stopwatch (com.welcometoearth.game.score.Stopwatch)
package com.welcometoearth.game.score {
import flash.display.*;
public class Stopwatch extends Sprite {
public var hand:Sprite;
public function setTime(_arg1:Number):void{
this.hand.rotation = ((Math.floor((_arg1 % 60)) / 60) * 360);
}
}
}//package com.welcometoearth.game.score
Section 22
//Capsule (com.welcometoearth.game.shield.Capsule)
package com.welcometoearth.game.shield {
import flash.events.*;
import gs.*;
import flash.display.*;
import fl.transitions.easing.*;
public class Capsule extends Sprite {
private var bobbing:Boolean;
private var initialY:Number;
public var hitAreaSprite:Sprite;
public var lightning:MovieClip;
private var angle:Number;
public var lightningMask:Sprite;
private static const ANGLE_INCREMENT:Number = 0.125663706143592;
private static const INTERMEDIATE_SCALE:Number = 1.2;
private static const REVEAL_DURATION:Number = 0.5;
private static const INITIAL_SCALE:Number = 0.8;
private static const REMOVE_DURATION:Number = 0.5;
private static const INTERMEDIATE_ALPHA:Number = 0.5;
private static const MAX_BOB:Number = 3;
public function Capsule(){
this.angle = 0;
this.lightning.cacheAsBitmap = true;
this.lightningMask.cacheAsBitmap = true;
this.lightning.mask = this.lightningMask;
this.addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage);
this.alpha = 0;
this.scaleX = INITIAL_SCALE;
this.scaleY = INITIAL_SCALE;
}
private function onFirstRemoveComplete():void{
TweenLite.to(this, REMOVE_DURATION, {alpha:0, ease:Strong.easeOut, scaleX:INITIAL_SCALE, scaleY:INITIAL_SCALE, onComplete:this.onSecondRemoveComplete});
}
public function remove():void{
TweenLite.to(this, REMOVE_DURATION, {alpha:INTERMEDIATE_ALPHA, ease:Strong.easeIn, scaleX:INTERMEDIATE_SCALE, scaleY:INTERMEDIATE_SCALE, onComplete:this.onFirstRemoveComplete});
}
private function onAddedToStage(_arg1:Event):void{
this.initialY = this.y;
this.removeEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage);
this.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
this.addEventListener(Event.REMOVED_FROM_STAGE, this.onRemovedFromStage);
TweenLite.to(this, REVEAL_DURATION, {alpha:INTERMEDIATE_ALPHA, scaleX:INTERMEDIATE_SCALE, scaleY:INTERMEDIATE_SCALE, ease:Strong.easeIn, onComplete:this.onRevealComplete});
}
private function bob():void{
if (this.bobbing){
this.angle = (this.angle + ANGLE_INCREMENT);
this.angle = (this.angle % (Math.PI * 2));
this.y = (this.initialY + (Math.sin(this.angle) * MAX_BOB));
};
}
public function setBobbing(_arg1:Boolean):void{
this.bobbing = _arg1;
}
private function onEnterFrame(_arg1:Event):void{
this.bob();
}
private function onRevealComplete():void{
TweenLite.to(this, REVEAL_DURATION, {alpha:1, scaleX:1, scaleY:1, ease:Strong.easeOut});
}
private function onSecondRemoveComplete():void{
if (this.parent != null){
this.parent.removeChild(this);
};
}
private function onRemovedFromStage(_arg1:Event):void{
this.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
this.removeEventListener(Event.REMOVED_FROM_STAGE, this.onRemovedFromStage);
}
}
}//package com.welcometoearth.game.shield
Section 23
//Shield (com.welcometoearth.game.shield.Shield)
package com.welcometoearth.game.shield {
import gs.*;
import flash.display.*;
public class Shield extends MovieClip {
private var previousWidth:Number;
protected var tweenDuration:Number;
protected var maxRadius:Number;
private var speed:Number;
private static const MIN_ALPHA:Number = 0;
private static const TWEEN_DURATION:Number = 2;
private static const MAX_RADIUS:Number = 400;
public function Shield(_arg1:Number, _arg2:Number){
this.x = _arg1;
this.y = _arg2;
this.tweenDuration = TWEEN_DURATION;
this.maxRadius = MAX_RADIUS;
this.initialize();
}
private function onTweenComplete():void{
this.remove();
}
public function remove():void{
TweenLite.killTweensOf(this);
if (this.parent != null){
this.parent.removeChild(this);
};
}
protected function initialize():void{
this.width = 0;
this.height = 0;
this.speed = 0;
this.previousWidth = 0;
this.blendMode = BlendMode.SCREEN;
TweenLite.to(this, this.tweenDuration, {width:this.maxRadius, height:this.maxRadius, alpha:MIN_ALPHA, onUpdate:this.onTweenUpdate, onComplete:this.onTweenComplete});
}
public function getSpeed():Number{
return (this.speed);
}
private function onTweenUpdate():void{
this.speed = (this.width - this.previousWidth);
this.previousWidth = this.width;
}
}
}//package com.welcometoearth.game.shield
Section 24
//ShieldContainer (com.welcometoearth.game.shield.ShieldContainer)
package com.welcometoearth.game.shield {
import flash.events.*;
import com.welcometoearth.game.player.*;
import flash.display.*;
import flash.utils.*;
import com.welcometoearth.*;
public class ShieldContainer extends Sprite {
private var capsule:Capsule;
private var shield:Shield;
private var capsuleTimeoutId:uint;
private static const MAX_CAPSULE_SPAWN_RADIUS:Number = 180;
private static const MIN_CAPSULE_SPAWN_RADIUS:Number = 100;
private static const CAPSULE_SPAWN_INTERVAL:Number = 8000;
public function spawnCapsule():void{
var _local1:Number;
var _local2:Number;
if (this.capsule == null){
this.capsule = new Capsule();
_local1 = ((Math.PI * 2) * Math.random());
_local2 = (MIN_CAPSULE_SPAWN_RADIUS + (Math.random() * (MAX_CAPSULE_SPAWN_RADIUS - MIN_CAPSULE_SPAWN_RADIUS)));
this.capsule.x = ((Main.STAGE_WIDTH / 2) + (_local2 * Math.cos(_local1)));
this.capsule.y = ((Main.STAGE_HEIGHT / 2) + (_local2 * Math.sin(_local1)));
this.capsule.addEventListener(Event.REMOVED_FROM_STAGE, this.onCapsuleRemovedFromStage);
this.capsule.setBobbing(true);
this.addChild(this.capsule);
};
}
private function onShieldRemovedFromStage(_arg1:Event):void{
var _local2:Shield;
_local2 = (_arg1.target as Shield);
_local2.removeEventListener(Event.REMOVED_FROM_STAGE, this.onShieldRemovedFromStage);
this.shield = null;
}
private function onCapsuleRemovedFromStage(_arg1:Event):void{
var _local2:Capsule;
_local2 = (_arg1.target as Capsule);
_local2.removeEventListener(Event.REMOVED_FROM_STAGE, this.onCapsuleRemovedFromStage);
this.capsule = null;
}
public function reset():void{
if (this.capsule != null){
this.capsule.remove();
};
}
public function setShield(_arg1:Shield):void{
if (this.shield == null){
this.shield = _arg1;
this.shield.addEventListener(Event.REMOVED_FROM_STAGE, this.onShieldRemovedFromStage);
this.addChild(_arg1);
};
}
private function startCapsuleSpawnTimer():void{
this.stopCapsuleSpawnTimer();
this.capsuleTimeoutId = setTimeout(this.spawnCapsule, CAPSULE_SPAWN_INTERVAL);
}
public function checkCapsuleCollision(_arg1:PlayerView):Shield{
if (this.capsule != null){
if (_arg1.hitTestObject(this.capsule.hitAreaSprite)){
this.setShield(new Shield(this.capsule.x, this.capsule.y));
this.removeChild(this.capsule);
this.startCapsuleSpawnTimer();
};
};
return (this.shield);
}
public function stopCapsuleSpawnTimer():void{
clearTimeout(this.capsuleTimeoutId);
}
}
}//package com.welcometoearth.game.shield
Section 25
//KeyboardListener (com.welcometoearth.game.ui.KeyboardListener)
package com.welcometoearth.game.ui {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class KeyboardListener extends EventDispatcher {
private var enabled:Boolean;
private var keysDown:Dictionary;
public function KeyboardListener(_arg1:Stage, _arg2:Array){
var _local3:uint;
super();
this.enabled = true;
this.keysDown = new Dictionary();
_local3 = 0;
while (_local3 < _arg2.length) {
this.keysDown[_arg2[_local3]] = false;
_local3++;
};
_arg1.addEventListener(KeyboardEvent.KEY_DOWN, this.onKeyDown);
_arg1.addEventListener(KeyboardEvent.KEY_UP, this.onKeyUp);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
this.setKeyDown(_arg1.keyCode, true);
}
public function getKeyDown(_arg1:uint):Boolean{
return (((this.keysDown[_arg1]) && (this.enabled)));
}
private function setKeyDown(_arg1:uint, _arg2:Boolean):void{
if (((!((this.keysDown[_arg1] == null))) && (!((this.keysDown[_arg1] == _arg2))))){
this.keysDown[_arg1] = _arg2;
this.dispatchEvent(new Event(Event.CHANGE));
};
}
private function onKeyUp(_arg1:KeyboardEvent):void{
this.setKeyDown(_arg1.keyCode, false);
}
public function setEnabled(_arg1:Boolean):void{
this.enabled = _arg1;
}
}
}//package com.welcometoearth.game.ui
Section 26
//Game (com.welcometoearth.game.Game)
package com.welcometoearth.game {
import flash.events.*;
import com.welcometoearth.game.player.*;
import com.welcometoearth.game.ui.*;
import flash.display.*;
import com.welcometoearth.game.missile.*;
import com.welcometoearth.game.shield.*;
import com.welcometoearth.game.explosion.*;
import flash.utils.*;
import com.welcometoearth.*;
import com.welcometoearth.game.score.*;
import flash.ui.*;
public class Game extends Sprite {
public var explosionContainer:ExplosionContainer;
private var highScore:Number;
public var missileContainer:MissileContainer;
public var playerView:PlayerView;
public var shieldContainer:ShieldContainer;
private var startTime:int;
private var frameIndex:int;
public var score:Score;
private var keyboardListener:KeyboardListener;
private var player:Player;
private var gameOver:Boolean;
public function Game(){
this.highScore = 0;
this.gameOver = true;
this.keyboardListener = new KeyboardListener(this.stage, [Keyboard.UP, Keyboard.DOWN, Keyboard.LEFT, Keyboard.RIGHT]);
this.keyboardListener.setEnabled(false);
this.missileContainer.createMissileViews();
this.missileContainer.setGame(this);
this.addEventListener(Event.REMOVED_FROM_STAGE, this.onRemovedFromStage);
}
private function onRemovedFromStage(_arg1:Event):void{
this.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
this.removeEventListener(Event.REMOVED_FROM_STAGE, this.onRemovedFromStage);
}
public function start():void{
this.missileContainer.reset();
this.playerView.addEventListener(PlayerView.REVEAL, this.onPlayerViewReveal);
this.playerView.reveal(PlayerView.REVEAL_DURATION);
}
public function getGameOver():Boolean{
return (this.gameOver);
}
public function setGameOver(_arg1:Boolean):void{
var _local2:Number;
var _local3:Shockwave;
if (_arg1){
_local2 = ((getTimer() - this.startTime) / 1000);
if (_local2 > this.highScore){
this.highScore = _local2;
};
this.explosionContainer.createExplosion(this.player.getModel().getX(), this.player.getModel().getY());
this.playerView.hide();
_local3 = new Shockwave(this.playerView.x, this.playerView.y);
this.missileContainer.setShield(_local3);
this.shieldContainer.setShield(_local3);
this.shieldContainer.stopCapsuleSpawnTimer();
this.score.addEventListener(Event.COMPLETE, this.onScoreHide);
this.score.hide();
};
this.gameOver = _arg1;
this.reset();
}
private function reset():void{
this.player.getModel().setX((Main.STAGE_WIDTH / 2));
this.player.getModel().setY((Main.STAGE_HEIGHT / 2));
this.player.getModel().setXSpeed(0);
this.player.getModel().setYSpeed(0);
this.shieldContainer.reset();
this.keyboardListener.setEnabled(false);
}
private function initialize():void{
this.gameOver = false;
this.frameIndex = 0;
this.startTime = getTimer();
this.player = new Player(this.playerView, this.keyboardListener);
this.shieldContainer.spawnCapsule();
this.keyboardListener.setEnabled(true);
this.score.reveal();
this.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
}
private function onPlayerViewReveal(_arg1:Event):void{
this.playerView.removeEventListener(PlayerView.REVEAL, this.onPlayerViewReveal);
this.initialize();
}
private function onEnterFrame(_arg1:Event):void{
var _local2:Shield;
_local2 = this.shieldContainer.checkCapsuleCollision(this.playerView);
this.missileContainer.setShield(_local2);
this.missileContainer.createMissile(this.frameIndex);
this.missileContainer.checkCollisions();
this.player.step(_arg1);
this.frameIndex++;
if (!this.gameOver){
this.score.setFrameIndex(this.frameIndex);
};
}
private function onScoreHide(_arg1:Event):void{
this.dispatchEvent(new Event(Event.COMPLETE));
}
public function getPlayer():Player{
return (this.player);
}
}
}//package com.welcometoearth.game
Section 27
//ControlsMessage (com.welcometoearth.ui.messages.ControlsMessage)
package com.welcometoearth.ui.messages {
import com.welcometoearth.game.player.*;
public class ControlsMessage extends Message {
public var playerView:PlayerView;
public function ControlsMessage(){
this.playerView.reveal();
}
}
}//package com.welcometoearth.ui.messages
Section 28
//HighScoreMessage (com.welcometoearth.ui.messages.HighScoreMessage)
package com.welcometoearth.ui.messages {
import com.welcometoearth.game.score.*;
public class HighScoreMessage extends Message {
public var scoreText:ScoreText;
public function setHighScore(_arg1:String):void{
this.scoreText.textField.text = _arg1;
}
}
}//package com.welcometoearth.ui.messages
Section 29
//HighScoreMessageList (com.welcometoearth.ui.messages.HighScoreMessageList)
package com.welcometoearth.ui.messages {
public class HighScoreMessageList extends MessageList {
public var newHighScore:Message;
public var highScoreMessage:HighScoreMessage;
public function HighScoreMessageList(){
this.setMessages([this.highScoreMessage]);
}
public function setInitialHighScore(_arg1:String):void{
this.highScoreMessage.setHighScore(_arg1);
}
public function setHighScore(_arg1:String, _arg2:Boolean=false):void{
this.highScoreMessage.setHighScore(_arg1);
this.hideAllMessages();
if (_arg2){
this.setMessages([this.newHighScore, this.highScoreMessage]);
} else {
this.setMessages([this.highScoreMessage]);
};
}
}
}//package com.welcometoearth.ui.messages
Section 30
//InstructionsMessageList (com.welcometoearth.ui.messages.InstructionsMessageList)
package com.welcometoearth.ui.messages {
public class InstructionsMessageList extends MessageList {
public var shields:Message;
public var controls:ControlsMessage;
public var dodge:Message;
public function InstructionsMessageList(){
this.setMessages([this.controls, this.dodge, this.shields]);
}
}
}//package com.welcometoearth.ui.messages
Section 31
//Message (com.welcometoearth.ui.messages.Message)
package com.welcometoearth.ui.messages {
import flash.display.*;
public class Message extends Sprite {
public function Message(){
this.visible = false;
}
}
}//package com.welcometoearth.ui.messages
Section 32
//MessageList (com.welcometoearth.ui.messages.MessageList)
package com.welcometoearth.ui.messages {
import flash.display.*;
public class MessageList extends Sprite {
private var messageIndex:uint;
private var messages:Array;
public function MessageList(){
this.visible = false;
this.messages = new Array();
}
public function showNextMessage():void{
if (this.messages.length > 0){
this.messages[this.messageIndex].visible = false;
this.messageIndex++;
if (this.messageIndex > (this.messages.length - 1)){
this.messageIndex = 0;
};
this.messages[this.messageIndex].visible = true;
};
}
protected function hideAllMessages():void{
var _local1:uint;
_local1 = 0;
while (_local1 < this.messages.length) {
this.messages[_local1].visible = false;
_local1++;
};
}
protected function setMessages(_arg1:Array):void{
this.messages = _arg1;
this.messageIndex = (this.messages.length - 1);
}
}
}//package com.welcometoearth.ui.messages
Section 33
//Messages (com.welcometoearth.ui.messages.Messages)
package com.welcometoearth.ui.messages {
import gs.*;
import flash.display.*;
import flash.utils.*;
public class Messages extends Sprite {
public var highScoreMessageList:HighScoreMessageList;
private var timeoutId:uint;
public var instructionsMessageList:InstructionsMessageList;
public var startMessageList:StartMessageList;
private var messageListIndex:uint;
private var messageLists:Array;
private static const HIDE_DURATION:Number = 0.4;
private static const REVEAL_DURATION:Number = 1;
private static const HIGH_SCORE_INDEX:uint = 0;
private static const MESSAGE_DISPLAY_DURATION:int = 3000;
public function Messages(){
this.alpha = 0;
this.messageLists = [this.startMessageList, this.highScoreMessageList, this.instructionsMessageList];
this.messageListIndex = (this.messageLists.length - 1);
}
public function hide(_arg1:Boolean=true, _arg2:Number=0.4):void{
clearTimeout(this.timeoutId);
if (_arg1){
TweenLite.to(this, _arg2, {alpha:0});
} else {
TweenLite.to(this, _arg2, {alpha:0, onComplete:this.onHidden});
};
}
private function showNextMessage():void{
this.hide(false);
}
private function onHidden():void{
this.reveal();
}
public function setInitialHighScore(_arg1:String):void{
this.highScoreMessageList.setInitialHighScore(_arg1);
}
public function reveal():void{
if (this.alpha == 0){
this.messageLists[this.messageListIndex].visible = false;
this.messageListIndex++;
if (this.messageListIndex > (this.messageLists.length - 1)){
this.messageListIndex = 0;
};
this.messageLists[this.messageListIndex].showNextMessage();
this.messageLists[this.messageListIndex].visible = true;
};
TweenLite.to(this, REVEAL_DURATION, {alpha:1});
this.timeoutId = setTimeout(this.showNextMessage, MESSAGE_DISPLAY_DURATION);
}
public function setHighScore(_arg1:String, _arg2:Boolean=false):void{
this.messageLists[this.messageListIndex].visible = false;
this.messageListIndex = HIGH_SCORE_INDEX;
this.highScoreMessageList.setHighScore(_arg1, _arg2);
}
}
}//package com.welcometoearth.ui.messages
Section 34
//StartMessageList (com.welcometoearth.ui.messages.StartMessageList)
package com.welcometoearth.ui.messages {
public class StartMessageList extends MessageList {
public var start:Message;
public function StartMessageList(){
this.setMessages([this.start]);
}
}
}//package com.welcometoearth.ui.messages
Section 35
//FinalScore (com.welcometoearth.ui.FinalScore)
package com.welcometoearth.ui {
import flash.display.*;
public class FinalScore extends Sprite {
public var finalScoreDisplayOutline:FinalScoreDisplay;
public var finalScoreDisplay:FinalScoreDisplay;
public function FinalScore(){
this.visible = false;
}
public function setLastScore(_arg1:String):void{
this.finalScoreDisplay.textField.text = _arg1;
this.finalScoreDisplayOutline.textField.text = _arg1;
}
}
}//package com.welcometoearth.ui
Section 36
//FinalScoreDisplay (com.welcometoearth.ui.FinalScoreDisplay)
package com.welcometoearth.ui {
import flash.display.*;
import flash.text.*;
public class FinalScoreDisplay extends Sprite {
public var textField:TextField;
}
}//package com.welcometoearth.ui
Section 37
//LargeMessage (com.welcometoearth.ui.LargeMessage)
package com.welcometoearth.ui {
import flash.events.*;
import gs.*;
import flash.display.*;
import fl.transitions.easing.*;
import flash.utils.*;
public class LargeMessage extends Sprite {
private var timeoutId:uint;
public var logo:Sprite;
public var finalScore:FinalScore;
public static const HIDE_DURATION:Number = 1;
public static const REVEAL_DURATION:Number = 1;
public static const HIDDEN:String = "logoHidden";
public static const REVEALED:String = "logoRevealed";
private static const REVERT_DELAY:uint = 5000;
public function LargeMessage(){
this.alpha = 0;
}
private function onRevealed():void{
this.dispatchEvent(new Event(REVEALED));
if (this.finalScore.visible){
this.timeoutId = setTimeout(this.revertToLogo, REVERT_DELAY);
};
}
public function hide():void{
clearTimeout(this.timeoutId);
TweenLite.to(this, HIDE_DURATION, {alpha:0, ease:None.easeNone, onComplete:this.onHidden});
}
private function onHidden():void{
this.dispatchEvent(new Event(HIDDEN));
}
public function setLastScore(_arg1:String):void{
this.finalScore.visible = true;
this.logo.visible = false;
this.finalScore.setLastScore(_arg1);
}
private function onFinalScoreHidden():void{
this.finalScore.visible = false;
this.logo.visible = true;
this.reveal();
}
private function revertToLogo():void{
TweenLite.to(this, HIDE_DURATION, {alpha:0, ease:None.easeNone, onComplete:this.onFinalScoreHidden});
}
public function reveal():void{
clearTimeout(this.timeoutId);
TweenLite.to(this, REVEAL_DURATION, {alpha:1, ease:None.easeNone, onComplete:this.onRevealed});
}
}
}//package com.welcometoearth.ui
Section 38
//Main (com.welcometoearth.Main)
package com.welcometoearth {
import flash.events.*;
import flash.display.*;
import com.welcometoearth.game.*;
import com.welcometoearth.ui.messages.*;
import com.welcometoearth.ui.*;
import com.welcometoearth.game.score.*;
public class Main extends Sprite {
public var messages:Messages;
public var largeMessage:LargeMessage;
public var score:Score;
public var game:Game;
public static const STAGE_HEIGHT:Number = 560;
public static const STAGE_WIDTH:Number = 706;
public function Main(){
this.stage.scaleMode = StageScaleMode.NO_SCALE;
this.game.score = this.score;
this.messages.setInitialHighScore(this.score.getHighScore());
this.initialize();
}
private function startGame():void{
this.messages.hide(true, LargeMessage.HIDE_DURATION);
this.largeMessage.addEventListener(LargeMessage.HIDDEN, this.onLogoHidden);
this.largeMessage.hide();
}
private function onLogoRevealed(_arg1:Event):void{
this.largeMessage.removeEventListener(LargeMessage.REVEALED, this.onLogoRevealed);
this.messages.reveal();
}
private function onLogoHidden(_arg1:Event):void{
this.largeMessage.removeEventListener(LargeMessage.HIDDEN, this.onLogoHidden);
this.game.addEventListener(Event.COMPLETE, this.onGameComplete);
this.game.start();
}
private function initialize():void{
this.stage.addEventListener(KeyboardEvent.KEY_DOWN, this.onStartKeyDown);
this.largeMessage.addEventListener(LargeMessage.REVEALED, this.onLogoRevealed);
this.largeMessage.reveal();
}
private function onStartKeyDown(_arg1:KeyboardEvent):void{
this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, this.onStartKeyDown);
this.startGame();
}
private function onGameComplete(_arg1:Event):void{
this.largeMessage.setLastScore(this.score.getLastScore());
this.messages.setHighScore(this.score.getHighScore(), this.score.getIsNewHighScore());
this.initialize();
}
}
}//package com.welcometoearth
Section 39
//None (fl.transitions.easing.None)
package fl.transitions.easing {
public class None {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeNone(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
}
}//package fl.transitions.easing
Section 40
//Strong (fl.transitions.easing.Strong)
package fl.transitions.easing {
public class Strong {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = ((_arg1 / _arg4) - 1);
return (((_arg3 * (((((_arg1 * _arg1) * _arg1) * _arg1) * _arg1) + 1)) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return (((((((_arg3 * _arg1) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((((((_arg3 / 2) * _arg1) * _arg1) * _arg1) * _arg1) * _arg1) + _arg2));
};
_arg1 = (_arg1 - 2);
return ((((_arg3 / 2) * (((((_arg1 * _arg1) * _arg1) * _arg1) * _arg1) + 2)) + _arg2));
}
}
}//package fl.transitions.easing
Section 41
//TweenLite (gs.TweenLite)
package gs {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.media.*;
public class TweenLite {
public var delay:Number;
protected var _initted:Boolean;
protected var _subTweens:Array;
public var startTime:int;
public var target:Object;
public var duration:Number;
protected var _hst:Boolean;
protected var _active:Boolean;
public var vars:Object;
public var tweens:Array;
public var initTime:int;
private static var _timer:Timer = new Timer(2000);
private static var _classInitted:Boolean;
public static var defaultEase:Function = TweenLite.easeOut;
public static var version:Number = 6.22;
private static var _sprite:Sprite = new Sprite();
protected static var _all:Dictionary = new Dictionary();
public static var killDelayedCallsTo:Function = killTweensOf;
protected static var _curTime:uint;
private static var _listening:Boolean;
public function TweenLite(_arg1:Object, _arg2:Number, _arg3:Object){
if (_arg1 == null){
return;
};
if (((((!((_arg3.overwrite == false))) && (!((_arg1 == null))))) || ((_all[_arg1] == undefined)))){
delete _all[_arg1];
_all[_arg1] = new Dictionary();
};
_all[_arg1][this] = this;
this.vars = _arg3;
this.duration = ((_arg2) || (0.001));
this.delay = ((_arg3.delay) || (0));
this.target = _arg1;
if (!(this.vars.ease is Function)){
this.vars.ease = defaultEase;
};
if (this.vars.easeParams != null){
this.vars.proxiedEase = this.vars.ease;
this.vars.ease = easeProxy;
};
if (!isNaN(Number(this.vars.autoAlpha))){
this.vars.alpha = Number(this.vars.autoAlpha);
};
this.tweens = [];
_subTweens = [];
_hst = (_initted = false);
_active = (((_arg2 == 0)) && ((this.delay == 0)));
if (!_classInitted){
_curTime = getTimer();
_sprite.addEventListener(Event.ENTER_FRAME, executeAll);
_classInitted = true;
};
this.initTime = _curTime;
if ((((((this.vars.runBackwards == true)) && (!((this.vars.renderOnStart == true))))) || (_active))){
initTweenVals();
this.startTime = _curTime;
if (_active){
render((this.startTime + 1));
} else {
render(this.startTime);
};
};
if (((!(_listening)) && (!(_active)))){
_timer.addEventListener("timer", killGarbage);
_timer.start();
_listening = true;
};
}
protected function addSubTween(_arg1:Function, _arg2:Object, _arg3:Object, _arg4:Object=null):void{
var _local5:Object;
var _local6:String;
_local5 = {proxy:_arg1, target:_arg2, info:_arg4};
_subTweens.push(_local5);
for (_local6 in _arg3) {
if (_arg2.hasOwnProperty(_local6)){
if (typeof(_arg3[_local6]) == "number"){
this.tweens.push({o:_arg2, p:_local6, s:_arg2[_local6], c:(_arg3[_local6] - _arg2[_local6]), sub:_local5});
} else {
this.tweens.push({o:_arg2, p:_local6, s:_arg2[_local6], c:Number(_arg3[_local6]), sub:_local5});
};
};
};
_hst = true;
}
public function initTweenVals(_arg1:Boolean=false, _arg2:String=""):void{
var _local3:Boolean;
var _local4:String;
var _local5:int;
var _local6:Array;
var _local7:ColorTransform;
var _local8:ColorTransform;
var _local9:Object;
_local3 = (this.target is DisplayObject);
if ((this.target is Array)){
_local6 = ((this.vars.endArray) || ([]));
_local5 = 0;
while (_local5 < _local6.length) {
if (((!((this.target[_local5] == _local6[_local5]))) && (!((this.target[_local5] == undefined))))){
this.tweens.push({o:this.target, p:_local5.toString(), s:this.target[_local5], c:(_local6[_local5] - this.target[_local5])});
};
_local5++;
};
} else {
for (_local4 in this.vars) {
if ((((((((((((((((((((((((((((((((((((_local4 == "ease")) || ((_local4 == "delay")))) || ((_local4 == "overwrite")))) || ((_local4 == "onComplete")))) || ((_local4 == "onCompleteParams")))) || ((_local4 == "onCompleteScope")))) || ((_local4 == "runBackwards")))) || ((_local4 == "onUpdate")))) || ((_local4 == "onUpdateParams")))) || ((_local4 == "onUpdateScope")))) || ((_local4 == "autoAlpha")))) || ((_local4 == "onStart")))) || ((_local4 == "onStartParams")))) || ((_local4 == "onStartScope")))) || ((_local4 == "renderOnStart")))) || ((_local4 == "proxiedEase")))) || ((_local4 == "easeParams")))) || (((_arg1) && (!((_arg2.indexOf(((" " + _local4) + " ")) == -1))))))){
} else {
if ((((_local4 == "tint")) && (_local3))){
_local7 = this.target.transform.colorTransform;
_local8 = new ColorTransform();
if (this.vars.alpha != undefined){
_local8.alphaMultiplier = this.vars.alpha;
delete this.vars.alpha;
_local5 = (this.tweens.length - 1);
while (_local5 > -1) {
if (this.tweens[_local5].p == "alpha"){
this.tweens.splice(_local5, 1);
break;
};
_local5--;
};
} else {
_local8.alphaMultiplier = this.target.alpha;
};
if (((((!((this.vars[_local4] == null))) && (!((this.vars[_local4] == ""))))) || ((this.vars[_local4] == 0)))){
_local8.color = this.vars[_local4];
};
addSubTween(tintProxy, {progress:0}, {progress:1}, {target:this.target, color:_local7, endColor:_local8});
} else {
if ((((_local4 == "frame")) && (_local3))){
addSubTween(frameProxy, {frame:this.target.currentFrame}, {frame:this.vars[_local4]}, {target:this.target});
} else {
if ((((_local4 == "volume")) && (((_local3) || ((this.target is SoundChannel)))))){
addSubTween(volumeProxy, this.target.soundTransform, {volume:this.vars[_local4]}, {target:this.target});
} else {
if (typeof(this.vars[_local4]) == "number"){
this.tweens.push({o:this.target, p:_local4, s:this.target[_local4], c:(this.vars[_local4] - this.target[_local4])});
} else {
this.tweens.push({o:this.target, p:_local4, s:this.target[_local4], c:Number(this.vars[_local4])});
};
};
};
};
};
};
};
if (this.vars.runBackwards == true){
_local5 = (this.tweens.length - 1);
while (_local5 > -1) {
_local9 = this.tweens[_local5];
this.tweens[_local5].s = (_local9.s + _local9.c);
_local9.c = (_local9.c * -1);
_local5--;
};
};
if (typeof(this.vars.autoAlpha) == "number"){
this.target.visible = !((((this.vars.runBackwards == true)) && ((this.target.alpha == 0))));
};
_initted = true;
}
public function get active():Boolean{
if (_active){
return (true);
};
if (((_curTime - this.initTime) / 1000) > this.delay){
_active = true;
this.startTime = (this.initTime + (this.delay * 1000));
if (!_initted){
initTweenVals();
} else {
if (typeof(this.vars.autoAlpha) == "number"){
this.target.visible = true;
};
};
if (this.vars.onStart != null){
this.vars.onStart.apply(this.vars.onStartScope, this.vars.onStartParams);
};
if (this.duration == 0.001){
this.startTime = (this.startTime - 1);
};
return (true);
//unresolved jump
};
return (false);
}
public function render(_arg1:uint):void{
var _local2:Number;
var _local3:Number;
var _local4:Object;
var _local5:int;
_local2 = ((_arg1 - this.startTime) / 1000);
if (_local2 > this.duration){
_local2 = this.duration;
};
_local3 = this.vars.ease(_local2, 0, 1, this.duration);
_local5 = (this.tweens.length - 1);
while (_local5 > -1) {
_local4 = this.tweens[_local5];
_local4.o[_local4.p] = (_local4.s + (_local3 * _local4.c));
_local5--;
};
if (_hst){
_local5 = (_subTweens.length - 1);
while (_local5 > -1) {
_subTweens[_local5].proxy(_subTweens[_local5]);
_local5--;
};
};
if (this.vars.onUpdate != null){
this.vars.onUpdate.apply(this.vars.onUpdateScope, this.vars.onUpdateParams);
};
if (_local2 == this.duration){
complete(true);
};
}
protected function easeProxy(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return (this.vars.proxiedEase.apply(null, arguments.concat(this.vars.easeParams)));
}
public function complete(_arg1:Boolean=false):void{
if (!_arg1){
if (!_initted){
initTweenVals();
};
this.startTime = (_curTime - (this.duration * 1000));
render(_curTime);
return;
};
if ((((typeof(this.vars.autoAlpha) == "number")) && ((this.target.alpha == 0)))){
this.target.visible = false;
};
if (this.vars.onComplete != null){
this.vars.onComplete.apply(this.vars.onCompleteScope, this.vars.onCompleteParams);
};
removeTween(this);
}
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((-(_arg3) * _arg1) * (_arg1 - 2)) + _arg2));
}
public static function frameProxy(_arg1:Object):void{
_arg1.info.target.gotoAndStop(Math.round(_arg1.target.frame));
}
public static function removeTween(_arg1:TweenLite=null):void{
if (((!((_arg1 == null))) && (!((_all[_arg1.target] == undefined))))){
delete _all[_arg1.target][_arg1];
};
}
public static function killTweensOf(_arg1:Object=null, _arg2:Boolean=false):void{
var _local3:Object;
var _local4:*;
if (((!((_arg1 == null))) && (!((_all[_arg1] == undefined))))){
if (_arg2){
_local3 = _all[_arg1];
for (_local4 in _local3) {
_local3[_local4].complete(false);
};
};
delete _all[_arg1];
};
}
public static function delayedCall(_arg1:Number, _arg2:Function, _arg3:Array=null, _arg4=null):TweenLite{
return (new TweenLite(_arg2, 0, {delay:_arg1, onComplete:_arg2, onCompleteParams:_arg3, onCompleteScope:_arg4, overwrite:false}));
}
public static function from(_arg1:Object, _arg2:Number, _arg3:Object):TweenLite{
_arg3.runBackwards = true;
return (new TweenLite(_arg1, _arg2, _arg3));
}
public static function executeAll(_arg1:Event=null):void{
var _local2:uint;
var _local3:Dictionary;
var _local4:Object;
var _local5:Object;
_local2 = (_curTime = getTimer());
if (_listening){
_local3 = _all;
for each (_local4 in _local3) {
for (_local5 in _local4) {
if (((!((_local4[_local5] == undefined))) && (_local4[_local5].active))){
_local4[_local5].render(_local2);
};
};
};
};
}
public static function volumeProxy(_arg1:Object):void{
_arg1.info.target.soundTransform = _arg1.target;
}
public static function killGarbage(_arg1:TimerEvent):void{
var _local2:uint;
var _local3:Boolean;
var _local4:Object;
var _local5:Object;
var _local6:Object;
_local2 = 0;
for (_local4 in _all) {
_local3 = false;
for (_local5 in _all[_local4]) {
_local3 = true;
break;
};
if (!_local3){
delete _all[_local4];
} else {
_local2++;
};
};
if (_local2 == 0){
_timer.removeEventListener("timer", killGarbage);
_timer.stop();
_listening = false;
};
}
public static function tintProxy(_arg1:Object):void{
var _local2:Number;
var _local3:Number;
var _local4:Object;
var _local5:Object;
_local2 = _arg1.target.progress;
_local3 = (1 - _local2);
_local4 = _arg1.info.color;
_local5 = _arg1.info.endColor;
_arg1.info.target.transform.colorTransform = new ColorTransform(((_local4.redMultiplier * _local3) + (_local5.redMultiplier * _local2)), ((_local4.greenMultiplier * _local3) + (_local5.greenMultiplier * _local2)), ((_local4.blueMultiplier * _local3) + (_local5.blueMultiplier * _local2)), ((_local4.alphaMultiplier * _local3) + (_local5.alphaMultiplier * _local2)), ((_local4.redOffset * _local3) + (_local5.redOffset * _local2)), ((_local4.greenOffset * _local3) + (_local5.greenOffset * _local2)), ((_local4.blueOffset * _local3) + (_local5.blueOffset * _local2)), ((_local4.alphaOffset * _local3) + (_local5.alphaOffset * _local2)));
}
public static function to(_arg1:Object, _arg2:Number, _arg3:Object):TweenLite{
return (new TweenLite(_arg1, _arg2, _arg3));
}
}
}//package gs
Section 42
//Dodge (Dodge)
package {
import com.welcometoearth.ui.messages.*;
public dynamic class Dodge extends Message {
}
}//package
Section 43
//NewHighScore (NewHighScore)
package {
import com.welcometoearth.ui.messages.*;
public dynamic class NewHighScore extends Message {
}
}//package
Section 44
//Shields (Shields)
package {
import com.welcometoearth.ui.messages.*;
public dynamic class Shields extends Message {
}
}//package
Section 45
//Start (Start)
package {
import com.welcometoearth.ui.messages.*;
public dynamic class Start extends Message {
}
}//package