Section 1
//flagWrap_33 (1DEV1_fla.flagWrap_33)
package 1DEV1_fla {
import flash.display.*;
public dynamic class flagWrap_33 extends MovieClip {
public function flagWrap_33(){
addFrameScript(5, frame6);
}
function frame6(){
stop();
}
}
}//package 1DEV1_fla
Section 2
//kleinesateliet_62 (1DEV1_fla.kleinesateliet_62)
package 1DEV1_fla {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class kleinesateliet_62 extends MovieClip {
public function kleinesateliet_62(){
addFrameScript(0, frame1);
}
function frame1(){
this.stop();
this.interactive = true;
}
}
}//package 1DEV1_fla
Section 3
//magnet_49 (1DEV1_fla.magnet_49)
package 1DEV1_fla {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class magnet_49 extends MovieClip {
public function magnet_49(){
addFrameScript(0, frame1);
}
function frame1(){
this.stop();
this.interactive = true;
}
}
}//package 1DEV1_fla
Section 4
//MainTimeline (1DEV1_fla.MainTimeline)
package 1DEV1_fla {
import flash.events.*;
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.utils.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class MainTimeline extends MovieClip {
public var bottomTween:Tween;
public var container:MovieClip;
public var conXTween:Tween;
public var deBot:botClip;
public var playBtn:SimpleButton;
public var borderTop:MovieClip;
public var leftHit:MovieClip;
public var containerHeight:uint;
public var conYTween:Tween;
public var topTween:Tween;
public var botYTween:Tween;
public var leftPressed:Boolean;
public var upPressed:Boolean;
public var downPressed:Boolean;
public var yPos:uint;
public var conXScaleTween:Tween;
public var bgClip:MovieClip;
public var conYScaleTween:Tween;
public var xPos:uint;
public var containerWidth:uint;
public var speed:uint;
public var interactiveClip:MovieClip;
public var rightHit:MovieClip;
public var rightPressed:Boolean;
public var bottomHit:MovieClip;
public var loadbar:MovieClip;
public var borderBottom:MovieClip;
public var botXTween:Tween;
public var topHit:MovieClip;
public var fgClouds:MovieClip;
public function MainTimeline(){
addFrameScript(0, frame1, 8, frame9, 9, frame10);
}
public function motionFinishHandler(_arg1:TweenEvent):void{
stage.removeEventListener(Event.ENTER_FRAME, rotateHandler);
container.removeChild(deBot);
interactiveClip.interactive = false;
interactiveClip.gotoAndPlay("interacting");
interactiveClip.addEventListener(Event.ENTER_FRAME, stopInteraction);
}
public function loadIt():void{
stop();
loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loaderInfo.addEventListener(Event.COMPLETE, completeHandler);
tweenHandler();
NewgroundsAPI.linkAPI(this);
NewgroundsAPI.connectMovie(4953);
}
public function bgMoveHandler(_arg1:Event):void{
}
public function stopInteraction(_arg1:Event):void{
if (interactiveClip.currentFrame == interactiveClip.totalFrames){
addBot(interactiveClip.x, interactiveClip.y);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(Event.ENTER_FRAME, keyboardMoveHandler);
interactiveClip.removeEventListener(Event.ENTER_FRAME, stopInteraction);
conXTween = new Tween(container, "x", null, container.x, (-(interactiveClip.x) + (stage.stageWidth / 2)), 0.5, true);
conYTween = new Tween(container, "y", null, container.y, (-(interactiveClip.y) + (stage.stageHeight / 2)), 0.5, true);
conXScaleTween = new Tween(container, "scaleX", null, container.scaleX, 1, 0.5, true);
conYScaleTween = new Tween(container, "scaleY", null, container.scaleY, 1, 0.5, true);
stage.addEventListener(Event.ENTER_FRAME, rotateHandler);
};
}
public function addBot(_arg1:uint, _arg2:uint):void{
deBot.x = _arg1;
deBot.y = _arg2;
deBot.rotation = 0;
container.addChild(deBot);
}
public function init():void{
stop();
addBot(100, 100);
stage.addEventListener(Event.ENTER_FRAME, bgMoveHandler);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
stage.addEventListener(Event.ENTER_FRAME, keyboardMoveHandler);
stage.addEventListener(Event.ENTER_FRAME, rotateHandler);
}
public function interact():void{
var _local1:uint;
while (_local1 < container.numChildren) {
interactiveClip = MovieClip(container.getChildAt(_local1));
if (((((!((deBot == interactiveClip))) && (deBot.hitTestObject(interactiveClip)))) && (interactiveClip.interactive))){
botXTween = new Tween(deBot, "x", null, deBot.x, interactiveClip.x, 0.5, true);
botYTween = new Tween(deBot, "y", null, deBot.y, interactiveClip.y, 0.5, true);
conXTween = new Tween(container, "x", null, container.x, ((interactiveClip.x * -2) + (stage.stageWidth / 2)), 0.5, true);
conYTween = new Tween(container, "y", null, container.y, ((interactiveClip.y * -2) + (stage.stageHeight / 2)), 0.5, true);
conXScaleTween = new Tween(container, "scaleX", null, container.scaleX, 2, 0.5, true);
conYScaleTween = new Tween(container, "scaleY", null, container.scaleY, 2, 0.5, true);
botXTween.addEventListener(TweenEvent.MOTION_FINISH, motionFinishHandler);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.removeEventListener(Event.ENTER_FRAME, keyboardMoveHandler);
break;
};
_local1++;
};
}
public function completeHandler(_arg1:Event):void{
gotoAndPlay(3);
}
function frame10(){
deBot = new botClip();
speed = 15;
leftPressed = false;
rightPressed = false;
upPressed = false;
downPressed = false;
containerHeight = container.height;
containerWidth = container.width;
xPos = deBot.x;
yPos = deBot.y;
init();
}
public function mouseMoveHandler(_arg1:MouseEvent):void{
deBot.x = container.mouseX;
deBot.y = container.mouseY;
}
public function keyUpHandler(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case 37:
leftPressed = false;
break;
case 38:
upPressed = false;
break;
case 39:
rightPressed = false;
break;
case 40:
downPressed = false;
break;
case 16:
speed = 15;
break;
};
}
public function keyboardMoveHandler(_arg1:Event):void{
if (leftPressed){
if (deBot.hitTestObject(leftHit)){
if (container.x <= 0){
container.x = (container.x + speed);
bgClip.x = (bgClip.x + (speed / 20));
fgClouds.x = (fgClouds.x + (speed / 4));
};
};
if (deBot.x >= 40){
deBot.x = (deBot.x - speed);
};
};
if (rightPressed){
if (deBot.x <= containerWidth){
if (deBot.hitTestObject(rightHit)){
container.x = (container.x - speed);
bgClip.x = (bgClip.x - (speed / 20));
fgClouds.x = (fgClouds.x - (speed / 4));
};
deBot.x = (deBot.x + speed);
};
};
if (upPressed){
if (deBot.hitTestObject(topHit)){
if (container.y <= 0){
container.y = (container.y + speed);
bgClip.y = (bgClip.y + (speed / 20));
fgClouds.y = (fgClouds.y + (speed / 8));
};
};
if (deBot.y >= 40){
deBot.y = (deBot.y - speed);
};
};
if (downPressed){
if (deBot.y <= containerHeight){
if (deBot.hitTestObject(bottomHit)){
container.y = (container.y - speed);
bgClip.y = (bgClip.y - (speed / 20));
fgClouds.y = (fgClouds.y - (speed / 8));
};
deBot.y = (deBot.y + speed);
};
};
}
public function progressHandler(_arg1:ProgressEvent):void{
loadbar.scaleX = (_arg1.bytesLoaded / _arg1.bytesTotal);
}
public function tweenHandler():void{
var _local1:uint = (stage.stageHeight / 2);
var _local2:uint = 10;
bottomTween = new Tween(borderBottom, "y", Regular.easeOut, _local1, (_local1 + _local2), 0.5, true);
topTween = new Tween(borderTop, "y", Regular.easeOut, _local1, (_local1 - _local2), 0.5, true);
}
function frame1(){
loadIt();
}
public function keyDownHandler(_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case 37:
leftPressed = true;
rightPressed = false;
break;
case 38:
upPressed = true;
downPressed = false;
break;
case 39:
rightPressed = true;
leftPressed = false;
break;
case 40:
downPressed = true;
upPressed = false;
break;
case 32:
interact();
break;
case 16:
speed = 40;
break;
};
}
function frame9(){
stop();
playBtn.addEventListener(MouseEvent.CLICK, playHandler);
}
public function rotateHandler(_arg1:Event):void{
if (((!((deBot.x == xPos))) || (!((deBot.y == yPos))))){
deBot.rotation = (((Math.atan2((deBot.y - yPos), (deBot.x - xPos)) / Math.PI) * 180) + 90);
} else {
deBot.rotation = 0;
};
xPos = deBot.x;
yPos = deBot.y;
}
public function playHandler(_arg1:MouseEvent):void{
play();
}
}
}//package 1DEV1_fla
Section 5
//NG_AD_OBJECT_1 (1DEV1_fla.NG_AD_OBJECT_1)
package 1DEV1_fla {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class NG_AD_OBJECT_1 extends MovieClip {
public var NG_Button:SimpleButton;
public var ng_ad:MovieClip;
public function NG_AD_OBJECT_1(){
addFrameScript(0, frame1);
}
public function ad_Loaded(_arg1:Event){
var _local2:* = String(_arg1.target.data);
var _local3:Loader = new Loader();
_local3.load(new URLRequest(_local2));
ng_ad.addChild(_local3);
}
function frame1(){
Security.allowDomain("70.87.128.99");
Security.allowInsecureDomain("70.87.128.99");
Security.allowDomain("ads.shizmoo.com");
Security.allowInsecureDomain("ads.shizmoo.com");
Security.allowDomain("www.cpmstar.com");
Security.allowInsecureDomain("www.cpmstar.com");
Security.allowDomain("server.cpmstar.com");
Security.allowInsecureDomain("server.cpmstar.com");
if (NewgroundsAPI.getAdURL()){
startAd(NewgroundsAPI.getAdURL());
};
NewgroundsAPI.addEventListener(NewgroundsAPI.ADS_APPROVED, startAd);
NG_Button.addEventListener(MouseEvent.CLICK, loadNGSite);
stop();
}
public function startAd(_arg1){
var _local2:URLLoader = new URLLoader(new URLRequest(_arg1));
_local2.addEventListener(Event.COMPLETE, ad_Loaded);
}
public function loadNGSite(_arg1:Event){
NewgroundsAPI.loadNewgrounds();
}
}
}//package 1DEV1_fla
Section 6
//NG_TANK_3 (1DEV1_fla.NG_TANK_3)
package 1DEV1_fla {
import flash.events.*;
import flash.display.*;
public dynamic class NG_TANK_3 extends MovieClip {
public var NG_Logo:SimpleButton;
public function NG_TANK_3(){
addFrameScript(0, frame1);
}
function frame1(){
NG_Logo.addEventListener(MouseEvent.CLICK, loadNGSite);
}
public function loadNGSite(_arg1:Event){
NewgroundsAPI.loadNewgrounds();
}
}
}//package 1DEV1_fla
Section 7
//sateliet_16 (1DEV1_fla.sateliet_16)
package 1DEV1_fla {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class sateliet_16 extends MovieClip {
public function sateliet_16(){
addFrameScript(0, frame1, 229, frame230);
}
function frame230(){
this.stop();
}
function frame1(){
stop();
this.interactive = true;
}
}
}//package 1DEV1_fla
Section 8
//sputnik_35 (1DEV1_fla.sputnik_35)
package 1DEV1_fla {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class sputnik_35 extends MovieClip {
public function sputnik_35(){
addFrameScript(0, frame1, 109, frame110);
}
function frame110(){
stop();
this.parent.removeChild(this);
}
function frame1(){
this.stop();
this.interactive = true;
}
}
}//package 1DEV1_fla
Section 9
//steentjesopelkaar_29 (1DEV1_fla.steentjesopelkaar_29)
package 1DEV1_fla {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class steentjesopelkaar_29 extends MovieClip {
public function steentjesopelkaar_29(){
addFrameScript(0, frame1, 54, frame55, 142, frame143);
}
function frame143(){
this.stop();
}
function frame1(){
this.interactive = true;
}
function frame55(){
this.gotoAndPlay(2);
}
}
}//package 1DEV1_fla
Section 10
//strandBal_59 (1DEV1_fla.strandBal_59)
package 1DEV1_fla {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class strandBal_59 extends MovieClip {
public function strandBal_59(){
addFrameScript(0, frame1, 258, frame259);
}
function frame259(){
this.stop();
this.parent.removeChild(this);
}
function frame1(){
this.stop();
this.interactive = true;
}
}
}//package 1DEV1_fla
Section 11
//Regular (fl.transitions.easing.Regular)
package fl.transitions.easing {
public class Regular {
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 easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((_arg3 * _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) + _arg2));
};
--_arg1;
return ((((-(_arg3) / 2) * ((_arg1 * (_arg1 - 2)) - 1)) + _arg2));
}
}
}//package fl.transitions.easing
Section 12
//Tween (fl.transitions.Tween)
package fl.transitions {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
public class Tween extends EventDispatcher {
private var _position:Number;// = NAN
public var prevTime:Number;// = NAN
public var prevPos:Number;// = NAN
public var isPlaying:Boolean;// = false
private var _fps:Number;// = NAN
private var _time:Number;// = NAN
public var begin:Number;// = NAN
private var _finish:Number;// = NAN
public var change:Number;// = NAN
public var looping:Boolean;// = false
private var _intervalID:uint;// = 0
public var func:Function;
private var _timer:Timer;// = null
private var _startTime:Number;// = NAN
public var prop:String;// = ""
private var _duration:Number;// = NAN
public var obj:Object;// = null
public var useSeconds:Boolean;// = false
protected static var _mc:MovieClip = new MovieClip();
public function Tween(_arg1:Object, _arg2:String, _arg3:Function, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Boolean=false){
this.func = function (_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
};
super();
if (!arguments.length){
return;
};
this.obj = _arg1;
this.prop = _arg2;
this.begin = _arg4;
this.position = _arg4;
this.duration = _arg6;
this.useSeconds = _arg7;
if ((_arg3 is Function)){
this.func = _arg3;
};
this.finish = _arg5;
this._timer = new Timer(100);
this.start();
}
public function continueTo(_arg1:Number, _arg2:Number):void{
this.begin = this.position;
this.finish = _arg1;
if (!isNaN(_arg2)){
this.duration = _arg2;
};
this.start();
}
protected function startEnterFrame():void{
var _local1:Number;
if (isNaN(this._fps)){
_mc.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, false, 0, true);
} else {
_local1 = (1000 / this._fps);
this._timer.delay = _local1;
this._timer.addEventListener(TimerEvent.TIMER, this.timerHandler, false, 0, true);
this._timer.start();
};
this.isPlaying = true;
}
public function stop():void{
this.stopEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_STOP, this._time, this._position));
}
private function fixTime():void{
if (this.useSeconds){
this._startTime = (getTimer() - (this._time * 1000));
};
}
public function set FPS(_arg1:Number):void{
var _local2:Boolean = this.isPlaying;
this.stopEnterFrame();
this._fps = _arg1;
if (_local2){
this.startEnterFrame();
};
}
public function get finish():Number{
return ((this.begin + this.change));
}
public function get duration():Number{
return (this._duration);
}
protected function stopEnterFrame():void{
if (isNaN(this._fps)){
_mc.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
} else {
this._timer.stop();
};
this.isPlaying = false;
}
public function set time(_arg1:Number):void{
this.prevTime = this._time;
if (_arg1 > this.duration){
if (this.looping){
this.rewind((_arg1 - this._duration));
this.update();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_LOOP, this._time, this._position));
} else {
if (this.useSeconds){
this._time = this._duration;
this.update();
};
this.stop();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_FINISH, this._time, this._position));
};
} else {
if (_arg1 < 0){
this.rewind();
this.update();
} else {
this._time = _arg1;
this.update();
};
};
}
public function getPosition(_arg1:Number=NaN):Number{
if (isNaN(_arg1)){
_arg1 = this._time;
};
return (this.func(_arg1, this.begin, this.change, this._duration));
}
public function set finish(_arg1:Number):void{
this.change = (_arg1 - this.begin);
}
public function set duration(_arg1:Number):void{
this._duration = ((_arg1)<=0) ? Infinity : _arg1;
}
public function get position():Number{
return (this.getPosition(this._time));
}
public function setPosition(_arg1:Number):void{
this.prevPos = this._position;
if (this.prop.length){
this.obj[this.prop] = (this._position = _arg1);
};
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_CHANGE, this._time, this._position));
}
public function resume():void{
this.fixTime();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_RESUME, this._time, this._position));
}
public function fforward():void{
this.time = this._duration;
this.fixTime();
}
protected function onEnterFrame(_arg1:Event):void{
this.nextFrame();
}
public function yoyo():void{
this.continueTo(this.begin, this.time);
}
public function nextFrame():void{
if (this.useSeconds){
this.time = ((getTimer() - this._startTime) / 1000);
} else {
this.time = (this._time + 1);
};
}
protected function timerHandler(_arg1:TimerEvent):void{
this.nextFrame();
_arg1.updateAfterEvent();
}
public function get FPS():Number{
return (this._fps);
}
public function rewind(_arg1:Number=0):void{
this._time = _arg1;
this.fixTime();
this.update();
}
public function set position(_arg1:Number):void{
this.setPosition(_arg1);
}
public function get time():Number{
return (this._time);
}
private function update():void{
this.setPosition(this.getPosition(this._time));
}
public function start():void{
this.rewind();
this.startEnterFrame();
this.dispatchEvent(new TweenEvent(TweenEvent.MOTION_START, this._time, this._position));
}
public function prevFrame():void{
if (!this.useSeconds){
this.time = (this._time - 1);
};
}
}
}//package fl.transitions
Section 13
//TweenEvent (fl.transitions.TweenEvent)
package fl.transitions {
import flash.events.*;
public class TweenEvent extends Event {
public var position:Number;// = NAN
public var time:Number;// = NAN
public static const MOTION_START:String = "motionStart";
public static const MOTION_STOP:String = "motionStop";
public static const MOTION_LOOP:String = "motionLoop";
public static const MOTION_CHANGE:String = "motionChange";
public static const MOTION_FINISH:String = "motionFinish";
public static const MOTION_RESUME:String = "motionResume";
public function TweenEvent(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:Boolean=false){
super(_arg1, _arg4, _arg5);
this.time = _arg2;
this.position = _arg3;
}
override public function clone():Event{
return (new TweenEvent(this.type, this.time, this.position, this.bubbles, this.cancelable));
}
}
}//package fl.transitions
Section 14
//botClip (botClip)
package {
import flash.display.*;
public dynamic class botClip extends MovieClip {
}
}//package
Section 15
//NewgroundsAPI (NewgroundsAPI)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
public class NewgroundsAPI {
public static const ADS_APPROVED:Number = 3;
public static const bridge:Sprite = new Sprite();
private static const STAT_NEW_VERSION:Number = 4;
private static const STAT_AUTHOR_SITE:Number = 2;
private static const GATEWAY_URL:String = "http://www.ngads.com/gateway.php";
private static const NEWGROUNDS_URL:String = "http://www.newgrounds.com";
private static const STAT_CUSTOM_STATS:Number = 50;
private static const STAT_MOVIE_VIEWS:Number = 1;
private static const STAT_NEWGROUNDS:Number = 3;
public static const NEW_VERSION:Number = 2;
public static const DENY_HOST:Number = 1;
private static var tracker_id:Number;
private static var movie_options:Object = new Object();
private static var connected:Boolean;
private static var custom_events:Object = new Object();
private static var host:String;
private static var linked:Boolean;
private static var events:Object = new Object();
private static var debug:Boolean;
private static var version:String;
private static var custom_links:Object = new Object();
public static function getNewVersionURL(){
return (((((((GATEWAY_URL + "?&id=") + tracker_id) + "&host=") + escape(host)) + "&stat=") + STAT_NEW_VERSION));
}
private static function ReadGatewayData(_arg1:Object){
var _local2:*;
var _local3:String;
var _local4:*;
var _local5:URLLoader;
for (_local2 in _arg1) {
_arg1[_local2] = unescape(_arg1[_local2]);
movie_options[_local2] = _arg1[_local2];
};
if (_arg1["settings_loaded"]){
SendMessage("You have successfully connected to the Newgrounds API gateway!");
SendMessage((("Movie Identified as '" + movie_options["movie_name"]) + "'"));
if (movie_options["message"]){
SendMessage(movie_options["message"]);
};
if (movie_options["ad_url"]){
SendMessage("Your movie has been approved to run Flash Ads");
if (events[ADS_APPROVED]){
var _local6 = events;
_local6[ADS_APPROVED](movie_options["ad_url"]);
} else {
onAdsApproved(movie_options["ad_url"]);
};
};
if (((movie_options["movie_version"]) && (!((String(movie_options["movie_version"]) == String(version)))))){
SendMessage("WARNING: The movie version configured in your API settings does not match this movie's version!");
if (events[NEW_VERSION]){
_local6 = events;
_local6[NEW_VERSION]({version:movie_options["movie_version"], real_url:getMovieURL(), redirect_url:getNewVersionURL()});
} else {
onNewVersionAvailable(movie_options["movie_version"], getMovieURL(), getNewVersionURL());
};
};
if (movie_options["deny_host"]){
SendMessage("You have blocked 'localHost' in your API settings.");
SendMessage("If you wish to test your movie you will need to remove this block.");
if (events[DENY_HOST]){
_local6 = events;
_local6[DENY_HOST]({host:host, real_url:getMovieURL(), redirect_url:getNewVersionURL()});
} else {
onDenyHost(host, getMovieURL(), getNewVersionURL());
};
};
if (movie_options["request_portal_url"]){
_local3 = bridge.root.loaderInfo.url;
_local4 = ((((GATEWAY_URL + "?&id=") + tracker_id) + "&portal_url=") + escape(_local3));
_local5 = new URLLoader(new URLRequest(_local4));
};
if (events[69]){
_local6 = events;
_local6[69]();
};
} else {
if (!movie_options["settings_loaded"]){
SendError("Could not establish connection to the API gateway.");
};
};
}
public static function setMovieVersion(_arg1){
if (!_arg1){
SendError("Missing required 'version' in NewgroundsAPI.setMovieVersion(version:String)");
} else {
version = String(_arg1);
};
}
public static function loadCustomLink(_arg1:String){
if (!_arg1){
SendError("Missing required 'link_name' parameter in NewgroundsAPI.loadCustomLink(link_name:String)");
} else {
if (!custom_links[_arg1]){
SendError(("Attempted to open undefined custom link: " + _arg1));
} else {
SendLink(custom_links[_arg1]);
};
};
}
public static function addCustomLink(_arg1:Number, _arg2:String){
if (!_arg1){
SendError("Missing required 'id' parameter in NewgroundsAPI.AddCustomLink(id:Number, link_name:String)");
} else {
if (!_arg2){
SendError("Missing required 'link_name' parameter in NewgroundsAPI.AddCustomLink(id:Number, link_name:String)");
} else {
custom_links[_arg2] = (STAT_CUSTOM_STATS + _arg1);
SendMessage(((("Created custom link " + _arg1) + ": ") + _arg2));
};
};
}
public static function getMovieURL(){
if (movie_options["movie_url"]){
return (movie_options["movie_url"]);
};
return ("Newgrounds.com");
}
public static function debugMode(){
debug = true;
}
public static function getAdURL(){
return (movie_options["ad_url"]);
}
private static function SendStat(_arg1:Number, _arg2:Boolean, _arg3=null){
var target_url:*;
var x:*;
var request:URLRequest;
var gateway_loader:URLLoader;
var stat_id = _arg1;
var open_in_browser = _arg2;
var extra = _arg3;
if (!tracker_id){
SendError("You must call NewgroundsAPI.connectMovie() with a valid movie id before using API features!");
} else {
var XML_Loaded:Function = function (_arg1:Event){
var _local5:XML;
var _local6:*;
var _local7:*;
XML.ignoreWhitespace = true;
var _local2:XML = XML(_arg1.target.data);
var _local3:Object = new Object();
var _local4:XMLList = _local2.children();
for each (_local5 in _local4) {
_local6 = _local5.localName();
_local7 = _local5.attribute("value");
if (_local7 == Number(_local7)){
_local7 = Number(_local7);
};
_local3[_local6] = _local7;
};
ReadGatewayData(_local3);
};
target_url = (((((((GATEWAY_URL + "?&id=") + tracker_id) + "&host=") + escape(host)) + "&stat=") + stat_id) + addSeed());
if (extra){
for (x in extra) {
target_url = (target_url + ((("&" + escape(x)) + "=") + escape(extra[x])));
};
};
if (debug){
target_url = (target_url + "&debug=1");
};
if (open_in_browser){
request = new URLRequest((target_url + addSeed()));
navigateToURL(request, "_blank");
} else {
gateway_loader = new URLLoader(new URLRequest((target_url + addSeed())));
gateway_loader.addEventListener(Event.COMPLETE, XML_Loaded);
};
};
}
public static function onAdsApproved(_arg1:String){
}
public static function loadMySite(_arg1:Event=null){
SendLink(STAT_AUTHOR_SITE);
}
private static function SendMessage(_arg1:String){
trace(("[NEWGROUNDS API] :: " + _arg1));
}
public static function linkAPI(_arg1){
_arg1.addChild(bridge);
linked = true;
}
public static function loadNewgrounds(_arg1:Event=null, _arg2:String=null){
var _local3:URLRequest;
var _local4:*;
if (!tracker_id){
_local3 = new URLRequest(((NEWGROUNDS_URL + "/") + _arg2));
navigateToURL(_local3, "_blank");
} else {
_local4 = null;
if (_arg2){
_local4 = new Object();
_local4.page = _arg2;
};
SendLink(STAT_NEWGROUNDS, _local4);
};
}
private static function SendLink(_arg1, _arg2=null){
SendStat(_arg1, true, _arg2);
}
public static function logCustomEvent(_arg1:String){
if (!_arg1){
SendError("Missing required 'event_name' parameter in NewgroundsAPI.logCustomEvent(event_name:String)");
} else {
if (!custom_events[_arg1]){
SendError(("Attempted to log undefined custom event: " + _arg1));
} else {
SendEvent(custom_events[_arg1]);
};
};
}
private static function SendError(_arg1:String){
trace(("[NEWGROUNDS API ERROR] :: " + _arg1));
}
public static function addCustomEvent(_arg1:Number, _arg2:String){
if (!_arg1){
SendError("Missing required 'id' parameter in NewgroundsAPI.AddCustomEvent(id:Number, event_name:String)");
} else {
if (!_arg2){
SendError("Missing required 'event_name' parameter in NewgroundsAPI.AddCustomEvent(id:Number, event_name:String)");
} else {
custom_events[_arg2] = (STAT_CUSTOM_STATS + _arg1);
SendMessage(("Created custom event: " + _arg2));
};
};
}
private static function addSeed(){
return (("&seed=" + Math.random()));
}
public static function addEventListener(_arg1:Number, _arg2:Function){
events[_arg1] = _arg2;
}
private static function SendEvent(_arg1){
SendStat(_arg1, false);
}
public static function onNewVersionAvailable(_arg1:String, _arg2:String, _arg3:String){
var _root:*;
var overlay:MovieClip;
var version = _arg1;
var movie_url = _arg2;
var redirect_url = _arg3;
var sw:* = bridge.stage.stageWidth;
var sh:* = bridge.stage.stageHeight;
var tw:* = 350;
var th:* = 160;
var mg:* = 20;
_root = bridge.root;
overlay = new MovieClip();
overlay.graphics.beginFill(0, 0.6);
overlay.graphics.lineStyle(0, 0);
overlay.graphics.drawRect(0, 0, sw, sh);
overlay.graphics.endFill();
var overlay_x:* = Math.round(((sw - tw) / 2));
var overlay_y:* = Math.round(((sh - th) / 2));
overlay.graphics.beginFill(102);
overlay.graphics.lineStyle(10, 0);
overlay.graphics.drawRect((overlay_x - mg), (overlay_y - mg), (tw + mg), (th + mg));
overlay.graphics.endFill();
overlay.close = function (_arg1:Event){
_root.removeChild(overlay);
};
var close_x:* = new MovieClip();
close_x.graphics.beginFill(0, 0.1);
close_x.graphics.lineStyle(3, 22015);
close_x.graphics.drawRect(0, 0, 16, 16);
close_x.graphics.endFill();
close_x.graphics.moveTo(4, 4);
close_x.graphics.lineTo(13, 13);
close_x.graphics.moveTo(13, 4);
close_x.graphics.lineTo(4, 13);
close_x.x = ((overlay_x + tw) - 26);
close_x.y = (overlay_y - 10);
close_x.addEventListener(MouseEvent.CLICK, overlay.close);
var blankarea:TextField = new TextField();
blankarea.x = (overlay_x - mg);
blankarea.y = (overlay_y - mg);
blankarea.width = (tw + mg);
blankarea.height = (th + mg);
blankarea.selectable = false;
var header:TextField = new TextField();
header.width = tw;
header.x = overlay_x;
header.y = overlay_y;
header.height = 100;
header.selectable = false;
var header_format:TextFormat = new TextFormat();
header_format.font = "Arial Black";
header_format.color = 0xFFFFFF;
header_format.size = 20;
header.defaultTextFormat = header_format;
header.text = "New Version Available!";
var msgtext:TextField = new TextField();
msgtext.x = overlay_x;
msgtext.y = (overlay_y + 70);
msgtext.width = tw;
msgtext.height = 60;
msgtext.selectable = false;
var msgtext_format:TextFormat = new TextFormat();
msgtext_format.font = "Arial";
msgtext_format.color = 0xFFFFFF;
msgtext_format.size = 12;
msgtext_format.bold = true;
var msgtext_link:TextFormat = new TextFormat();
msgtext_link.font = "Arial";
msgtext_link.color = 0xFFFF00;
msgtext_link.size = 12;
msgtext_link.bold = true;
msgtext_link.url = redirect_url;
msgtext_link.target = "_blank";
if (version){
version = ("Version " + version);
} else {
version = "A new version";
};
msgtext.defaultTextFormat = msgtext_format;
msgtext.appendText((version + " is now available"));
if (movie_url){
msgtext.appendText(" at:\n");
msgtext.defaultTextFormat = msgtext_link;
msgtext.appendText(movie_url);
} else {
msgtext.appendText("!");
};
_root.addChild(overlay);
overlay.addChild(blankarea);
overlay.addChild(header);
overlay.addChild(msgtext);
overlay.addChild(close_x);
}
public static function onDenyHost(_arg1:String, _arg2:String, _arg3:String){
var _local4:* = bridge.stage.stageWidth;
var _local5:* = bridge.stage.stageHeight;
var _local6:* = 350;
var _local7:* = 160;
var _local8:* = bridge.root;
var _local9:MovieClip = new MovieClip();
_local9.graphics.beginFill(0x660000);
_local9.graphics.lineStyle(20, 0);
_local9.graphics.drawRect(0, 0, _local4, _local5);
_local9.graphics.endFill();
var _local10:TextField = new TextField();
_local10.x = 0;
_local10.y = 0;
_local10.width = _local4;
_local10.height = _local5;
_local10.selectable = false;
var _local11:TextField = new TextField();
_local11.x = Math.round(((_local4 - _local6) / 2));
_local11.y = Math.round(((_local5 - _local7) / 2.5));
_local11.width = _local6;
_local11.height = 100;
_local11.selectable = false;
var _local12:TextFormat = new TextFormat();
_local12.font = "Arial Black";
_local12.color = 0xFF0000;
_local12.size = 38;
_local11.defaultTextFormat = _local12;
_local11.text = "ERROR!";
var _local13:TextField = new TextField();
_local13.x = Math.round(((_local4 - _local6) / 2));
_local13.y = (Math.round(((_local5 - _local7) / 2.5)) + 80);
_local13.width = _local6;
_local13.height = 80;
_local13.selectable = false;
var _local14:TextFormat = new TextFormat();
_local14.font = "Arial";
_local14.color = 0xFFFFFF;
_local14.size = 12;
_local14.bold = true;
var _local15:TextFormat = new TextFormat();
_local15.font = "Arial";
_local15.color = 0xFFFF00;
_local15.size = 12;
_local15.bold = true;
_local15.url = _arg3;
_local15.target = "_blank";
_local13.defaultTextFormat = _local14;
_local13.appendText((("This movie has not been approved for use on " + _arg1) + "\n"));
_local13.appendText("For an approved copy, please visit:\n");
_local13.defaultTextFormat = _local15;
_local13.appendText(_arg2);
_local8.addChild(_local9);
_local9.addChild(_local10);
_local9.addChild(_local11);
_local9.addChild(_local13);
}
public static function connectMovie(_arg1:Number){
var _local2:String;
var _local3:*;
if (!_arg1){
SendError("Missing required 'id' parameter in NewgroundsAPI.connectMovie(id:Number)");
} else {
if (!linked){
SendError("Attempted to call MewgroundsAPI.connectMovie() without first calling NewgroundsAPI.linkAPI(this)");
} else {
if (!tracker_id){
SendMessage("Connecting to API gateway...");
tracker_id = _arg1;
_local2 = bridge.root.loaderInfo.url;
host = _local2.split("/")[2].toLowerCase();
if (host.length < 1){
host = "localhost";
};
_local3 = new Object();
SendEvent(STAT_MOVIE_VIEWS);
};
};
};
}
public static function isInstalled(){
return (true);
}
}
}//package