flash on 2013-4-11

by h_sakurai
♥0 | Line 3308 | Modified 2013-04-11 18:36:35 | MIT License
play

ActionScript3 source code

/**
 * Copyright h_sakurai ( http://wonderfl.net/user/h_sakurai )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/g6oA
 */

package {
    import flash.display.MovieClip;
    public class flash__Root extends MovieClip {
        function flash__Root() {
            super();
            addChild(new __main__())
        }
    }
}

dynamic class enum {
    public var tag : String;
    public var index : int;
    public var params : Array;
    public function toString() : String { return flash__Boot.enum_to_string(this); }
}

dynamic final class Void extends enum {
    public static const __isenum : Boolean = true;
    public function Void( t : String, index : int, p : Array = null ) : void { this.tag = t; this.index = index; this.params = p; }
    public static var __constructs__ : Array = [];;
}

import flash.text.TextFormat;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.setTimeout;
import flash.events.Event;
import flash.utils.getQualifiedClassName;
dynamic class flash__Boot extends flash.display.MovieClip {
    public function flash__Boot() : void { if( !flash__Boot.skip_constructor ) {
        super();
    }}
    
    protected function init() : void {
        throw "assert";
    }
    
    protected function doInitDelay(_ : *) : void {
        flash__Lib.current.removeEventListener(flash.events.Event.ADDED_TO_STAGE,this.doInitDelay);
        this.start();
    }
    
    protected function start() : void {
        var c : flash.display.MovieClip = flash__Lib.current;
        try {
            if(c == this && c.stage != null && c.stage.align == "") c.stage.align = "TOP_LEFT";
        }
        catch( e : * ){
        }
        if(c.stage == null) c.addEventListener(flash.events.Event.ADDED_TO_STAGE,this.doInitDelay);
        else if(c.stage.stageWidth == 0) flash.utils.setTimeout(this.start,1);
        else this.init();
    }
    
    static protected var tf : flash.text.TextField;
    static protected var lines : Array;
    static protected var lastError : Error;
    static public var skip_constructor : Boolean = false;
    static public function enum_to_string(e : *) : String {
        if(e.params == null) return e.tag;
        var pstr : Array = [];
        {
            var _g : int = 0, _g1 : Array = e.params;
            while(_g < _g1.length) {
                var p : * = _g1[_g];
                ++_g;
                pstr.push(flash__Boot.__string_rec(p,""));
            }
        }
        return e.tag + "(" + pstr.join(",") + ")";
    }
    
    static public function __instanceof(v : *,t : *) : Boolean {
        try {
            if(t == Object) return true;
            return v is t;
        }
        catch( e : * ){
        }
        return false;
    }
    
    static public function __clear_trace() : void {
        if(flash__Boot.tf == null) return;
        flash__Boot.tf.parent.removeChild(flash__Boot.tf);
        flash__Boot.tf = null;
        flash__Boot.lines = null;
    }
    
    static public function __set_trace_color(rgb : uint) : void {
        var tf : flash.text.TextField = flash__Boot.getTrace();
        tf.textColor = rgb;
        tf.filters = [];
    }
    
    static public function getTrace() : flash.text.TextField {
        var mc : flash.display.MovieClip = flash__Lib.current;
        if(flash__Boot.tf == null) {
            flash__Boot.tf = new flash.text.TextField();
            var format : flash.text.TextFormat = flash__Boot.tf.getTextFormat();
            format.font = "_sans";
            flash__Boot.tf.defaultTextFormat = format;
            flash__Boot.tf.selectable = false;
            flash__Boot.tf.width = ((mc.stage == null)?800:mc.stage.stageWidth);
            flash__Boot.tf.autoSize = flash.text.TextFieldAutoSize.LEFT;
            flash__Boot.tf.mouseEnabled = false;
        }
        if(mc.stage == null) mc.addChild(flash__Boot.tf);
        else mc.stage.addChild(flash__Boot.tf);
        return flash__Boot.tf;
    }
    
    static public function __trace(v : *,pos : *) : void {
        var tf : flash.text.TextField = flash__Boot.getTrace();
        var pstr : String = ((pos == null)?"(null)":pos.fileName + ":" + pos.lineNumber);
        if(flash__Boot.lines == null) flash__Boot.lines = [];
        flash__Boot.lines = flash__Boot.lines.concat((pstr + ": " + flash__Boot.__string_rec(v,"")).split("\n"));
        tf.text = flash__Boot.lines.join("\n");
        var stage : flash.display.Stage = flash__Lib.current.stage;
        if(stage == null) return;
        while(flash__Boot.lines.length > 1 && tf.height > stage.stageHeight) {
            flash__Boot.lines.shift();
            tf.text = flash__Boot.lines.join("\n");
        }
    }
    
    static public function __string_rec(v : *,str : String) : String {
        var cname : String = flash.utils.getQualifiedClassName(v);
        switch(cname) {
        case "Object":
        {
            var k : Array = function() : Array {
                var $r : Array;
                $r = new Array();
                for(var $k2 : String in v) $r.push($k2);
                return $r;
            }();
            var s : String = "{";
            var first : Boolean = true;
            {
                var _g1 : int = 0, _g : int = k.length;
                while(_g1 < _g) {
                    var i : int = _g1++;
                    var key : String = k[i];
                    if(key == "toString") try {
                        return v.toString();
                    }
                    catch( e : * ){
                    }
                    if(first) first = false;
                    else s += ",";
                    s += " " + key + " : " + flash__Boot.__string_rec(v[key],str);
                }
            }
            if(!first) s += " ";
            s += "}";
            return s;
        }
        break;
        case "Array":
        {
            if(v == Array) return "#Array";
            var s1 : String = "[";
            var i1 : *;
            var first1 : Boolean = true;
            var a : Array = v;
            {
                var _g11 : int = 0, _g2 : int = a.length;
                while(_g11 < _g2) {
                    var i2 : int = _g11++;
                    if(first1) first1 = false;
                    else s1 += ",";
                    s1 += flash__Boot.__string_rec(a[i2],str);
                }
            }
            return s1 + "]";
        }
        break;
        default:
        switch(typeof v) {
        case "function":
        return "<function>";
        break;
        }
        break;
        }
        return new String(v);
    }
    
    static protected function __unprotect__(s : String) : String {
        return s;
    }
    
}

dynamic class __main__ extends flash__Boot {
    public function __main__() {
        super();
        flash__Lib.current = this;
        {
            Math["NaN"] = Number.NaN;
            Math["NEGATIVE_INFINITY"] = Number.NEGATIVE_INFINITY;
            Math["POSITIVE_INFINITY"] = Number.POSITIVE_INFINITY;
            Math["isFinite"] = function(i : Number) : Boolean {
                return isFinite(i);
            }
            Math["isNaN"] = function(i1 : Number) : Boolean {
                return isNaN(i1);
            }
        }
        {
            var aproto : * = Array.prototype;
            aproto.copy = function() : * {
                return this.slice();
            }
            aproto.insert = function(i : *,x : *) : void {
                this.splice(i,0,x);
            }
            aproto.remove = function(obj : *) : Boolean {
                var idx : int = this.indexOf(obj);
                if(idx == -1) return false;
                this.splice(idx,1);
                return true;
            }
            aproto.iterator = function() : * {
                var cur : int = 0;
                var arr : Array = this;
                return { hasNext : function() : Boolean {
                    return cur < arr.length;
                }, next : function() : * {
                    return arr[cur++];
                }}
            }
            aproto.setPropertyIsEnumerable("copy",false);
            aproto.setPropertyIsEnumerable("insert",false);
            aproto.setPropertyIsEnumerable("remove",false);
            aproto.setPropertyIsEnumerable("iterator",false);
            String.prototype.charCodeAtHX = function(i1 : *) : * {
                var s : String = this;
                var x1 : Number = s.charCodeAt(i1);
                if(isNaN(x1)) return null;
                return Std._int(x1);
            }
        }
        com__abagames__stgldemo__Main.main();
    }
}

import flash.text.TextFormatAlign;
import flash.text.TextFormat;
import flash.text.TextFieldType;
import flash.events.FocusEvent;
import flash.events.KeyboardEvent;
import flash.display.Sprite;
import flash.text.TextField;
dynamic class com__abagames__stgldemo__LineNumberedTextField extends flash.display.Sprite {
    public function com__abagames__stgldemo__LineNumberedTextField(width : Number = 320,height : Number = 480) : void { if( !flash__Boot.skip_constructor ) {
        super();
        this.createTextFields(width,height);
    }}
    
    protected function onFocusOut(e : flash.events.FocusEvent) : void {
        this.hasFocus = false;
    }
    
    protected function onFocusIn(e : flash.events.FocusEvent) : void {
        this.hasFocus = true;
    }
    
    protected function refreshLines() : void {
        if(this.prevScrollV == this.textField.scrollV && this.prevNumLines == this.textField.numLines) return;
        var text : String = "";
        var el : int = Std._int(Math.min(this.textField.scrollV + this.lineHeight - 1,this.textField.numLines));
        {
            var _g1 : int = this.textField.scrollV, _g : int = el + 1;
            while(_g1 < _g) {
                var i : int = _g1++;
                text += i + "\n";
            }
        }
        this.lineNumberField.text = text;
        this.prevScrollV = this.textField.scrollV;
        this.prevNumLines = this.textField.numLines;
    }
    
    protected var prevNumLines : int = -1;
    protected var prevScrollV : int = -1;
    protected function onKeyUp(e : flash.events.KeyboardEvent) : void {
        this.refreshLines();
        if(e.keyCode != 13) return;
        var prevLineIndex : int = this.textField.getLineIndexOfChar(this.textField.caretIndex - 1);
        if(prevLineIndex < 0) return;
        var lineText : String = this.textField.getLineText(prevLineIndex);
        var indexStr : String = "";
        {
            var _g1 : int = 0, _g : int = lineText.length;
            while(_g1 < _g) {
                var i : int = _g1++;
                var c : String = lineText.charAt(i);
                if(c == " " || c == "\t") indexStr += c;
                else break;
            }
        }
        var ci : int = this.textField.caretIndex;
        this.textField.replaceText(ci,ci,indexStr);
        ci += indexStr.length;
        this.textField.setSelection(ci,ci);
    }
    
    protected function onKeyFocusChange(e : flash.events.FocusEvent) : void {
        e.preventDefault();
        var tf : flash.text.TextField = (function($this:com__abagames__stgldemo__LineNumberedTextField) : flash.text.TextField {
            var $r : flash.text.TextField;
            var $t : * = e.currentTarget;
            if(Std._is($t,flash.text.TextField)) (($t) as flash.text.TextField);
            else throw "Class cast error";
            $r = $t;
            return $r;
        }(this));
        tf.replaceText(tf.caretIndex,tf.caretIndex,"\t");
        tf.setSelection(tf.caretIndex + 1,tf.caretIndex + 1);
    }
    
    protected function createTextFields(width : Number,height : Number) : void {
        this.textField = new flash.text.TextField();
        this.textField.borderColor = 16777215;
        this.textField.border = true;
        this.textField.backgroundColor = 0;
        this.textField.textColor = 8978312;
        this.textField.width = width - 36;
        this.textField.height = height - 8;
        this.textField.multiline = true;
        this.textField.type = flash.text.TextFieldType.INPUT;
        this.textField.x = 32;
        this.textField.y = 3;
        this.textField.addEventListener(flash.events.FocusEvent.KEY_FOCUS_CHANGE,this.onKeyFocusChange);
        this.textField.addEventListener(flash.events.KeyboardEvent.KEY_UP,this.onKeyUp);
        this.textField.addEventListener(flash.events.FocusEvent.FOCUS_IN,this.onFocusIn);
        this.textField.addEventListener(flash.events.FocusEvent.FOCUS_OUT,this.onFocusOut);
        var textFormat : flash.text.TextFormat = new flash.text.TextFormat();
        var tabStops : Array = new Array();
        {
            var _g : int = 0;
            while(_g < 20) {
                var i : int = _g++;
                tabStops.push((i + 1) * 20);
            }
        }
        textFormat.tabStops = tabStops;
        textFormat.font = "_typewriter";
        this.textField.defaultTextFormat = textFormat;
        this.addChild(this.textField);
        this.lineNumberField = new flash.text.TextField();
        this.lineNumberField.y = this.textField.y;
        this.lineNumberField.width = 32;
        this.lineNumberField.height = this.textField.height;
        this.lineNumberField.multiline = true;
        this.lineNumberField.backgroundColor = 0;
        this.lineNumberField.textColor = 16777096;
        var lnTextFormat : flash.text.TextFormat = new flash.text.TextFormat();
        lnTextFormat.align = flash.text.TextFormatAlign.RIGHT;
        lnTextFormat.underline = true;
        lnTextFormat.font = "_typewriter";
        this.lineNumberField.defaultTextFormat = lnTextFormat;
        this.addChild(this.lineNumberField);
        this.lineHeight = Std._int(this.textField.height / this.textField.getLineMetrics(0).height);
        this.refreshLines();
    }
    
    protected var lineHeight : int;
    protected var lineNumberField : flash.text.TextField;
    protected var textField : flash.text.TextField;
    public function setText(s : String) : String {
        this.textField.text = s;
        this.refreshLines();
        return s;
    }
    
    public function getText() : String {
        return this.textField.text;
    }
    
    public function get text() : String { return getText(); }
    public function set text( __v : String ) : void { setText(__v); }
    protected var $text : String;
    public var hasFocus : Boolean = false;
}

import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
dynamic class com__abagames__util__Frame {
    public function com__abagames__util__Frame(x : int = -1,y : int = -1,width : int = -1,height : int = -1) : void { if( !flash__Boot.skip_constructor ) {
        flash__Lib.current.stage.align = flash.display.StageAlign.TOP_LEFT;
        flash__Lib.current.stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
        com__abagames__util__Frame.i = this;
        com__abagames__util__Screen.initialize(x,y,width,height);
        com__abagames__util__Key.initialize();
        com__abagames__util__Mouse.initialize();
        com__abagames__util__Letter.initialize();
        this.random = new com__abagames__util__Random();
        this.initializeFirst();
        this.initializeGame();
        if(this.isDebugging) this.beginGame();
        this.lastTimer = flash__Lib._getTimer();
        flash__Lib.current.addEventListener(flash.events.Event.ACTIVATE,this.onActivated);
        flash__Lib.current.addEventListener(flash.events.Event.DEACTIVATE,this.onDeactivated);
        flash__Lib.current.addEventListener(flash.events.Event.ENTER_FRAME,this.updateFrame);
    }}
    
    protected function onDeactivated(e : flash.events.Event) : void {
        com__abagames__util__Key.reset();
        if(this.isInGame) this.isPaused = true;
    }
    
    protected function onActivated(e : flash.events.Event) : void {
        this.isPaused = false;
    }
    
    protected function calcFps() : void {
        this.fpsCount++;
        var currentTimer : int = flash__Lib._getTimer();
        var delta : int = currentTimer - this.lastTimer;
        if(delta >= 1000) {
            this.fps = this.fpsCount * 1000 / delta;
            this.lastTimer = currentTimer;
            this.fpsCount = 0;
        }
    }
    
    protected var lastTimer : int = 0;
    protected var fpsCount : int = 0;
    protected function handleTitleScreen() : void {
        com__abagames__util__Letter.draw(this.title,com__abagames__util__Screen.center.x,com__abagames__util__Screen.center.y - 20);
        com__abagames__util__Letter.draw(this.platform.clickStr,com__abagames__util__Screen.center.x,com__abagames__util__Screen.center.y + 8);
        com__abagames__util__Letter.draw("TO",com__abagames__util__Screen.center.x,com__abagames__util__Screen.center.y + 18);
        com__abagames__util__Letter.draw("START",com__abagames__util__Screen.center.x,com__abagames__util__Screen.center.y + 28);
        if(com__abagames__util__Mouse.isPressing) {
            if(this.wasReleased) this.wasClicked = true;
        }
        else {
            if(this.wasClicked) this.beginGame();
            if(--this.titleTicks <= 0) this.wasReleased = true;
        }
    }
    
    protected function updateFrame(e : flash.events.Event) : void {
        com__abagames__util__Screen.begin();
        if(!this.isPaused) {
            this.update();
            if(this.isDebugging) com__abagames__util__Letter.drawAligned("FPS: " + Std.string(Std._int(this.fps)),com__abagames__util__Screen.size.getXi(),20,com__abagames__util__LetterAlign.Right);
            com__abagames__util__Se.updateAll();
            this.ticks++;
        }
        else {
            com__abagames__util__Letter.draw("PAUSED",com__abagames__util__Screen.center.x,com__abagames__util__Screen.center.y - 8);
            com__abagames__util__Letter.draw(this.platform.clickStr + " TO RESUME",com__abagames__util__Screen.center.x,com__abagames__util__Screen.center.y + 8);
        }
        com__abagames__util__Bgm.update();
        com__abagames__util__Letter.drawAligned(Std.string(this.score),com__abagames__util__Screen.size.x,2,com__abagames__util__LetterAlign.Right);
        com__abagames__util__Screen.end();
        this.calcFps();
    }
    
    protected function initializeGame() : void {
        com__abagames__util__Particle.initialize();
        com__abagames__util__Message.initialize();
        this.initialize();
    }
    
    protected function beginGame() : void {
        this.isInGame = true;
        this.score = 0;
        this.ticks = 0;
        this.random.setSeed();
        this.initializeGame();
    }
    
    protected var titleTicks : int = 0;
    protected var wasReleased : Boolean = false;
    protected var wasClicked : Boolean = false;
    protected var isPaused : Boolean = false;
    public function endGame() : Boolean {
        if(!this.isInGame) return false;
        this.platform.recordScore(this.score);
        this.isInGame = false;
        this.wasClicked = this.wasReleased = false;
        this.ticks = 0;
        this.titleTicks = 10;
        return true;
    }
    
    public var fps : Number = 0.0;
    public var isInGame : Boolean = false;
    public var ticks : int = 0;
    public var score : int = 0;
    public var random : com__abagames__util__Random;
    public function update() : void {
    }
    
    public function initialize() : void {
    }
    
    public function initializeFirst() : void {
    }
    
    public var platform : com__abagames__util__Platform;
    public var isDebugging : Boolean = false;
    public var title : String = "";
    static public var i : com__abagames__util__Frame;
}

dynamic class com__abagames__stgldemo__Main extends com__abagames__util__Frame {
    public function com__abagames__stgldemo__Main() : void { if( !flash__Boot.skip_constructor ) {
        super(320,0,320,480);
    }}
    
    protected function drawConsoleMessage() : void {
        var y : int = 50;
        {
            var _g : int = 0, _g1 : Array = this.consoleMessages;
            while(_g < _g1.length) {
                var l : String = _g1[_g];
                ++_g;
                com__abagames__util__Letter.drawAligned(l,10,y,com__abagames__util__LetterAlign.Left);
                y += 20;
            }
        }
    }
    
    protected function setConsoleMessage(msg : String) : void {
        var maxChar : int = 30;
        this.consoleMessages = new Array();
        {
            var _g : int = 0, _g1 : Array = msg.toUpperCase().split("\n");
            while(_g < _g1.length) {
                var l : String = _g1[_g];
                ++_g;
                while(l.length > maxChar) {
                    this.consoleMessages.push(l.substr(0,maxChar));
                    l = l.substr(maxChar);
                }
                this.consoleMessages.push(l);
            }
        }
    }
    
    protected function readStgl() : void {
        try {
            this.score = 0;
            com__abagames__util__Message.s = new Array();
            com__abagames__util__stgl__Command.read(this.textField.getText().split("\r").join("\n"));
            this.beginGame();
            com__abagames__util__stgl__StglActor.add("main");
            this.setConsoleMessage("STGL SUCCESSFULLY PARSED.");
            this.hasError = false;
            this.isStarted = true;
            com__abagames__stgldemo__Main.parsedSe.play();
        }
        catch( msg : String ){
            this.setError(msg);
        }
    }
    
    protected function setError(msg : String) : void {
        this.player.destroy(true);
        this.initialize();
        this.setConsoleMessage(msg);
        this.hasError = true;
    }
    
    public override function update() : void {
        if(this.ticks == 0) {
            com__abagames__util__Message.addOnce("u",new com__abagames__util__Xy(50,40));
            com__abagames__util__Message.addOnce("PUSH 'START' TO PARSE STGL",new com__abagames__util__Xy(140,60));
        }
        else if(this.ticks == 30) {
            com__abagames__util__Message.addOnce("u ",new com__abagames__util__Xy(180,80));
            com__abagames__util__Message.addOnce("OR SELECT OTHER 'SAMPLES'",new com__abagames__util__Xy(170,100));
        }
        else if(this.ticks == 60) {
            com__abagames__util__Message.addOnce("l",new com__abagames__util__Xy(10,120));
            com__abagames__util__Message.addOnce("OR WRITE YOUR OWN STGL",new com__abagames__util__Xy(120,140));
        }
        else if(this.ticks == 120) {
            com__abagames__util__Message.addOnce("[u][d][l][r]: MOVE YOUR SHIP",new com__abagames__util__Xy(150,400));
            com__abagames__util__Message.addOnce("[Z]: FIRE",new com__abagames__util__Xy(150,420));
            com__abagames__util__Message.addOnce("[F5]: START",new com__abagames__util__Xy(150,450));
        }
        if(--this.starAddTicks <= 0) {
            com__abagames__stgldemo__Star.s.push(new com__abagames__stgldemo__Star());
            this.starAddTicks = 5;
        }
        com__abagames__util__Actor.updateAll(com__abagames__stgldemo__Star.s);
        com__abagames__util__Particle.updateAll();
        com__abagames__util__Actor.updateAll(com__abagames__stgldemo__Shot.s);
        this.player.isAbleToMove = !this.textField.hasFocus;
        this.player.update();
        if(!this.hasError && this.player.isAbleToMove) {
            try {
                com__abagames__util__Actor.updateAll(com__abagames__stgldemo__SActor.s);
            }
            catch( msg : String ){
                this.setError(msg);
            }
            if(this.ticks % 60 == 0) com__abagames__stgldemo__Main.inGameSe.play();
        }
        else if(this.isStarted) this.initialize();
        this.drawConsoleMessage();
        com__abagames__util__Message.updateAll();
        this.startButton.update();
        if(this.startButton.isClicked || !this.isF5Pressed && com__abagames__util__Key.s[116]) {
            flash__Lib.current.stage.focus = null;
            this.isSampleButtonsOpen = false;
            this.readStgl();
        }
        this.isF5Pressed = com__abagames__util__Key.s[116];
        this.sampleOpenButton.update();
        if(this.sampleOpenButton.isClicked) this.isSampleButtonsOpen = !this.isSampleButtonsOpen;
        else if(this.isSampleButtonsOpen) {
            var i : int = 0;
            {
                var _g : int = 0, _g1 : Array = this.sampleButtons;
                while(_g < _g1.length) {
                    var b : com__abagames__util__Button = _g1[_g];
                    ++_g;
                    b.update();
                    if(b.isClicked) this.setSample(i);
                    i++;
                }
            }
        }
    }
    
    public override function initialize() : void {
        this.isStarted = false;
        com__abagames__stgldemo__SActor.s = new Array();
        this.setConsoleMessage("");
    }
    
    protected function setSample(i : int) : void {
        this.textField.setText(com__abagames__stgldemo__Sample.s[i][1].split("\r\n").join("\r"));
    }
    
    public override function initializeFirst() : void {
        this.title = "STGL DEMO";
        this.isDebugging = false;
        this.platform = new com__abagames__util__Platform();
        this.textField = new com__abagames__stgldemo__LineNumberedTextField();
        flash__Lib.current.stage.addChild(this.textField);
        this.setSample(com__abagames__stgldemo__Sample.s.length - 1);
        this.startButton = new com__abagames__util__Button("START",10,10,80,25);
        this.sampleOpenButton = new com__abagames__util__Button("SAMPLES",120,10,100,25);
        this.sampleButtons = new Array();
        {
            var _g1 : int = 0, _g : int = com__abagames__stgldemo__Sample.s.length;
            while(_g1 < _g) {
                var i : int = _g1++;
                this.sampleButtons.push(new com__abagames__util__Button(com__abagames__stgldemo__Sample.s[i][0].toUpperCase(),120,40 + i * 30,180,25));
            }
        }
        this.sManager = new com__abagames__util__stgl__StglManager();
        com__abagames__util__stgl__StglActor.initialize(this.sManager);
        this.player = new com__abagames__stgldemo__Player(this.sManager);
        com__abagames__stgldemo__Shot.s = new Array();
        com__abagames__stgldemo__Star.s = new Array();
        this.consoleMessages = new Array();
    }
    
    protected var isF5Pressed : Boolean = false;
    protected var isStarted : Boolean = false;
    protected var starAddTicks : int = 0;
    protected var hasError : Boolean = false;
    protected var consoleMessages : Array;
    protected var player : com__abagames__stgldemo__Player;
    protected var isSampleButtonsOpen : Boolean = false;
    protected var sampleButtons : Array;
    protected var sampleOpenButton : com__abagames__util__Button;
    protected var startButton : com__abagames__util__Button;
    protected var textField : com__abagames__stgldemo__LineNumberedTextField;
    protected var sManager : com__abagames__util__stgl__StglManager;
    static protected var parsedSe : com__abagames__util__Se = new com__abagames__util__Se().b(com__abagames__util__SeType.Major).t(0.1,3,0.5).t(0.3,3,0.7).t(0.5,3,0.9).e();
    static protected var inGameSe : com__abagames__util__Se = new com__abagames__util__Se().b(com__abagames__util__SeType.Minor).t(0.3,2,0.2).r().t(0.3,2,0.2).e();
    static public function main() : void {
        new com__abagames__stgldemo__Main();
    }
    
}

dynamic class com__abagames__util__Actor {
    public function com__abagames__util__Actor() : void { if( !flash__Boot.skip_constructor ) {
        this.pos = new com__abagames__util__Xy();
        this.vel = new com__abagames__util__Xy();
        this.size = new com__abagames__util__Xy();
    }}
    
    public function update() : Boolean {
        return true;
    }
    
    public var radius : Number = -1.0;
    public var size : com__abagames__util__Xy;
    public var speed : Number = 0.0;
    public var angle : Number = 0.0;
    public var vel : com__abagames__util__Xy;
    public var pos : com__abagames__util__Xy;
    static public function updateAll(s : Array) : void {
        var i : int = 0;
        while(i < s.length) if(s[i].update()) i++;
        else s.splice(i,1);
    }
    
    static public function checkHitCircle(ca : *,s : Array,callHit : Boolean = false) : Boolean {
        return com__abagames__util__Actor.checkHit(ca,s,callHit,function(ca1 : *,a : *) : Boolean {
            return ca1.pos.distance(a.pos) <= ca1.radius + a.radius;
        });
    }
    
    static public function checkHitRect(ca : *,s : Array,callHit : Boolean = false) : Boolean {
        return com__abagames__util__Actor.checkHit(ca,s,callHit,function(ca1 : *,a : *) : Boolean {
            return Math.abs(ca1.pos.x - a.pos.x) <= (ca1.size.x + a.size.x) / 2 && Math.abs(ca1.pos.y - a.pos.y) <= (ca1.size.y + a.size.y) / 2;
        });
    }
    
    static public function checkHit(ca : *,s : Array,callHit : Boolean,hitTest : Function) : Boolean {
        var hf : Boolean = false;
        {
            var _g : int = 0;
            while(_g < s.length) {
                var a : * = s[_g];
                ++_g;
                if(ca == a) continue;
                if(hitTest(ca,a)) {
                    if(callHit) a.hit(ca);
                    hf = true;
                }
            }
        }
        return hf;
    }
    
}

dynamic class com__abagames__stgldemo__Player extends com__abagames__util__Actor {
    public function com__abagames__stgldemo__Player(sManager : com__abagames__util__stgl__StglManager = null) : void { if( !flash__Boot.skip_constructor ) {
        super();
        this.sManager = sManager;
        this.spPos = new com__abagames__util__Xy();
        this.size.setV(1);
        this.initialize();
    }}
    
    public function destroy(isParseError : Boolean = false) : void {
        if(!isParseError && this.invincibleTicks > 0) return;
        com__abagames__util__Particle.add(this.pos,com__abagames__util__Color.green.getRz().getRz().getRz(),50,50,10);
        this.invincibleTicks = 180;
        com__abagames__stgldemo__Player.dstSe.play();
    }
    
    public override function update() : Boolean {
        if(this.invincibleTicks < 120 && this.isAbleToMove) {
            var s : com__abagames__util__Xy = com__abagames__util__Key.getStick();
            s.scaleBy(5);
            this.pos.incrementBy(s);
            this.fireTicks--;
            if(this.fireTicks <= 0 && com__abagames__util__Key.getIsButtonPressed()) {
                this.spPos.setXy(this.pos);
                this.spPos.x -= 14;
                com__abagames__util__Particle.add(this.spPos,com__abagames__util__Color.cyan.getGz().getRz(),10,1,10,20,Math.PI,0.5);
                this.spPos.x += 28;
                com__abagames__util__Particle.add(this.spPos,com__abagames__util__Color.cyan.getGz().getRz(),10,1,10,20,Math.PI,0.5);
                com__abagames__stgldemo__Shot.s.push(new com__abagames__stgldemo__Shot(this.pos));
                this.fireTicks = 3;
            }
        }
        this.pos.x = com__abagames__util__FloatUtil.clamp(this.pos.x,0,com__abagames__util__Screen.size.x);
        this.pos.y = com__abagames__util__FloatUtil.clamp(this.pos.y,0,com__abagames__util__Screen.size.y);
        if(this.invincibleTicks == 120) this.initialize();
        if(this.invincibleTicks <= 0) com__abagames__util__Actor.checkHitRect(this,com__abagames__stgldemo__SActor.s,true);
        if(this.invincibleTicks <= 0 || this.invincibleTicks < 120 && this.invincibleTicks % 30 > 15) com__abagames__stgldemo__Player.shape.draw(this.pos);
        this.sManager.playerX = this.pos.x;
        this.sManager.playerY = this.pos.y;
        this.invincibleTicks--;
        return true;
    }
    
    protected function initialize() : void {
        this.pos.x = com__abagames__util__Screen.center.x;
        this.pos.y = com__abagames__util__Screen.size.y * 0.8;
    }
    
    protected var invincibleTicks : int = 0;
    protected var spPos : com__abagames__util__Xy;
    protected var fireTicks : int = 0;
    protected var sManager : com__abagames__util__stgl__StglManager;
    public var isAbleToMove : Boolean = true;
    static protected var shape : com__abagames__util__DotShape = new com__abagames__util__DotShape().c(com__abagames__util__Color.cyan.getRz(),com__abagames__util__Color.cyan.getRz().getRz()).sa(3,2,1).fr(5,3).c(com__abagames__util__Color.cyan.getGz().getGz().getGz(),com__abagames__util__Color.green.getBz()).o(5,0).fr(2,5).o(-5,0).fr(2,5).c(com__abagames__util__Color.green,com__abagames__util__Color.cyan.getGz()).o(0,-5).fr(3,5);
    static protected var dstSe : com__abagames__util__Se = new com__abagames__util__Se().b(com__abagames__util__SeType.NoiseScale).t(0.7,3,0.2).t(0.3,3,0.9).t(0.5,5,0).e();
}

dynamic class com__abagames__stgldemo__SActor extends com__abagames__util__Actor {
    public function com__abagames__stgldemo__SActor(stglActor : com__abagames__util__stgl__StglActor = null) : void { if( !flash__Boot.skip_constructor ) {
        super();
        this.stglActor = stglActor;
        this.pPos = new com__abagames__util__Xy();
        this.sVel = new com__abagames__util__Xy();
        {
            var $e : enum = (stglActor.type);
            switch( $e.index ) {
            case 2:
            if(stglActor.name.substr(0,3) == "big") {
                this.shape = com__abagames__stgldemo__SActor.bigEnemyShape;
                this.shield = 50;
                this.size.x = 90;
                this.size.y = 60;
            }
            else if(stglActor.name.substr(0,3) == "mid") {
                this.shape = com__abagames__stgldemo__SActor.midEnemyShape;
                this.shield = 10;
                this.size.x = 60;
                this.size.y = 45;
            }
            else {
                this.shape = com__abagames__stgldemo__SActor.enemyShape;
                this.size.setV(30);
            }
            break;
            case 3:
            this.shape = com__abagames__stgldemo__SActor.turretShape;
            break;
            case 4:
            {
                this.size.setV(15);
                this.shape = com__abagames__stgldemo__SActor.bulletShape;
            }
            break;
            default:
            break;
            }
        }
    }}
    
    protected function destroy() : void {
        if(this.stglActor.type == com__abagames__util__stgl__ActorType.Enemy) {
            com__abagames__util__Particle.add(this.pos,com__abagames__util__Color.red.getGz().getGz(),20,20,10);
            if(this.stglActor.name.substr(0,3) == "big") com__abagames__stgldemo__SActor.bigDstSe.play();
            else if(this.stglActor.name.substr(0,3) == "mid") com__abagames__stgldemo__SActor.midDstSe.play();
            else com__abagames__stgldemo__SActor.dstSe.play();
        }
        else if(this.stglActor.type == com__abagames__util__stgl__ActorType.Bullet) com__abagames__util__Particle.add(this.pos,com__abagames__util__Color.magenta.getGz(),10,10,5);
        this.stglActor.vanish();
    }
    
    public function hit(s : *) : void {
        if(!this.stglActor.getExists()) return;
        if(Std._is(s,com__abagames__stgldemo__Shot)) {
            if(this.stglActor.type != com__abagames__util__stgl__ActorType.Enemy) return;
            if(--this.shield <= 0) {
                this.destroy();
                com__abagames__util__Frame.i.score++;
            }
            else com__abagames__util__Particle.add(this.pos,com__abagames__util__Color.red.getGz().getGz().getGz(),10,10,10,30,0,1);
            s.remove();
        }
        else if(Std._is(s,com__abagames__stgldemo__Player)) {
            if(this.stglActor.type == com__abagames__util__stgl__ActorType.Enemy || this.stglActor.type == com__abagames__util__stgl__ActorType.Bullet) {
                this.destroy();
                s.destroy();
            }
        }
    }
    
    public override function update() : Boolean {
        if(!this.stglActor.update()) return false;
        this.pos.x = this.stglActor.xVar.value * com__abagames__util__Screen.size.x;
        this.pos.y = this.stglActor.yVar.value * com__abagames__util__Screen.size.y;
        this.angle = this.stglActor.angleVar.value * Math.PI / 180;
        if(this.stglActor.type == com__abagames__util__stgl__ActorType.Bullet) {
            if(!com__abagames__util__Screen.isIn(this.pos,10)) return false;
            this.sVel.setXy(this.pos);
            this.sVel.decrementBy(this.pPos);
            var s : Number = this.sVel.length;
            var t : int = this.stglActor.ticks;
            if(t == 2) {
                if(this.stglActor.parent.type != com__abagames__util__stgl__ActorType.Bullet) {
                    com__abagames__util__Particle.add(this.pos,com__abagames__util__Color.red.getGz().getGz(),15,5,s,60,this.angle,1);
                    com__abagames__stgldemo__SActor.fireSe.play();
                }
            }
            else if(t > 2) com__abagames__util__Particle.add(this.pos,com__abagames__util__Color.magenta.getGz(),5,1,s,15,this.angle + Math.PI,0);
            com__abagames__stgldemo__SActor.bulletShape.draw(this.pos,this.angle);
        }
        if(this.shape != null) this.shape.draw(this.pos,this.angle);
        this.pPos.setXy(this.pos);
        return true;
    }
    
    protected var shield : int = 1;
    protected var shape : com__abagames__util__DotShape = null;
    protected var sVel : com__abagames__util__Xy;
    protected var pPos : com__abagames__util__Xy;
    protected var stglActor : com__abagames__util__stgl__StglActor;
    static public var s : Array;
    static protected var enemyShape : com__abagames__util__DotShape = new com__abagames__util__DotShape().c(com__abagames__util__Color.red.getGz(),com__abagames__util__Color.red.getGz().getGz()).sa(1,2,3).fr(5,4).c(com__abagames__util__Color.yellow.getRz().getRz(),com__abagames__util__Color.yellow.getRz()).sa(8,0,7).o(5,-1).fr(2,4).o(-5,-1).fr(2,4);
    static protected var midEnemyShape : com__abagames__util__DotShape = new com__abagames__util__DotShape().c(com__abagames__util__Color.red.getGz(),com__abagames__util__Color.red.getGz().getGz()).sa(9,4,0).o(0,-2).fr(5,4).o(0,2).fr(7,4).c(com__abagames__util__Color.yellow.getRz().getRz(),com__abagames__util__Color.yellow.getRz()).sa(7,5,0).o(7,-4).fr(3,5).o(-7,-4).fr(3,5).o(8,4).fr(4,6).o(-8,4).fr(4,6);
    static protected var bigEnemyShape : com__abagames__util__DotShape = new com__abagames__util__DotShape().c(com__abagames__util__Color.red.getGz(),com__abagames__util__Color.red.getGz().getGz()).sa(4,5,6).fr(5,4).o(0,-5).fr(7,4).o(0,5).fr(9,4).c(com__abagames__util__Color.yellow.getRz().getRz(),com__abagames__util__Color.yellow.getRz()).sa(6,5,4).o(9,0).fr(5,4).o(-9,0).fr(5,4).o(9,7).fr(6,5).o(-9,7).fr(6,5).o(9,-7).fr(7,6).o(-9,-7).fr(7,6);
    static protected var turretShape : com__abagames__util__DotShape = new com__abagames__util__DotShape().c(com__abagames__util__Color.yellow.getRz().getRz(),com__abagames__util__Color.red.getGz()).sa(3,2,1).lc(1);
    static protected var bulletShape : com__abagames__util__DotShape = new com__abagames__util__DotShape().c(com__abagames__util__Color.red.getBz().getBz(),com__abagames__util__Color.magenta.getRz().getRz()).sa(2,1).fr(1,3).c(com__abagames__util__Color.red).lr(3,5);
    static protected var fireSe : com__abagames__util__Se = new com__abagames__util__Se().b(com__abagames__util__SeType.Noise,64,12).t(0,2,0.5).e();
    static protected var dstSe : com__abagames__util__Se = new com__abagames__util__Se().b(com__abagames__util__SeType.Noise).t(0.7,2,0.3).t(0.5,3,0).e();
    static protected var midDstSe : com__abagames__util__Se = new com__abagames__util__Se().b(com__abagames__util__SeType.Noise).t(0.6,2,0.3).t(0.9,5,0.1).e();
    static protected var bigDstSe : com__abagames__util__Se = new com__abagames__util__Se().b(com__abagames__util__SeType.Noise).t(0.9,5,0).t(0,10,0.3).e();
    static public function countEnemies() : int {
        var c : int = 0;
        {
            var _g : int = 0, _g1 : Array = com__abagames__stgldemo__SActor.s;
            while(_g < _g1.length) {
                var a : com__abagames__stgldemo__SActor = _g1[_g];
                ++_g;
                if(a.stglActor.type == com__abagames__util__stgl__ActorType.Enemy) c++;
            }
        }
        return c;
    }
    
}

dynamic class com__abagames__util__stgl__StglManager {
    public function com__abagames__util__stgl__StglManager() : void {
    }
    
    public function getEnemyCount() : int {
        return com__abagames__stgldemo__SActor.countEnemies();
    }
    
    public function add(stglActor : com__abagames__util__stgl__StglActor) : void {
        var actor : com__abagames__stgldemo__SActor = new com__abagames__stgldemo__SActor(stglActor);
        com__abagames__stgldemo__SActor.s.push(actor);
    }
    
    public function get enemyCount() : int { return getEnemyCount(); }
    protected function set enemyCount( __v : int ) : void { $enemyCount = __v; }
    protected var $enemyCount : int;
    public var playerY : Number = 240.0;
    public var playerX : Number = 160.0;
    public var screenHeight : Number = 480.0;
    public var screenWidth : Number = 320.0;
    public var baseSpeed : Number = 0.01;
}

import flash.geom.Vector3D;
dynamic class com__abagames__stgldemo__Shot extends com__abagames__util__Actor {
    public function com__abagames__stgldemo__Shot(p : flash.geom.Vector3D = null) : void { if( !flash__Boot.skip_constructor ) {
        super();
        this.pos.setXy(p);
        this.vel.y = -15;
        this.size.setV(30);
    }}
    
    public function remove() : void {
        this.isRemoving = true;
    }
    
    public override function update() : Boolean {
        if(this.isRemoving) return false;
        this.pos.incrementBy(this.vel);
        com__abagames__util__Actor.checkHitRect(this,com__abagames__stgldemo__SActor.s,true);
        com__abagames__stgldemo__Shot.shape.draw(this.pos);
        return com__abagames__util__Screen.isIn(this.pos,10);
    }
    
    protected var isRemoving : Boolean = false;
    static public var s : Array;
    static protected var shape : com__abagames__util__DotShape = new com__abagames__util__DotShape().c(com__abagames__util__Color.green.getRz().getRz(),com__abagames__util__Color.cyan.getRz().getRz()).sa(0,1,1).o(4,0).fr(2,5).o(-4,0).fr(2,5);
}

dynamic class com__abagames__stgldemo__Star extends com__abagames__util__Actor {
    public function com__abagames__stgldemo__Star() : void { if( !flash__Boot.skip_constructor ) {
        super();
        this.pos.x = com__abagames__util__Frame.i.random.sx();
        this.vel.y = com__abagames__util__Frame.i.random.n(5,1);
        this.color = com__abagames__util__Color.white.getBlink().getI();
    }}
    
    public override function update() : Boolean {
        this.pos.incrementBy(this.vel);
        com__abagames__util__Screen.fillRect(this.pos.x,this.pos.y,3,3,this.color);
        return this.pos.y < com__abagames__util__Screen.size.y;
    }
    
    protected var color : int;
    static public var s : Array;
}

dynamic final class com__abagames__util__LetterAlign extends enum {
    public static const __isenum : Boolean = true;
    public function com__abagames__util__LetterAlign( t : String, index : int, p : Array = null ) : void { this.tag = t; this.index = index; this.params = p; }
    public static var Center : com__abagames__util__LetterAlign = new com__abagames__util__LetterAlign("Center",1);
    public static var Left : com__abagames__util__LetterAlign = new com__abagames__util__LetterAlign("Left",0);
    public static var Right : com__abagames__util__LetterAlign = new com__abagames__util__LetterAlign("Right",2);
    public static var __constructs__ : Array = ["Left","Center","Right"];;
}

dynamic class com__abagames__util__Message extends com__abagames__util__Actor {
    public function com__abagames__util__Message() : void { if( !flash__Boot.skip_constructor ) {
        super();
    }}
    
    public override function update() : Boolean {
        this.pos.incrementBy(this.vel);
        com__abagames__util__Letter.draw(this.text,this.pos.x,this.pos.y);
        return --this.ticks > 0;
    }
    
    public var ticks : int;
    public var text : String;
    static public var s : Array;
    static protected var shownMessages : Array = new Array();
    static public function addOnce(text : String,pos : com__abagames__util__Xy,vx : Number = 0,vy : Number = 0,ticks : int = 240) : com__abagames__util__Message {
        {
            var _g : int = 0, _g1 : Array = com__abagames__util__Message.shownMessages;
            while(_g < _g1.length) {
                var m : String = _g1[_g];
                ++_g;
                if(m == text) return null;
            }
        }
        com__abagames__util__Message.shownMessages.push(text);
        return com__abagames__util__Message.add(text,pos,vx,vy,ticks);
    }
    
    static public function add(text : String,pos : com__abagames__util__Xy,vx : Number = 0,vy : Number = 0,ticks : int = 60) : com__abagames__util__Message {
        var m : com__abagames__util__Message = new com__abagames__util__Message();
        m.text = text;
        m.pos.setXy(pos);
        m.vel.x = vx / ticks;
        m.vel.y = vy / ticks;
        m.ticks = ticks;
        com__abagames__util__Message.s.push(m);
        return m;
    }
    
    static public function initialize() : void {
        com__abagames__util__Message.s = new Array();
    }
    
    static public function updateAll() : void {
        com__abagames__util__Actor.updateAll(com__abagames__util__Message.s);
    }
    
}

dynamic class com__abagames__util__Particle extends com__abagames__util__Actor {
    public function com__abagames__util__Particle() : void { if( !flash__Boot.skip_constructor ) {
        super();
    }}
    
    public override function update() : Boolean {
        this.pos.incrementBy(this.vel);
        this.vel.scaleBy(0.98);
        if(this.isExpand) {
            this.scale *= 1.5;
            if(this.scale > this.targetSize) this.isExpand = false;
        }
        else this.scale *= 0.95;
        com__abagames__util__Screen.fillRect(this.pos.x,this.pos.y,this.scale,this.scale,this.color.getBlink().getI());
        return --this.ticks > 0;
    }
    
    protected var isExpand : Boolean = true;
    protected var targetSize : Number;
    protected var scale : Number = 1.0;
    protected var color : com__abagames__util__Color;
    protected var ticks : int;
    static public function add(pos : com__abagames__util__Xy,color : com__abagames__util__Color,size : Number,count : int,speed : Number,ticks : Number = 60,angle : Number = 0,angleWidth : Number = 6.28) : void {
        var random : com__abagames__util__Random = com__abagames__util__Frame.i.random;
        {
            var _g : int = 0;
            while(_g < count) {
                var i : int = _g++;
                var pt : com__abagames__util__Particle = new com__abagames__util__Particle();
                pt.color = color;
                pt.targetSize = size;
                pt.pos.setXy(pos);
                pt.vel.addAngle(angle + random.pmn(angleWidth / 2),random.n(speed));
                pt.ticks = Std._int(ticks * random.n(1,0.5));
                com__abagames__util__Particle.s.push(pt);
            }
        }
    }
    
    static public var s : Array;
    static public function initialize() : void {
        com__abagames__util__Particle.s = new Array();
    }
    
    static public function updateAll() : void {
        com__abagames__util__Actor.updateAll(com__abagames__util__Particle.s);
    }
    
}

dynamic final class com__abagames__util__SeType extends enum {
    public static const __isenum : Boolean = true;
    public function com__abagames__util__SeType( t : String, index : int, p : Array = null ) : void { this.tag = t; this.index = index; this.params = p; }
    public static var Major : com__abagames__util__SeType = new com__abagames__util__SeType("Major",0);
    public static var Minor : com__abagames__util__SeType = new com__abagames__util__SeType("Minor",1);
    public static var Noise : com__abagames__util__SeType = new com__abagames__util__SeType("Noise",2);
    public static var NoiseScale : com__abagames__util__SeType = new com__abagames__util__SeType("NoiseScale",3);
    public static var __constructs__ : Array = ["Major","Minor","Noise","NoiseScale"];;
}

import flash.geom.Vector3D;
dynamic class com__abagames__util__Xy extends flash.geom.Vector3D {
    public function com__abagames__util__Xy(x : Number = 0,y : Number = 0) : void { if( !flash__Boot.skip_constructor ) {
        super(x,y);
    }}
    
    public function getYi() : int {
        return Std._int(this.y);
    }
    
    public function getXi() : int {
        return Std._int(this.x);
    }
    
    public function getAngle() : Number {
        return Math.atan2(this.x,this.y);
    }
    
    public function setXy(v : flash.geom.Vector3D) : flash.geom.Vector3D {
        this.x = v.x;
        this.y = v.y;
        return this;
    }
    
    public function setV(v : Number) : Number {
        return this.x = this.y = v;
    }
    
    public function get yi() : int { return getYi(); }
    protected function set yi( __v : int ) : void { $yi = __v; }
    protected var $yi : int;
    public function get xi() : int { return getXi(); }
    protected function set xi( __v : int ) : void { $xi = __v; }
    protected var $xi : int;
    public function get angle() : Number { return getAngle(); }
    protected function set angle( __v : Number ) : void { $angle = __v; }
    protected var $angle : Number;
    protected function get xy() : flash.geom.Vector3D { return $xy; }
    public function set xy( __v : flash.geom.Vector3D ) : void { setXy(__v); }
    protected var $xy : flash.geom.Vector3D;
    protected function get v() : Number { return $v; }
    public function set v( __v : Number ) : void { setV(__v); }
    protected var $v : Number;
    public function rotate(a : Number) : void {
        var px : Number = this.x;
        this.x = -this.x * Math.cos(a) + this.y * Math.sin(a);
        this.y = px * Math.sin(a) + this.y * Math.cos(a);
    }
    
    public function addAngle(a : Number,s : Number) : void {
        this.x += Math.sin(a) * s;
        this.y += Math.cos(a) * s;
    }
    
    public function wayTo(p : flash.geom.Vector3D) : Number {
        return Math.atan2(p.x - this.x,p.y - this.y);
    }
    
    public function distanceTo(p : flash.geom.Vector3D) : Number {
        var ox : Number = p.x - this.x;
        var oy : Number = p.y - this.y;
        return Math.sqrt(ox * ox + oy * oy);
    }
    
    static public var ZERO : com__abagames__util__Xy = new com__abagames__util__Xy();
}

dynamic final class com__abagames__util__stgl__ActorType extends enum {
    public static const __isenum : Boolean = true;
    public function com__abagames__util__stgl__ActorType( t : String, index : int, p : Array = null ) : void { this.tag = t; this.index = index; this.params = p; }
    public static var Bullet : com__abagames__util__stgl__ActorType = new com__abagames__util__stgl__ActorType("Bullet",4);
    public static var Enemy : com__abagames__util__stgl__ActorType = new com__abagames__util__stgl__ActorType("Enemy",2);
    public static var None : com__abagames__util__stgl__ActorType = new com__abagames__util__stgl__ActorType("None",0);
    public static var Stage : com__abagames__util__stgl__ActorType = new com__abagames__util__stgl__ActorType("Stage",1);
    public static var Turret : com__abagames__util__stgl__ActorType = new com__abagames__util__stgl__ActorType("Turret",3);
    public static var __constructs__ : Array = ["None","Stage","Enemy","Turret","Bullet"];;
}

dynamic final class com__abagames__util__stgl__CommandType extends enum {
    public static const __isenum : Boolean = true;
    public function com__abagames__util__stgl__CommandType( t : String, index : int, p : Array = null ) : void { this.tag = t; this.index = index; this.params = p; }
    public static function Function(name : String) : com__abagames__util__stgl__CommandType { return new com__abagames__util__stgl__CommandType("Function",6,[name]); }
    public static var Notify : com__abagames__util__stgl__CommandType = new com__abagames__util__stgl__CommandType("Notify",5);
    public static var Repeat : com__abagames__util__stgl__CommandType = new com__abagames__util__stgl__CommandType("Repeat",0);
    public static var Vanish : com__abagames__util__stgl__CommandType = new com__abagames__util__stgl__CommandType("Vanish",4);
    public static function Var(name : String, type : com__abagames__util__stgl__VarCommandType) : com__abagames__util__stgl__CommandType { return new com__abagames__util__stgl__CommandType("Var",7,[name,type]); }
    public static var Wait : com__abagames__util__stgl__CommandType = new com__abagames__util__stgl__CommandType("Wait",2);
    public static var WaitUntil : com__abagames__util__stgl__CommandType = new com__abagames__util__stgl__CommandType("WaitUntil",3);
    public static var While : com__abagames__util__stgl__CommandType = new com__abagames__util__stgl__CommandType("While",1);
    public static var __constructs__ : Array = ["Repeat","While","Wait","WaitUntil","Vanish","Notify","Function","Var"];;
}

dynamic final class com__abagames__util__stgl__Operator extends enum {
    public static const __isenum : Boolean = true;
    public function com__abagames__util__stgl__Operator( t : String, index : int, p : Array = null ) : void { this.tag = t; this.index = index; this.params = p; }
    public static var And : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("And",18);
    public static var Cos : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Cos",1);
    public static var Division : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Division",8);
    public static var Equal : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Equal",16);
    public static var Greater : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Greater",12);
    public static var GreaterEqual : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("GreaterEqual",13);
    public static var IntRandom : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("IntRandom",4);
    public static var Lesser : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Lesser",14);
    public static var LesserEqual : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("LesserEqual",15);
    public static var Minus : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Minus",11);
    public static var Modolo : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Modolo",9);
    public static var Multiple : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Multiple",7);
    public static var NotEqual : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("NotEqual",17);
    public static var NumberRandom : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("NumberRandom",5);
    public static var Or : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Or",19);
    public static var OrRandom : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("OrRandom",6);
    public static var Plus : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Plus",10);
    public static function ReadOnlyVariable(name : String) : com__abagames__util__stgl__Operator { return new com__abagames__util__stgl__Operator("ReadOnlyVariable",22,[name]); }
    public static var Sin : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Sin",0);
    public static var Ternary : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("Ternary",20);
    public static var UnaryMinus : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("UnaryMinus",2);
    public static var UnaryNot : com__abagames__util__stgl__Operator = new com__abagames__util__stgl__Operator("UnaryNot",3);
    public static function Value(v : Number) : com__abagames__util__stgl__Operator { return new com__abagames__util__stgl__Operator("Value",23,[v]); }
    public static function Variable(name : String) : com__abagames__util__stgl__Operator { return new com__abagames__util__stgl__Operator("Variable",21,[name]); }
    public static var __constructs__ : Array = ["Sin","Cos","UnaryMinus","UnaryNot","IntRandom","NumberRandom","OrRandom","Multiple","Division","Modolo","Plus","Minus","Greater","GreaterEqual","Lesser","LesserEqual","Equal","NotEqual","And","Or","Ternary","Variable","ReadOnlyVariable","Value"];;
}

dynamic final class com__abagames__util__stgl__VarCommandType extends enum {
    public static const __isenum : Boolean = true;
    public function com__abagames__util__stgl__VarCommandType( t : String, index : int, p : Array = null ) : void { this.tag = t; this.index = index; this.params = p; }
    public static var Add : com__abagames__util__stgl__VarCommandType = new com__abagames__util__stgl__VarCommandType("Add",1);
    public static var Assignment : com__abagames__util__stgl__VarCommandType = new com__abagames__util__stgl__VarCommandType("Assignment",0);
    public static var ConsistentlyAdd : com__abagames__util__stgl__VarCommandType = new com__abagames__util__stgl__VarCommandType("ConsistentlyAdd",4);
    public static var ConsistentlyAssignment : com__abagames__util__stgl__VarCommandType = new com__abagames__util__stgl__VarCommandType("ConsistentlyAssignment",3);
    public static var ConsistentlySub : com__abagames__util__stgl__VarCommandType = new com__abagames__util__stgl__VarCommandType("ConsistentlySub",5);
    public static var Sub : com__abagames__util__stgl__VarCommandType = new com__abagames__util__stgl__VarCommandType("Sub",2);
    public static var Target : com__abagames__util__stgl__VarCommandType = new com__abagames__util__stgl__VarCommandType("Target",6);
    public static var __constructs__ : Array = ["Assignment","Add","Sub","ConsistentlyAssignment","ConsistentlyAdd","ConsistentlySub","Target"];;
}

dynamic class EReg {
    public function EReg(r : String = null,opt : String = null) : void { if( !flash__Boot.skip_constructor ) {
        this.r = new RegExp(r,opt);
    }}
    
    public function customReplace(s : String,f : Function) : String {
        var buf : StringBuf = new StringBuf();
        while(true) {
            if(!this.match(s)) break;
            buf.add(this.matchedLeft());
            buf.add(f(this));
            s = this.matchedRight();
        }
        buf.add(s);
        return buf.toString();
    }
    
    public function replace(s : String,by : String) : String {
        return s.replace(this.r,by);
    }
    
    public function split(s : String) : Array {
        var d : String = "#__delim__#";
        var s1 : String = s.replace(this.r,d);
        return s1.split(d);
    }
    
    public function matchedPos() : * {
        if(this.result == null) throw "No string matched";
        return { pos : this.result.index, len : this.result[0].length}
    }
    
    public function matchedRight() : String {
        if(this.result == null) throw "No string matched";
        var rl : int = this.result.index + this.result[0].length;
        var s : String = this.result.input;
        return s.substr(rl,s.length - rl);
    }
    
    public function matchedLeft() : String {
        if(this.result == null) throw "No string matched";
        var s : String = this.result.input;
        return s.substr(0,this.result.index);
    }
    
    public function matched(n : int) : String {
        return ((this.result != null && n >= 0 && n < this.result.length)?this.result[n]:(function($this:EReg) : String {
            var $r : String;
            throw "EReg::matched";
            return $r;
        }(this)));
    }
    
    public function match(s : String) : Boolean {
        if(this.r.global) this.r.lastIndex = 0;
        this.result = this.r.exec(s);
        return this.result != null;
    }
    
    protected var result : *;
    protected var r : RegExp;
}

import flash.utils.Dictionary;
dynamic class Hash {
    public function Hash() : void { if( !flash__Boot.skip_constructor ) {
        this.h = new flash.utils.Dictionary();
    }}
    
    public function toString() : String {
        var s : StringBuf = new StringBuf();
        s.add("{");
        var it : * = this.keys();
        { var $it : * = it;
        while( $it.hasNext() ) { var i : String = $it.next();
        {
            s.add(i);
            s.add(" => ");
            s.add(Std.string(this.get(i)));
            if(it.hasNext()) s.add(", ");
        }
        }}
        s.add("}");
        return s.toString();
    }
    
    public function iterator() : * {
        return { ref : this.h, it : (function($this:Hash) : * {
            var $r : *;
            $r = new Array();
            for(var $k2 : String in $this.h) $r.push($k2);
            return $r;
        }(this)).iterator(), hasNext : function() : * {
            return this.it.hasNext();
        }, next : function() : * {
            var i : * = this.it.next();
            return this.ref[i];
        }}
    }
    
    public function keys() : * {
        return (function($this:Hash) : * {
            var $r : *;
            $r = new Array();
            for(var $k2 : String in $this.h) $r.push($k2.substr(1));
            return $r;
        }(this)).iterator();
    }
    
    public function remove(key : String) : Boolean {
        key = "$" + key;
        if(!this.h.hasOwnProperty(key)) return false;
        delete(this.h[key]);
        return true;
    }
    
    public function exists(key : String) : Boolean {
        return this.h.hasOwnProperty("$" + key);
    }
    
    public function get(key : String) : * {
        return this.h["$" + key];
    }
    
    public function set(key : String,value : *) : void {
        this.h["$" + key] = value;
    }
    
    protected var h : flash.utils.Dictionary;
}

dynamic class IntIter {
    public function IntIter(min : int = 0,max : int = 0) : void { if( !flash__Boot.skip_constructor ) {
        this.min = min;
        this.max = max;
    }}
    
    public function next() : int {
        return this.min++;
    }
    
    public function hasNext() : Boolean {
        return this.min < this.max;
    }
    
    protected var max : int;
    protected var min : int;
}

dynamic class Std {
    static public function _is(v : *,t : *) : Boolean {
        return flash__Boot.__instanceof(v,t);
    }
    
    static public function string(s : *) : String {
        return flash__Boot.__string_rec(s,"");
    }
    
    static public function _int(x : Number) : int {
        return int(x);
    }
    
    static public function _parseInt(x : String) : * {
        var v : * = parseInt(x);
        if(isNaN(v)) return null;
        return v;
    }
    
    static public function _parseFloat(x : String) : Number {
        return parseFloat(x);
    }
    
    static public function random(x : int) : int {
        return Math.floor(Math.random() * x);
    }
    
}

dynamic class StringBuf {
    public function StringBuf() : void {
    }
    
    public function toString() : String {
        return this.b;
    }
    
    public function addSub(s : String,pos : int,len : * = null) : void {
        this.b += s.substr(pos,len);
    }
    
    public function addChar(c : int) : void {
        this.b += String.fromCharCode(c);
    }
    
    public function add(x : *) : void {
        this.b += Std.string(x);
    }
    
    protected var b : String = "";
}

dynamic class com__abagames__stgldemo__Sample {
    static public var s : Array = [["fire bullet",":stage\nmain\n\tfire 0, 1"],["V nway bullet",":stage\nmain\n\tvnway 15, 80\n:turret\nvnway count, angle\n\tatp = $angleToPlayer\n\toa = 0\n\ts = 1\n\tfire atp, s\n\trc = count / 2 - 1\n\tia = angle / rc\n\tis = 2 / rc\n\trepeat rc\n\t\twait 3\n\t\toa += ia\n\t\ts += is\n\t\tfire atp + oa, s\n\t\tfire atp - oa, s"],["wave bullet",":stage\nmain\n\trepeat 5\n\t\trfBullet -45, 5\n\t\twait 30\n\t\trfBullet 45, -5\n\t\twait 30\n:bullet\nrfBullet angle, roll\n\t@angle = angle\n\t@speed = 1\n\ta = $angleToPlayer\n\trepeat 10\n\t\twait 3\n\t\tfire a, 1\n\t\ta += roll\n\tvanish"],["bounce bullet",":stage\nmain\n\trepeat 10\n\t\tbnBullet $angleToPlayer\n\t\tbnBullet $angleToPlayer - 45\n\t\tbnBullet $angleToPlayer + 45\n\t\twait 20\n:bullet\nbnBullet a\n\t@angle = a\n\t@speed = 1\n\t@angle <+= @x < 0 && @angle < 0 ? (-@angle * 2) : (@x > 1 && @angle > 0 ? (-@angle * 2) : 0)\n\twait 480\n\tvanish"],["descent bullet",":stage\nmain\n\trepeat 10\n\t\tsoBullet\n\t\twait 30\n:bullet\nsoBullet\n\tvx = -0.02__0.02\n\t@x <+= vx\n\tvy = 0\n\t@y <+= vy\n\tvy <+= 0.0005\n\trepeat\n\t\tfire $angleToPlayer, 1\n\t\twait 10"],["rusher enemy",":stage\nmain\n\ts = 0.003\n\trepeat 30\n\t\trusherEnemy s\n\t\ts += 0.0007\n\t\twait 60 / (s / 0.003)\n:enemy\nrusherEnemy s\n\t@x = 0.1__0.9\n\t@y = -0.1\n\t@y <+= s\n\trepeat\n\t\twait 30\n\t\tvariableSpeedBullet\n:bullet\nvariableSpeedBullet\n\t@angle = $angleToPlayer\n\t@speed = 0.5__1.5"],["turn enemy",":stage\nmain\n\trepeat 10\n\t\tturnEnemy\n\t\twait 60\n:enemy\nturnEnemy\n\t@x = 0__1\n\t@y = 0\n\t@angle = $angleToPlayer + -10__10\n\ts = 1__1.5\n\t@speed = s\n\twaitUntil @y > $playerY - 0.2\n\t@speed = 0\n\t@angle => $angleToPlayer + 180|-180 + -30__30, 15\n\twait 15\n\tfire $angleToPlayer, 1\n\t@speed = s * 2"],["explode enemy",":stage\nmain\n\tgzkt\n:enemy\ngzkt\n\t@x = 0.1__0.9\n\t@y = -0.1\n\t@y <+= 0.015\n\twait 30\n\ta = 0\n\trepeat 16\n\t\tfire a, 2\n\t\ta += 360 / 16\n\trepeat 4\n\t\thoming a\n\t\ta += 360 / 4\n\tvanish\n:bullet\nhoming a\n\tvx = sin(a) * 0.01\n\tvy = cos(a) * 0.01\n\t@x <+= vx\n\t@y <+= vy\n\tvx <+= ($px - @x) * 0.003\n\tvy <+= ($py - @y) * 0.003"],["turn 90 enemy",":stage\nmain\n\trepeat 20\n\t\tt90Enemy 0.015\n\t\twait 30\n:enemy\nt90Enemy s\n\t@x = 0.1__0.9\n\t@y = -0.1\n\t@y <+= s\n\twaitUntil @y > $py\n\t@y = @y\n\tvx = @x < $px ? 1 : -1\n\t@x <+= vx * s\n\trepeat\n\t\twait 15\n\t\tvariableSpeedBullet\n:bullet\nvariableSpeedBullet\n\t@angle = $angleToPlayer\n\t@speed = 0.5__1.5"],["wave enemy",":stage\nmain\n\taddWaves 10\naddWaves count\n\txs = $playerX > 0.5 ? -1 : 1\n\t@y = -0.1\n\trepeat count\n\t\twave 800, 0.003, xs\n\t\t@y -= 0.02\n\t\twait 2\n:enemy\nwave vx, vy, xs\n\t@x <= cos(@y * vx) * 0.4 * xs + 0.5\n\t@y <+= vy\n\tfirePeriod 60\n:turret\nfirePeriod interval\n\trepeat\n\t\tvariableSpeedBullet\n\t\twait interval\n:bullet\nvariableSpeedBullet\n\t@angle = $angleToPlayer\n\t@speed = 0.5__1.5"],["escaping enemy",":stage\nmain\n\trepeat 5\n\t\taddEscapeEnemy 2..4\n\t\tnotifyNoEnemy\n\t\twait 200\nnotifyNoEnemy\n\twaitUntil $enemyCount == 0\n\tnotify\naddEscapeEnemy count\n\tpx = $playerX < 0.5 ? 1 : -1\n\trepeat count\n\t\t@x = 0.5 + 0.3__0.6 * px\n\t\t@y = -0.3__-0.1\n\t\tescapeEnemy -px\n:enemy\nescapeEnemy xs\n\tvx = xs * 0.002\n\t@x <+= vx\n\t@y <+= 0.005\n\twaitUntil (@x - $playerX) * xs > -0.1\n\tvx <-= xs* 0.001\n\tfire $angleToPlayer, 1"],["mid whip enemy",":stage\nmain\n\t@y = -0.1\n\trepeat 10\n\t\t@x = 0.1__0.9\n\t\tmidWhipEnemy\n\t\twait 100..200\n:enemy\nmidWhipEnemy\n\twhipTurret -0.1\n\twhipTurret 0.1\n\t@y => 0.2, 60\n\twait 60\n\t@y => 0.5, 240\n\twait 240\n\t@y => 1.2, 120\n:turret\nwhipTurret ox\n\t@x <= $parentX + ox\n\twhile $parentY < 0.4\n\t\twait 60\n\t\ts = 1\n\t\trepeat 7\n\t\t\tfire $angleToPlayer, s\n\t\t\ts += 0.1\n\t\t\twait 3"],["mid rollig enemy",":stage\nmain\n\trepeat 10\n\t\tmidRbEnemy\n\t\twait 120\n:enemy\nmidRbEnemy\n\tsx = -1|1\n\t@x = 0.5 + 0.3__0.6 * sx\n\t@y = -0.1\n\t@x => 0.5 + 0.1__0.3 * sx, 60\n\t@y => 0.1__0.2, 60\n\twait 60\n\t@y <+= 0.4 / 200\n\trbTurret\n\twait 200\n\tvanish rbTurret\n\t@x => 0.5 + 0.7 * sx, 120\n:turret\nrbTurret\n\trepeat\n\t\ta = 0\n\t\trepeat 16\n\t\t\trBullet a\n\t\t\ta += 360 / 16\n\t\twait 60\n:bullet\nrBullet a\n\tr = 0\n\tr <+= 0.01\n\tva = 5\n\t@angle = a\n\t@angle <+= va\n\t@x <= $prx + sin(@angle) * r\n\t@y <= $pry + cos(@angle) * r\n\twait 20\n\tva => 0, 30"],["stage1",":stage\nmain\n\taddWaves 10\n\twait 150\n\trepeat 10\n\t\tt90Enemy 0.01\n\t\twait 20\n\twait 60\n\taddWaves 10\n\twait 150\n\trepeat 10\n\t\tt90Enemy 0.015\n\t\twait 20\n\twait 60\n\ts = 0.003\n\trepeat 20\n\t\trusherEnemy s\n\t\ts += 0.001\n\t\twait 60 / (s / 0.003)\n\taddBigEnemy1\n\twait 600\n\tvanish addBigEnemy1\n\trepeat 5\n\t\taddEscapeEnemy 2..4\n\t\tnotifyNoEnemy\n\t\twait 120\n\trepeat 10\n\t\tturnEnemy\n\t\twait 30\n\twait 60\n\tgzkt\n\twait 60\n\tbigEnemy2\naddBigEnemy1\n\tbigEnemy1\n\tnotifyNoEnemy\n\twait\n\trepeat\n\t\trusherEnemy 0.005\n\t\twait 40\nnotifyNoEnemy\n\twaitUntil $enemyCount == 0\n\tnotify\naddWaves count\n\txs = $playerX > 0.5 ? -1 : 1\n\t@y = -0.1\n\trepeat count\n\t\twave 800, 0.003, xs\n\t\t@y -= 0.02\n\t\twait 2\naddEscapeEnemy count\n\tpx = $playerX < 0.5 ? 1 : -1\n\trepeat count\n\t\t@x = 0.5 + 0.3__0.6 * px\n\t\t@y = -0.3__-0.1\n\t\tescapeEnemy -px\n:enemy\nwave vx, vy, xs\n\t@x <= cos(@y * vx) * 0.4 * xs + 0.5\n\t@y <+= vy\n\tfirePeriod 60\nt90Enemy s\n\t@x = 0.1__0.9\n\t@y = -0.1\n\t@y <+= s\n\twaitUntil @y > $py\n\t@y = @y\n\tvx = @x < $px ? 1 : -1\n\t@x <+= vx * s\n\trepeat\n\t\twait 15\n\t\tvariableSpeedBullet\nrusherEnemy s\n\t@x = 0.1__0.9\n\t@y = -0.1\n\t@y <+= s\n\trepeat\n\t\twait 30\n\t\tvariableSpeedBullet\nescapeEnemy xs\n\tvx = xs * 0.002\n\t@x <+= vx\n\t@y <+= 0.005\n\twaitUntil (@x - $playerX) * xs > -0.1\n\tvx <-= xs* 0.001\n\tfire $angleToPlayer, 1\nturnEnemy\n\t@x = 0__1\n\t@y = 0\n\t@angle = $angleToPlayer + -10__10\n\ts = 1__1.5\n\t@speed = s\n\twaitUntil @y > $playerY - 0.2\n\t@speed = 0\n\t@angle => $angleToPlayer + 180|-180 + -30__30, 15\n\twait 15\n\tfire $angleToPlayer, 1\n\t@speed = s * 2\ngzkt\n\t@x = 0.1__0.9\n\t@y = -0.1\n\t@y <+= 0.015\n\twait 30\n\ta = 0\n\trepeat 16\n\t\tfire a, 2\n\t\ta += 360 / 16\n\trepeat 4\n\t\thoming a\n\t\ta += 360 / 4\n\tvanish\nbigEnemy1\n\t@y = -0.1\n\t@x <= sin($ticks) * 0.3 + 0.5\n\t@y <+= 0.005\n\twait 60\n\tsy = @y\n\t@y <= sy + sin($ticks - 60) * 0.1\n\trepeat 26\n\t\tsoBullet\n\t\twait 20\n\t@y <-= 0.01\nbigEnemy2\n\t@y = -0.1\n\t@x <= -sin($ticks) * 0.3 + 0.5\n\t@y <+= 0.005\n\twait 60\n\tsy = @y\n\t@y <= sy + sin($ticks - 60) * 0.1\n\trepeat 3\n\t\trepeat 3\n\t\t\trfBullet -45, 5\n\t\t\twait 20\n\t\t\trfBullet 45, -5\n\t\t\twait 20\n\t\twait 40\n\t\trepeat 6\n\t\t\tbnBullet $angleToPlayer\n\t\t\tbnBullet $angleToPlayer - 30\n\t\t\tbnBullet $angleToPlayer - 60\n\t\t\tbnBullet $angleToPlayer + 30\n\t\t\tbnBullet $angleToPlayer + 60\n\t\t\twait 20\n\t\twait 40\n\t@y <-= 0.01\n:turret\nfirePeriod interval\n\trepeat\n\t\tvariableSpeedBullet\n\t\twait interval\n:bullet\nvariableSpeedBullet\n\t@angle = $angleToPlayer\n\t@speed = 0.5__1.5\nhoming a\n\tvx = sin(a) * 0.01\n\tvy = cos(a) * 0.01\n\t@x <+= vx\n\t@y <+= vy\n\tvx <+= ($px - @x) * 0.003\n\tvy <+= ($py - @y) * 0.003\nrfBullet angle, roll\n\t@angle = angle\n\t@speed = 1\n\ta = $angleToPlayer\n\trepeat 10\n\t\twait 3\n\t\tfire a, 1\n\t\ta += roll\n\tvanish\nbnBullet a\n\t@angle = a\n\t@speed = 1\n\t@angle <+= @x < 0 && @angle < 0 ? (-@angle * 2) : (@x > 1 && @angle > 0 ? (-@angle * 2) : 0)\n\twait 480\n\tvanish\nsoBullet\n\tvx = -0.02__0.02\n\t@x <+= vx\n\tvy = 0\n\t@y <+= vy\n\tvy <+= 0.0005\n\trepeat\n\t\tfire $angleToPlayer, 1\n\t\twait 10"]];
}

import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.media.Sound;
dynamic class com__abagames__util__Bgm {
    public function com__abagames__util__Bgm(sound : flash.media.Sound = null) : void { if( !flash__Boot.skip_constructor ) {
        this.sound = sound;
        this.soundTransform = new flash.media.SoundTransform();
    }}
    
    public function handleFadeOut() : void {
        if(this.soundChannel == null || !this.isFadingOut) return;
        this.soundTransform.volume -= 0.015;
        this.soundChannel.soundTransform = this.soundTransform;
        if(this.soundTransform.volume <= 0.05) this.stop();
    }
    
    protected var isFadingOut : Boolean = false;
    protected var soundTransform : flash.media.SoundTransform;
    protected var soundChannel : flash.media.SoundChannel;
    protected var sound : flash.media.Sound;
    public function stop() : void {
        if(this.soundChannel == null) return;
        this.soundChannel.stop();
        this.soundChannel = null;
        com__abagames__util__Bgm.currentBgm = null;
    }
    
    public function fadeOut() : void {
        if(this.soundChannel == null) return;
        this.isFadingOut = true;
    }
    
    public function play() : void {
        if(com__abagames__util__Bgm.currentBgm != null) com__abagames__util__Bgm.currentBgm.stop();
        this.soundTransform.volume = 0.9;
        this.isFadingOut = false;
        this.soundChannel = this.sound.play(0,999999,this.soundTransform);
        com__abagames__util__Bgm.currentBgm = this;
    }
    
    static protected var currentBgm : com__abagames__util__Bgm;
    static public function update() : void {
        if(com__abagames__util__Bgm.currentBgm == null) return;
        com__abagames__util__Bgm.currentBgm.handleFadeOut();
    }
    
}

dynamic class com__abagames__util__Button {
    public function com__abagames__util__Button(text : String = null,x : Number = NaN,y : Number = NaN,width : Number = NaN,height : Number = NaN) : void { if( !flash__Boot.skip_constructor ) {
        this.text = text;
        this.pos = new com__abagames__util__Xy(x + width / 2,y + height / 2);
        this.size = new com__abagames__util__Xy(width,height);
        var sw : int = Std._int(width / 3);
        var sh : int = Std._int(height / 3);
        this.shape = new com__abagames__util__DotShape().c(com__abagames__util__Color.white.getDz()).lr(sw,sh);
        this.pressingShape = new com__abagames__util__DotShape().c(com__abagames__util__Color.white).lr(sw,sh);
        this.notOverShape = new com__abagames__util__DotShape().c(com__abagames__util__Color.white.getBz().getDz()).fr(sw - 2,sh - 2);
        this.overShape = new com__abagames__util__DotShape().c(com__abagames__util__Color.white.getRz().getDz()).fr(sw - 2,sh - 2);
    }}
    
    protected var wasPressed : Boolean = false;
    protected var overShape : com__abagames__util__DotShape;
    protected var notOverShape : com__abagames__util__DotShape;
    protected var pressingShape : com__abagames__util__DotShape;
    protected var shape : com__abagames__util__DotShape;
    protected var size : com__abagames__util__Xy;
    protected var pos : com__abagames__util__Xy;
    protected var text : String;
    public function update() : void {
        this.isClicked = false;
        this.isOver = Math.abs(this.pos.x - com__abagames__util__Mouse.pos.x) < this.size.x / 2 && Math.abs(this.pos.y - com__abagames__util__Mouse.pos.y) < this.size.y / 2;
        if(this.isOver) {
            if(com__abagames__util__Mouse.isPressing) {
                if(!this.wasPressed) this.isPressing = true;
            }
            else {
                if(this.isPressing) this.isClicked = true;
                this.isPressing = false;
            }
        }
        else this.isPressing = false;
        if(this.isPressing) this.pressingShape.draw(this.pos);
        else this.shape.draw(this.pos);
        if(this.isOver) this.overShape.draw(this.pos);
        else this.notOverShape.draw(this.pos);
        com__abagames__util__Letter.draw(this.text,this.pos.x,this.pos.y - 5);
        this.wasPressed = com__abagames__util__Mouse.isPressing;
    }
    
    public var isClicked : Boolean = false;
    public var isPressing : Boolean = false;
    public var isOver : Boolean = false;
}

dynamic class com__abagames__util__Color {
    public function com__abagames__util__Color(r : int = 0,g : int = 0,b : int = 0) : void { if( !flash__Boot.skip_constructor ) {
        this.r = r;
        this.g = g;
        this.b = b;
    }}
    
    protected function normalize() : void {
        this.r = com__abagames__util__IntUtil.clampi(this.r,0,250);
        this.g = com__abagames__util__IntUtil.clampi(this.g,0,250);
        this.b = com__abagames__util__IntUtil.clampi(this.b,0,250);
    }
    
    protected function changeValueColor(color : com__abagames__util__Color,rv : int,gv : int,bv : int) : void {
        color.setRgb(this);
        color.r += rv;
        color.g += gv;
        color.b += bv;
        color.normalize();
    }
    
    protected function changeValue(rv : int,gv : int,bv : int) : com__abagames__util__Color {
        var changedColor : com__abagames__util__Color = new com__abagames__util__Color();
        this.changeValueColor(changedColor,rv,gv,bv);
        return changedColor;
    }
    
    public function getBz() : com__abagames__util__Color {
        return this.changeValue(-25,-25,50);
    }
    
    public function getGz() : com__abagames__util__Color {
        return this.changeValue(-25,50,-25);
    }
    
    public function getRz() : com__abagames__util__Color {
        return this.changeValue(50,-25,-25);
    }
    
    public function getDz() : com__abagames__util__Color {
        return this.changeValue(-50,-50,-50);
    }
    
    public function getWz() : com__abagames__util__Color {
        return this.changeValue(50,50,50);
    }
    
    public function getBlink() : com__abagames__util__Color {
        var random : com__abagames__util__Random = com__abagames__util__Frame.i.random;
        this.changeValueColor(com__abagames__util__Color.blinkColor,random.i(128,-64),random.i(128,-64),random.i(128,-64));
        return com__abagames__util__Color.blinkColor;
    }
    
    public function setRgb(c : com__abagames__util__Color) : com__abagames__util__Color {
        this.r = c.r;
        this.g = c.g;
        this.b = c.b;
        return this;
    }
    
    public function getI() : int {
        return -16777216 + this.r * 65536 + this.g * 256 + this.b;
    }
    
    public function blend(c : com__abagames__util__Color,ratio : Number) : com__abagames__util__Color {
        return this.changeValue(Std._int((c.r - this.r) * ratio),Std._int((c.g - this.g) * ratio),Std._int((c.b - this.b) * ratio));
    }
    
    public function get bz() : com__abagames__util__Color { return getBz(); }
    protected function set bz( __v : com__abagames__util__Color ) : void { $bz = __v; }
    protected var $bz : com__abagames__util__Color;
    public function get gz() : com__abagames__util__Color { return getGz(); }
    protected function set gz( __v : com__abagames__util__Color ) : void { $gz = __v; }
    protected var $gz : com__abagames__util__Color;
    public function get rz() : com__abagames__util__Color { return getRz(); }
    protected function set rz( __v : com__abagames__util__Color ) : void { $rz = __v; }
    protected var $rz : com__abagames__util__Color;
    public function get dz() : com__abagames__util__Color { return getDz(); }
    protected function set dz( __v : com__abagames__util__Color ) : void { $dz = __v; }
    protected var $dz : com__abagames__util__Color;
    public function get wz() : com__abagames__util__Color { return getWz(); }
    protected function set wz( __v : com__abagames__util__Color ) : void { $wz = __v; }
    protected var $wz : com__abagames__util__Color;
    public function get blink() : com__abagames__util__Color { return getBlink(); }
    protected function set blink( __v : com__abagames__util__Color ) : void { $blink = __v; }
    protected var $blink : com__abagames__util__Color;
    protected function get rgb() : com__abagames__util__Color { return $rgb; }
    public function set rgb( __v : com__abagames__util__Color ) : void { setRgb(__v); }
    protected var $rgb : com__abagames__util__Color;
    public function get i() : int { return getI(); }
    protected function set i( __v : int ) : void { $i = __v; }
    protected var $i : int;
    public var b : int;
    public var g : int;
    public var r : int;
    static public var transparent : com__abagames__util__Color = new com__abagames__util__Color(-1);
    static public var black : com__abagames__util__Color = new com__abagames__util__Color(0,0,0);
    static public var red : com__abagames__util__Color = new com__abagames__util__Color(250,0,0);
    static public var green : com__abagames__util__Color = new com__abagames__util__Color(0,250,0);
    static public var blue : com__abagames__util__Color = new com__abagames__util__Color(0,0,250);
    static public var yellow : com__abagames__util__Color = new com__abagames__util__Color(250,250,0);
    static public var magenta : com__abagames__util__Color = new com__abagames__util__Color(250,0,250);
    static public var cyan : com__abagames__util__Color = new com__abagames__util__Color(0,250,250);
    static public var white : com__abagames__util__Color = new com__abagames__util__Color(250,250,250);
    static protected var LEVEL : int = 5;
    static protected var LEVEL_VALUE : int = 50;
    static protected var MAX_VALUE : int = 250;
    static protected var WHITENESS : int = 0;
    static protected var blinkColor : com__abagames__util__Color = new com__abagames__util__Color();
}

import flash.geom.Rectangle;
dynamic class com__abagames__util__DotShape {
    public function com__abagames__util__DotShape() : void { if( !flash__Boot.skip_constructor ) {
        this.dots = new Array();
        this.color = com__abagames__util__Color.transparent;
        this.colorSpot = com__abagames__util__Color.transparent;
        this.offset = new com__abagames__util__Xy();
    }}
    
    protected function setCircleDotsEdge(x : int,y : int,r : int) : void {
        var ry : Number = (y + r) / (r * 2);
        this.fd(-x,y,ry);
        this.fd(x,y,ry);
        ry = (-y + r) / (r * 2);
        this.fd(-x,-y,ry);
        this.fd(x,-y,ry);
    }
    
    protected function setXLine(xb : int,xe : int,y : int,r : int) : void {
        var ry : Number = (y + r) / (r * 2);
        {
            var _g1 : int = xb, _g : int = xe + 1;
            while(_g1 < _g) {
                var x : int = _g1++;
                this.fd(x,y,ry);
            }
        }
    }
    
    protected function setCircleDots(x : int,y : int,r : int) : void {
        this.setXLine(-x,x,y,r);
        this.setXLine(-x,x,-y,r);
    }
    
    protected function setCircle(radius : int,isDrawingEdge : Boolean = false) : com__abagames__util__DotShape {
        var d : int = 3 - radius * 2;
        var y : int = radius;
        {
            var _g1 : int = 0, _g : int = y + 1;
            while(_g1 < _g) {
                var x : int = _g1++;
                if(isDrawingEdge) {
                    this.setCircleDotsEdge(x,y,radius);
                    this.setCircleDotsEdge(y,x,radius);
                }
                else {
                    this.setCircleDots(x,y,radius);
                    this.setCircleDots(y,x,radius);
                }
                if(d < 0) d += 6 + x * 4;
                else {
                    d += 10 + x * 4 - y * 4;
                    y--;
                }
            }
        }
        return this;
    }
    
    protected function setRect(width : int,height : int,isDrawingEdge : Boolean = false) : com__abagames__util__DotShape {
        var ox : int = Std._int(-width / 2), oy : int = -Std._int(height / 2);
        {
            var _g : int = 0;
            while(_g < height) {
                var y : int = _g++;
                {
                    var _g1 : int = 0;
                    while(_g1 < width) {
                        var x : int = _g1++;
                        if(!isDrawingEdge || x == 0 || x == width - 1 || y == 0 || y == height - 1) this.fd(x + ox,y + oy,y / height);
                    }
                }
            }
        }
        return this;
    }
    
    protected var offset : com__abagames__util__Xy;
    protected var xyAngleVel : Number = 0.0;
    protected var yAngleVel : Number = 0.0;
    protected var xAngleVel : Number = 0.0;
    protected var spotThreshold : Number = 0.3;
    protected var colorBottomSpot : com__abagames__util__Color;
    protected var colorBottom : com__abagames__util__Color;
    protected var colorSpot : com__abagames__util__Color;
    protected var color : com__abagames__util__Color;
    protected var dots : Array;
    public function draw(pos : com__abagames__util__Xy,angle : Number = 0,scaleX : Number = 3,scaleY : Number = 0,rectScale : int = 0,color : com__abagames__util__Color = null) : void {
        var sx : Number = scaleX;
        var sy : Number = ((scaleY > 0)?scaleY:scaleX);
        if(rectScale > 0) com__abagames__util__DotShape.rect.width = com__abagames__util__DotShape.rect.height = rectScale;
        else {
            com__abagames__util__DotShape.rect.width = Math.abs(sx);
            com__abagames__util__DotShape.rect.height = Math.abs(sy);
        }
        var ox : int = Std._int(scaleX / 2), oy : int = Std._int(scaleY / 2);
        {
            var _g : int = 0, _g1 : Array = this.dots;
            while(_g < _g1.length) {
                var d : com__abagames__util__OffsetColor = _g1[_g];
                ++_g;
                com__abagames__util__DotShape.rPos.x = d.offset.x * sx;
                com__abagames__util__DotShape.rPos.y = d.offset.y * sy;
                if(angle != 0) com__abagames__util__DotShape.rPos.rotate(angle);
                com__abagames__util__DotShape.rect.x = Std._int(pos.x + com__abagames__util__DotShape.rPos.x) - ox;
                com__abagames__util__DotShape.rect.y = Std._int(pos.y + com__abagames__util__DotShape.rPos.y) - oy;
                if(color != null) com__abagames__util__Screen.bd.fillRect(com__abagames__util__DotShape.rect,color.getI());
                else com__abagames__util__Screen.bd.fillRect(com__abagames__util__DotShape.rect,d.color);
            }
        }
    }
    
    public function fd(x : int,y : int,ry : Number = 0) : com__abagames__util__DotShape {
        var ca : Number = Math.cos(x * this.xAngleVel) * Math.cos(y * this.yAngleVel) * Math.cos((x + y) * this.xyAngleVel);
        var c : com__abagames__util__Color;
        if(Math.abs(ca) < this.spotThreshold) {
            if(this.colorBottomSpot != null) c = this.colorSpot.blend(this.colorBottomSpot,ry);
            else c = this.colorSpot;
        }
        else if(this.colorBottom != null) c = this.color.blend(this.colorBottom,ry);
        else c = this.color;
        if(c.r < 0) return this;
        var d : com__abagames__util__OffsetColor = new com__abagames__util__OffsetColor();
        d.offset.x = x + this.offset.x;
        d.offset.y = y + this.offset.y;
        d.color = c.getI();
        this.dots.push(d);
        return this;
    }
    
    public function lc(radius : int) : com__abagames__util__DotShape {
        return this.setCircle(radius,true);
    }
    
    public function fc(radius : int) : com__abagames__util__DotShape {
        return this.setCircle(radius,false);
    }
    
    public function lr(width : int,height : int) : com__abagames__util__DotShape {
        return this.setRect(width,height,true);
    }
    
    public function fr(width : int,height : int) : com__abagames__util__DotShape {
        return this.setRect(width,height,false);
    }
    
    public function o(x : Number = 0,y : Number = 0) : com__abagames__util__DotShape {
        this.offset.x = x;
        this.offset.y = y;
        return this;
    }
    
    public function st(v : Number) : com__abagames__util__DotShape {
        this.spotThreshold = v;
        return this;
    }
    
    public function sa(x : Number = 0,y : Number = 0,xy : Number = 0) : com__abagames__util__DotShape {
        this.xAngleVel = x;
        this.yAngleVel = y;
        this.xyAngleVel = xy;
        return this;
    }
    
    public function c(c : com__abagames__util__Color,cs : com__abagames__util__Color = null,cb : com__abagames__util__Color = null,cbs : com__abagames__util__Color = null) : com__abagames__util__DotShape {
        if(c != null) this.color = c;
        if(cs != null) this.colorSpot = cs;
        this.colorBottom = cb;
        this.colorBottomSpot = cbs;
        return this;
    }
    
    static public var BASE_SCALE : int = 3;
    static protected var rect : flash.geom.Rectangle = new flash.geom.Rectangle();
    static protected var rPos : com__abagames__util__Xy = new com__abagames__util__Xy();
}

dynamic class com__abagames__util__FloatUtil {
    static public function clamp(v : Number,min : Number,max : Number) : Number {
        if(v > max) v = max;
        else if(v < min) v = min;
        return v;
    }
    
    static public function normalizeAngle(v : Number) : Number {
        var r : Number = v % (Math.PI * 2);
        if(r < -Math.PI) r += Math.PI * 2;
        else if(r > Math.PI) r -= Math.PI * 2;
        return r;
    }
    
    static public function aimAngle(v : Number,targetAngle : Number,angleVel : Number) : Number {
        var oa : Number = com__abagames__util__FloatUtil.normalizeAngle(targetAngle - v);
        var r : Number;
        if(oa > angleVel) r = v + angleVel;
        else if(oa < -angleVel) r = v - angleVel;
        else r = targetAngle;
        return com__abagames__util__FloatUtil.normalizeAngle(r);
    }
    
    static public function circle(v : Number,max : Number,min : Number = 0) : Number {
        var w : Number = max - min;
        v -= min;
        var r : Number;
        if(v >= 0) r = v % w + min;
        else r = w + v % w + min;
        return r;
    }
    
}

dynamic class com__abagames__util__IntUtil {
    static public function clampi(v : int,min : int,max : int) : int {
        if(v > max) v = max;
        else if(v < min) v = min;
        return v;
    }
    
    static public function circlei(v : int,max : int,min : int = 0) : int {
        var w : int = max - min;
        v -= min;
        var r : int;
        if(v >= 0) r = v % w + min;
        else r = w + v % w + min;
        return r;
    }
    
}

import flash.events.KeyboardEvent;
dynamic class com__abagames__util__Key {
    static public var s : Array;
    static public function get isWPressed() : Boolean { return getIsWPressed(); }
    protected function set isWPressed( __v : Boolean ) : void { $isWPressed = __v; }
    static protected var $isWPressed : Boolean;
    static public function get isAPressed() : Boolean { return getIsAPressed(); }
    protected function set isAPressed( __v : Boolean ) : void { $isAPressed = __v; }
    static protected var $isAPressed : Boolean;
    static public function get isSPressed() : Boolean { return getIsSPressed(); }
    protected function set isSPressed( __v : Boolean ) : void { $isSPressed = __v; }
    static protected var $isSPressed : Boolean;
    static public function get isDPressed() : Boolean { return getIsDPressed(); }
    protected function set isDPressed( __v : Boolean ) : void { $isDPressed = __v; }
    static protected var $isDPressed : Boolean;
    static public function get isButtonPressed() : Boolean { return getIsButtonPressed(); }
    protected function set isButtonPressed( __v : Boolean ) : void { $isButtonPressed = __v; }
    static protected var $isButtonPressed : Boolean;
    static public function get isButton1Pressed() : Boolean { return getIsButton1Pressed(); }
    protected function set isButton1Pressed( __v : Boolean ) : void { $isButton1Pressed = __v; }
    static protected var $isButton1Pressed : Boolean;
    static public function get isButton2Pressed() : Boolean { return getIsButton2Pressed(); }
    protected function set isButton2Pressed( __v : Boolean ) : void { $isButton2Pressed = __v; }
    static protected var $isButton2Pressed : Boolean;
    static public function get stick() : com__abagames__util__Xy { return getStick(); }
    protected function set stick( __v : com__abagames__util__Xy ) : void { $stick = __v; }
    static protected var $stick : com__abagames__util__Xy;
    static protected var stickXy : com__abagames__util__Xy;
    static public function initialize() : void {
        com__abagames__util__Key.s = new Array();
        {
            var _g : int = 0;
            while(_g < 256) {
                var i : int = _g++;
                com__abagames__util__Key.s.push(false);
            }
        }
        com__abagames__util__Key.stickXy = new com__abagames__util__Xy();
        flash__Lib.current.stage.addEventListener(flash.events.KeyboardEvent.KEY_DOWN,com__abagames__util__Key.onPressed);
        flash__Lib.current.stage.addEventListener(flash.events.KeyboardEvent.KEY_UP,com__abagames__util__Key.onReleased);
    }
    
    static public function reset() : void {
        var _g : int = 0;
        while(_g < 256) {
            var i : int = _g++;
            com__abagames__util__Key.s[i] = false;
        }
    }
    
    static protected function onPressed(e : flash.events.KeyboardEvent) : void {
        com__abagames__util__Key.s[e.keyCode] = true;
    }
    
    static protected function onReleased(e : flash.events.KeyboardEvent) : void {
        com__abagames__util__Key.s[e.keyCode] = false;
    }
    
    static public function getIsWPressed() : Boolean {
        return com__abagames__util__Key.s[38] || com__abagames__util__Key.s[87];
    }
    
    static public function getIsAPressed() : Boolean {
        return com__abagames__util__Key.s[37] || com__abagames__util__Key.s[65];
    }
    
    static public function getIsSPressed() : Boolean {
        return com__abagames__util__Key.s[40] || com__abagames__util__Key.s[83];
    }
    
    static public function getIsDPressed() : Boolean {
        return com__abagames__util__Key.s[39] || com__abagames__util__Key.s[68];
    }
    
    static public function getIsButtonPressed() : Boolean {
        return com__abagames__util__Key.getIsButton1Pressed() || com__abagames__util__Key.getIsButton2Pressed();
    }
    
    static public function getIsButton1Pressed() : Boolean {
        return com__abagames__util__Key.s[90] || com__abagames__util__Key.s[190] || com__abagames__util__Key.s[32];
    }
    
    static public function getIsButton2Pressed() : Boolean {
        return com__abagames__util__Key.s[88] || com__abagames__util__Key.s[191];
    }
    
    static public function getStick() : com__abagames__util__Xy {
        com__abagames__util__Key.stickXy.setV(0);
        if(com__abagames__util__Key.getIsWPressed()) com__abagames__util__Key.stickXy.y -= 1;
        if(com__abagames__util__Key.getIsAPressed()) com__abagames__util__Key.stickXy.x -= 1;
        if(com__abagames__util__Key.getIsSPressed()) com__abagames__util__Key.stickXy.y += 1;
        if(com__abagames__util__Key.getIsDPressed()) com__abagames__util__Key.stickXy.x += 1;
        if(com__abagames__util__Key.stickXy.x != 0 && com__abagames__util__Key.stickXy.y != 0) com__abagames__util__Key.stickXy.scaleBy(0.7);
        return com__abagames__util__Key.stickXy;
    }
    
}

import flash.geom.Rectangle;
import flash.display.BitmapData;
dynamic class com__abagames__util__Letter {
    static protected var BASE_SCALE : int = 2;
    static public function draw(text : String,x : Number,y : Number) : void {
        com__abagames__util__Letter.drawAligned(text,x,y,com__abagames__util__LetterAlign.Center);
    }
    
    static public function drawAligned(text : String,x : Number,y : Number,align : com__abagames__util__LetterAlign,scale : int = 2,color : com__abagames__util__Color = null) : void {
        var tx : int = Std._int(x), ty : int = Std._int(y);
        var ci : int = ((color == null)?com__abagames__util__Color.white.getI():color.getI());
        var lw : int = scale * 5;
        {
            var $e : enum = (align);
            switch( $e.index ) {
            case 0:
            break;
            case 1:
            tx -= Std._int(text.length * lw / 2);
            break;
            case 2:
            tx -= text.length * lw;
            break;
            }
        }
        com__abagames__util__Letter.rect.width = com__abagames__util__Letter.rect.height = scale;
        {
            var _g1 : int = 0, _g : int = text.length;
            while(_g1 < _g) {
                var i : int = _g1++;
                var c : * = text["charCodeAtHX"](i);
                var li : int = com__abagames__util__Letter.charToIndex[c];
                if(li >= 0) com__abagames__util__Letter.drawDots(li,tx,ty,ci);
                tx += lw;
            }
        }
    }
    
    static protected var COUNT : int = 64;
    static protected var dotPatterns : Array;
    static protected var charToIndex : Array;
    static protected var rect : flash.geom.Rectangle;
    static protected var bd : flash.display.BitmapData;
    static public function initialize() : void {
        var patterns : Array = [1178905252,1864668900,-177968823,376992244,613021335,-379152746,2046400104,-1852409479,528062838,292683543,-107032170,-297513319,1398351172,-101641959,-1646552679,2037815702,2128188945,-2044814983,-1723579161,1181324953,1771503001,-196699751,572846664,639910948,1682204194,-2077736376,1089531940,251675876,1208634944,-1706716892,678422,1678001392,-2147467191,1077936132,1145323584,10485764,1692722176,1172595161,1143272484,1123173605];
        com__abagames__util__Letter.dotPatterns = new Array();
        var p : int = 0, d : int = 32;
        var pIndex : int = 0;
        var dots : Array;
        {
            var _g : int = 0;
            while(_g < 64) {
                var i : int = _g++;
                dots = new Array();
                {
                    var _g1 : int = 0;
                    while(_g1 < 5) {
                        var j : int = _g1++;
                        {
                            var _g2 : int = 0;
                            while(_g2 < 4) {
                                var k : int = _g2++;
                                if(++d >= 32) {
                                    p = patterns[pIndex++];
                                    d = 0;
                                }
                                if((p & 1) > 0) dots.push(new com__abagames__util__Xy(k,j));
                                p >>= 1;
                            }
                        }
                    }
                }
                com__abagames__util__Letter.dotPatterns.push(dots);
            }
        }
        var charCodes : Array = [40,41,91,93,60,62,61,43,45,42,47,37,38,95,33,63,44,46,58,124,39,34,36,64,117,114,100,108];
        com__abagames__util__Letter.charToIndex = new Array();
        {
            var _g3 : int = 0;
            while(_g3 < 128) {
                var c : int = _g3++;
                var li : int = -1;
                if(c >= 48 && c < 58) li = c - 48;
                else if(c >= 65 && c <= 90) li = c - 65 + 10;
                else {
                    var lic : int = 36;
                    {
                        var _g11 : int = 0;
                        while(_g11 < charCodes.length) {
                            var cc : int = charCodes[_g11];
                            ++_g11;
                            if(cc == c) {
                                li = lic;
                                break;
                            }
                            lic++;
                        }
                    }
                }
                com__abagames__util__Letter.charToIndex.push(li);
            }
        }
        com__abagames__util__Letter.rect = new flash.geom.Rectangle();
        com__abagames__util__Letter.bd = com__abagames__util__Screen.bd;
    }
    
    static protected function drawDots(i : int,x : int,y : int,color : int) : void {
        var _g : int = 0, _g1 : Array = com__abagames__util__Letter.dotPatterns[i];
        while(_g < _g1.length) {
            var p : com__abagames__util__Xy = _g1[_g];
            ++_g;
            com__abagames__util__Letter.rect.x = x + p.getXi() * 2;
            com__abagames__util__Letter.rect.y = y + p.getYi() * 2;
            com__abagames__util__Letter.bd.fillRect(com__abagames__util__Letter.rect,color);
        }
    }
    
}

import flash.events.Event;
import flash.events.MouseEvent;
dynamic class com__abagames__util__Mouse {
    static public var pos : com__abagames__util__Xy;
    static public var isPressing : Boolean = false;
    static public function initialize() : void {
        com__abagames__util__Mouse.pos = new com__abagames__util__Xy();
        flash__Lib.current.stage.addEventListener(flash.events.MouseEvent.MOUSE_MOVE,com__abagames__util__Mouse.onMoved);
        flash__Lib.current.stage.addEventListener(flash.events.MouseEvent.MOUSE_DOWN,com__abagames__util__Mouse.onPressed);
        flash__Lib.current.stage.addEventListener(flash.events.MouseEvent.MOUSE_UP,com__abagames__util__Mouse.onReleased);
        flash__Lib.current.stage.addEventListener(flash.events.Event.MOUSE_LEAVE,com__abagames__util__Mouse.onReleased);
    }
    
    static protected function onMoved(e : flash.events.MouseEvent) : void {
        com__abagames__util__Mouse.pos.x = e.stageX - com__abagames__util__Screen.pos.x;
        com__abagames__util__Mouse.pos.y = e.stageY - com__abagames__util__Screen.pos.y;
    }
    
    static protected function onPressed(e : flash.events.MouseEvent) : void {
        com__abagames__util__Mouse.isPressing = true;
        com__abagames__util__Mouse.onMoved(e);
    }
    
    static protected function onReleased(e : flash.events.Event) : void {
        com__abagames__util__Mouse.isPressing = false;
    }
    
}

dynamic class com__abagames__util__OffsetColor {
    public function com__abagames__util__OffsetColor() : void { if( !flash__Boot.skip_constructor ) {
        this.offset = new com__abagames__util__Xy();
    }}
    
    public var color : uint;
    public var offset : com__abagames__util__Xy;
}

dynamic class com__abagames__util__Platform {
    public function com__abagames__util__Platform() : void {
    }
    
    public function recordScore(score : int) : void {
    }
    
    public var isTouchDevice : Boolean = false;
    public var clickStr : String = "CLICK";
}

dynamic class com__abagames__util__Random {
    public function com__abagames__util__Random(v : int = -2147483647) : void { if( !flash__Boot.skip_constructor ) {
        this.setSeed(v);
    }}
    
    public function get() : Number {
        var t : int = this.x ^ this.x << 11;
        this.x = this.y;
        this.y = this.z;
        this.z = this.w;
        this.w = ((this.w ^ this.w >> 19) ^ (t ^ t >> 8));
        return (function($this:com__abagames__util__Random) : Number {
            var $r : Number;
            var $t : int = $this.w;
            if(Std._is($t,Number)) (($t) as Number);
            else throw "Class cast error";
            $r = $t;
            return $r;
        }(this)) / 2147483647;
    }
    
    public function setSeed(v : int = -2147483647) : void {
        var sv : int;
        if(v == -2147483647) sv = Std._int(Math.random() * 2147483647);
        else sv = v;
        this.x = sv = 1812433253 * (sv ^ sv >> 30);
        this.y = sv = 1812433253 * (sv ^ sv >> 30) + 1;
        this.z = sv = 1812433253 * (sv ^ sv >> 30) + 2;
        this.w = sv = 1812433253 * (sv ^ sv >> 30) + 3;
    }
    
    protected var w : int;
    protected var z : int;
    protected var y : int;
    protected var x : int;
    public function pmn(v : Number = 1) : Number {
        return this.n(v) * this.pm();
    }
    
    public function pm() : int {
        return this.i(2) * 2 - 1;
    }
    
    public function sy(v : Number = 1,s : Number = 0) : Number {
        return this.n(v,s) * com__abagames__util__Screen.size.y;
    }
    
    public function sx(v : Number = 1,s : Number = 0) : Number {
        return this.n(v,s) * com__abagames__util__Screen.size.x;
    }
    
    public function i(v : int,s : int = 0) : int {
        return Std._int(this.n(v,s));
    }
    
    public function n(v : Number = 1,s : Number = 0) : Number {
        return this.get() * v + s;
    }
    
}

import flash.geom.Point;
import flash.filters.BlurFilter;
import flash.display.Bitmap;
import flash.filters.ColorMatrixFilter;
import flash.geom.Rectangle;
import flash.display.BitmapData;
dynamic class com__abagames__util__Screen {
    static public var size : com__abagames__util__Xy;
    static public var center : com__abagames__util__Xy;
    static public var backgroundColor : int = 0;
    static public function isIn(p : com__abagames__util__Xy,spacing : Number = 0) : Boolean {
        return p.x >= -spacing && p.x <= com__abagames__util__Screen.size.x + spacing && p.y >= -spacing && p.y <= com__abagames__util__Screen.size.y + spacing;
    }
    
    static public function fillRect(x : Number,y : Number,width : Number,height : Number,color : int) : void {
        com__abagames__util__Screen.fRect.x = Std._int(x) - Std._int(width / 2);
        com__abagames__util__Screen.fRect.y = Std._int(y) - Std._int(height / 2);
        com__abagames__util__Screen.fRect.width = width;
        com__abagames__util__Screen.fRect.height = height;
        com__abagames__util__Screen.bd.fillRect(com__abagames__util__Screen.fRect,color);
    }
    
    static public var bd : flash.display.BitmapData;
    static public var pos : com__abagames__util__Xy;
    static protected var blurBd : flash.display.BitmapData;
    static protected var fRect : flash.geom.Rectangle;
    static public function initialize(x : int = -1,y : int = -1,width : int = -1,height : int = -1) : void {
        if(x < 0) com__abagames__util__Screen.size = new com__abagames__util__Xy(flash__Lib.current.stage.stageWidth,flash__Lib.current.stage.stageHeight);
        else com__abagames__util__Screen.size = new com__abagames__util__Xy(width,height);
        com__abagames__util__Screen.center = new com__abagames__util__Xy(com__abagames__util__Screen.size.x / 2,com__abagames__util__Screen.size.y / 2);
        com__abagames__util__Screen.bd = new flash.display.BitmapData(com__abagames__util__Screen.size.getXi(),com__abagames__util__Screen.size.getYi(),true,0);
        com__abagames__util__Screen.blurBd = new flash.display.BitmapData(com__abagames__util__Screen.size.getXi(),com__abagames__util__Screen.size.getYi(),false,0);
        var bm : flash.display.Bitmap = new flash.display.Bitmap(com__abagames__util__Screen.blurBd);
        com__abagames__util__Screen.pos = new com__abagames__util__Xy();
        if(x >= 0) {
            bm.x = com__abagames__util__Screen.pos.x = x;
            bm.y = com__abagames__util__Screen.pos.y = y;
        }
        flash__Lib.current.addChild(bm);
        com__abagames__util__Screen.fRect = new flash.geom.Rectangle();
    }
    
    static public function begin() : void {
        com__abagames__util__Screen.bd.lock();
        com__abagames__util__Screen.bd.fillRect(com__abagames__util__Screen.bd.rect,com__abagames__util__Screen.backgroundColor);
    }
    
    static public function end() : void {
        com__abagames__util__Screen.bd.unlock();
        com__abagames__util__Screen.drawBlur();
    }
    
    static protected var fadeFilter : flash.filters.ColorMatrixFilter = new flash.filters.ColorMatrixFilter([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.8,0]);
    static protected var blurFilter10 : flash.filters.BlurFilter = new flash.filters.BlurFilter(10,10);
    static protected var blurFilter20 : flash.filters.BlurFilter = new flash.filters.BlurFilter(20,20);
    static protected var zeroPoint : flash.geom.Point = new flash.geom.Point();
    static protected function drawBlur() : void {
        com__abagames__util__Screen.blurBd.lock();
        com__abagames__util__Screen.blurBd.applyFilter(com__abagames__util__Screen.blurBd,com__abagames__util__Screen.blurBd.rect,com__abagames__util__Screen.zeroPoint,com__abagames__util__Screen.fadeFilter);
        com__abagames__util__Screen.blurBd.copyPixels(com__abagames__util__Screen.bd,com__abagames__util__Screen.bd.rect,com__abagames__util__Screen.zeroPoint,null,null,true);
        com__abagames__util__Screen.blurBd.applyFilter(com__abagames__util__Screen.blurBd,com__abagames__util__Screen.blurBd.rect,com__abagames__util__Screen.zeroPoint,com__abagames__util__Screen.blurFilter20);
        com__abagames__util__Screen.blurBd.copyPixels(com__abagames__util__Screen.bd,com__abagames__util__Screen.bd.rect,com__abagames__util__Screen.zeroPoint,null,null,true);
        com__abagames__util__Screen.blurBd.applyFilter(com__abagames__util__Screen.blurBd,com__abagames__util__Screen.blurBd.rect,com__abagames__util__Screen.zeroPoint,com__abagames__util__Screen.blurFilter10);
        com__abagames__util__Screen.blurBd.copyPixels(com__abagames__util__Screen.bd,com__abagames__util__Screen.bd.rect,com__abagames__util__Screen.zeroPoint,null,null,true);
        com__abagames__util__Screen.blurBd.unlock();
    }
    
}

import org.si.sion.SiONDriver;
import org.si.sion.SiONData;
dynamic class com__abagames__util__Se {
    public function com__abagames__util__Se() : void {
    }
    
    public function update() : void {
        this.lastPlayTicks--;
        if(!this.isPlaying) return;
        if(!com__abagames__util__Se.isStarting) {
            com__abagames__util__Se.driver.volume = 0.9;
            com__abagames__util__Se.isStarting = true;
        }
        com__abagames__util__Se.driver.sequenceOn(this.data,null,0,0,0);
        this.isPlaying = false;
        this.lastPlayTicks = 5;
    }
    
    protected var lastPlayTicks : int = 0;
    protected var toneIndex : int = 0;
    protected var type : com__abagames__util__SeType;
    protected var mml : String;
    protected var isPlaying : Boolean = false;
    protected var data : org.si.sion.SiONData;
    public function play() : void {
        if(!com__abagames__util__Frame.i.isInGame || this.lastPlayTicks > 0) return;
        this.isPlaying = true;
    }
    
    public function e() : com__abagames__util__Se {
        com__abagames__util__Se.isStarting = false;
        this.data = com__abagames__util__Se.driver.compile(this.mml);
        com__abagames__util__Se.driver.volume = 0;
        com__abagames__util__Se.driver.play();
        com__abagames__util__Se.s.push(this);
        return this;
    }
    
    public function v(v : int = 16) : com__abagames__util__Se {
        this.mml += "v" + v;
        return this;
    }
    
    public function l(v : int = 64) : com__abagames__util__Se {
        this.mml += "l" + Std.string(this.l);
        return this;
    }
    
    public function r(v : int = 1) : com__abagames__util__Se {
        {
            var _g : int = 0;
            while(_g < v) {
                var i : int = _g++;
                this.mml += "r";
            }
        }
        return this;
    }
    
    public function t(from : Number,time : int = 1,to : Number = 0,waveWidth : Number = 0,waveAngle : Number = 0) : com__abagames__util__Se {
        var tone : Number = from;
        var step : Number = ((time > 1)?(to - from) / (time - 1):0.0);
        var wa : Number = 0.0;
        {
            var _g : int = 0;
            while(_g < time) {
                var i : int = _g++;
                tone = com__abagames__util__FloatUtil.clamp(tone,0,1);
                var tv : Number = com__abagames__util__FloatUtil.clamp(tone + Math.sin(wa) * (waveWidth / 2),0,1);
                wa += waveAngle;
                {
                    var $e : enum = (this.type);
                    switch( $e.index ) {
                    case 0:
                    case 1:
                    {
                        var ti : int = Std._int(tv * 39);
                        var o : int = Std._int(ti / 5 + 2);
                        this.mml += "o" + o + com__abagames__util__Se.tones[this.toneIndex][ti % 5];
                    }
                    break;
                    case 2:
                    case 3:
                    {
                        var ti1 : int = Std._int(tv * 14);
                        if(ti1 < 4) this.mml += "o5" + com__abagames__util__Se.tones[0][3 - ti1];
                        else this.mml += "o4" + com__abagames__util__Se.tones[0][15 - ti1];
                    }
                    break;
                    }
                }
                tone += step;
            }
        }
        return this;
    }
    
    public function b(t : com__abagames__util__SeType,l : int = 64,v : int = 16) : com__abagames__util__Se {
        this.type = t;
        if(this.mml == null) this.mml = "";
        else this.mml += ";";
        var voice : int;
        {
            var $e : enum = (this.type);
            switch( $e.index ) {
            case 0:
            {
                voice = 1;
                this.toneIndex = 1;
            }
            break;
            case 1:
            {
                voice = 1;
                this.toneIndex = 2;
            }
            break;
            case 2:
            voice = 9;
            break;
            case 3:
            voice = 10;
            break;
            }
        }
        this.mml += "%1@" + voice + "l" + l + "v" + v;
        return this;
    }
    
    static public var s : Array = new Array();
    static protected var tones : Array = [["c","c+","d","d+","e","f","f+","g","g+","a","a+","b"],["c","d","e","g","a"],["c","d-","e-","g-","a-"]];
    static protected var driver : org.si.sion.SiONDriver = new org.si.sion.SiONDriver();
    static protected var isStarting : Boolean = false;
    static public function updateAll() : void {
        var _g : int = 0, _g1 : Array = com__abagames__util__Se.s;
        while(_g < _g1.length) {
            var se : com__abagames__util__Se = _g1[_g];
            ++_g;
            se.update();
        }
    }
    
}

dynamic class com__abagames__util__stgl__Command {
    public function com__abagames__util__stgl__Command(actorType : com__abagames__util__stgl__ActorType = null,commandName : String = null,commandOperator : String = null,argStrs : Array = null,lineCount : int = 0) : void { if( !flash__Boot.skip_constructor ) {
        this.actorType = actorType;
        this.lineCount = lineCount;
        this.name = commandName;
        if(commandOperator != null && commandOperator.length > 0) {
            var ereg : EReg = new EReg("^@?\\w+$","");
            if(!ereg.match(commandName)) throw "invalid VARIABLE: " + commandName;
            switch(commandOperator) {
            case "=":
            this.type = com__abagames__util__stgl__CommandType.Var(commandName,com__abagames__util__stgl__VarCommandType.Assignment);
            break;
            case "+=":
            this.type = com__abagames__util__stgl__CommandType.Var(commandName,com__abagames__util__stgl__VarCommandType.Add);
            break;
            case "-=":
            this.type = com__abagames__util__stgl__CommandType.Var(commandName,com__abagames__util__stgl__VarCommandType.Sub);
            break;
            case "<=":
            this.type = com__abagames__util__stgl__CommandType.Var(commandName,com__abagames__util__stgl__VarCommandType.ConsistentlyAssignment);
            break;
            case "<+=":
            this.type = com__abagames__util__stgl__CommandType.Var(commandName,com__abagames__util__stgl__VarCommandType.ConsistentlyAdd);
            break;
            case "<-=":
            this.type = com__abagames__util__stgl__CommandType.Var(commandName,com__abagames__util__stgl__VarCommandType.ConsistentlySub);
            break;
            case "=>":
            this.type = com__abagames__util__stgl__CommandType.Var(commandName,com__abagames__util__stgl__VarCommandType.Target);
            break;
            default:
            throw "invalid COMMAND_NAME: " + commandName + " " + commandOperator;
            break;
            }
            this.name += " " + commandOperator;
        }
        else {
            var ereg1 : EReg = new EReg("^\\w+$","");
            if(!ereg1.match(commandName)) throw "invalid COMMAND_NAME: " + commandName;
            switch(commandName) {
            case "repeat":
            this.type = com__abagames__util__stgl__CommandType.Repeat;
            break;
            case "while":
            this.type = com__abagames__util__stgl__CommandType.While;
            break;
            case "wait":
            this.type = com__abagames__util__stgl__CommandType.Wait;
            break;
            case "waitUntil":
            this.type = com__abagames__util__stgl__CommandType.WaitUntil;
            break;
            case "vanish":
            this.type = com__abagames__util__stgl__CommandType.Vanish;
            break;
            case "notify":
            this.type = com__abagames__util__stgl__CommandType.Notify;
            break;
            default:
            this.type = com__abagames__util__stgl__CommandType.Function(commandName);
            break;
            }
        }
        this.args = new Array();
        if(argStrs != null) {
            var _g : int = 0;
            while(_g < argStrs.length) {
                var a : String = argStrs[_g];
                ++_g;
                this.args.push(new com__abagames__util__stgl__Expression(a));
            }
        }
        this.children = new Array();
    }}
    
    public function toString(indent : int = 0) : String {
        var s : String = "";
        {
            var _g : int = 0;
            while(_g < indent) {
                var i : int = _g++;
                s += " ";
            }
        }
        s += this.name + " ";
        {
            var _g1 : int = 0, _g11 : Array = this.args;
            while(_g1 < _g11.length) {
                var a : com__abagames__util__stgl__Expression = _g11[_g1];
                ++_g1;
                s += a.string + ",";
            }
        }
        s = s.substr(0,s.length - 1);
        return s;
    }
    
    public function addChildToTail(command : com__abagames__util__stgl__Command) : void {
        this.children.push(command);
    }
    
    public function addChildToHead(command : com__abagames__util__stgl__Command) : void {
        this.children.unshift(command);
    }
    
    public var lineCount : int;
    public var children : Array;
    public var args : Array;
    public var type : com__abagames__util__stgl__CommandType;
    public var actorType : com__abagames__util__stgl__ActorType;
    public var name : String;
    static public var s : Hash;
    static protected var COMMAND_EREG : EReg = new EReg("^([@\\$:]?\\w+)(?:\\s*)(<?[\\+\\-]?=>?)?(?:\\s+)?(.*)$","");
    static public function read(string : String) : void {
        com__abagames__util__stgl__Command.s = new Hash();
        var lineCount : int = 0;
        var indentSpaceCounts : Array = new Array();
        var indentSpaceCount : int = 0;
        var parents : Array = new Array();
        indentSpaceCounts.push(indentSpaceCount);
        var lines : Array = string.split("\r\n").join("\n").split("\n");
        lines.push(":bullet");
        lines.push("fire angle, speed");
        lines.push("\t@angle = angle");
        lines.push("\t@speed = speed");
        var parent : com__abagames__util__stgl__Command = null;
        var current : com__abagames__util__stgl__Command = null;
        var currentActorType : com__abagames__util__stgl__ActorType = com__abagames__util__stgl__ActorType.None;
        var errorMessages : String = "";
        var errorCount : int = 0;
        {
            var _g : int = 0;
            while(_g < lines.length) {
                var line : String = lines[_g];
                ++_g;
                lineCount++;
                var ci : int = line.indexOf("#");
                if(ci >= 0) line = line.substr(0,ci);
                if(line.length <= 0) continue;
                var isc : int = 0;
                while(true) {
                    var cc : * = line["charCodeAtHX"](isc);
                    if(cc != 9 && cc != 32) break;
                    isc++;
                }
                if(line.length <= isc) continue;
                var l : String = line.substr(isc,line.length - isc);
                var ereg : EReg = new EReg("^([@\\$:]?\\w+)(?:\\s*)(<?[\\+\\-]?=>?)?(?:\\s+)?(.*)$","");
                if(!ereg.match(l)) {
                    errorMessages += "l." + lineCount + " parse error (" + l + ")\n";
                    errorCount++;
                    continue;
                }
                var commandName : String = ereg.matched(1);
                if(commandName.charAt(0) == ":") {
                    var actorTypeName : String = commandName.substr(1);
                    switch(actorTypeName) {
                    case "none":
                    currentActorType = null;
                    break;
                    case "stage":
                    currentActorType = com__abagames__util__stgl__ActorType.Stage;
                    break;
                    case "enemy":
                    currentActorType = com__abagames__util__stgl__ActorType.Enemy;
                    break;
                    case "turret":
                    currentActorType = com__abagames__util__stgl__ActorType.Turret;
                    break;
                    case "bullet":
                    currentActorType = com__abagames__util__stgl__ActorType.Bullet;
                    break;
                    default:
                    {
                        errorMessages += "l." + lineCount + " invalid ACTOR_TYPE: " + actorTypeName + " (" + l + ")\n";
                        errorCount++;
                    }
                    break;
                    }
                    continue;
                }
                var commandOperator : String = ereg.matched(2);
                var argStr : String = ereg.matched(3);
                var args : Array = null;
                if(argStr.length > 0) args = ereg.matched(3).split(",");
                if(parent == null) indentSpaceCount = isc;
                if(isc > indentSpaceCount) {
                    indentSpaceCounts.push(indentSpaceCount);
                    indentSpaceCount = isc;
                    parents.push(parent);
                    parent = current;
                }
                else if(isc < indentSpaceCount) while(isc < indentSpaceCount) {
                    indentSpaceCount = indentSpaceCounts.pop();
                    parent = parents.pop();
                }
                if(parents.length == 0 && parent != null) {
                    com__abagames__util__stgl__Command.addRootCommand(parent.name,parent);
                    parent = null;
                }
                try {
                    current = new com__abagames__util__stgl__Command(currentActorType,commandName,commandOperator,args,lineCount);
                }
                catch( msg : String ){
                    errorMessages += "l." + lineCount + " " + msg + " (" + l + ")\n";
                    errorCount++;
                    continue;
                }
                if(parent == null) parent = current;
                else parent.children.push(current);
            }
        }
        if(parents.length > 0) com__abagames__util__stgl__Command.addRootCommand(parents[0].name,parents[0]);
        if(errorCount > 0) throw errorCount + " error(s)\n" + errorMessages;
    }
    
    static protected function addRootCommand(name : String,command : com__abagames__util__stgl__Command) : void {
        com__abagames__util__stgl__Command.s.set(name,command);
        if(command.actorType == com__abagames__util__stgl__ActorType.Turret) {
            command.addChildToHead(new com__abagames__util__stgl__Command(command.actorType,"@y","<=",["$parentY"],-1));
            command.addChildToHead(new com__abagames__util__stgl__Command(command.actorType,"@x","<=",["$parentX"],-1));
        }
        if(command.actorType == com__abagames__util__stgl__ActorType.Stage || command.actorType == com__abagames__util__stgl__ActorType.Turret) command.addChildToTail(new com__abagames__util__stgl__Command(command.actorType,"vanish",null,null,-1));
    }
    
}

dynamic class com__abagames__util__stgl__Expression {
    public function com__abagames__util__stgl__Expression(s : String = null) : void { if( !flash__Boot.skip_constructor ) {
        this.string = s;
        this.operators = this.parseToRPN(this.string.split(" ").join("").split("\t").join(""));
        if(com__abagames__util__Frame.i != null) this.random = com__abagames__util__Frame.i.random;
    }}
    
    protected function calcTernaryOperator(op : com__abagames__util__stgl__Operator,v1 : Number,v2 : Number,v3 : Number) : Number {
        {
            var $e : enum = (op);
            switch( $e.index ) {
            case 20:
            return ((v1 == 0)?v3:v2);
            break;
            default:
            throw "invalid OPERATOR: " + Std.string(op);
            break;
            }
        }
        return 0.;
    }
    
    protected function calcBinaryOperator(op : com__abagames__util__stgl__Operator,v1 : Number,v2 : Number) : Number {
        {
            var $e : enum = (op);
            switch( $e.index ) {
            case 4:
            {
                var sv : int = ((v1 < 0)?Std._int(v1) - 1:Std._int(v1));
                return this.random.i(Std._int(v2 - v1 + 1),sv);
            }
            break;
            case 5:
            return this.random.n(v2 - v1,v1);
            break;
            case 6:
            return ((this.random.i(2) == 0)?v1:v2);
            break;
            case 10:
            return v1 + v2;
            break;
            case 11:
            return v1 - v2;
            break;
            case 7:
            return v1 * v2;
            break;
            case 8:
            {
                if(v2 == 0) throw "divide by zero";
                return v1 / v2;
            }
            break;
            case 9:
            {
                if(v2 == 0) throw "divide by zero";
                return v1 % v2;
            }
            break;
            case 12:
            return ((v1 > v2)?1:0);
            break;
            case 13:
            return ((v1 >= v2)?1:0);
            break;
            case 14:
            return ((v1 < v2)?1:0);
            break;
            case 15:
            return ((v1 <= v2)?1:0);
            break;
            case 16:
            return ((v1 == v2)?1:0);
            break;
            case 17:
            return ((v1 != v2)?1:0);
            break;
            case 18:
            return ((v1 * v2 == 0)?0:1);
            break;
            case 19:
            return ((v1 + v2 == 0)?0:1);
            break;
            default:
            throw "invalid OPERATOR: " + Std.string(op);
            break;
            }
        }
        return 0.;
    }
    
    protected function calcUnaryOperator(op : com__abagames__util__stgl__Operator,v : Number) : Number {
        {
            var $e : enum = (op);
            switch( $e.index ) {
            case 0:
            return Math.sin(v * Math.PI / 180);
            break;
            case 1:
            return Math.cos(v * Math.PI / 180);
            break;
            case 2:
            return -v;
            break;
            case 3:
            return ((v == 0)?1:0);
            break;
            default:
            throw "invalid OPERATOR: " + Std.string(op);
            break;
            }
        }
        return 0.;
    }
    
    protected function pushValue(v : Number,operators : Array) : void {
        operators.push(com__abagames__util__stgl__Operator.Value(v));
    }
    
    protected function pushVariable(name : String,operators : Array) : void {
        if(name.charAt(0) == "$") operators.push(com__abagames__util__stgl__Operator.ReadOnlyVariable(name));
        else operators.push(com__abagames__util__stgl__Operator.Variable(name));
    }
    
    protected function doInstantBinaryOperation(op : com__abagames__util__stgl__Operator,operators : Array) : Boolean {
        {
            var $e : enum = (operators[operators.length - 2]);
            switch( $e.index ) {
            case 23:
            var v2 : Number = $e.params[0];
            {
                {
                    var $e2 : enum = (operators[operators.length - 1]);
                    switch( $e2.index ) {
                    case 23:
                    var v1 : Number = $e2.params[0];
                    {
                        operators.pop();
                        operators.pop();
                        this.pushValue(this.calcBinaryOperator(op,v2,v1),operators);
                        return true;
                    }
                    break;
                    default:
                    return false;
                    break;
                    }
                }
            }
            break;
            default:
            return false;
            break;
            }
        }
        return false;
    }
    
    protected function doInstantUnaryOperation(op : com__abagames__util__stgl__Operator,operators : Array) : Boolean {
        {
            var $e : enum = (operators[operators.length - 1]);
            switch( $e.index ) {
            case 23:
            var v : Number = $e.params[0];
            {
                operators.pop();
                this.pushValue(this.calcUnaryOperator(op,v),operators);
                return true;
            }
            break;
            default:
            return false;
            break;
            }
        }
        return false;
    }
    
    protected function pushOperator(op : com__abagames__util__stgl__Operator,operators : Array) : void {
        {
            var $e : enum = (op);
            switch( $e.index ) {
            case 2:
            case 3:
            if(!this.doInstantUnaryOperation(op,operators)) operators.push(op);
            break;
            case 10:
            case 11:
            case 7:
            case 8:
            case 9:
            if(!this.doInstantBinaryOperation(op,operators)) operators.push(op);
            break;
            default:
            operators.push(op);
            break;
            }
        }
    }
    
    protected function parseFloatValue(string : String) : Array {
        var ppEreg : EReg = new EReg("^" + "parse_" + "(\\d+)" + "_d" + "$","");
        if(ppEreg.match(string)) {
            var pi : * = Std._parseInt(ppEreg.matched(1));
            return this.parsedOperators[pi];
        }
        var operators : Array = new Array();
        var valueEreg : EReg = new EReg("^" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "$","");
        var ppmEreg : EReg = new EReg("parse_" + "(\\d+)" + "_d","");
        if(ppmEreg.match(string) || !valueEreg.match(string)) {
            while(ppmEreg.match(string)) string = ppmEreg.replace(string,"");
            throw "invalid VALUE: " + string;
        }
        var v : Number = Std._parseFloat(string);
        if(Math["isNaN"](v)) this.pushVariable(string,operators);
        else this.pushValue(v,operators);
        return operators;
    }
    
    protected function searchOpeator(string : String,ereg : EReg,n : int,pushOperatorFunc : Function) : String {
        while(ereg.match(string)) {
            var operators : Array = new Array();
            {
                var _g : int = 0;
                while(_g < n) {
                    var i : int = _g++;
                    operators = operators.concat(this.parseToRPN(ereg.matched(i * 2 + 1)));
                }
            }
            {
                var _g1 : int = 0, _g2 : int = n - 1;
                while(_g1 < _g2) {
                    var i1 : int = _g1++;
                    pushOperatorFunc(ereg.matched(i1 * 2 + 2),operators);
                }
            }
            string = ereg.replace(string,"parse_" + this.addParsed(operators) + "_d");
        }
        return string;
    }
    
    protected function searchUnaryOpeator(string : String,ereg : EReg,pushOperatorFunc : Function) : String {
        while(ereg.match(string)) {
            var operators : Array = this.parseToRPN(ereg.matched(3));
            pushOperatorFunc(ereg.matched(2),operators);
            string = ereg.replace(string,"$1" + "parse_" + this.addParsed(operators) + "_d");
        }
        return string;
    }
    
    protected function searchFunction(string : String,ereg : EReg,pushOperatorFunc : Function) : String {
        while(ereg.match(string)) {
            var operators : Array = this.parseToRPN(ereg.matched(2));
            pushOperatorFunc(ereg.matched(1),operators);
            string = ereg.replace(string,"parse_" + this.addParsed(operators) + "_d");
        }
        return string;
    }
    
    protected function addParsed(operators : Array) : int {
        if(this.parsedOperators == null) this.parsedOperators = new Array();
        this.parsedOperators.push(operators);
        return this.parsedOperators.length - 1;
    }
    
    protected function parseToRPN(string : String) : Array {
        var _g : com__abagames__util__stgl__Expression = this;
        var ppEreg : EReg = new EReg("^" + "parse_" + "(\\d+)" + "_d" + "$","");
        if(ppEreg.match(string)) {
            var pi : * = Std._parseInt(ppEreg.matched(1));
            return this.parsedOperators[pi];
        }
        string = this.searchFunction(string,new EReg("(sin|cos)" + "\\(([^()]+)\\)",""),function(opStr : String,operators : Array) : void {
            switch(opStr) {
            case "sin":
            _g.pushOperator(com__abagames__util__stgl__Operator.Sin,operators);
            break;
            case "cos":
            _g.pushOperator(com__abagames__util__stgl__Operator.Cos,operators);
            break;
            }
        });
        string = this.searchOpeator(string,new EReg("\\(([^()]+)\\)",""),1,null);
        string = this.searchUnaryOpeator(string,new EReg("([!\\._\\|*\\/%\\+\\-<>=%&\\?:]|^)([\\-!])" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)",""),function(opStr1 : String,operators1 : Array) : void {
            switch(opStr1) {
            case "-":
            _g.pushOperator(com__abagames__util__stgl__Operator.UnaryMinus,operators1);
            break;
            case "!":
            _g.pushOperator(com__abagames__util__stgl__Operator.UnaryNot,operators1);
            break;
            }
        });
        string = this.searchOpeator(string,new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "(\\.\\.|__|\\|)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)",""),2,function(opStr2 : String,operators2 : Array) : void {
            switch(opStr2) {
            case "..":
            _g.pushOperator(com__abagames__util__stgl__Operator.IntRandom,operators2);
            break;
            case "__":
            _g.pushOperator(com__abagames__util__stgl__Operator.NumberRandom,operators2);
            break;
            case "|":
            _g.pushOperator(com__abagames__util__stgl__Operator.OrRandom,operators2);
            break;
            }
        });
        string = this.searchOpeator(string,new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "([*\\/%])" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)",""),2,function(opStr3 : String,operators3 : Array) : void {
            switch(opStr3) {
            case "*":
            _g.pushOperator(com__abagames__util__stgl__Operator.Multiple,operators3);
            break;
            case "/":
            _g.pushOperator(com__abagames__util__stgl__Operator.Division,operators3);
            break;
            case "%":
            _g.pushOperator(com__abagames__util__stgl__Operator.Modolo,operators3);
            break;
            }
        });
        string = this.searchOpeator(string,new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "([\\+\\-])" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)",""),2,function(opStr4 : String,operators4 : Array) : void {
            switch(opStr4) {
            case "+":
            _g.pushOperator(com__abagames__util__stgl__Operator.Plus,operators4);
            break;
            case "-":
            _g.pushOperator(com__abagames__util__stgl__Operator.Minus,operators4);
            break;
            }
        });
        string = this.searchOpeator(string,new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "([<>]=?)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)",""),2,function(opStr5 : String,operators5 : Array) : void {
            switch(opStr5) {
            case ">":
            _g.pushOperator(com__abagames__util__stgl__Operator.Greater,operators5);
            break;
            case ">=":
            _g.pushOperator(com__abagames__util__stgl__Operator.GreaterEqual,operators5);
            break;
            case "<":
            _g.pushOperator(com__abagames__util__stgl__Operator.Lesser,operators5);
            break;
            case "<=":
            _g.pushOperator(com__abagames__util__stgl__Operator.LesserEqual,operators5);
            break;
            }
        });
        string = this.searchOpeator(string,new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "([!=]=)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)",""),2,function(opStr6 : String,operators6 : Array) : void {
            switch(opStr6) {
            case "==":
            _g.pushOperator(com__abagames__util__stgl__Operator.Equal,operators6);
            break;
            case "!=":
            _g.pushOperator(com__abagames__util__stgl__Operator.NotEqual,operators6);
            break;
            }
        });
        string = this.searchOpeator(string,new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "(&&|\\|\\|)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)",""),2,function(opStr7 : String,operators7 : Array) : void {
            switch(opStr7) {
            case "&&":
            _g.pushOperator(com__abagames__util__stgl__Operator.And,operators7);
            break;
            case "||":
            _g.pushOperator(com__abagames__util__stgl__Operator.Or,operators7);
            break;
            }
        });
        string = this.searchOpeator(string,new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "(\\?)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "(:)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)",""),3,function(opStr8 : String,operators8 : Array) : void {
            switch(opStr8) {
            case "?":
            _g.pushOperator(com__abagames__util__stgl__Operator.Ternary,operators8);
            break;
            }
        });
        return this.parseFloatValue(string);
    }
    
    protected var parsedOperators : Array;
    protected var random : com__abagames__util__Random;
    protected var operators : Array;
    public var string : String;
    public function getAsName() : String {
        var op : com__abagames__util__stgl__Operator = this.operators[0];
        {
            var $e : enum = (op);
            switch( $e.index ) {
            case 21:
            var name : String = $e.params[0];
            return name;
            break;
            default:
            throw "invalid NAME: " + this.string;
            break;
            }
        }
        return null;
    }
    
    public function calc(actor : com__abagames__util__stgl__StglActor) : Number {
        var vars : Hash = actor.vars;
        var stack : Array = new Array();
        {
            var _g : int = 0, _g1 : Array = this.operators;
            while(_g < _g1.length) {
                var op : com__abagames__util__stgl__Operator = _g1[_g];
                ++_g;
                {
                    var $e : enum = (op);
                    switch( $e.index ) {
                    case 23:
                    var v : Number = $e.params[0];
                    stack.push(v);
                    break;
                    case 21:
                    var name : String = $e.params[0];
                    {
                        var v1 : com__abagames__util__stgl__Variable = vars.get(name);
                        if(v1 == null) throw "VARIABLE " + name + " doesn't exist";
                        stack.push(v1.value);
                    }
                    break;
                    case 22:
                    var name1 : String = $e.params[0];
                    stack.push(actor.getReadOnlyVariableValue(name1));
                    break;
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                    {
                        var v2 : * = stack.pop();
                        stack.push(this.calcUnaryOperator(op,v2));
                    }
                    break;
                    case 4:
                    case 5:
                    case 6:
                    case 10:
                    case 11:
                    case 7:
                    case 8:
                    case 9:
                    case 12:
                    case 13:
                    case 14:
                    case 15:
                    case 16:
                    case 17:
                    case 18:
                    case 19:
                    {
                        var v11 : * = stack.pop();
                        var v21 : * = stack.pop();
                        stack.push(this.calcBinaryOperator(op,v21,v11));
                    }
                    break;
                    case 20:
                    {
                        var v12 : * = stack.pop();
                        var v22 : * = stack.pop();
                        var v3 : * = stack.pop();
                        stack.push(this.calcTernaryOperator(op,v3,v22,v12));
                    }
                    break;
                    default:
                    throw "invalid OPERATOR: " + Std.string(op);
                    break;
                    }
                }
            }
        }
        return stack.pop();
    }
    
    static public var TRUE : com__abagames__util__stgl__Expression = new com__abagames__util__stgl__Expression("1");
    static public var FALSE : com__abagames__util__stgl__Expression = new com__abagames__util__stgl__Expression("0");
    static protected var PARSED_PREFIX_STRING : String = "parse_";
    static protected var PARSED_POSTFIX_STRING : String = "_d";
    static protected var PARSED_PATTERN : EReg = new EReg("^" + "parse_" + "(\\d+)" + "_d" + "$","");
    static protected var PARSED_PATTERN_MATCH : EReg = new EReg("parse_" + "(\\d+)" + "_d","");
    static protected var IN_BRACKETS_PATTERN : String = "\\(([^()]+)\\)";
    static protected var FUNCTION_PATTERN : EReg = new EReg("(sin|cos)" + "\\(([^()]+)\\)","");
    static protected var BRACKETS_PATTERN : EReg = new EReg("\\(([^()]+)\\)","");
    static protected var VALUE_PATTERN : String = "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)";
    static protected var UNARY_PATTERN : EReg = new EReg("([!\\._\\|*\\/%\\+\\-<>=%&\\?:]|^)([\\-!])" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)","");
    static protected var RANDOM_PATTERN : EReg = new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "(\\.\\.|__|\\|)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)","");
    static protected var MULDIV_PATTERN : EReg = new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "([*\\/%])" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)","");
    static protected var ADDSUB_PATTERN : EReg = new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "([\\+\\-])" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)","");
    static protected var COMPARE_PATTERN : EReg = new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "([<>]=?)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)","");
    static protected var EQUAL_PATTERN : EReg = new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "([!=]=)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)","");
    static protected var LOGIC_PATTERN : EReg = new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "(&&|\\|\\|)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)","");
    static protected var TERNARY_PATTERN : EReg = new EReg("(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "(\\?)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)" + "(:)" + "(\\d+(?:\\.\\d+)?|[@\\$:]?\\w+)","");
}

dynamic class com__abagames__util__stgl__ScopeState {
    public function com__abagames__util__stgl__ScopeState(actor : com__abagames__util__stgl__StglActor = null,rootCommand : com__abagames__util__stgl__Command = null,repeatCount : int = 1,whileCond : com__abagames__util__stgl__Expression = null) : void { if( !flash__Boot.skip_constructor ) {
        this.actor = actor;
        this.rootCommand = rootCommand;
        this.repeatCount = repeatCount;
        this.whileCond = whileCond;
    }}
    
    protected function doCommand(command : com__abagames__util__stgl__Command) : void {
        {
            var $e : enum = (command.type);
            switch( $e.index ) {
            case 0:
            {
                var count : int = 9999999;
                if(command.args.length > 0) count = Std._int(command.args[0].calc(this.actor));
                this.actor.pushScopeState(new com__abagames__util__stgl__ScopeState(this.actor,command,count));
            }
            break;
            case 1:
            {
                var cond : com__abagames__util__stgl__Expression;
                if(command.args.length > 0) cond = command.args[0];
                else cond = new com__abagames__util__stgl__Expression("1");
                this.actor.pushScopeState(new com__abagames__util__stgl__ScopeState(this.actor,command,1,cond));
            }
            break;
            case 2:
            {
                var count1 : int = 9999999;
                if(command.args.length > 0) count1 = Std._int(command.args[0].calc(this.actor));
                this.actor.setWaitTicks(count1);
            }
            break;
            case 3:
            {
                var cond1 : com__abagames__util__stgl__Expression;
                if(command.args.length > 0) cond1 = command.args[0];
                else cond1 = new com__abagames__util__stgl__Expression("0");
                this.actor.setWaitCond(cond1);
            }
            break;
            case 4:
            {
                var name : String = null;
                if(command.args.length > 0) name = command.args[0].getAsName();
                this.actor.vanish(name);
            }
            break;
            case 5:
            {
                var name1 : String = null;
                if(command.args.length > 0) name1 = command.args[0].getAsName();
                this.actor.notify(name1);
            }
            break;
            case 6:
            var name2 : String = $e.params[0];
            {
                var args : Array = new Array();
                {
                    var _g : int = 0, _g1 : Array = command.args;
                    while(_g < _g1.length) {
                        var a : com__abagames__util__stgl__Expression = _g1[_g];
                        ++_g;
                        args.push(a.calc(this.actor));
                    }
                }
                com__abagames__util__stgl__StglActor.add(name2,args,this.actor);
            }
            break;
            case 7:
            var type : com__abagames__util__stgl__VarCommandType = $e.params[1], name3 : String = $e.params[0];
            {
                var v : com__abagames__util__stgl__Variable = this.actor.vars.get(name3);
                if(v == null) v = this.actor.addVar(name3);
                v.targetTicks = 0;
                v.consistentlyValue = null;
                v.consistentlyAdd = null;
                v.consistentlySub = null;
                var a1 : com__abagames__util__stgl__Expression = command.args[0];
                if(a1 == null) throw "lack of the assignment value";
                {
                    var $e2 : enum = (type);
                    switch( $e2.index ) {
                    case 0:
                    v.value = a1.calc(this.actor);
                    break;
                    case 1:
                    v.value += a1.calc(this.actor);
                    break;
                    case 2:
                    v.value -= a1.calc(this.actor);
                    break;
                    case 6:
                    v.target = a1.calc(this.actor);
                    break;
                    case 3:
                    v.consistentlyValue = a1;
                    break;
                    case 4:
                    v.consistentlyAdd = a1;
                    break;
                    case 5:
                    v.consistentlySub = a1;
                    break;
                    }
                }
                if(type == com__abagames__util__stgl__VarCommandType.Target) {
                    if(command.args.length < 2) throw "lack of the target ticks argument";
                    v.targetTicks = Std._int(command.args[1].calc(this.actor));
                }
            }
            break;
            }
        }
    }
    
    public function update() : void {
        if(this.programCount >= this.rootCommand.children.length) {
            this.repeatCount--;
            if(this.repeatCount > 0 || this.whileCond != null && this.whileCond.calc(this.actor) == 1) this.programCount = 0;
            else {
                this.actor.popScopeState();
                return;
            }
        }
        var command : com__abagames__util__stgl__Command = this.rootCommand.children[this.programCount];
        this.programCount++;
        try {
            this.doCommand(command);
        }
        catch( msg : String ){
            var tMsg : String = msg;
            if(msg.indexOf("l.") != 0) tMsg = "l." + command.lineCount + " " + msg + " (" + command.toString() + ")";
            throw tMsg;
        }
    }
    
    protected var whileCond : com__abagames__util__stgl__Expression;
    protected var repeatCount : int = 1;
    protected var programCount : int = 0;
    protected var rootCommand : com__abagames__util__stgl__Command;
    protected var actor : com__abagames__util__stgl__StglActor;
}

dynamic class com__abagames__util__stgl__StglActor {
    public function com__abagames__util__stgl__StglActor(name : String = null,args : Array = null,parent : com__abagames__util__stgl__StglActor = null) : void { if( !flash__Boot.skip_constructor ) {
        var command : com__abagames__util__stgl__Command = com__abagames__util__stgl__Command.s.get(name);
        if(command == null) throw "FUNCTION " + name + " doesn't exist";
        this.name = name;
        this.vars = new Hash();
        var ai : int = 0;
        {
            var _g : int = 0, _g1 : Array = command.args;
            while(_g < _g1.length) {
                var a : com__abagames__util__stgl__Expression = _g1[_g];
                ++_g;
                var v : com__abagames__util__stgl__Variable = this.addVar(a.getAsName());
                if(args != null && ai < args.length) v.value = args[ai];
                ai++;
            }
        }
        this.type = command.actorType;
        this.xVar = this.addVar("@x");
        this.yVar = this.addVar("@y");
        this.angleVar = this.addVar("@angle");
        this.speedVar = this.addVar("@speed");
        this.scopeStates = new Array();
        this.childActors = new Array();
        this.dynamicValues = new Hash();
        this.parent = parent;
        if(parent == null) {
            this.xVar.value = 0.5;
            this.yVar.value = 0.2;
        }
        else {
            this.xVar.value = parent.xVar.value;
            this.yVar.value = parent.yVar.value;
        }
        this.angleVar.value = 0;
        this.speedVar.value = 0;
        this.currentState = new com__abagames__util__stgl__ScopeState(this,command);
        if(parent != null) parent.childActors.push(this);
    }}
    
    public function getExists() : Boolean {
        return !this.isRemoving;
    }
    
    protected function removeChildTurret() : void {
        var _g : int = 0, _g1 : Array = this.childActors;
        while(_g < _g1.length) {
            var c : com__abagames__util__stgl__StglActor = _g1[_g];
            ++_g;
            if(c.type == com__abagames__util__stgl__ActorType.Turret) c.remove();
        }
    }
    
    public function getReadOnlyVariableValue(name : String) : Number {
        switch(name) {
        case "$playerX":case "$px":
        return com__abagames__util__stgl__StglActor.stglManager.playerX / com__abagames__util__stgl__StglActor.stglManager.screenWidth;
        break;
        case "$playerY":case "$py":
        return com__abagames__util__stgl__StglActor.stglManager.playerY / com__abagames__util__stgl__StglActor.stglManager.screenHeight;
        break;
        case "$enemyCount":case "$ec":
        return com__abagames__util__stgl__StglActor.stglManager.getEnemyCount();
        break;
        case "$angleToPlayer":case "$atp":
        {
            var px : Number = com__abagames__util__stgl__StglActor.stglManager.playerX / com__abagames__util__stgl__StglActor.stglManager.screenWidth;
            var py : Number = com__abagames__util__stgl__StglActor.stglManager.playerY / com__abagames__util__stgl__StglActor.stglManager.screenHeight;
            return Math.atan2(px - this.xVar.value,py - this.yVar.value) * 180 / Math.PI;
        }
        break;
        case "$distanceToPlayer":case "$dtp":
        {
            var ox : Number = com__abagames__util__stgl__StglActor.stglManager.playerX - this.xVar.value * com__abagames__util__stgl__StglActor.stglManager.screenWidth;
            var oy : Number = com__abagames__util__stgl__StglActor.stglManager.playerY - this.yVar.value * com__abagames__util__stgl__StglActor.stglManager.screenHeight;
            return Math.sqrt(ox * ox + oy * oy) / Math.min(com__abagames__util__stgl__StglActor.stglManager.screenWidth,com__abagames__util__stgl__StglActor.stglManager.screenHeight);
        }
        break;
        case "$ticks":case "$t":
        return this.ticks;
        break;
        case "$parentX":case "$prx":
        {
            if(this.parent == null) throw "parent doesn't exist";
            return this.parent.xVar.value;
        }
        break;
        case "$parentY":case "$pry":
        {
            if(this.parent == null) throw "parent doesn't exist";
            return this.parent.yVar.value;
        }
        break;
        case "$infinity":case "$inf":
        return 9999999;
        break;
        default:
        throw "invalid READ_ONLY_VARIABLE: " + name;
        break;
        }
        return 0.;
    }
    
    public function notifyThis() : void {
        this.waitTicks = 0;
        this.waitCond = null;
    }
    
    public function notify(actorName : String = null) : void {
        if(actorName == null) {
            if(this.parent != null) this.parent.notifyThis();
            return;
        }
        {
            var _g : int = 0, _g1 : Array = this.childActors;
            while(_g < _g1.length) {
                var ca : com__abagames__util__stgl__StglActor = _g1[_g];
                ++_g;
                if(ca.name == actorName) ca.notifyThis();
            }
        }
    }
    
    public function remove() : void {
        this.isRemoving = true;
    }
    
    public function vanish(actorName : String = null) : void {
        if(actorName == null) this.remove();
        else {
            var _g : int = 0, _g1 : Array = this.childActors;
            while(_g < _g1.length) {
                var ca : com__abagames__util__stgl__StglActor = _g1[_g];
                ++_g;
                if(ca.name == actorName) ca.remove();
            }
        }
    }
    
    public function setWaitCond(cond : com__abagames__util__stgl__Expression) : void {
        this.waitCond = cond;
    }
    
    public function setWaitTicks(v : int) : void {
        this.waitTicks = v;
    }
    
    public function popScopeState() : void {
        this.currentState = this.scopeStates.pop();
    }
    
    public function pushScopeState(state : com__abagames__util__stgl__ScopeState) : void {
        this.scopeStates.push(this.currentState);
        this.currentState = state;
    }
    
    protected var sPos : com__abagames__util__Xy;
    protected var wasInScreen : Boolean = false;
    protected var isRemoving : Boolean = false;
    protected var dynamicValues : Hash;
    protected var currentState : com__abagames__util__stgl__ScopeState;
    protected var scopeStates : Array;
    protected var waitCond : com__abagames__util__stgl__Expression = null;
    protected var waitTicks : int = 0;
    public function get exists() : Boolean { return getExists(); }
    protected function set exists( __v : Boolean ) : void { $exists = __v; }
    protected var $exists : Boolean;
    public function addVar(name : String) : com__abagames__util__stgl__Variable {
        var v : com__abagames__util__stgl__Variable = new com__abagames__util__stgl__Variable(name);
        this.vars.set(name,v);
        return v;
    }
    
    public function update() : Boolean {
        { var $it : * = this.vars.iterator();
        while( $it.hasNext() ) { var v : com__abagames__util__stgl__Variable = $it.next();
        v.update(this);
        }}
        var x : Number = this.xVar.value;
        var y : Number = this.yVar.value;
        var angle : Number = this.angleVar.value * Math.PI / 180;
        var speed : Number = this.speedVar.value;
        if(speed != 0) {
            x += Math.sin(angle) * speed * com__abagames__util__stgl__StglActor.baseSpeed;
            y += Math.cos(angle) * speed * com__abagames__util__stgl__StglActor.baseSpeed;
            this.xVar.value = x;
            this.yVar.value = y;
        }
        if(this.type == com__abagames__util__stgl__ActorType.Enemy || this.type == com__abagames__util__stgl__ActorType.Turret || this.type == com__abagames__util__stgl__ActorType.Bullet) {
            if(x > -0.1 && x < 1.1 && y > -0.1 && y < 1.1) this.wasInScreen = true;
            else if(this.wasInScreen) this.remove();
        }
        var commandCount : int = 0;
        while(true) {
            if(this.waitCond != null) {
                if(this.waitCond.calc(this) == 0) break;
                else this.waitCond = null;
            }
            if(this.currentState == null || this.waitTicks > 0) break;
            this.currentState.update();
            if(++commandCount > 1000) throw "execute too many commands at a frame";
        }
        if(this.isRemoving) {
            if(this.type == com__abagames__util__stgl__ActorType.Enemy) this.removeChildTurret();
            return false;
        }
        this.ticks++;
        this.waitTicks--;
        return true;
    }
    
    public var childActors : Array;
    public var parent : com__abagames__util__stgl__StglActor;
    public var ticks : int;
    public var vars : Hash;
    public var speedVar : com__abagames__util__stgl__Variable;
    public var angleVar : com__abagames__util__stgl__Variable;
    public var yVar : com__abagames__util__stgl__Variable;
    public var xVar : com__abagames__util__stgl__Variable;
    public var type : com__abagames__util__stgl__ActorType;
    public var name : String;
    static public function initialize(manager : com__abagames__util__stgl__StglManager) : void {
        com__abagames__util__stgl__StglActor.stglManager = manager;
        com__abagames__util__stgl__StglActor.baseSpeed = manager.baseSpeed;
    }
    
    static protected var stglManager : com__abagames__util__stgl__StglManager;
    static protected var baseSpeed : Number;
    static public function add(name : String,args : Array = null,parent : com__abagames__util__stgl__StglActor = null) : com__abagames__util__stgl__StglActor {
        var actor : com__abagames__util__stgl__StglActor = new com__abagames__util__stgl__StglActor(name,args,parent);
        com__abagames__util__stgl__StglActor.stglManager.add(actor);
        return actor;
    }
    
}

dynamic class com__abagames__util__stgl__Variable {
    public function com__abagames__util__stgl__Variable(name : String = null) : void { if( !flash__Boot.skip_constructor ) {
        this.name = name;
    }}
    
    public function update(actor : com__abagames__util__stgl__StglActor) : void {
        if(this.targetTicks > 0) {
            this.value += (this.target - this.value) / this.targetTicks;
            this.targetTicks--;
        }
        if(this.consistentlyValue != null) this.value = this.consistentlyValue.calc(actor);
        if(this.consistentlyAdd != null) this.value += this.consistentlyAdd.calc(actor);
        if(this.consistentlySub != null) this.value -= this.consistentlySub.calc(actor);
    }
    
    public var consistentlySub : com__abagames__util__stgl__Expression = null;
    public var consistentlyAdd : com__abagames__util__stgl__Expression = null;
    public var consistentlyValue : com__abagames__util__stgl__Expression = null;
    public var targetTicks : int = 0;
    public var target : Number = 0.0;
    public var value : Number = 0.0;
    public var name : String;
}

import flash.net.URLRequest;
import flash.utils.getDefinitionByName;
import flash.system.fscommand;
import flash.display.MovieClip;
import flash.utils.getTimer;
import flash.net.navigateToURL;
dynamic class flash__Lib {
    static public var current : flash.display.MovieClip;
    static public function _getTimer() : int {
        return flash.utils.getTimer();
    }
    
    static public function eval(path : String) : * {
        var p : Array = path.split(".");
        var fields : Array = new Array();
        var o : * = null;
        while(p.length > 0) {
            try {
                o = flash.utils.getDefinitionByName(p.join("."));
            }
            catch( e : * ){
                fields.unshift(p.pop());
            }
            if(o != null) break;
        }
        {
            var _g : int = 0;
            while(_g < fields.length) {
                var f : String = fields[_g];
                ++_g;
                if(o == null) return null;
                o = o[f];
            }
        }
        return o;
    }
    
    static public function getURL(url : flash.net.URLRequest,target : String = null) : void {
        var f : Function = flash.net.navigateToURL;
        if(target == null) f(url);
        else f(url,target);
    }
    
    static public function fscommand(cmd : String,param : String = null) : void {
        flash.system.fscommand(cmd,((param == null)?"":param));
    }
    
    static public function _trace(arg : *) : void {
        trace(arg);
    }
    
    static public function attach(name : String) : flash.display.MovieClip {
        var cl : * = flash.utils.getDefinitionByName(name) as Class;
        return new cl();
    }
    
    static public function _as(v : *,c : Class) : * {
        return v as c;
    }
    
}