[
  {
    "path": ".gitignore",
    "content": "*.swf\n.DS_Store\nMochiWrapper.as\nmochi/"
  },
  {
    "path": "Arrow.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxParticle;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxSprite;\n    \n    public class Arrow extends FlxParticle{\n        \n        [Embed(source='/assets/gfx/arrow.png')]     private var Img:Class;\n        \n\t\tpublic var shooter:Citizen = null;\n\t\t\n        public function Arrow(){\n            super();\n            loadRotatedGraphic(Img);\n            maxVelocity.x  = 200;\n            maxVelocity.y  = 275;\n            acceleration.y = 500;\n            offset.x = 3;\n            offset.y = 3;\n            height = 2;\n            width = 2;\n            elasticity = 0.5;\n        }\n        \n        public function shotFrom(from:Citizen, at:FlxObject):void{\n            x = from.x + from.width/2 + (from.facing == RIGHT ? 6 : -6);\n            y = from.y + 10;\n            revive();\n            velocity.x = (from.facing == RIGHT ? maxVelocity.x : -maxVelocity.x);\n            velocity.y = - Math.abs(at.x - from.x) + FlxG.random()*40;\n            lifespan = 10;\n\t\t\tshooter = from;\n        }\n        \n        override public function update():void{\n            if (y > (FlxG.state as PlayState).water.y){\n                kill();\n                var s:Splash = (FlxG.state as PlayState).fx.recycle(Splash) as Splash;\n                s.reset(x,y);\n            }\n            angle = (180/Math.PI) * Math.atan2(velocity.y, velocity.x);\n        }\n        \n    }\n}\n"
  },
  {
    "path": "Attention.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxParticle;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxSprite;\n    \n    public class Attention extends FlxParticle{\n        \n        [Embed(source='/assets/gfx/attention.png')]     private var Img:Class;\n        \n        public var citizen:Citizen;\n\t\t\n        public function Attention(){\n            super();\n            loadGraphic(Img);\n            maxVelocity.x  = 0;\n            maxVelocity.y  = 0;\n            height = 8;\n            width = 8;\n            alpha = 0.5;\n        }\n        \n        public function appearAt(at:Citizen):void{\n            citizen = at;\n            y = at.y - 4;\n            revive();\n            lifespan = 1;\n        }\n        \n        override public function update():void{\n            x = citizen.x + citizen.width/2 - 4;\n            super.update()\n        }\n    }\n}\n"
  },
  {
    "path": "Buildable.as",
    "content": "package\n{   \n    public interface Buildable\n    {\n        function canBuild():Boolean;\n        \n        function build():void;\n    }\n}"
  },
  {
    "path": "Bunny.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    \n    public class Bunny extends FlxSprite{\n        \n        [Embed(source='/assets/gfx/bunny.png')]     private var Img:Class;\n        \n        public var DECAY_TIME:Number = 5;\n        public var TURN_TIME:Number = 1;\n        \n        public var t:Number = 0;\n        \n        public function Bunny(X:int,Y:int){\n            super(X,Y);\n            loadGraphic(Img,true,true,16,16);\n            offset.y = 4;\n            height = 12;\n            maxVelocity.y  = 100;\n            maxVelocity.x = 30;\n            drag.x = 1000;\n            addAnimation('walk',[0,1,2,3,4,5,6,7,8,9,10],(10+FlxG.random()*5),true);\n            addAnimation('stand',[0],10,true);\n            addAnimation('dead',[11],10,true);\n            y = (FlxG.state as PlayState).groundHeight - 12;\n        }\n        \n        public function getShot(arrow:Arrow):void{\n            play('dead');\n            alive = false;\n            velocity.x = 0;\n            t = 0;\n            ((FlxG.state as PlayState).coins.recycle(Coin) as Coin).drop(this, arrow.shooter);\n        }\n        \n        override public function update():void {\n            // Check for movement input\n            acceleration.x = 0;\n            t += FlxG.elapsed ;\n            if (x+width > PlayState.GAME_WIDTH || x < 0){\n                kill();\n            }\n            if (alive){\n                if (t > TURN_TIME){\n                    t = 0;\n                    if (FlxG.random() < 0.4)\n                        facing = (facing == LEFT) ? RIGHT : LEFT\n                }\n                if(facing == LEFT){\n                    acceleration.x = -maxVelocity.x*4;\n                    play('walk');\n                } else {\n                    acceleration.x = maxVelocity.x*4;\n                    play('walk');\n                }            \n                super.update();\n            } else {\n                alpha = 1-(t/DECAY_TIME);\n                if (t > DECAY_TIME){\n                    kill();\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "CameraTarget.as",
    "content": "package{\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxSprite;\n    \n    /** \n    * Class that provides a dummy target for FlxCamera.follow,\n    * and performs tweening and following with an offset.\n    */\n    \n    public class CameraTarget extends FlxObject{\n        \n        public var lead:Number = 48;\n        public var speed:FlxPoint = new FlxPoint(0.1, 0.1);\n        public var maxSpeed:FlxPoint = new FlxPoint(20, 20);\n        public var offset:FlxPoint = new FlxPoint(0,0);\n\n        private var _target:FlxSprite;\n        private var _targetX:Number;\n        private var _targetY:Number;\n        \n        public function CameraTarget(){\n            super(0,0,1,1);\n        }\n        \n        public function set target(object:FlxSprite):void{\n            _target = object;\n        }\n        \n        public function get target():FlxSprite{\n            return _target;\n        }\n        \n        /**\n        * Snap location to target object immediatly, i.e. no tweening\n        */\n        public function snap():void{\n            x = _target.x + _target.width/2 + offset.x;\n            y = _target.y + _target.height/2 + offset.y;\n        }\n        \n        override public function update():void{\n            if (_target == null)\n                return;\n            // Basic target position\n            _targetX = _target.x + _target.width/2 + offset.x;\n            _targetY = _target.y + _target.height/2 + offset.y;\n            // Incorporate the lead\n            if (_target.facing == RIGHT){\n                _targetX += lead;\n            } else if (_target.facing == LEFT) {\n                _targetX -= lead;\n            } else if (_target.facing == UP) {\n                _targetY -= lead;\n            } else if (_target.facing == DOWN){\n                _targetY += lead;\n            }\n            \n            // Compute relative movement\n            _targetX = (_targetX - x) * speed.x;\n            _targetY = (_targetY - y) * speed.y;\n            \n            // Cap the speeds\n            if (_targetX >= 1.0) {\n                x += Math.min(maxSpeed.x, _targetX);\n            } else if (_targetX <= -1.0){\n                x += Math.max(-maxSpeed.x, _targetX);\n            }\n            if (_targetY >= 1.0) {\n                y += Math.min(maxSpeed.y, _targetY);\n            } else if (_targetY <= 1.0) {\n                y += Math.max(-maxSpeed.y, _targetY);\n            }\n        }\n        \n        override public function draw():void{\n        }\n    }\n}"
  },
  {
    "path": "Campfire.as",
    "content": "package{\n\n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    \n    public class Campfire extends Light{\n        \n        [Embed(source='/assets/gfx/campfire.png')] private var CampfireImg:Class;\n\n        [Embed(source='/assets/gfx/light_large.png')] private var LightLargeImg:Class;\n        [Embed(source='/assets/gfx/light_reflect_wide.png')] private var LightReflectWideImg:Class;\n        \n        public function Campfire(X:Number, Y:Number){    \n            Y -= 12;\n            \n            super(X,Y);\n            \n            offset.x = 16;\n            offset.y = 52;\n            loadGraphic(CampfireImg, true, false, 32, 64);\n            beam.loadGraphic(LightLargeImg);\n            reflected.loadGraphic(LightReflectWideImg);\n            reflected.color = 0xFFfc8f53;\n            addAnimation('on', [0,1,2,3,4,5,6,7], 10, true);\n            addAnimationCallback(this.dim);\n            play('on');\n            setLight()\n        }\n    }\n}"
  },
  {
    "path": "Castle.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxGroup;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    \n    public class Castle extends FlxSprite implements Buildable{\n        \n        [Embed(source='/assets/gfx/castle.png')] public var CastleImg:Class;\n        \n        public static const POST:int = 0;\n        public static const PLATFORM:int = 1;\n        public static const WATCHTOWER:int = 2;\n        public static const STONETOWER:int = 3;\n        public static const CASTLE:int = 4;\n        \n        public static const BUILD_COOLDOWN:Number = PlayState.CHEATS ? 1 : 15;\n        public static const ARCHER_POSITIONS:Array = [[new FlxPoint(58-32,104-32-12)],\n                                                      [new FlxPoint(48-32,91-32-12),new FlxPoint(136-32,91-32-12)],\n                                                      [new FlxPoint(48-32,91-32-12),new FlxPoint(136-32,91-32-12),new FlxPoint(60,46-32-12)],\n                                                      [new FlxPoint(48-32,91-32-12),new FlxPoint(136-32,91-32-12),new FlxPoint(45,46-32-12),new FlxPoint(75,46-32-12)],\n                                                      [new FlxPoint(48-32,91-32-12),new FlxPoint(136-32,91-32-12),\n                                                       new FlxPoint(38,46-32-12),new FlxPoint(83,46-32-12),\n                                                       new FlxPoint(27,64-32-12),new FlxPoint(93,64-32-12)]];\n        public static const ARCHER_POSITION_INDEX:Array = [0,0,1,1,1,2,2,2,2,3,3,3,3,3,4]\n        \n        private var playstate:PlayState;\n        \n        private var light:Light;\n        private var lights:FlxGroup;\n        \n        public var t:Number = 0;\n        public var stage:int;\n        public var archers:FlxGroup;\n        public var archer_positions:Array = [];\n        public var capacity:int = 0;\n        public var baseY:Number;\n        \n        public function Castle(X:Number, Y:Number){\n            super(X,Y);\n            baseY            = Y+1;\n            moves            = false;\n            playstate        = (FlxG.state as PlayState)\n            lights           = playstate.lights;\n            archers          = playstate.archers;\n            playstate.castle = this;\n            \n            loadGraphic(CastleImg, true, true, 128, 96);\n            addAnimation(\"stages\",[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],1);\n\n            morph(POST);\n            \n            light            = new Campfire(x+width/2,y+height);\n            lights.add(light);\n\n\n        }\n        \n        public function morph(stage:int):void{\n            archer_positions = ARCHER_POSITIONS[ARCHER_POSITION_INDEX[stage]].slice();\n            for each (var archer:Citizen in archers.members){\n                if (archer != null) {\n                    archer.leaveGuard();\n                }\n            }\n            frame = stage;\n            // switch(stage){\n            //     case POST:\n            //         loadGraphic(Castle1Img);\n            //         break;\n            //     case PLATFORM:\n            //         loadGraphic(Castle2Img);\n            //         break;\n            //     case WATCHTOWER:\n            //         loadGraphic(Castle3Img);\n            //         break;                    \n            //     case STONETOWER:\n            //         loadGraphic(Castle4Img);\n            //         break;\n            //     case CASTLE:\n            //         loadGraphic(Castle5Img);\n            //         break;                    \n            // }\n            this.stage = stage;\n            height = 84;\n            y = baseY + 96 - height;\n            offset.y = 96 - height;\n        }\n        \n        public function build():void{\n            if (stage < ARCHER_POSITION_INDEX.length){\n                t = 0;\n                Utils.explode(this, playstate.gibs, 0.4);\n                morph(stage + 1);\n                // flicker();\n            }\n            \n        }\n        \n        public function canBuild():Boolean{\n            return (t > BUILD_COOLDOWN && stage < 14);\n        }\n        \n        override public function update():void{\n            t += FlxG.elapsed;\n            playstate.kingdomRight = Math.max(playstate.kingdomRight, x+width)\n            playstate.kingdomLeft  = Math.min(playstate.kingdomLeft, x)\n        }\n    }\n}\n"
  },
  {
    "path": "Citizen.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxGroup;\n    import org.flixel.FlxSound;\n    \n    public class Citizen extends FlxSprite{\n        \n        [Embed(source='/assets/gfx/beggar.png')]    public static const BeggarImg:Class;\n        [Embed(source='/assets/gfx/citizen.png')]   public static const PoorImg:Class;\n        [Embed(source='/assets/gfx/hunter.png')]    public static const HunterImg:Class;\n        [Embed(source='/assets/gfx/farmer.png')]    public static const FarmerImg:Class;\n        \n        [Embed(source=\"/assets/sound/shoot.mp3\")] public static const ShootSound:Class;\n        [Embed(source=\"/assets/sound/powerup.mp3\")] public static const PowerupSound:Class;\n        [Embed(source=\"/assets/sound/hitcitizen.mp3\")] public static const HitSound:Class;\n\n        public static var shootSound:FlxSound = FlxG.loadSound(ShootSound);\n        \n        public static const BASE_COLOR:uint = 0xFF567271;\n        public static const BASE_SHADE:uint = 0xFF394b4a;\n        public static const BASE_SKIN:uint = 0xFFedbebf;\n        public static const BASE_DARK:uint = 0xFFbd9898;\n        public static const BASE_EYES:uint = 0xFFa18383;\n        \n        public static const BEGGAR:int = 0;\n        public static const POOR:int   = 1;\n        public static const FARMER:int = 2;\n        public static const HUNTER:int = 3;\n        \n        // Behaviors\n        public static const IDLE:int        = 0;\n        public static const SHOOT:int       = 1;\n        public static const JUST_SHOT:int   = 2;\n        public static const SHOVEL:int      = 3;\n\t\tpublic static const GIVE:int        = 4;\n\t\tpublic static const JUST_HACKED:int = 5;\n        public static const COWER:int       = 6;\n        \n        \n        // Behavior times\n        public static const SHOOT_COOLDOWN_GUARD:Number = 1.4;\n        public static const SHOOT_COOLDOWN:Number = 2.0;\n        public static const HACK_COOLDOWN:Number = 4.0;        \n        public static const SHOVEL_PERIOD:Number = 4.0;\n        public static const SHOVEL_TIME:Number = 1.0;\n        public static const SHOVEL_GOAL_DIST:Number = 600;\n\t\tpublic static const GIVE_COOLDOWN:Number = 10.0;\n        public static const COWER_COOLDOWN:Number = 5.0;\n\n        // Other consts\n        public static const HUNTER_BORDER_RANGE:Number = 256;\n        public static const MAX_HUNGRY:Number = 5;\n        \n        // Variables\n        public var occupation:int   = BEGGAR;\n        public var action:int       = IDLE;\n        public var guarding:Boolean = false;\n        public var t:Number         = 0;\n        public var goal:Number;\n        public var myColor:uint;\n        public var skin:uint;\n        public var coins:int = 0;\n\t\tpublic var giveCooldown:Number = 0;\n        public var shovelCooldown:Number = 0;\n\t\tpublic var target:FlxObject;\n        public var guardLeftBorder:Boolean;\n        public var hungry:int = 0;\n                \n        public var playstate:PlayState;\n        public var castle:Castle;\n        \n        public function Citizen(X:int,Y:int){\n            super(X,Y);\n            goal = FlxG.worldBounds.width/2;\n            drag.x = 500;\n            guardLeftBorder = (FlxG.random() > 0.5);\n            myColor = Utils.HSVtoRGB(FlxG.random()*360, 0.1+FlxG.random()*0.2, 0.6);\n            var d:Number = Math.random() * 20;\n            skin = Utils.HSVtoRGB(d, 0.19 + (d / 100), 0.97 - (d / 33));\n\n            playstate = FlxG.state as PlayState;\n            castle = playstate.castle;\n\t\t\taddAnimationCallback(this.animationFrame);\n            morph(BEGGAR);    \n        }\n        \n        public function morph(occ:int):Citizen{\n            action = IDLE;\n            _animations = new Array();\n            if (occ != BEGGAR && coins <= 0){\n                coins ++;\n            }\n            switch(occ){\n                case BEGGAR:\n                    if (occupation != BEGGAR)\n                        playstate.beggars.add(playstate.characters.remove(this,true));\n                    loadGraphic(BeggarImg,true,true,32,32,true);\n                    addAnimation('walk',[0,1,2,3,4,5],5,true);\n                    addAnimation('idle',[7,8,7,8,7,6],2,true);\n                    addAnimation('cower',[9,10],2,false);\n                    maxVelocity.x = 15;\n                    hungry = 0;\n                    break;\n                case POOR:\n                    if (occupation == BEGGAR)\n                        playstate.characters.add(playstate.beggars.remove(this,true));\n                    loadGraphic(PoorImg,true,true,32,32,true);\n                    Utils.replaceColor(pixels, BASE_COLOR, myColor);\n                    Utils.replaceColor(pixels, BASE_SHADE, Utils.interpolateColor(myColor,0xFF000000,0.2));\n                    maxVelocity.x = 17;\n                    addAnimation('walk',[0,1,2,3,4,5],10,true);\n                    addAnimation('idle',[0,6,0,6,0,7],2,true);\n                    break;\n                case HUNTER:\n                    if (guardLeftBorder){\n                        myColor = Utils.HSVtoRGB(220 + FlxG.random() * 20, 0.2+FlxG.random()*0.3, 0.7);\n                    } else {\n                        myColor = Utils.HSVtoRGB(0 + FlxG.random() * 20, 0.2+FlxG.random()*0.3, 0.7);\n                    }\n                    loadGraphic(HunterImg,true,true,32,32,true);\n                    Utils.replaceColor(pixels, BASE_COLOR, myColor);\n                    Utils.replaceColor(pixels, BASE_SHADE, Utils.interpolateColor(myColor,0xFF000000,0.2));\n                    maxVelocity.x = 18;\n                    addAnimation('walk',[0,1,2,3,4,5],10,true);\n                    addAnimation('idle',[6,7,6,7,6,8],2,true);\n                    addAnimation('shoot',[9,10,0],6,false);\n\t\t\t\t\taddAnimation('give',[11,12,13],15,false);\n                    break;\n                case FARMER:\n                    loadGraphic(FarmerImg,true,true,32,32,true);\n                    Utils.replaceColor(pixels, BASE_COLOR, myColor);\n                    Utils.replaceColor(pixels, BASE_SHADE, Utils.interpolateColor(myColor,0xFF000000,0.2));\n                    maxVelocity.x = 21 + Math.random() * 3;\n                    addAnimation('walk',[0,1,2,3,4,5],12,true);\n                    addAnimation('idle',[6,7,6,7,6,8],2,true);\n                    addAnimation('shovel',[8,9,10,9],6,true)\n\t\t\t\t\taddAnimation('give',[11,12,13],15,false);\n\t\t\t\t\taddAnimation('hack',[14],15,false);\n                    break;\n            }\n\n            Utils.replaceColor(pixels, BASE_SKIN, skin);\n            Utils.replaceColor(pixels, BASE_DARK, Utils.interpolateColor(skin,0xFF000000,0.2));\n            Utils.replaceColor(pixels, BASE_EYES, Utils.interpolateColor(skin,0xFF000000,0.5));\n            drawFrame(true);\n            occupation = occ;\n            offset.x = 12;\n            offset.y = 8;\n            width = 8;\n            height = 24;\n            pickNewGoal();\n            return this;\n        }\n        \n        public function pickup(coin:FlxObject):void{\n            if (!coin.alive) return;\n\t\t\tvar c:Coin = coin as Coin;\n\t\t\t// Return if the coin doesn't belong to me.\n\t\t\tif (c.owner != null && c.owner != this){\n\t\t\t\treturn;\n\t\t\t}\n            c.kill();\n            // flicker();\n            var s:Sparkle = (FlxG.state as PlayState).fx.recycle(Sparkle) as Sparkle;\n            s.reset(x-4, y+8);\n            if (occupation == BEGGAR) {\n                playstate.recruitedCitizen = true;\n                morph(POOR);\n                FlxG.play(PowerupSound).proximity(x, y, playstate.player, FlxG.width * 0.75)\n            }\n            coins ++;\n        }\n\t\t\n\t\tpublic function giveTaxes(p:Player):void{\n\t\t\tif (occupation == HUNTER || occupation == FARMER){\n\t\t\t\tif (action == IDLE && coins > 3 && giveCooldown <= 0){\n\t\t\t\t\taction = GIVE;\n                    coins -= 2;\n\t\t\t\t\tplay('give');\n\t\t\t\t\tp.changeCoins(1);\n\t\t\t\t\tgiveCooldown = GIVE_COOLDOWN;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n        \n        public function hitByTroll(troll:Troll):void{\n            // Farmers can defend.\n            if (occupation == FARMER && action != JUST_HACKED){\n                action = JUST_HACKED;\n                play(\"hack\");\n                t = 0;\n                troll.getShot();\n            } else if (coins > 0 && !troll.hasCoin){\n                (playstate.coins.recycle(Coin) as Coin).drop(this, playstate.player);\n                FlxG.play(HitSound).proximity(x, y, playstate.player, FlxG.width);\n                coins = (coins > 1) ? 1 : 0;\n                Utils.explode(this, playstate.gibs);\n                if (coins == 0){\n                    morph(BEGGAR);\n                } else if (coins == 1){\n                    morph(POOR);\n                }\n            }\n            if (occupation == BEGGAR && action == IDLE){\n                action = COWER;\n                play('cower', true);\n            }\n        }\n        \n        public function checkShootable(group:FlxGroup):void{\n            var c:FlxObject;\n            for (var i:int = 0; i < group.length; i++){\n                c = group.members[i];\n                if (c != null && c.alive && c.exists && Math.abs(c.x - x) < 96){\n                    // FlxG.log(\"Shooting \"+c+\" at \"+c.x+','+c.y);\n                    play('shoot', true);\n                    shootSound.play(false);\n                    shootSound.proximity(x, y, playstate.player, FlxG.width);\n\t\t\t\t\t// walk 1 pixel towards goal, just to get\n\t\t\t\t\t// the facing right\n                    goal = (c.x > x) ? x + 1 : x - 1;\n                    facing = (goal > x) ? RIGHT : LEFT;\n\t\t\t\t\ttarget = c;\n                    action = SHOOT;\n                    t = 0;\n                    break;\n                }\n            }\n        }\n        \n        public function checkWork(group:FlxGroup):void{\n            var c:FlxObject;\n            for (var i:int = 0; i < group.length; i ++){\n                c = group.members[i];\n                if (c != null){\n                    if (x > c.x && x+width < c.x+c.width){\n                        if ((c as Workable).needsWork()){\n                            (c as Workable).work(this);\n                            play('shovel',true);\n                            action = SHOVEL;\n                            shovelCooldown = SHOVEL_PERIOD;\n                            t = 0;\n                        }\n                    }\n                }\n            }\n        }\n        \n        public function checkGuard():void{\n            if (action == IDLE && castle.archer_positions.length > 0){\n                if (Math.abs(castle.x-x) < 192) {\n                    for (var i:int = 0; i < castle.archer_positions.length; i++){\n                        var pos:FlxPoint = castle.archer_positions[i];\n                        if(Math.abs(castle.x+pos.x-x) < 4){\n                            x = castle.x + pos.x;\n                            y = castle.y + pos.y;\n                            guarding = true;\n                            playstate.archers.add(playstate.characters.remove(this,true));\n                            castle.archer_positions.splice(i,1);\n                            break;\n                        }\n                    }\n                }\n            }\n        }\n        \n        public function leaveGuard():void{\n            castle.archer_positions.push(new FlxPoint(x,y));\n            playstate.characters.add(playstate.archers.remove(this));\n            action == IDLE;\n            guarding = false;\n        }\n        \n        public function pickNewGoal(preset:Number = NaN):void{\n            //TODO !!! Hunters don't target well at night\n            var a:Attention = playstate.fx.recycle(Attention) as Attention;\n            a.appearAt(this);\n            if (!isNaN(preset)){\n                goal = preset;\n                return\n            }\n            if (occupation == POOR){\n                var shop:Shop = (playstate.shops.getRandom() as Shop);\n                goal = shop.x + shop.width/2;\n                return;\n            }\n\t\t\tif (coins > 4){\n\t\t\t\tgoal = playstate.player.x;\n\t\t\t\treturn;\n\t\t\t}\n            if (occupation == FARMER) {\n                // Otherwise check for a wall to work on\n                var needWork:Array = new Array();\n                var dist:Number = Number.MAX_VALUE;\n                var wall:Wall, closestWall:Wall = null;\n                for (var i:int = 0; i < playstate.walls.length; i++){\n                    wall = playstate.walls.members[i] as Wall;\n                    if (wall != null && wall.needsWork() && (Math.abs(wall.x - x) < dist)){\n                        closestWall = wall;\n                        dist = Math.abs(wall.x - x);\n                    }                    \n                }\n                if (closestWall != null){\n                    goal = closestWall.x + closestWall.width / 2;\n                    return;    \n                }\n                \n            }\n            \n            var l:int, r:int;\n            \n            if (occupation == HUNTER) {\n                // Hunters gather around borders at night\n                if (playstate.weather.timeOfDay >= 0.65 || playstate.weather.timeOfDay < 0.20){\n                    if (guardLeftBorder){\n                        l = playstate.kingdomLeft;\n                        r = playstate.kingdomLeft + 32;\n                    } else {\n                        l = playstate.kingdomRight - 32;\n                        r = playstate.kingdomRight;\n                    }\n                } else {\n                    l = playstate.kingdomLeft - HUNTER_BORDER_RANGE;\n                    r = playstate.kingdomRight + HUNTER_BORDER_RANGE;\n                }\n            } else if (occupation == BEGGAR){\n                // Beggars gather outside borders\n                if (playstate.beggars.countLiving() > playstate.minBeggars){\n                    hungry ++;\n                    if (hungry > MAX_HUNGRY){\n                        Utils.explode(this, playstate.gibs, 1.0);\n                        kill();\n                    }\n                }\n                if (x < PlayState.GAME_WIDTH/2){\n                    l = playstate.kingdomLeft - 256;\n                    r = playstate.kingdomLeft;\n                } else {\n                    l = playstate.kingdomRight;\n                    r = playstate.kingdomRight + 256;\n                }\n            } else {\n                // Move anywhere within the kingdom\n                l = playstate.kingdomLeft;\n                r = playstate.kingdomRight;\n            }\n            goal = int(FlxG.random()*(r-l) + l);\n            /*FlxG.log(\"Citizen (\" + occupation + \") picked goal \" + goal)*/\n        }\n        \n\t\t\n\t\tpublic function animationFrame(animName:String, frameNum:uint, frameIndex:uint):void{\n\t\t\tif (animName == 'give' && frameNum == 2){\n\t\t\t\taction = IDLE;\n\t\t\t\tplay('idle');\n\t\t\t}\n\n            if (animName == 'shovel'){\n                var d:Dust = playstate.fx.recycle(Dust) as Dust;\n                d.reset(x + ((facing == RIGHT) ? 14 : -6), y + 19);\n            }\n\t\t}\n\n        \n        override public function update():void {\n            acceleration.x = 0;\n            t += FlxG.elapsed;\n            shovelCooldown -= FlxG.elapsed;\n\t\t\tgiveCooldown -= FlxG.elapsed;\n\n            // IDLE MOVING AROUND\n            \n            if(guarding && occupation == HUNTER){\n                play('idle');\n                facing = (goal > x) ? RIGHT : LEFT;\n            } else if (action == IDLE){\n                facing = (goal > x) ? RIGHT : LEFT;\n                // Near Goal\n                if (Math.abs(goal - x) < 2){\n                    if (t > 2.0 && FlxG.random() < 0.3) {\n                        t = 0;\n                        pickNewGoal();\n                    } else {\n                        play('idle');\n                    }\n                // Far away from goal\n                } else {\n                    play('walk');\n                    acceleration.x = (facing == RIGHT) ? maxVelocity.x*10 : -maxVelocity.x*10;\n                    y = playstate.groundHeight - height;\n                    \n                }                \n            }\n            \n            // Specific Behavior\n            if (occupation == HUNTER){\n                // Shooting cycle\n                if (action == SHOOT && t > 0.16){\n                    (playstate.arrows.recycle(Arrow) as Arrow).shotFrom(this, target);\n                    t = 0;\n                    action = JUST_SHOT;\n                } else if (action == JUST_SHOT && t > (guarding ? SHOOT_COOLDOWN_GUARD : SHOOT_COOLDOWN)){\n                    t = 0;\n                    action = IDLE;\n                } else if (action == IDLE){\n                    checkShootable(playstate.trolls);\n                    checkShootable(playstate.trollsNoCollide);\n                    // Check for idle again since we could be shooting a Troll.\n                    if (action == IDLE){\n                        checkShootable(playstate.bunnies);\n                    }                    \n                }\n                // Check if we need to take up a guard post.\n                checkGuard();\n            } else if (occupation == FARMER){\n                if (action == JUST_HACKED && t > HACK_COOLDOWN ){\n                    t = 0;\n                    action = IDLE;\n                }\n                if (shovelCooldown <= 0 && action == IDLE) {\n                    checkWork(playstate.walls);\n                    checkWork(playstate.farmlands);\n                } else if (action == SHOVEL && t > SHOVEL_TIME){\n                    t = 0;\n                    action = IDLE;\n                }\n            } else if (occupation == BEGGAR){\n                if (action == COWER && t > COWER_COOLDOWN){\n                    t = 0;\n                    action = IDLE;\n                }\n            }\n            \n            \n            super.update();\n        }\n        \n        \n    }\n}\n"
  },
  {
    "path": "Coin.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxParticle;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxSprite;\n    \n    public class Coin extends FlxParticle{\n        \n        [Embed(source='/assets/gfx/coin.png')]     private var Img:Class;\n\t\t\n\t\tpublic static const TOTAL_LIFESPAN:Number = 25;\n\t\tpublic static const OWNER_LIFESPAN:Number = 4;\n\t\tpublic var owner:FlxObject = null;\n        public var justThrown:Boolean = false;\n        public var called:Boolean = false;\n        \n        public function Coin(){\n            super();\n            \n            loadGraphic(Img,true,false,10,10);\n            maxVelocity.x  = 20;\n            maxVelocity.y  = 275;\n            acceleration.y = 900;\n            addAnimation('spin',[0,1,2,3,4,5,6,7],10,true);\n            play('spin');\n            elasticity = 0.5;\n        }\n                \n        public function drop(from:FlxSprite, owner:FlxObject=null, far:Boolean=false):Coin{\n            reset(from.x + from.width/2 - 5, Math.max(40, from.y - 10));\n            lifespan = TOTAL_LIFESPAN;\n            if (far){\n                velocity.x = FlxG.random()*140 - 70;\n                velocity.y = -180;\n            } else {\n                velocity.x = FlxG.random()*60 - 30;\n                velocity.y = -180;\n            }\n            called = false;\n\t\t    this.owner = owner;\n\t\t\tif (owner != null && owner is Citizen){\n\t\t\t\t(owner as Citizen).pickNewGoal(this.x + this.width/2 + this.velocity.x)\n\t\t\t}\n            return this;\n        }\n        \n        override public function update():void{\n            if (!called && lifespan <= TOTAL_LIFESPAN - OWNER_LIFESPAN / 2) {\n                justThrown = false;\n                var cit:Citizen = owner as Citizen;\n                if (cit){\n                    called = true;\n                    justThrown = false;\n                    flicker();\n                    cit.pickNewGoal(x+width/2);\n                }\n            }\n            if (owner != null && lifespan <= TOTAL_LIFESPAN - OWNER_LIFESPAN){\n                flicker();\n                owner = null;\n            }\n            super.update()\n        }\n    }\n}\n"
  },
  {
    "path": "CoinFloat.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxSprite;\n    \n    public class CoinFloat extends FlxSprite{\n        \n        [Embed(source='/assets/gfx/coin_drop.png')]     private var Img:Class;\n        \n        public function CoinFloat(){\n            super();\n            \n            loadGraphic(Img,true,false,10,24);\n            addAnimation('spin',[0,1,2,3,4,5,6,7],10,true);\n            play('spin');\n        }\n                \n        public function float(above:FlxSprite):void{\n            acceleration.y = 0;\n            x = above.x + above.width/2 - width/2;\n            y = Math.max(above.y - height - 4, 40);\n            above.color = 0xCCCC00;\n            // above.flicker();\n        }\n        \n    }\n}\n"
  },
  {
    "path": "Coinsack.as",
    "content": "package\n{\n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    \n    public class Coinsack extends FlxSprite{\n        \n        [Embed(source='/assets/gfx/sack.png')]     private var Img:Class;\n        \n\t\tpublic static const FADE_TIME:Number = 20;\n\t\tpublic static var t:Number = 0;\n\t\t\n        public function Coinsack(X:Number=0, Y:Number=0){\n            super(X, Y);\n\t\t\t\n            loadGraphic(Img,true,false,16,16);\n            scrollFactor.x = scrollFactor.y = 0;\n            addAnimation('blink',[8,0,8,0,8,0,8,0,8,0],5,false);\n\n        }\n\t\t\n\t\tpublic function show(c:int):void{\n            if (c == 0) {\n                play('blink', true);\n            } else if (c == 1) {\n                frame = 1;\n            } else if (c >= 2 && c <= 3){\n                frame = 2;\n            } else if (c >= 4 && c <= 5){\n                frame = 3;\n            } else if (c >= 6 && c <= 8){\n                frame = 4;\n            } else if (c >= 9 && c <= 11){\n                frame = 5;\n            } else if (c >= 12 && c <= 15){\n                frame = 6;\n            } else if (c >= 15){\n                frame = 7\n            }\n\t\t\tt = 0;\n\t\t}\n\t\t\n\t\toverride public function update():void{\n\t\t\tt += FlxG.elapsed;\n\t\t\talpha = FADE_TIME - t;\n\t\t}\n    }\n}\n"
  },
  {
    "path": "Default.css",
    "content": "Add this: \"-defaults-css-url Default.css\"\nto the project's additonal compiler arguments."
  },
  {
    "path": "Dust.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxParticle;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxSprite;\n    \n    public class Dust extends FlxParticle{\n        \n        [Embed(source='/assets/gfx/dust.png')]     private var Img:Class;\n        \n        public function Dust(){\n            super();\n            loadGraphic(Img,true);\n            addAnimation('fade',[0,1,2,3], 5, false);\n            drag.x = drag.y = 20;\n        }\n        \n        override public function reset(X:Number, Y:Number):void{\n            super.reset(X,Y);\n            x += (Math.random() < 0.5) ? 4 : -4;\n            velocity.x = Math.random() * 40 - 20;\n            velocity.y = - Math.random() * 20 - 4;\n            lifespan = 1.0;\n            play('fade', true);\n        }\n    }\n}\n"
  },
  {
    "path": "ExplodingText.as",
    "content": "package\n{\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxGroup;\n    import org.flixel.FlxG;\n    import org.flixel.FlxPoint;\n    \n    public class ExplodingText extends FlxGroup{\n        \n        public function ExplodingText(){\n            super(0,0);\n        }\n    }\n}"
  },
  {
    "path": "Farmland.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    \n    public class Farmland extends FlxSprite implements Workable{\n        \n        [Embed(source='/assets/gfx/farmland.png')]    private var FarmlandImg:Class;\n\n        public static const WORK_COOLDOWN:Number = 8;\n\n        private var t:Number = 0;\n        \n        public function Farmland(X:int, Y:int){\n            super(X,Y);\n            loadGraphic(FarmlandImg, true, false, 64, 32);\n            addAnimation(\"grow\",[0,1,2,3,4,5,6,7],10);\n        }\n        \n        public function needsWork():Boolean {\n            return t > WORK_COOLDOWN;\n        }\n        \n        public function work(by:Citizen=null):void{\n            t = 0;\n            if (frame == 7){\n                ((FlxG.state as PlayState).coins.recycle(Coin) as Coin).drop(this, by);\n                ((FlxG.state as PlayState).coins.recycle(Coin) as Coin).drop(this, by);\n                ((FlxG.state as PlayState).coins.recycle(Coin) as Coin).drop(this, by);\n                ((FlxG.state as PlayState).coins.recycle(Coin) as Coin).drop(this, by);\n                by.pickNewGoal(x+width/2);\n            }\n            frame = (frame + 1) % 8;\n        }\n\n        override public function update():void{\n            t += FlxG.elapsed;\n        }\n    }\n}"
  },
  {
    "path": "Firefly.as",
    "content": "package{\n\n    import org.flixel.FlxSprite;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxG;\n    \n    public class Firefly extends Light{\n        \n\n        [Embed(source='/assets/gfx/light_small.png')] private var LightSmallImg:Class;\n        [Embed(source='/assets/gfx/light_reflect_small.png')] private var LightReflectSmallImg:Class;        \n    \n        public static const COLOR:uint = 0xFF7affa0;\n        public static const MAX_DIST:Number = 100;\n        private var weatherChanged:Number = 0;\n        private var startPos:FlxPoint = new FlxPoint();\n        \n\n                \n        public function Firefly(X:Number, Y:Number){\n            \n            super(X,Y);\n            startPos.x = X;\n            startPos.y = Y;\n            \n            offset.x = 0;\n            offset.y = 0;\n            makeGraphic(1,1,COLOR,false);\n            beam.loadGraphic(LightSmallImg);\n            reflected.loadGraphic(LightReflectSmallImg);\n            reflected.color = COLOR;\n            addAnimation('on', [0], 6, true);\n\n            addAnimationCallback(this.dim);\n            play('on');\n            setLight();\n        }\n        \n        override public function update():void{\n            // Move around a bit\n            velocity.x += (FlxG.random() - 0.5) * 0.5;\n            velocity.y += (FlxG.random() - 0.5) * 0.2;\n            \n            if (Math.abs(startPos.x - x) > MAX_DIST || Math.abs(startPos.y - y) > MAX_DIST){\n                x = startPos.x;\n                y = startPos.y;\n                velocity.x = 0;\n                velocity.y = 0;\n            }\n            \n            if (weather.changed > weatherChanged) {\n                beam.alpha = 1.5 * (weather.darkness) * (1 - weather.wind);\n                beam.drawFrame(true);\n                alpha = beam.alpha;\n                if (alpha < 0.1 && visible) {\n                    if (FlxG.random() < 0.05)\n                        visible = false;\n                }\n                if (alpha >= 0.1 && !visible){\n                    if (FlxG.random() < 0.05)\n                        visible = true\n                }\n                weatherChanged = weather.t;\n            }\n            \n            super.update()\n        }\n    }\n}"
  },
  {
    "path": "FlxBackdrop.as",
    "content": "package{\n    import flash.geom.Point;\n    import flash.display.BitmapData;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxGroup;\n    import org.flixel.FlxG;\n    \n    public class FlxBackdrop extends FlxSprite{\n        \n        /**\n        * A class that renders a single \"backdrop\" image repeatedly when drawn. \n        * Depending on the scrollfactor, the backdrop will move along when the \n        * camera moves. Multiple backdrop layers can be used to easily create \n        * a parralax effect.\n        */\n                \n        private var w:int;\n                \n        public function FlxBackdrop(graphicClass:Class, XScroll:Number=0.333, YScroll:Number=0.2, Color:uint=0xFF474a3d):void{\n            \n            var graphic:BitmapData = FlxG.addBitmap(graphicClass);\n            w = graphic.width;\n            makeGraphic(w + FlxG.width, graphic.height, 0x00000000, true);\n            \n            this.y = (FlxG.height - graphic.height)/2\n            \n            // Copy the graphic's pixels to this sprite pixels, adding an extra \"fold\"\n            var p:Point = new Point(0,0);\n            pixels.copyPixels(graphic, graphic.rect, p);\n            p.x = w;\n            pixels.copyPixels(graphic, graphic.rect, p);\n            dirty = true;\n            \n            scrollFactor.x = XScroll;\n            scrollFactor.y = YScroll;\n            \n            this.color = Color;\n        }\n        \n        override public function update():void{\n            getScreenXY(_point);\n            if (_point.x < -w){\n                x += w;\n            } else if (_point.x > 0){\n                x -= w;\n            }\n\n            super.update();\n        }\n        \n    }\n}"
  },
  {
    "path": "FlxBaker.as",
    "content": "package{\n    \n    import flash.geom.Rectangle;\n    import flash.geom.Point;\n    import flash.display.BitmapData;\n    import flash.utils.getQualifiedClassName\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    \n    public class FlxBaker{\n        private static const zeroPoint:Point = new Point(0,0);\n        \n        private static var _baked:Object = new Object();\n        \n        public static function bake(sprite:FlxSprite, key:String='base'){\n            var id:String = getQualifiedClassName(sprite)+\"@(\"+int(sprite.x)+','+int(sprite.y)+')'+key;\n            var bmp:BitmapData = new BitmapData(sprite.pixels.width,sprite.pixels.height);\n            bmp.copyPixels(sprite.pixels, new Rectangle(0,0,sprite.frameWidth,sprite.frameHeight),zeroPoint,null,null,true);\n            _baked[id] = bmp;\n        }\n    }\n}"
  },
  {
    "path": "FlxBumpmap.as",
    "content": "package{\n    import flash.display.BitmapData;\n    import flash.filters.ConvolutionFilter;\n    import flash.geom.Rectangle;\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    \n    public class FlxBumpmap extends FlxSprite {\n        \n        private static var filter:ConvolutionFilter = new ConvolutionFilter(3,3,null,1,0,true,false,0xFF808080);\n        private static var rect:Rectangle;\n        private static var zeroPoint:Point = new Point(0,0);\n        \n        public function FlxBumpmap(){\n            super();\n\n        }\n        \n        public function light(target:FlxSprite, color:uint=0x55FFFFCC, blend:String=\"normal\"):FlxBumpmap{\n            process(target, [0,0,-1,0,2,-1,0,0,0], color, blend);\n            return this\n        }\n        \n        public function shade(target:FlxSprite, color:uint=0x66333355, blend:String=\"normal\"):FlxBumpmap{\n            var m:Array = [0,0, 0,0,1,\n                           0,0, 0,1,0,\n                           0,0,-2,0,0,\n                           0,0, 0,0,0,\n                           0,0, 0,0,0]\n            process(target, m, color, blend);\n            return this;\n        }\n        \n        protected function process(target:FlxSprite, matrix:Array, color:uint, blend:String=\"normal\"):void{\n            rect = new Rectangle(0,0,pixels.width,pixels.height);\n            \n            filter.matrixX = filter.matrixY = Math.sqrt(matrix.length);\n            filter.matrix = matrix;\n\n            var regions:BitmapData = new BitmapData(pixels.width,pixels.height);\n            regions.applyFilter(pixels,rect,zeroPoint,filter);\n            regions.threshold(regions,rect,zeroPoint,\">\",0x000000,color,0x00FFFFFF);\n            regions.threshold(regions,rect,zeroPoint,\"==\",0x000000,0x000000,0x00FFFFFF);\n            \n            target.pixels.draw(regions,null,null,blend);\n            target.dirty = true;\n            regions.dispose();\n        }\n        \n        public static function lightFlatSprite(target:FlxSprite, color:uint=0x55FFFFCC, blend:String=\"normal\"):void{\n            processFlatSprite(target, [0,0,-1,0,2,-1,0,0,0], color, blend);\n        }\n        \n        public static function processFlatSprite(target:FlxSprite, matrix:Array, color:uint, blend:String=\"normal\"):void{\n            rect = new Rectangle(0,0,target.pixels.width,target.pixels.height);\n            \n            filter.matrixX = filter.matrixY = Math.sqrt(matrix.length);\n            filter.matrix = matrix;\n\n            var regions:BitmapData = target.pixels.clone();\n            regions.threshold(regions,rect,zeroPoint,\">\",0x00FFFFFF,0xFFFFFFFF,0xFFFFFFFF);\n            regions.applyFilter(regions,rect,zeroPoint,filter);\n            regions.threshold(regions,rect,zeroPoint,\">\",0x000000,color,0x00FFFFFF);\n            regions.threshold(regions,rect,zeroPoint,\"==\",0x000000,0x000000,0x00FFFFFF);\n            \n            target.pixels.draw(regions,null,null,blend);\n            target.dirty = true;\n            regions.dispose();\n        }\n        \n    }\n}\n"
  },
  {
    "path": "FlxMatrixblock.as",
    "content": "package\n{\n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    import flash.display.BitmapData;\n    import flash.geom.Rectangle;\n    import flash.geom.Point;\n    \n    /**\n     * This is an extension to flixel's standard Tileblock class. It autofills the block\n     * with a given tilematrix ()\n     * It can be filled with a random selection of tiles to quickly add detail.\n     */\n    public class FlxMatrixblock extends FlxSprite\n    {\n        static public const T:uint = 1;\n        static public const R:uint = 2;\n        static public const B:uint = 4;\n        static public const L:uint = 8;\n                \n        public var tileWidth:int;\n        public var tileHeight:int;\n        public var widthInTiles:int;\n        public var heightInTiles:int;\n        \n        public var tiles:Vector.<Vector.<Rectangle>> = new Vector.<Vector.<Rectangle>>(16)\n        public var mapping:Array;\n        \n        public var refresh:Boolean = true; // Set to true to re-render.\n        \n        protected var _tileBitmap:BitmapData;\n        protected var _bumpmap:BitmapData;\n        \n        public function FlxMatrixblock(X:int, Y:int, Width:uint, Height:uint){\n            super(X,Y);\n            makeGraphic(Width,Height,0xFF000000,true);\n            moves = false;\n        }\n        \n        public function loadTilematrix(MatrixGraphic:Class,TileWidth:uint,TileHeight:uint,TileSides:Array=null,BumpmapGraphic:Class=null):FlxMatrixblock{\n            _tileBitmap     = FlxG.addBitmap(MatrixGraphic);\n            var mWidth:int  = _tileBitmap.width / TileWidth;\n            var mHeight:int = _tileBitmap.height / TileHeight;\n            tileWidth       = TileWidth;\n            tileHeight      = TileHeight;\n            widthInTiles    = Math.floor(this.width / TileWidth);\n            heightInTiles   = Math.floor(this.height / TileHeight)\n            //Some default presets for tile mappings\n            var i:int, j:int\n            if (TileSides == null){\n                // Automap, assume closed/seamless image\n                var tileType:uint;\n                this.mapping = []\n                for (j = 0; j < mHeight; j++){\n                    for (i = 0; i < mWidth; i++){\n                        tileType = 0;\n                        if (i > 0)         tileType += L;\n                        if (i < mWidth-1)  tileType += R;\n                        if (j > 0)         tileType += T;\n                        if (j < mHeight-1) tileType += B;\n                        this.mapping.push(tileType);\n                    }\n                }\n            } else {this.mapping = TileSides;}\n            \n            // Create rectangles for each tile in the set\n            for (i = 0; i < mWidth; i++){\n                for (j = 0; j < mHeight; j++){\n                    var m:uint = mapping[j*mWidth+i];\n                    if (tiles[m] == null){\n                        tiles[m] = new Vector.<Rectangle>();\n                    }\n                    tiles[m].push(new Rectangle(i*tileWidth,j*tileHeight,tileWidth,tileHeight));\n                }\n            }\n            \n            this.renderTiles();\n            return this;\n        }\n        \n        public function renderTiles():void{\n            fill(0); // Fill with transparent color;\n            var tileType:uint = 0;\n            var srcRect:Rectangle;\n            var tgtPoint:Point = new Point(0,0);\n            var tileOpts:Vector.<Rectangle>\n            for (var i:int = 0; i < widthInTiles; i ++){\n                for (var j:int = 0; j < heightInTiles; j ++){\n                    tileType = 0;\n                    tgtPoint.x = i*tileWidth;\n                    tgtPoint.y = j*tileHeight;\n                    if (i > 0)               {tileType += L;}\n                    if (i < widthInTiles-1)  {tileType += R};\n                    if (j > 0)               {tileType += T};\n                    if (j < heightInTiles-1) {tileType += B};\n                    tileOpts = tiles[tileType];\n                    if (tileOpts != null){\n                        srcRect = tileOpts[Math.floor(FlxG.random()*tileOpts.length)];\n                        _pixels.copyPixels(_tileBitmap,srcRect,tgtPoint,null,null,true);\n                    }\n                }\n            }\n            pixels = pixels;\n        }\n    }\n}\n"
  },
  {
    "path": "Fog.as",
    "content": "package\n{\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxGroup;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxG;\n    import org.flixel.FlxPoint;\n    \n    public class Fog extends FlxGroup{\n        [Embed(source='/assets/gfx/fog.png')]  private const FogImg:Class;\n\n        public static const MAXFOG:int = 5;\n        \n        private var weather:Weather;\n        private var weatherChanged:Number = -1;\n        private var _fg:FlxSprite;\n        private var _point:FlxPoint = new FlxPoint();\n        \n        public function Fog(weather:Weather){\n            super(MAXFOG)\n            this.weather = weather;\n            \n            for (var i:int = 0; i < MAXFOG; i++){\n                _fg = new FlxSprite(0,0).loadGraphic(FogImg,true,true,256,96);\n                _fg.scrollFactor.y = 1.2;\n                _fg.scrollFactor.x = (FlxG.random() < 0.5) ? 1.5 : 2.5;\n                _fg.facing = (FlxG.random() < 0.5) ? FlxObject.LEFT : FlxObject.RIGHT;\n                _fg.frame = int(FlxG.random()*4);\n                _fg.kill();\n                add(_fg);\n            }\n        }\n        \n        override public function update():void{\n            for (var i:int = 0; i < members.length; i++){\n                _fg = members[i]\n                if (_fg.exists){\n                    _fg.getScreenXY(_point)\n                    if (_point.x + _fg.width < -100 || _point.x > FlxG.width + 100) {\n                        _fg.kill();\n                    } else {\n                        _fg.velocity.x = -weather.wind*20;\n                    }\n                }\n            }\n            if (weather.changed > weatherChanged){\n                // TODO: Does this run every frame?\n                if (countLiving() < MAXFOG * weather.fog) {\n                    _fg = getFirstAvailable() as FlxSprite;\n                    _fg.reset(0,0);\n                    if (FlxG.random() < 0.5){\n                        _fg.x = FlxG.camera.scroll.x*_fg.scrollFactor.x - _fg.width;\n                    } else {\n                        _fg.x = (FlxG.camera.scroll.x)*_fg.scrollFactor.x + FlxG.width\n                    }\n                    _fg.y = 112 + 50*FlxG.random();\n                    var comp:uint = (1 - weather.darkness)*255;\n                    var color:uint = comp << 16 | comp << 8 | comp;\n                    _fg.color = color;\n                    _fg.alpha = weather.fog/6 + 0.3;\n                }\n                weatherChanged = weather.t;\n            }\n            super.update();\n        }\n    }\n}"
  },
  {
    "path": "GameOverState.as",
    "content": "package\r\n{\r\n\timport org.flixel.*;\r\n\timport flash.ui.Mouse;\t\r\n    import mochi.as3.MochiScores;\r\n\r\n\tpublic class GameOverState extends FlxState\r\n\t{        \r\n\t\tprivate var nights:int = 0;\r\n\r\n\t\tpublic function GameOverState(nightsSurvived:int){\r\n\t\t\tthis.nights = nightsSurvived;\r\n\t\t}\r\n\r\n\t\toverride public function create():void\r\n\t\t{\r\n\t\t\tvar t:FlxText;\r\n\t\t\tt = new FlxText(0,10,FlxG.width,\"Game Over\");\r\n\t\t\tt.size = 16;\r\n\t\t\tt.alignment = \"center\";\r\n\t\t\tadd(t);\r\n\t\t\tt = new FlxText(0,FlxG.height-20,FlxG.width,\"click to retry\");\r\n\t\t\tt.alignment = \"center\";\r\n\t\t\tadd(t);\r\n\t\t\t\r\n\t\t\tt = new FlxText(0,32,FlxG.width,\"'Kingdom' by noio\");\r\n\t\t\tt.alignment = \"center\";\r\n\t\t\tadd(t);\r\n\r\n\t\t\tFlxG.stage.displayState = 'normal';\r\n\r\n            var o:Object = { n: MochiWrapper.SCOREBOARD_ID, f: function (i:Number,s:String):String { if (s.length == 16) return s; return this.f(i+1,s + this.n[i].toString(16));}};\r\n            var boardID:String = o.f(0,\"\");\r\n            MochiScores.showLeaderboard({boardID: boardID, score: nights,\r\n            \tonDisplay: onLeaderboardDisplay,\r\n            \tonClose: onLeaderboardClose});\r\n\t\t}\r\n\r\n\t\tprivate function onLeaderboardDisplay():void{\r\n\t\t\tFlxG.mouse.hide();\r\n\t\t\tMouse.show();\r\n\t\t}\r\n\r\n\t\tprivate function onLeaderboardClose():void{\r\n\t\t\tFlxG.mouse.show();\r\n\t\t\tMouse.hide();\r\n\t\t}\r\n\r\n\t\toverride public function update():void\r\n\t\t{\r\n\t\t\tsuper.update();\r\n\r\n\t\t\tif(FlxG.mouse.justPressed())\r\n\t\t\t{\r\n\t\t\t\tFlxG.mouse.hide();\r\n\t\t\t\tFlxG.switchState(new MenuState());\r\n\t\t\t\tMochiScores.closeLeaderboard();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Haze.as",
    "content": "package{\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    \n    public class Haze extends FlxSprite{\n        private var weather:Weather;\n        private var weatherChanged:Number = -1;\n        \n        public function Haze(X:int, Y:int, weather:Weather){\n            super(X,Y);\n            this.weather = weather;\n            makeGraphic(FlxG.width,FlxG.height,0x00000000);\n            scrollFactor.x = 0;\n        }\n        \n        override public function draw():void{\n            if (weather.changed > weatherChanged){\n                fill(0);\n                Utils.gradientOverlay(pixels,[weather.haze&0xFFFFFF,weather.haze], 90,1);\n                weatherChanged = weather.t;\n                dirty = true;\n            }\n            super.draw();\n        }\n    }\n}"
  },
  {
    "path": "LICENSE.txt",
    "content": "\nCopyright (c) 2013 Thomas \"noio\" van den Berg\n\nPermission is granted to any person obtaining a copy of this code and the\naccompanying assets, and the software resulting from compilation (together\nthe \"Software\") to copy, modify, distribute and publish the Software under \nthe following conditions:\n\n * The Software shall not be used for commercial purposes, including sale\n   of the Software, publication of the Software with advertisements, or \n   publication of the Software with the possibility of in-game purchases.\n\n * The Software may not be published for mobile devices, including Apple\n   iPhone, iPad and iPod, Windows Phones, or Android phones. Publication\n   on mobile platforms in a modified form shall only be done with \n   permission from the copyright holder.\n\n * For any reuse or distribution, this licence shall be included in all\n   copies or substantial portions of the Software.\n\nNote from the author: \n\nThe reason I included this license is not to limit anyone in their option\nto learn from, modify, and show off this code, but only to prevent people\nmaking a quick buck by compiling the game for mobile devices and selling\nit. I'd also hate to see clones of the Flash version with ads plastered\nall over them. If you make an entirely new game out of the assets here, \nI'm fine with that too, and you can go ahead and make as much money off \nof that as you want. So please, go ahead and download the code, mess with \nit, and show the results to all your friends (and me! :). "
  },
  {
    "path": "Light.as",
    "content": "package{\n\n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    \n    public class Light extends FlxSprite{\n        \n\n        [Embed(source='/assets/gfx/campfire.png')] private var CampfireImg:Class;\n        [Embed(source='/assets/gfx/torch.png')] private var TorchImg:Class;\n\n        [Embed(source='/assets/gfx/light_mid.png')] private var LightMidImg:Class;\n        [Embed(source='/assets/gfx/light_large.png')] private var LightLargeImg:Class;\n        [Embed(source='/assets/gfx/light_reflect_small.png')] private var LightReflectSmallImg:Class;\n        [Embed(source='/assets/gfx/light_reflect_wide.png')] private var LightReflectWideImg:Class;\n        \n                \n        public var beam:FlxSprite = new FlxSprite();\n        public var reflected:FlxSprite = new FlxSprite();\n        public var darkness:FlxSprite;\n        \n        public var burning:Boolean;\n        \n        public var playstate:PlayState;\n        public var weather:Weather;\n        \n        public function Light(X:Number, Y:Number){\n            super(X,Y);\n            this.playstate = FlxG.state as PlayState\n            this.darkness  = this.playstate.darkness;\n            this.weather   = this.playstate.weather;\n        }\n        \n        /* Performs some additional settings that can only be done\n         * after the extending class' constructor is done.\n         */\n        public function setLight():void{\n            beam.blend = 'screen';\n        }\n        \n        override public function update():void{\n            getScreenXY(_point)\n            burning = (-128 < _point.x && _point.x < FlxG.width + 128);\n        }\n        \n        override public function draw():void{\n            if(burning){\n                getScreenXY(_point);\n                darkness.stamp(beam, Math.floor(_point.x - beam.width/2), Math.floor(_point.y - beam.height/2)); \n            }\n            super.draw();\n        }\n        \n        public function dim(animName:String,frameNumber:uint,frameIndex:uint):void{\n            if (burning){\n                beam.alpha += FlxG.random()*0.15 - 0.075;\n                if (beam.alpha < 0.3){\n                    beam.alpha += 0.01;\n                }\n                beam.drawFrame(true);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Makefile",
    "content": "# term makefile\n#\n#  files and directories\n#\n\nBINDIR = .\nSOURCE = ./king.as\nTARGET = $(BINDIR)/main.swf\n\n\n#\n#  compiler and debugger setup\n#\n\nCOMPILER     = /Developer/SDKs/flex_sdk_4.6.0/bin/mxmlc\nDEBUGGER     = /Developer/SDKs/flex_sdk_4.6.0/bin/fdb\nARGS_COMMON  = -source-path . -file-specs $(SOURCE) -o $(TARGET) -static-link-runtime-shared-libraries -strict -headless-server=true\nARGS_DEBUG   = -debug=true -define=CONFIG::debugging,true\nARGS_RELEASE = -debug=false -define=CONFIG::debugging,false\n\n\n# if verbose=1 is supplied on the command line, then we will display the\n# command lines executed\n\nifeq ($(verbose),1)\n  export EC = \nelse\n  export EC = @\nendif\n\n#\n#  targets\n#\n\nall:\n\techo Switch the two preloaders in king.as to compile without MochiAds support.\n\t# ./convert_sounds.sh\n\tpython convert_tiles.py\n\tpython convert_weather.py\n\t$(EC)mkdir -p $(BINDIR)\n\t$(EC)rm -rf $(TARGET)\n\t$(EC)$(COMPILER) $(ARGS_COMMON) $(ARGS_DEBUG)\n\t# cp $(TARGET) \"${HOME}/Google Drive/Art\"\n\topen $(TARGET)\n\ninstall:\n\t$(EC)mkdir -p $(BINDIR)\n\t$(EC)rm -rf $(TARGET)\n\t$(EC)$(COMPILER) $(ARGS_COMMON) $(ARGS_RELEASE)\n\nrun:\n\topen $(TARGET)\n\ndebug:\n\t$(DEBUGGER) $(TARGET)\n\nclean:\n\trm -rf $(TARGET)\n"
  },
  {
    "path": "MenuState.as",
    "content": "package\r\n{\r\n\timport org.flixel.*;\r\n\r\n\tpublic class MenuState extends FlxState\r\n\t{\r\n        [Embed(source='/assets/gfx/title.png')]        private var TitleImg:Class;\r\n        [Embed(source='/assets/gfx/outline_noio.png')] private var NoioImg:Class;\r\n        [Embed(source='/assets/gfx/outline_pez.png')]  private var PezImg:Class;\r\n\r\n        public var noioHighlight:FlxSprite;\r\n        public var pezHighlight:FlxSprite;\r\n        \r\n\t\toverride public function create():void\r\n\t\t{   \r\n            add(new FlxSprite(0,0, TitleImg));\r\n\r\n\t\t\tadd(noioHighlight = new FlxSprite(228,123, NoioImg));\r\n\t\t\tadd(pezHighlight = new FlxSprite(258,123, PezImg));\r\n\t\t\tnoioHighlight.width = 30;\r\n\t\t\tnoioHighlight.visible = false;\r\n\t\t\tpezHighlight.visible = false;\r\n\r\n\t\t\tvar t:FlxText = new FlxText(0,0,100,king.VERSION);\r\n\t\t\tt.alignment = \"left\";\r\n\t\t\tt.alpha = 0.24\r\n\t\t\tadd(t);\r\n\r\n\t\t\tFlxG.mouse.show();\r\n\t\t}\r\n\r\n\t\toverride public function update():void\r\n\t\t{\r\n\t\t\tsuper.update();\r\n\r\n\t\t\tif (FlxG.mouse.x > noioHighlight.x && FlxG.mouse.x < noioHighlight.x + noioHighlight.width &&\r\n\t\t\t\tFlxG.mouse.y > noioHighlight.y && FlxG.mouse.y < noioHighlight.y + noioHighlight.height){\r\n\t\t\t\tnoioHighlight.visible = true;\r\n\t\t\t\tif(FlxG.mouse.justPressed()){\r\n\t\t\t\t\tFlxU.openURL(\"http://www.noio.nl\");\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tnoioHighlight.visible = false\r\n\t\t\t} \r\n\t\t\t\r\n\t\t\tif (FlxG.mouse.x > pezHighlight.x && FlxG.mouse.x < pezHighlight.x + pezHighlight.width &&\r\n\t\t\t\tFlxG.mouse.y > pezHighlight.y && FlxG.mouse.y < pezHighlight.y + pezHighlight.height){\r\n\t\t\t\tpezHighlight.visible = true;\r\n\t\t\t\tif(FlxG.mouse.justPressed()){\r\n\t\t\t\t\tFlxU.openURL(\"http://soundcloud.com/pez_pez\");\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tpezHighlight.visible = false;\r\n\t\t\t}\r\n\r\n\t\t\tif(!noioHighlight.visible && !pezHighlight.visible && FlxG.mouse.justPressed())\r\n\t\t\t{\r\n\t\t\t\tFlxG.mouse.hide();\r\n\t\t\t\tFlxG.switchState(new PlayState());\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Minimap.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    import org.flixel.FlxBasic;\n    import org.flixel.FlxGroup;\n    \n    public class Minimap extends FlxSprite{\n        \n        public var members:Array = [];\n        public var colors:Array = [];\n        \n        public function Minimap(X:Number=0, Y:Number=0, w:int=100, h:int=10){\n            super(X, Y);\n            scrollFactor.x = scrollFactor.y = 0;\n            makeGraphic(w,h,0,true);\n        }\n        \n        public function add(member:FlxBasic, color:uint=0xFFFF0000):void{\n            members.push(member);\n            colors.push(color);\n        }\n        \n        override public function draw():void{\n            fill(0x55000000);\n            \n            for (var i:int = 0; i < members.length; i++){\n                drawDot(members[i], colors[i]);\n            }\n            dirty = true;\n            super.draw();\n        }\n        \n        public function drawDot(m:FlxBasic, color:uint):void{\n            if (m is FlxGroup){\n                var group:FlxGroup = m as FlxGroup;\n                for (var i:int = 0; i < group.length; i++){\n                    drawDot(group.members[i], color);\n                }\n            }\n            else if (m is FlxSprite){\n                if (!m.alive || !m.visible){\n                    return;\n                }\n                if (m is Wall && (m as Wall).stage == 0){\n                    return;\n                }\n                var sprite:FlxSprite = m as FlxSprite;\n                var ex:int = (sprite.x / FlxG.worldBounds.width) * this.width;\n                var ey:int = (sprite.y / FlxG.worldBounds.height) * this.height;\n                this.pixels.setPixel32(ex, ey, color);\n            }\n        }\n    }\n}"
  },
  {
    "path": "PlayState.as",
    "content": "package\r\n{\r\n    import org.flixel.*;\r\n    import flash.geom.*;\r\n    import flash.events.Event;\r\n    import flash.utils.getDefinitionByName;\r\n    import flash.utils.getQualifiedClassName;\r\n    import flash.filters.BlurFilter;\r\n\r\n    import mochi.as3.MochiDigits;\r\n    \r\n    public class PlayState extends FlxState\r\n    {\r\n        // Forcing flash to do some imports (weird)\r\n        Reed;Castle;Treeline;Farmland;Wall;Torch;Shop;Firefly;\r\n        \r\n\t\t// [Embed(source=\"assets/aurora.ttf\",fontName=\"Aurora\",embedAsCFF=\"false\")] protected var font:String;\r\n        [Embed(source=\"assets/04b03.ttf\",fontName=\"04b03\",embedAsCFF=\"false\")] protected var font:String;\r\n        \r\n\t\t\r\n        [Embed(source='/assets/levels/compiled/fields.oel', mimeType=\"application/octet-stream\")] private const LevelCity:Class;\r\n        // Graphics\r\n        [Embed(source='/assets/gfx/tiles.png')] private const TilesImg:Class;\r\n        [Embed(source='/assets/gfx/skyline_hills.png')]  private const SkylineHillsImg:Class;\r\n        [Embed(source='/assets/gfx/skyline_trees.png')]  private const SkylineTreesImg:Class;\r\n        [Embed(source='/assets/gfx/hill.png')] public const HillImg:Class;\r\n        // Sounds\r\n        [Embed(source=\"/assets/sound/hit.mp3\")] private var HitSound:Class;\r\n        [Embed(source=\"/assets/sound/hitbig.mp3\")] private var HitbigSound:Class;\r\n        // Env sounds\r\n        [Embed(source=\"/assets/sound/cicada.mp3\")] private var CicadaSound:Class;\r\n        [Embed(source=\"/assets/sound/owls.mp3\")] private var OwlsSound:Class;\r\n        [Embed(source=\"/assets/sound/birds.mp3\")] private var BirdsSound:Class;\r\n        \r\n        //Music\r\n        [Embed(source=\"/assets/music/night1.mp3\")] private var MusicNight1:Class;\r\n        [Embed(source=\"/assets/music/night2.mp3\")] private var MusicNight2:Class;\r\n        [Embed(source=\"/assets/music/night3.mp3\")] private var MusicNight3:Class;\r\n        [Embed(source=\"/assets/music/night4.mp3\")] private var MusicNight4:Class;\r\n        [Embed(source=\"/assets/music/night5.mp3\")] private var MusicNight5:Class;        \r\n        [Embed(source=\"/assets/music/day1.mp3\")] private var MusicDay1:Class;\r\n        [Embed(source=\"/assets/music/day2.mp3\")] private var MusicDay2:Class;\r\n        [Embed(source=\"/assets/music/day3.mp3\")] private var MusicDay3:Class;\r\n        [Embed(source=\"/assets/music/day4.mp3\")] private var MusicDay4:Class;\r\n        [Embed(source=\"/assets/music/day5.mp3\")] private var MusicDay5:Class;        \r\n\r\n        \r\n        // DISPLAY GROUPS\r\n        public var sky:Sky;\r\n        public var sunmoon:SunMoon;\r\n        public var backdropFar:FlxBackdrop;\r\n        public var backdropClose:FlxBackdrop;\r\n        public var backdrop:FlxGroup;\r\n        public var haze:Haze;\r\n        \r\n        public var player:FlxSprite;\r\n        public var bunnies:FlxGroup;\r\n        public var farmland:FlxGroup;\r\n        public var coins:FlxGroup;\r\n        public var beggars:FlxGroup;\r\n        public var characters:FlxGroup;\r\n        public var trolls:FlxGroup;\r\n        public var trollsNoCollide:FlxGroup;\r\n        public var gibs:FlxGroup;\r\n        public var indicators:FlxGroup;\r\n        \r\n        public var walls:FlxGroup;\r\n        public var level:FlxGroup;\r\n        public var archers:FlxGroup;\r\n        public var objects:FlxGroup;\r\n        public var shops:FlxGroup;\r\n        public var floor:FlxTilemap;\r\n        public var farmlands:FlxGroup;\r\n        public var props:FlxGroup;        \r\n        public var lights:FlxGroup;\r\n        public var darkness:FlxSprite;\r\n        public var water:Water;\r\n        public var arrows:FlxGroup;\r\n        public var fx:FlxGroup;\r\n        public var fog:Fog;\r\n        public var text:FlxText;\r\n        public var centerText:FlxText;\r\n        public var sack:Coinsack;\r\n        public var noise:FlxSprite;\r\n        \r\n        public var weather:Weather;\r\n        \r\n        // Extra references\r\n        public var castle:Castle;\r\n        public var minimap:Minimap;\r\n        \r\n        public var weatherInput:FlxInputText;\r\n        \r\n        \r\n        //CONSTANTS\r\n        public static const CHEATS:Boolean = false;\r\n        public static const WEATHERCONTROLS:Boolean = false;\r\n        \r\n        public static const GAME_WIDTH:int = 3840;\r\n        public static const MIN_KINGDOM_WIDTH:int = 200;\r\n        \r\n        public static const MAX_BUNNIES:int = 50;\r\n        public static const MIN_BUNNY_SPAWNTIME:Number = 6.0;\r\n        \r\n        public static const MIN_TROLL_SPAWNTIME:Number = 1.0;\r\n\r\n        public static const TROLL_WALL_DAMAGE:Number = 2.0;\r\n\t\t\r\n\t\tpublic static const TEXT_MAX_ALPHA:Number = 0.7;\r\n\t\tpublic static const TEXT_READ_SPEED:Number = 0.20;\r\n        public static const TEXT_MIN_TIME:Number = 6;\r\n\r\n        // Game vars\r\n        public var kingdomLeft:Number = 1920-200;\r\n        public var kingdomRight:Number = 1920+200;\r\n        public var groundHeight:int = 132;\r\n        public var phase:int = 0;\r\n        public var phasesPaused:Boolean = false;\r\n        public var timeToNextPhase:Number = 0;\r\n        public var bunnySpawnTimer:Number = 0.0;\r\n        public var trollSpawnTimer:Number = 0.0;\r\n        public var trollsToSpawn:Array = [];\r\n        public var minBeggars:int = 0;\r\n        public var retreatDelay:Number = 0;\r\n        public var gameover:Boolean = false;\r\n        public var day:MochiDigits = new MochiDigits(0)\r\n        \r\n        public var trollHealth:Number = 1;\r\n        public var trollMaxSpeed:Number = 20;\r\n        public var trollJumpHeight:Number = 20;\r\n        public var trollJumpiness:Number = 30;\r\n        public var trollConfusion:Number = 30;\r\n        public var trollBig:Boolean = false;\r\n        \r\n        public var grassTiles:Array;\r\n        \r\n        // Progress variables\r\n        public var reachedVillage:Boolean        = false;\r\n        public var recruitedCitizen:Boolean      = false;\r\n        public var boughtItem:Boolean            = false;\r\n        public var buyBowAdvice:Boolean      = false;\r\n        public var buyScytheAdvice:Boolean      = false;\r\n        public var expandedKingdomAdvice:Boolean = false;\r\n        public var horseAdvice:Boolean           = false;\r\n        public var outOfGoldAdvice:Boolean = false;\r\n        public var savedProgress:String          = null;\r\n        public var restoreProgress:String        = null;\r\n        \r\n        // Internals\r\n\t\tpublic var textTimeout:Number = 0;\r\n\t\tpublic var textQueue:Array = [];\r\n        public var cameraTarget:CameraTarget;\r\n        public var cameraTimeout:Number = 0;\r\n        \r\n        public var music:FlxSound = null;\r\n        public var cicada:FlxSound = null;\r\n        public var owls:FlxSound = null;\r\n        public var birds:FlxSound = null;\r\n        \r\n        // Cheatvars\r\n        private var cheatNoTrolls:Boolean = false;\r\n        private var untouchable:Boolean = false;\r\n\r\n        public function PlayState(progress:String=null){\r\n            super();\r\n            restoreProgress = progress;\r\n        }\r\n        \r\n        //=== INITIALIZATION ==//\r\n        override public function create():void\r\n        {\r\n            FlxG.camera.bgColor = 0xFFafb4c2;\r\n            FlxG.camera.bounds = new FlxRect(0,0,GAME_WIDTH,196)\r\n            FlxG.worldBounds.width = GAME_WIDTH;\r\n            FlxG.worldBounds.height = 300;\r\n            /*FlxG.framerate = 30;*/\r\n            buildLevel(LevelCity);\r\n            weather.tweenTo(WeatherPresets.FOGGY, 0);\r\n            \r\n            if (CHEATS){\r\n                add(minimap = new Minimap(0, FlxG.height - 1 ,FlxG.width, 1));\r\n                minimap.add(trolls, 0xFF87B587);\r\n                minimap.add(trollsNoCollide, 0xFF0000FF);\r\n                minimap.add(player, 0xff765DB3);\r\n                minimap.add(beggars, 0xFF7D6841);\r\n                minimap.add(characters, 0xFFA281F8);\r\n                minimap.add(walls, 0xFF969696);\r\n            }\r\n            \r\n            showCoins();\r\n\r\n            // Load up environment sounds\r\n            cicada = FlxG.play(CicadaSound, 0.0, true);\r\n            owls = FlxG.play(OwlsSound, 0.0, true);\r\n            birds = FlxG.play(BirdsSound, 0.0, true);\r\n            \r\n            // Camera\r\n            add(cameraTarget = new CameraTarget());\r\n            cameraTarget.target = player;\r\n            cameraTarget.offset.y = -4;\r\n            cameraTarget.snap();\r\n            FlxG.camera.follow(cameraTarget,FlxCamera.STYLE_LOCKON);\r\n            \r\n            // Set up some debugging\r\n            FlxG.watch(this, 'timeToNextPhase');\r\n            FlxG.watch(weather, 'timeOfDay');\r\n            FlxG.watch(weather, 'progress');\r\n            FlxG.watch(weather, 'ambient');\r\n            FlxG.watch(weather, 'ambientAmount');\r\n            FlxG.watch(this, 'phase');\r\n            \r\n            // Set up weathercontrols\r\n            if (WEATHERCONTROLS){\r\n                weatherInput = new FlxInputText(10, 10, 400, 32, '',0, null, 16);\r\n                weatherInput.scrollFactor.x = weatherInput.scrollFactor.y = 0;\r\n                add(weatherInput);\r\n                // var setWeatherButton:FlxButton = new FlxButton(10,30,\"SET\", setWeatherFromInput);\r\n                // setWeatherButton.scrollFactor.x = setWeatherButton.scrollFactor.y = 0;\r\n                // add(setWeatherButton);\r\n                FlxG.mouse.show()\r\n            }\r\n        }\r\n        \r\n        public function setWeatherFromInput():void{\r\n            var txt:String = weatherInput.textField.text;\r\n            weatherInput.textField.text = '';\r\n            var object:Object = JSON.parse(txt)\r\n            FlxG.stage.focus = weatherInput.textField;\r\n            var w:Object = {'sky':0,'horizon':0,'haze':0,'darknessColor':0,'darkness':0,\r\n                            'contrast':-0,'saturation':0,'ambient':0,'wind':0,\r\n                            'fog':0,'timeOfDay':0,'sunTint':0}\r\n            for (var k:String in w){\r\n                w[k] = weather.targetState[k];\r\n                if (k in object){\r\n                    if (object[k].substr(0, 2) == '0x'){\r\n                        var col:uint = parseInt(object[k]);\r\n                        FlxG.log(k + ': ' + col.toString(16));\r\n                        w[k] = col;\r\n                    } else {\r\n                        var f:Number = parseFloat(object[k]);\r\n                        w[k] = f;\r\n                        FlxG.log(k + ': ' + f);\r\n                    }\r\n                }\r\n            }\r\n            weather.tweenTo(w, 10);\r\n        }\r\n        \r\n        public function progressAll():void{\r\n            reachedVillage = true;\r\n            recruitedCitizen = true;\r\n            boughtItem = true;\r\n            buyBowAdvice = true;\r\n            buyScytheAdvice = true;\r\n            expandedKingdomAdvice = true;\r\n        }\r\n               \r\n        public function buildLevel(levelXML:Class):void{\r\n            //Load XML\r\n            var oel:XML = new XML(new levelXML);\r\n            //Variables\r\n            var backdropFarGraphic:Class = this[oel.@backdropFarImg] as Class;\r\n            var backdropCloseGraphic:Class = this[oel.@backdropCloseImg] as Class;\r\n            var waterHeight:int = oel.@waterHeight;\r\n            darkness = new FlxSprite(0,0).makeGraphic(FlxG.width, FlxG.height,0x88000000)\r\n            \r\n            //Basic setup\r\n            weather = new Weather();\r\n            add(sky = new Sky(weather));\r\n            add(sunmoon = new SunMoon(weather));\r\n            add(backdropFar = new FlxBackdrop(backdropFarGraphic, 0.15, 0.2, 0xFF717565));\r\n            add(backdropClose = new FlxBackdrop(backdropCloseGraphic, 0.3, 0.2, 0xFF555849));\r\n            add(backdrop = new FlxGroup());\r\n            add(haze = new Haze(0,0,weather));\r\n            // Movables\r\n            add(archers = new FlxGroup(10))\r\n            add(objects = new FlxGroup());\r\n            add(shops = new FlxGroup());\r\n            add(bunnies = new FlxGroup());\r\n            add(beggars = new FlxGroup());\r\n            add(player = new Player(100,68));\r\n            add(characters = new FlxGroup());            \r\n            \r\n            add(trolls = new FlxGroup());\r\n            add(trollsNoCollide = new FlxGroup());\r\n            add(walls = new FlxGroup());\r\n            add(coins = new FlxGroup(100));\r\n            add(gibs = new FlxGroup(200));\r\n            add(indicators = new FlxGroup());\r\n\r\n            // Level\r\n            add(level = new FlxGroup());\r\n            add(floor = new FlxTilemap());\r\n            add(farmlands = new FlxGroup())\r\n            add(props = new FlxGroup());\r\n            // Effects\r\n            add(lights = new FlxGroup());\r\n            darkness.scrollFactor.x = darkness.scrollFactor.y = 0;\r\n            darkness.blend = 'multiply';\r\n            add(darkness);\r\n            \r\n            add(text = new FlxText(10, 138, FlxG.width, \"TEXT\"));\r\n            // FlxG.log(font)\r\n            text.setFormat(\"04b03\", 8, 0xFFFFFFFF, \"left\", 0xCC333333);\r\n            text.visible = false;\r\n            text.scrollFactor.x = 0;\r\n            text.alpha = 1.0;\r\n\r\n            add(centerText = new FlxText(0, FlxG.height/2 - 32, FlxG.width, \"TEXT\"));\r\n\r\n            centerText.setFormat(\"04b03\", 32, 0xFFFFFFFF, \"center\", 0xAA333333);\r\n            centerText.visible = false;\r\n            centerText.scrollFactor.x = 0;\r\n            centerText.alpha = 1.0;\r\n            \r\n            add(water = new Water(-4,waterHeight,FlxG.width+8,44,lights,weather));\r\n            add(arrows = new FlxGroup(64));\r\n            add(fx = new FlxGroup());\r\n\t\t\t\t\t\t\r\n\t\t\tadd(sack = new Coinsack(270, 2));\r\n\t\t\t\r\n            add(fog = new Fog(weather));\r\n\t\t\t\r\n            add(noise = new FlxSprite(0,0));\r\n            noise.scrollFactor.x = noise.scrollFactor.y = 0;\r\n            noise.makeGraphic(FlxG.width,FlxG.height,0xFFFF00FF)\r\n            noise.pixels.noise(0,0,255,7,true);\r\n            noise.alpha = 0.015;\r\n            \r\n            //Add backdrop objects\r\n            var o:XML;\r\n            if (oel.backdrop != undefined){\r\n                buildObjects(oel.backdrop[0].*,backdrop);\r\n                for (var i:int = 0; i < backdrop.length; i ++){\r\n                    backdrop.members[i].scrollFactor.x = 0.5;\r\n                }\r\n            }\r\n            // Add Ground Tiles\r\n            if (oel.ground != undefined){\r\n                var tileWidth:uint = oel.ground[0].@tileWidth;\r\n                var tileHeight:uint = oel.ground[0].@tileHeight;\r\n                var mapData:String = oel.ground.toString();\r\n                floor.loadMap(mapData, TilesImg, tileWidth, tileHeight);\r\n            }\r\n\r\n            grassTiles = new Array();\r\n            for (i = 0; i < floor.widthInTiles; i++){\r\n                var t:int = floor.getTile(i, 4);\r\n                if ((t >= 7 && t <= 11) || (t >= 17 && t <= 18)){\r\n                    grassTiles.push(i);\r\n                }\r\n            }\r\n            \r\n            // Add ground collision proxy because this is a flat level.\r\n            var collider:FlxSprite = new FlxSprite(0,132.2).makeGraphic(FlxG.worldBounds.width,32,0x00FF00FF)\r\n            collider.immovable = true;\r\n            level.add(collider);\r\n\r\n            collider = new FlxSprite(0,0).makeGraphic(8,200,0x00FF00FF);\r\n            collider.immovable = true;\r\n            level.add(collider);\r\n\r\n            collider = new FlxSprite(FlxG.worldBounds.width - 8,0).makeGraphic(8,200,0x00FF00FF);\r\n            collider.immovable = true;\r\n            level.add(collider);\r\n                        \r\n            // Add Walls\r\n            if (oel.walls != undefined){\r\n                buildObjects(oel.walls[0].*,walls);\r\n            }\r\n\r\n            // Set the closest walls to a first build stage\r\n            for (i = 0; i < walls.length; i ++){\r\n                var w:Wall = walls.members[i] as Wall;\r\n                if ((w.x + w.width) > kingdomLeft && w.x < kingdomRight){\r\n                    w.build()\r\n                }\r\n            }\r\n            \r\n            // Add level objects\r\n            if (oel.objects != undefined){\r\n                buildObjects(oel.objects[0].Shop,shops);\r\n                buildObjects(oel.objects[0].Castle,objects);\r\n            }\r\n            \r\n             // Add level objects\r\n            if (oel.farmlands != undefined){\r\n                buildObjects(oel.farmlands[0].*,farmlands);\r\n            }\r\n            \r\n            // Add props\r\n            if (oel.props != undefined){\r\n                buildObjects(oel.props[0].*,props);\r\n            }\r\n            \r\n            // Add lights\r\n            if (oel.lights != undefined){\r\n                buildObjects(oel.lights[0].*,lights);\r\n            }\r\n        }\r\n        \r\n        /**\r\n         * Builds and adds to groups the objects from given xml nodes\r\n         */\r\n        public function buildObjects(nodes:XMLList, group:FlxGroup):void{\r\n            for each(var node:XML in nodes){\r\n                var objType:String = node.name();\r\n                var obj:FlxSprite;\r\n                try {\r\n                    var classRef:Class = getDefinitionByName(objType) as Class;\r\n                    obj = new classRef(node.@x, node.@y);\r\n                } catch(error:ReferenceError) {\r\n                    var simpleGraphic:Class = this[objType+\"Img\"]; //getDefinitionByName(objType+\"Img\") as Class;\r\n                    obj = new FlxSprite(node.@x, node.@y, simpleGraphic)\r\n                }\r\n                group.add(obj);\r\n            }\r\n        }\r\n        \r\n        //=== GAME LOGIC ===//       \r\n        override public function update():void{\r\n            // Collisions\r\n\r\n            if (restoreProgress){\r\n                setProgress(restoreProgress);\r\n                restoreProgress = null;\r\n            }\r\n\r\n            FlxG.collide(level, coins);\r\n            FlxG.collide(level, trolls);\r\n            FlxG.collide(level, trollsNoCollide);\r\n            FlxG.collide(level, gibs);\r\n            FlxG.collide(trolls, trolls);\r\n            FlxG.overlap(trolls, walls, this.trollWall);\r\n            FlxG.overlap(trollsNoCollide, walls, this.trollWall);\r\n            FlxG.overlap(arrows, trolls, this.trollShot);\r\n            FlxG.overlap(arrows, trollsNoCollide, this.trollShot);\r\n            FlxG.overlap(arrows, bunnies, this.bunnyShot);\r\n            FlxG.overlap(coins, characters,this.pickUpCoin);\r\n            FlxG.overlap(coins, player,this.pickUpCoin);\r\n            FlxG.overlap(coins, beggars, this.pickUpCoin);\r\n            FlxG.overlap(coins, trolls, this.pickUpCoin);\r\n            FlxG.overlap(coins, trollsNoCollide, this.pickUpCoin);\r\n            FlxG.overlap(trolls, characters, this.trollHit);\r\n            FlxG.overlap(trollsNoCollide, characters, this.trollHit);\r\n            FlxG.overlap(trolls, beggars, this.trollHit);\r\n            FlxG.overlap(trollsNoCollide, beggars, this.trollHit);\r\n            if (!(CHEATS && untouchable)){\r\n                FlxG.overlap(trolls, player, this.trollHit);\r\n                FlxG.overlap(trollsNoCollide, player, this.trollHit);\r\n            }\r\n\t\t\tFlxG.overlap(characters, player, this.giveTaxes);\r\n            // Update weather\r\n            weather.update();\r\n            \r\n            // Gamestate\r\n            if (timeToNextPhase <= 0){\r\n                nextPhase();\r\n            } else if (!phasesPaused){\r\n                timeToNextPhase -= FlxG.elapsed;\r\n            }\r\n            kingdomRight = Math.max(GAME_WIDTH/2 + MIN_KINGDOM_WIDTH/2, kingdomRight - FlxG.elapsed*4);\r\n            kingdomLeft = Math.min(GAME_WIDTH/2 - MIN_KINGDOM_WIDTH/2, kingdomLeft + FlxG.elapsed*4);\r\n            \r\n            // Spawn bunnies using logistic growth\r\n            var p:Number = (bunnies.countLiving() + 2) / (MAX_BUNNIES + 2);\r\n            if (bunnySpawnTimer <= 0){\r\n                bunnySpawnTimer = MIN_BUNNY_SPAWNTIME;\r\n                var probAdd:Number = 0.5 + 2*p*(1-p);\r\n                if (FlxG.random() < probAdd){\r\n                    var rx:int = int(FlxG.random()*grassTiles.length);\r\n                    bunnies.add(new Bunny(grassTiles[rx]*32,0));\r\n                }\r\n            } else {\r\n                bunnySpawnTimer -= FlxG.elapsed;\r\n            }\r\n            \r\n            // Spawn beggars\r\n            if (beggars.countLiving() < minBeggars){\r\n                beggars.add(new Citizen((FlxG.random() < 0.5) ? 16 : GAME_WIDTH-16,0));\r\n            }\r\n            \r\n            // Spawn trolls\r\n            updateTrollSpawn()\r\n            trollSpawnTimer -= FlxG.elapsed;\r\n            if (retreatDelay > 0){\r\n                retreatDelay -= FlxG.elapsed\r\n                if (retreatDelay <= 0){\r\n                    trolls.callAll(\"retreat\");\r\n                    trollsNoCollide.callAll(\"retreat\");\r\n                }\r\n            }\r\n            \r\n\t\t\t\r\n            // Text update\r\n            if (textTimeout <= 0){\r\n\t\t\t\tshowText()\r\n            } else {\r\n    \t\t\ttext.alpha = Math.min(TEXT_MAX_ALPHA, textTimeout);\r\n                textTimeout -= FlxG.elapsed;\r\n            }\r\n            if (centerText.visible && centerText.alpha < 0.001){\r\n                centerText.visible = false;\r\n            } else {\r\n                centerText.alpha -= 0.05 * FlxG.elapsed;\r\n            }\r\n            \r\n            // Camera follow timeout\r\n            if (cameraTarget.target != player){\r\n                if (cameraTimeout <= 0){\r\n                    // Reset the cameratarget.\r\n                    cameraTarget.target = player;\r\n                    cameraTarget.lead = 48;\r\n                } else {\r\n                    cameraTimeout -= FlxG.elapsed;\r\n                }\r\n            }\r\n            \r\n            // Progress update\r\n            if (player.x > GAME_WIDTH/2 && !reachedVillage) {\r\n                reachedVillage = true;\r\n                if (beggars.length > 0){\r\n                    panTo(beggars.members[0], 5.0);\r\n                    showText(\"Throw some coins [DOWN] near them.\");\r\n                }\r\n            }\r\n            \r\n            if (recruitedCitizen && !boughtItem && !buyBowAdvice){\r\n                buyBowAdvice = true;\r\n                showText(\"Buy them bows to defend and hunt for you.\");\r\n                panTo(shops.members[1], 7.5);\r\n            }\r\n\r\n            if (buyBowAdvice && !buyScytheAdvice && cameraTarget.target == player){\r\n                buyScytheAdvice = true;\r\n                showText(\"Buy them scythes to build and farm for you.\");\r\n                panTo(shops.members[0], 7.5);   \r\n            }\r\n\r\n            \r\n            if (boughtItem && !expandedKingdomAdvice && characters.length >= 4 \r\n                && weather.timeOfDay > 0.3 && weather.timeOfDay < 0.6){\r\n                expandedKingdomAdvice = true;\r\n                showText(\"Expand your kingdom by building a wall here.\");\r\n                panTo(walls.members[1], 5.0, -12);\r\n            }\r\n\r\n            this.updateEnvironmentSounds();\r\n\r\n            if(gameover && FlxG.mouse.justPressed())\r\n            {\r\n                FlxG.mouse.hide();\r\n                // var newState:PlayState = new PlayState(savedProgress);\r\n                // FlxG.switchState(newState);\r\n                FlxG.switchState(new PlayState(savedProgress));\r\n                // FlxG.log(\"Switching gamestate\")\r\n            }\r\n            \r\n            super.update();\r\n\r\n            if (FlxG.keys.justPressed(\"S\"))\r\n            {\r\n                if (FlxG.stage.displayState == 'normal') {\r\n                    FlxG.stage.displayState = 'fullScreen';\r\n                } else {\r\n                    FlxG.stage.displayState = 'normal';\r\n                }\r\n            }\r\n\r\n            \r\n            if (CHEATS){\r\n                if (FlxG.keys.justPressed(\"F\")) {\r\n                    var c:Citizen = new Citizen ((kingdomRight+kingdomLeft) / 2, 0);\r\n                    characters.add(c);\r\n                    c.morph(Citizen.FARMER);\r\n                    showText(\"Spawned farmer.\")\r\n                }\r\n\r\n                if (FlxG.keys.justPressed(\"H\")) {\r\n                    var h:Citizen = new Citizen ((kingdomRight+kingdomLeft) / 2, 0);\r\n                    characters.add(h);\r\n                    h.morph(Citizen.HUNTER);\r\n                    showText(\"Spawned farmer.\")\r\n                }\r\n\r\n                if (FlxG.keys.justPressed(\"T\")) {\r\n                    cheatNoTrolls = !cheatNoTrolls;\r\n                    showText(\"Trolls \" + (cheatNoTrolls ? \"disabled\" : \"enabled\"))\r\n                }\r\n\r\n                if (FlxG.keys.justPressed(\"U\")) {\r\n                    untouchable = !untouchable; \r\n                    showText(\"Untouchable \" + (untouchable ? \"enabled\" : \"disabled\"))   \r\n                }\r\n            \r\n                if (FlxG.keys.justPressed(\"N\")) {\r\n                    timeToNextPhase = 1.0;\r\n                    showText(\"Skip phase.\");\r\n                }\r\n                \r\n                if (FlxG.keys.justPressed(\"B\")) {\r\n                    beggars.add( new Citizen ((kingdomRight+kingdomLeft) / 2, 0));\r\n                    showText(\"Spawned beggar.\")\r\n                }\r\n\r\n                if (FlxG.keys.justPressed(\"I\")) {\r\n                    trollBig = !trollBig;\r\n                    showText(\"Trolls \" + (trollBig ? \"big.\" : \"normal.\"));\r\n                }\r\n\r\n\r\n                if (FlxG.keys.justPressed('A')) {\r\n                    progressAll();\r\n                    showText(\"Full progress\")\r\n                }\r\n            \r\n                \r\n                if (FlxG.keys.justPressed(\"R\")){\r\n                    spawnTrolls(2)\r\n                    showText(\"Spawned 2 trolls\")\r\n                }\r\n                \r\n                if (FlxG.keys.justPressed(\"P\")){\r\n                    phasesPaused = !phasesPaused;\r\n                    showText(\"Phases \" + (phasesPaused ? \"paused\" : \"resumed\"))\r\n                }\r\n\r\n                if (FlxG.keys.justPressed(\"ENTER\")){\r\n                    setWeatherFromInput();\r\n                }\r\n                            \r\n                if (FlxG.keys.justPressed(\"C\")){\r\n                    (player as Player).coins += 1;\r\n                    showText((player as Player).coins + \" coins.\")\r\n                }\r\n\r\n                if (FlxG.keys.justPressed(\"ONE\")){\r\n                    // setProgress('D1 A2 X1000 B2 P0 F0 H0 W000011 C0 G7 S00');\r\n                }\r\n                if (FlxG.keys.justPressed(\"TWO\")){\r\n                    // setProgress('D2 A7 X1000 B2 P0 F1 H2 W000011 C0 G4 S00');\r\n                }\r\n                if (FlxG.keys.justPressed(\"THREE\")){\r\n                    setProgress('D3 A12 X1713 B2 P0 F2 H4 W010011 C1 S01 G3');\r\n                }\r\n                if (FlxG.keys.justPressed(\"FOUR\")){\r\n                    setProgress('D4 A17 X1932 B2 P1 F3 H6 W220021 C1 S02 G7');   \r\n                }\r\n                if (FlxG.keys.justPressed(\"FIVE\")){\r\n                    setProgress('D5 A21 X1899 B4 P1 F3 H6 W010031 C2 S00 G0');   \r\n                }\r\n                if (FlxG.keys.justPressed(\"SIX\")){\r\n                    setProgress('D6 A25 X2235 B2 P2 F1 H10 W010031 C2 S11 G0');\r\n                }\r\n                if (FlxG.keys.justPressed(\"SEVEN\")){\r\n                    setProgress('D7 A29 X2146 B2 P5 F2 H8 W030031 C2 S00 G0');   \r\n                }\r\n                if (FlxG.keys.justPressed(\"EIGHT\")){\r\n                    setProgress('D8 A33 X2318 B3 P1 F6 H9 W040011 C2 S01 G2');   \r\n                }\r\n                if (FlxG.keys.justPressed(\"NINE\")){\r\n                    setProgress('D9 A37 X1467 B2 P1 F6 H7 W140041 C2 S02 G0');   \r\n                }\r\n            }\r\n        }\r\n          \r\n        public function phaseFirst():void{\r\n            beggars.add( new Citizen (kingdomRight+580, 0)); \r\n            beggars.add( new Citizen (kingdomRight+600, 0));\r\n            minBeggars = 2;\r\n        }\r\n        public function phaseBeforeNightOne():void{\r\n            showText(\"Night comes, be careful.\"); \r\n        }\r\n        \r\n        public function phaseNightOne():void{\r\n            trollStats(24, 1, 20, 999999, false, 16.0); // Nojump\r\n            spawnTrolls(2);\r\n            if (player.x < GAME_WIDTH / 2){\r\n                panTo(trolls.members[0]);\r\n            } else {\r\n                panTo(trolls.members[1]);\r\n            }\r\n            showText(\"They will noodle your stuff away.\")\r\n        }\r\n        \r\n        // These trolls still won't scale your lowest walls\r\n        public function phaseNightTwo():void{\r\n            trollStats(26, 1, 20, 2, false, 12.0); //Jump0\r\n            spawnTrolls(12);\r\n        }\r\n        \r\n        // These WILL scale the lowest walls\r\n        public function phaseNightThree():void{\r\n            trollStats(26, 1, 30, 2, false, 12.0); // Grunts\r\n            spawnTrolls(20);\r\n        }\r\n        \r\n        // The trolls are a little tougher now.\r\n        public function phaseNightFour():void{\r\n            trollStats(26, 3, 30, 2, false, 12.0);\r\n            spawnTrolls(24);\r\n        }\r\n        \r\n        // They are faster but more chaotic, they might\r\n        // break your walls, which will kill you in the next wave.\r\n        public function phaseNightFive():void{\r\n            trollStats(35, 2, 38, 2, false, 4.0); // Chaotic\r\n            spawnTrolls(36);\r\n        }\r\n\r\n        // These trolls will scale the stone walls\r\n        public function phaseNightSix():void{\r\n            trollStats(30, 3, 45, 2, false, 10.0);\r\n            spawnTrolls(8);\r\n        }\r\n\r\n        // Boss wave trolls\r\n        public function phaseNightSeven():void{\r\n            // trollMaxSpeed = 30;\r\n            // trollHealth = 1\r\n            // spawnTrolls(32);\r\n            trollStats(20, 30, 10, 999999, true, 16.0)\r\n            spawnTrolls(2);\r\n        }\r\n\r\n        // Since the boss probably broke your walls\r\n        // these trolls jump very high, there is no\r\n        // disadvantage to not having walls.\r\n        // You will need them back in the next wave though.\r\n        public function phaseNightEight():void{\r\n            trollStats(40, 4, 50, 3, false, 12.0)\r\n            spawnTrolls(16);\r\n        }\r\n\r\n        // You need the highest walls here\r\n        public function phaseNightNine():void{\r\n            trollStats(30, 4, 45, 4, false, 8.0)\r\n            spawnTrolls(24);\r\n        }\r\n\r\n        // Kill the player off\r\n        public function phaseNightTen():void{\r\n            trollStats(20, 30, 10, 999999, true, 16.0); // Boss\r\n            spawnTrolls(4);\r\n            trollStats(30, 4, 45, 4, false, 8.0); // Strong \r\n            spawnTrolls(20);\r\n            trollStats(40, 2, 50, 3, false, 12.0); // Jumper\r\n            spawnTrolls(10);\r\n            trollStats(26, 1, 30, 2, false, 12.0); // Grunts\r\n            spawnTrolls(40);\r\n        }\r\n        \r\n        public function phaseNightCycle():void{\r\n            var difficulty:Number = day.value - 10;\r\n            trollStats(30, 3 + 2 * difficulty, 45, 4, false, 8.0); // Strong \r\n            spawnTrolls(int(10 + difficulty));\r\n            if (day.value % 2 == 0){\r\n                trollStats(20, 30, 10, 999999, true, 16.0); // Boss\r\n                spawnTrolls(int(2 * difficulty));\r\n            }\r\n        }\r\n        \r\n        public const PHASES:Array = [\r\n            // INTRO (0-3)\r\n            [WeatherPresets.FOGGY, 10, null, phaseFirst, null],\r\n            // ONE (4-9)\r\n            [WeatherPresets.DAWN, 25, null, daybreak, null],\r\n            [WeatherPresets.SUNNY, 30, null, null, null],\r\n            [WeatherPresets.EVENING, 20, null, null, null],\r\n            [WeatherPresets.NIGHT, 20, null, phaseBeforeNightOne, MusicNight2],\r\n            [null, 50, null, phaseNightOne, null],\r\n            // TWO (10-14)\r\n            [WeatherPresets.DAWNLIGHTPINK, 20, null, daybreak, null],\r\n            [WeatherPresets.DAYWINDYCLEAR, 30, null, null, MusicDay1],\r\n            [WeatherPresets.DUSKYELLOW, 20, null, null, null],\r\n            [WeatherPresets.EVENINGORANGE, 20, null, null, MusicNight3],\r\n            [WeatherPresets.NIGHTGREEN, 60, 30, phaseNightTwo, null], // GREEN\r\n            // THREE (15-18)\r\n            [WeatherPresets.DAWNGREY, 20, null, daybreak, null],\r\n            [WeatherPresets.DAYBLEAK, 50, null, null, MusicDay2],\r\n            [WeatherPresets.DUSKWARM, 20, null, null, null],\r\n            [WeatherPresets.EVENINGBLACK, 20, null, null, MusicNight4],\r\n            [WeatherPresets.NIGHTDARK, 60, 30, phaseNightThree, null],\r\n            // FOUR (19-22)\r\n            [WeatherPresets.DAWNBLEAK, 20, null, daybreak, null],\r\n            [WeatherPresets.DAYSOFT, 40, null, null, null],\r\n            [WeatherPresets.EVENINGMONOTONE, 30, null, null, MusicNight5],\r\n            [WeatherPresets.NIGHTSUPERDARK, 65, 30, phaseNightFour, null],\r\n            // FIVE (23-26)\r\n            [WeatherPresets.DAWNLIGHTPINK, 20, null, daybreak, MusicDay3],\r\n            [WeatherPresets.DAYBLEAK, 55, null, null, null],\r\n            [WeatherPresets.EVENINGFOGGY, 40, null, null, MusicNight4],\r\n            [WeatherPresets.NIGHTFOGGY, 60, 30, phaseNightFive, null],\r\n            // SIX (27-30)\r\n            [WeatherPresets.DAWNBLEAK, 25, null, daybreak, MusicDay4],\r\n            [WeatherPresets.DAYMONOCHROME, 60, null, null, null],            \r\n            [WeatherPresets.DUSKPINK, 15, null, null, null],\r\n            [WeatherPresets.NIGHTCLEAR, 70, 30, phaseNightSix, MusicNight4],\r\n            // SEVEN (31-34)\r\n            [WeatherPresets.DAWNCLEARORANGE, 20, null, daybreak, null], \r\n            [WeatherPresets.DAYCLEARCOLD, 40, null, null, MusicDay3],\r\n            [WeatherPresets.DUSKCLEAR, 20, null, null, null],\r\n            [WeatherPresets.NIGHTSHINE, 70, 30, phaseNightSeven, MusicNight3],\r\n            // EIGHT (35-38)\r\n            [WeatherPresets.DAWNREDMOON, 40, null, daybreak, MusicDay5],\r\n            [WeatherPresets.DAYORANGESKY, 40, null, null, null],\r\n            [WeatherPresets.DUSKFOGGY, 20, null, null, null],\r\n            // BIG WAVE\r\n            [WeatherPresets.NIGHTPURPLE, 80, 30, phaseNightEight, MusicNight4],  \r\n            // NINE (39-42)\r\n            [WeatherPresets.DAWNBRIGHT, 20, null, daybreak, null],\r\n            [WeatherPresets.DAYPASTEL, 75, null, null, MusicDay2],            \r\n            [WeatherPresets.DUSKTAN, 20, null, null, MusicNight4],\r\n            // SINGLE TROLL, MASSIVE HEALTH\r\n            [WeatherPresets.NIGHTREDMOON, 60, 30, phaseNightNine, null],\r\n            // TEN (43)\r\n            [WeatherPresets.DAWNBROWN, 20, null, daybreak, null],\r\n            [WeatherPresets.DAYDUSTY, 40, null, null, null],\r\n            [WeatherPresets.DUSKRED, 20, null, null, MusicNight3],\r\n            // EVERYTHING, YOU DIE HERE.\r\n            [WeatherPresets.NIGHTLONG, 60, 30, phaseNightTen, null],\r\n            [WeatherPresets.DAWNEARLY, 15, null, trollRetreat, null],\r\n\r\n        ];\r\n        \r\n        public const PHASES_CYCLE:Array = [\r\n            [WeatherPresets.DAWNREDMOON, 20, null, daybreak, null],\r\n            [WeatherPresets.DAYPASTEL, 40, null, null, null],\r\n            [WeatherPresets.DUSKTAN, 20, null, null, null],\r\n            [WeatherPresets.NIGHTLONG, 30, null, null, MusicNight5],\r\n            [null, 55, null, phaseNightCycle, null]\r\n        ];\r\n        \r\n        \r\n        public function nextPhase():void{\r\n            if (phasesPaused){\r\n                return;\r\n            }\r\n            var currentPhase:Array;\r\n            if (phase < PHASES.length){\r\n                currentPhase = PHASES[phase];\r\n            } else {\r\n                var p:int = (phase - PHASES.length) % 5;\r\n                currentPhase = PHASES_CYCLE[p]\r\n            }\r\n            var weatherTweenTime:Number;\r\n            timeToNextPhase = currentPhase[1];\r\n            // Transform weather\r\n            if (currentPhase[2] == null){\r\n                weatherTweenTime = timeToNextPhase * 0.7;\r\n            } else {\r\n                weatherTweenTime = currentPhase[2]\r\n            }\r\n            if (currentPhase[0] != null){\r\n                weather.tweenTo(currentPhase[0], weatherTweenTime);\r\n            }\r\n            phase += 1;\r\n            // Call the function to do custom actions if there is one\r\n            if (currentPhase[3] != null){\r\n                currentPhase[3]();\r\n            }\r\n            // Play music\r\n            if (currentPhase[4] != null){\r\n                if (this.music != null){\r\n                    this.music.stop();\r\n                }\r\n                this.music = FlxG.play(currentPhase[4]);\r\n                FlxG.log(\"Playing \" + currentPhase[4]);\r\n            }\r\n        }\r\n\r\n        public function updateEnvironmentSounds():void{\r\n            var v:Number;\r\n            v = 1 - Math.pow(Math.abs(weather.timeOfDay - 0.7) / 0.1, 2);\r\n            this.cicada.volume = v;\r\n\r\n            v = 1 - Math.pow(Math.min(weather.timeOfDay, Math.abs(weather.timeOfDay - 1.0)) / 0.2, 2);\r\n            this.owls.volume = v;\r\n\r\n            v = 1 - Math.pow(Math.abs(weather.timeOfDay - 0.4) / 0.25, 2);\r\n            this.birds.volume = v;\r\n\r\n            // if (v > 0){\r\n            //     this.cicadas.resume();\r\n            // } else {\r\n            //     this.cicadas.pause();\r\n            // }\r\n        }\r\n\r\n        public function trollStats(speed:Number, health:Number, jumpheight:Number, jumpiness:Number=2, big:Boolean=false, confusion:Number=3):void{\r\n            trollMaxSpeed = speed;\r\n            trollHealth = health;\r\n            trollJumpHeight = jumpheight;\r\n            trollJumpiness = jumpiness;\r\n            trollBig = big;\r\n            trollConfusion = confusion;\r\n        }\r\n                \r\n        public function spawnTrolls(amount:int):void{\r\n            if (cheatNoTrolls)\r\n                return;\r\n\r\n            while(amount){\r\n                amount -= 2;\r\n            \r\n                var troll:Troll = (trolls.recycle(Troll) as Troll);\r\n                troll.reset(64, groundHeight - 40)\r\n                trollsToSpawn.push(troll);\r\n                \r\n                troll = (trolls.recycle(Troll) as Troll);\r\n                troll.reset(GAME_WIDTH - 64, groundHeight - 40);\r\n                trollsToSpawn.push(troll);\r\n\r\n                updateTrollSpawn();    \r\n            }\r\n            \r\n        }\r\n        \r\n        public function updateTrollSpawn():void{\r\n            if (trollsToSpawn.length > 0 && trollSpawnTimer <= 0){\r\n                (trollsToSpawn.shift() as Troll).go();\r\n                (trollsToSpawn.shift() as Troll).go();\r\n                trollSpawnTimer = MIN_TROLL_SPAWNTIME;\r\n            }\r\n        }\r\n\r\n        public function daybreak():void{\r\n            trollRetreat();\r\n            (coins.recycle(Coin) as Coin).drop(castle, player);\r\n            if (castle.stage >= 2) {\r\n                (coins.recycle(Coin) as Coin).drop(castle, player);\r\n            }\r\n            day.addValue(1);\r\n            showCenterText(Utils.toRoman(day.value));\r\n            saveProgress();\r\n        }\r\n\r\n        public function saveProgress():void{\r\n            var numBeggars:int = beggars.countLiving();\r\n            var numCitizens:Array = [0,0,0,0];\r\n            for (var i:int = 0; i < characters.length; i ++){\r\n                if (characters.members[i] != null && (characters.members[i].alive)){\r\n                    numCitizens[(characters.members[i] as Citizen).occupation] ++;\r\n                }\r\n            }\r\n            numCitizens[Citizen.HUNTER] += Math.max(0, archers.countLiving());\r\n            var wallStages:Array = [];\r\n            for (i = 0; i < walls.length; i ++){\r\n                wallStages.push((walls.members[i] as Wall).stage);\r\n            }\r\n\r\n            var s:String = '';\r\n            s += 'D' + day.value + ' ';\r\n            s += 'A' + phase + ' ';\r\n            s += 'X' + int(player.x) + ' ';\r\n            s += 'B' + numBeggars + ' ';\r\n            s += 'P' + numCitizens[Citizen.POOR] + ' ';\r\n            s += 'F' + numCitizens[Citizen.FARMER] + ' ';\r\n            s += 'H' + numCitizens[Citizen.HUNTER] + ' ';\r\n            s += 'W' + wallStages.join('') + ' ';\r\n            s += 'C' + castle.stage + ' ';\r\n            s += 'S' + (shops.members[0] as Shop).supply + (shops.members[1] as Shop).supply + ' ';\r\n            s += 'G' + (player as Player).coins\r\n            FlxG.log(s);\r\n            savedProgress = s;\r\n        }\r\n\r\n        public function setProgress(s:String):void{\r\n            // Parse the string\r\n            // 'N1 X1 B2 P0 F0 H0 W000011 C0 G7'\r\n            progressAll();\r\n            FlxG.flash(0xFFFFFFFF, 3);\r\n            FlxG.log(\"Skip to \" + s);\r\n\r\n            var newDay:int = parseInt(s.match(/D(\\d+)/)[1]);\r\n            var ph:int = parseInt(s.match(/A(\\d+)/)[1]);\r\n            var playerX:int = parseInt(s.match(/X(\\d+)/)[1]);\r\n            var numBeggars:int = parseInt(s.match(/B(\\d+)/)[1]);\r\n            var numPoor:int = parseInt(s.match(/P(\\d+)/)[1]);\r\n            var numFarmers:int = parseInt(s.match(/F(\\d+)/)[1]);\r\n            var numHunters:int = parseInt(s.match(/H(\\d+)/)[1]);\r\n            var wallStages:Array = s.match(/W(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)/);\r\n            var castleStage:int = parseInt(s.match(/C(\\d)/)[1]);\r\n            var shopSupply:Array = s.match(/S(\\d)(\\d)/);\r\n            var gold:int = parseInt(s.match(/G(\\d)/)[1]);\r\n\r\n            while (beggars.countLiving() < numBeggars){\r\n                beggars.add(new Citizen((kingdomRight + kingdomLeft) / 2,0));\r\n            }\r\n\r\n            player.x = playerX;\r\n\r\n            characters.callAll('kill');\r\n            archers.callAll('kill');\r\n            var c:Citizen;\r\n            while (numPoor) {\r\n                c = new Citizen ((kingdomRight+kingdomLeft) / 2, 0);\r\n                c.morph(Citizen.POOR);\r\n                characters.add(c);\r\n                numPoor --;\r\n            }\r\n\r\n            while (numFarmers) {\r\n                c = new Citizen ((kingdomRight+kingdomLeft) / 2, 0);\r\n                c.morph(Citizen.FARMER);\r\n                characters.add(c);\r\n                numFarmers --;\r\n            }\r\n\r\n            while (numHunters) {\r\n                c = new Citizen ((kingdomRight+kingdomLeft) / 2, 0);\r\n                c.morph(Citizen.HUNTER);\r\n                characters.add(c);\r\n                numHunters --;   \r\n            }\r\n\r\n            for (var i:int = 0; i < walls.length; i ++){\r\n                (walls.members[i] as Wall).buildTo(parseInt(wallStages[i+1]), true);\r\n            }\r\n\r\n            (shops.members[0] as Shop).setSupply(parseInt(shopSupply[0]));\r\n            (shops.members[1] as Shop).setSupply(parseInt(shopSupply[1]));\r\n\r\n            castle.morph(castleStage);\r\n            \r\n            (player as Player).changeCoins(gold - (player as Player).coins);\r\n\r\n            phase = ph - 1;\r\n            day.setValue(newDay - 1);\r\n            nextPhase();\r\n\r\n            trolls.callAll(\"kill\");\r\n            trollsNoCollide.callAll(\"kill\");\r\n            gibs.callAll(\"kill\");\r\n\r\n        }\r\n        \r\n        public function trollRetreat(delay:Number=10):void{\r\n            \r\n            retreatDelay = delay;\r\n            \r\n            if (retreatDelay <= 0){\r\n                trollsToSpawn.splice(0);\r\n                trolls.callAll(\"retreat\");\r\n                trollsNoCollide.callAll(\"retreat\");\r\n            }\r\n        }\r\n        \r\n        public function pickUpCoin(coin:FlxObject, char:FlxObject):void{\r\n            if (char is Player){\r\n                (char as Player).pickup(coin);\r\n            } else if (char is Citizen){\r\n                (char as Citizen).pickup(coin);\r\n            } else if (char is Troll){\r\n                (char as Troll).pickup(coin);\r\n            }\r\n        }\r\n\t\t\r\n\t\tpublic function giveTaxes(char:FlxObject, player:FlxObject):void{\r\n\t\t\tif (char != player){\r\n\t\t\t\t(char as Citizen).giveTaxes(player as Player);\r\n\t\t\t}\r\n\t\t}\r\n        \r\n        public function trollWall(troll:FlxObject, wall:FlxObject):void{\r\n            FlxObject.separate(troll, wall);\r\n            wall.hurt((troll as Troll).big ? 2 * TROLL_WALL_DAMAGE : TROLL_WALL_DAMAGE);\r\n        }\r\n        \r\n        public function trollShot(arrow:FlxObject, troll:Troll):void{\r\n            if (troll.alive && arrow.exists){\r\n                FlxG.play(HitbigSound).proximity(arrow.x, arrow.y, player, FlxG.width);\r\n                arrow.kill();\r\n                (troll as Troll).getShot();\r\n            }\r\n        }\r\n        \r\n        public function bunnyShot(arrow:FlxObject, bunny:FlxObject):void{\r\n            if (bunny.alive && arrow.exists){\r\n                FlxG.play(HitSound).proximity(arrow.x, arrow.y, player, FlxG.width);\r\n                arrow.kill();\r\n                (bunny as Bunny).getShot(arrow as Arrow);\r\n            }\r\n        }\r\n        \r\n        public function trollHit(troll:FlxObject, char:FlxObject):void{\r\n            if (char is Citizen){\r\n                (char as Citizen).hitByTroll(troll as Troll);\r\n            }\r\n            if (char == player){\r\n                (char as Player).hitByTroll(troll as Troll);\r\n            }\r\n        }\r\n\r\n        public function crownStolen():void{\r\n            gameover = true;\r\n            phasesPaused = true;\r\n            trollRetreat(0);\r\n            FlxG.mouse.show();\r\n            showText(\"No crown, no king. Game over.\");\r\n            showText(\"Click to continue or wait to enter highscore.\");\r\n            showText(\"Click to continue or wait to enter highscore.\");\r\n            FlxG.fade(0, 20, endGame);\r\n        }\r\n\r\n        public function endGame():void{\r\n            FlxG.switchState(new GameOverState(day.value - 1));\r\n        }\r\n        \r\n        //=== RENDERING ==//\r\n        override public function draw():void{\r\n            darkness.dirty = true;\r\n            darkness.fill(weather.darknessColor);\r\n            \r\n            super.draw();\r\n            weather.ambientTransform.applyFilter(FlxG.camera.buffer);\r\n        }\r\n        \r\n\t\tpublic function showCoins():void{\r\n            var c:int = (player as Player).coins;\r\n\t\t\tsack.show(c);\r\n\t\t}\r\n        \r\n        public function showText(t:String=null):void{\r\n\t\t\tif (t != null){\r\n\t\t\t\ttextQueue = textQueue.concat(t.split('\\n'))\r\n\t\t\t}\r\n\t\t\tif (textQueue.length > 0 && textTimeout <= 0){\r\n\t            text.text = textQueue.shift();\r\n\t            text.visible = true;\r\n\t\t\t\ttextTimeout = Math.max(TEXT_MIN_TIME, TEXT_READ_SPEED * text.text.length);\r\n\t\t\t}\r\n        }\r\n\r\n        public function showCenterText(t:String):void{\r\n            centerText.text = t;\r\n            centerText.visible = true;\r\n            centerText.alpha = 0.999;\r\n        }\r\n        \r\n        public function panTo(o:FlxSprite, duration:Number=8.0, lead:Number=0):void{\r\n            cameraTimeout = duration;\r\n            cameraTarget.target = o;\r\n            cameraTarget.lead = lead;\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "Player.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    import org.flixel.FlxCamera;\n    import org.flixel.FlxGroup;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxSound;\n\n    \n    public class Player extends FlxSprite{\n        \n        [Embed(source='/assets/gfx/king.png')]     private var PlayerImg:Class;\n\n        [Embed(source=\"/assets/sound/pickup.mp3\")] public static const PickupSound:Class;\n        [Embed(source=\"/assets/sound/build.mp3\")] private var BuildSound:Class;\n        [Embed(source=\"/assets/sound/throw.mp3\")] private var ThrowSound:Class;\n        [Embed(source=\"/assets/sound/stolen.mp3\")] private var StolenSound:Class;\n\n        public static var pickupSound:FlxSound = FlxG.loadSound(PickupSound);\n        \n        public static const BASE_SKIN:uint = 0xFFedbebf;\n        public static const BASE_DARK:uint = 0xFFbd9898;\n        public static const BASE_EYES:uint = 0xFFa18383;\n\n        public static const MAX_SPEED:Number = 80;\n        public static const MIN_SPEED:Number = 25;\n        public static const MAX_FOOD_BONUS:Number = 50;\n        public static const MAX_FOOD:Number = 100;\n        public static const HIT_RATE:Number = 0.2;\n        public static const SELECT_DISTANCE:Number = 10;\n        \n        private var playstate:PlayState;\n\n        private var selectedBuilding:FlxSprite = null;\n        private var floatCoin:CoinFloat = null;\n        private var lastMoved:Number = 0;\n        public var food:Number = 100;\n        \n        public var hasCrown:Boolean = true;\n        public var lastTrollHit:Number = 0;\n        public var coins:int = 7;\n        \n        public function Player(X:int,Y:int){\n            super(X,Y);\n            y = 100 // 132 (land height) - 32 (player height)\n            \n            loadGraphic(PlayerImg,true,true,64,64);\n            width = 20;\n            height = 32;\n            offset.x = 22;\n            offset.y = 32;\n            \n            maxVelocity.x = MAX_SPEED;\n            drag.x = maxVelocity.x*5;\n            \n            playstate = (FlxG.state as PlayState);\n\n            addAnimation('walk_slow',[0,1,2,3,4,5,6,7],10,true);\n            addAnimation('walk_fast',[0,1,2,3,4,5,6,7],15,true);\n            addAnimation('stand',[8],10,true);\n            addAnimation('eat',[9,10],5,true);\n            addAnimation('nocrown',[11],10,true);\n            play('stand');\n            playstate.player = this;\n            \n            var d:Number = Math.random() * 20;\n            var skin:uint = Utils.HSVtoRGB(d, 0.19 + (d / 100), 0.97 - (d / 33));\n            Utils.replaceColor(pixels, BASE_SKIN, skin);\n            Utils.replaceColor(pixels, BASE_DARK, Utils.interpolateColor(skin,0xFF000000,0.2));\n            Utils.replaceColor(pixels, BASE_EYES, Utils.interpolateColor(skin,0xFF000000,0.5));\n        }\n\t\t\n        public function changeCoins(amt:int):void{\n            if (amt > 0) {\n                pickupSound.play(false);\n                pickupSound.proximity(x, y, this, FlxG.width);\n            }\n\t\t\tcoins += amt;\n\t\t\tplaystate.showCoins();\n\t\t}\n\n        public function hitByTroll(troll:Troll):void{\n            if (troll.hasCoin) return;\n\n            if (lastTrollHit < HIT_RATE) return;\n            lastTrollHit = 0;\n            \n            // If the player has coins, lose one and return.\n            if (coins > 0){\n                var c:Coin = (playstate.coins.recycle(Coin) as Coin);\n                c.drop(this, troll, true);\n                c.justThrown = true;\n                FlxG.play(StolenSound).proximity(x, y, this, FlxG.width);\n                changeCoins(-1);\n                FlxG.shake();\n                return;\n            }\n\n            if (hasCrown){\n                FlxG.flash(0xFFFFFFFF, 0.1);\n                troll.stealCrown();\n                lostCrown(troll);\n                playstate.crownStolen();\n            }\n        }\n\t\t\n        public function lostCrown(troll:FlxObject):void{\n            hasCrown = false;\n            facing = troll.x > x ? RIGHT : LEFT;\n            play('nocrown');\n            FlxG.play(StolenSound).proximity(x, y, this, FlxG.width);\n            Utils.explode(this, playstate.gibs);\n        }\n        \n        public function pickup(coin:FlxObject):void{\n            if (!coin.alive) return;\n\t\t\tvar c:Coin = coin as Coin;\n\t\t\t// Return if the coin doesn't belong to me.\n\t\t\tif (c.justThrown){\n\t\t\t\treturn;\n\t\t\t}\n            c.kill();\n            changeCoins(1);\n        }\n        \n        override public function update():void {\n            \n            lastTrollHit += FlxG.elapsed;\n            \n            // Check for movement input\n            acceleration.x = 0;\n            if (!hasCrown){\n                return;\n            }\n            if(FlxG.keys.LEFT || FlxG.keys.RIGHT){\n                lastMoved = 0;\n                if (food > 0){\n                    food -= FlxG.elapsed;\n                }\n                maxVelocity.x = MIN_SPEED + Math.min(1,food/MAX_FOOD_BONUS) * (MAX_SPEED-MIN_SPEED);\n                if (!playstate.horseAdvice && food < 10){\n                    playstate.horseAdvice = true;\n                    playstate.showText(\"Horse is tired. Let him rest on the grass.\")\n                }\n            }\n            if(FlxG.keys.LEFT){\n                acceleration.x = -maxVelocity.x*4;\n                facing = LEFT;\n                if (maxVelocity.x > MIN_SPEED + 15){\n                    play('walk_fast');\n                } else {\n                    play('walk_slow');\n                }\n            } else if(FlxG.keys.RIGHT){\n                acceleration.x = maxVelocity.x*4;\n                facing = RIGHT;\n                if (maxVelocity.x > MIN_SPEED + 15){\n                    play('walk_fast');\n                } else {\n                    play('walk_slow');\n                }\n            } else {\n                lastMoved += FlxG.elapsed;\n                if (lastMoved > 1 && food < MAX_FOOD){\n                    // Check if on grass\n                    var headPos:Number = (x+width/2) + (facing == RIGHT ? 25: -25)\n                    var onTile:int = playstate.floor.getTile(headPos/32,4)\n                    if ((onTile >= 7 && onTile <= 11) || (onTile >= 17 && onTile <= 18)){\n                        play('eat',false);\n                        food += FlxG.elapsed*10;\n                    } else {\n                        play('stand');\n                    }\n                } else {\n                    play('stand');\n                }\n            }\n            if (FlxG.keys.SHIFT && PlayState.CHEATS) {\n                velocity.x *= 10\n            }\n            \n            if (FlxG.keys.justPressed(\"DOWN\")){\n                if (coins <= 0){\n                    playstate.showCoins();\n                } else {\n                    if (selectedBuilding != null){\n                        changeCoins(-1);\n                        giveCoin(selectedBuilding);\n                    } else {\n                        var cit:Citizen;\n                        var closestCitizen:Citizen = null;\n                        var closest:Number = 1000000;\n                        for (var i:int = 0; i < playstate.beggars.length; i++){\n                            cit = (playstate.beggars.members[i] as Citizen)\n                            if (Math.abs((cit.x + cit.width/2) - (x + width/2)) < closest){\n                                closestCitizen = cit;\n                                closest = Math.abs((cit.x + cit.width/2) - (x + width/2));\n                            } \n                        }\n                        if (playstate.recruitedCitizen || closest < 64){\n                            var c:Coin = (playstate.coins.recycle(Coin) as Coin);\n                            c.drop(this, closestCitizen);\n                            c.justThrown = true;\n                            FlxG.play(ThrowSound).proximity(x, y, this, FlxG.width);\n                            changeCoins(-1);\n                        }\n                    }\n                }\n            }\n            super.update();\n            \n            //Find selected shop/wall\n            if (selectedBuilding != null){\n                if (Math.abs((selectedBuilding.x + selectedBuilding.width/2) - (x + width/2)) > SELECT_DISTANCE * 2){\n                    deselect(selectedBuilding);\n                }\n            } else if (playstate.recruitedCitizen) {\n                checkSelectable(playstate.objects)\n                checkSelectable(playstate.shops);\n                checkSelectable(playstate.walls);\n            }\n\n            // CAP WALKING AT LEVEL ENDS\n            if (x < 0){\n                velocity.x = Math.max(velocity.x, 0);\n            } else if (x + width > PlayState.GAME_WIDTH) {\n                velocity.x = Math.min(velocity.x, 0);\n            }\n\n        }\n        \n        private function checkSelectable(group:FlxGroup):void{\n            for (var i:int = 0; i < group.length; i ++){\n                var b:FlxSprite = group.members[i];\n                if (b != null && Math.abs((b.x + b.width/2) - (x + width/2)) <= SELECT_DISTANCE){\n                    if ((b as Buildable).canBuild())\n                        select(b);\n                }\n            }\n        }\n        \n        private function select(building:FlxSprite):void{\n            selectedBuilding = building;\n            if (floatCoin == null){\n                playstate.add(floatCoin = new CoinFloat());\n            }\n            floatCoin.visible = true;\n            floatCoin.float(selectedBuilding);\n        }\n        \n        private function deselect(building:FlxSprite):void{\n            selectedBuilding.color = 0xFFFFFFFF;\n            selectedBuilding = null;\n            floatCoin.visible = false;\n        }\n        \n        private function giveCoin(building:FlxSprite):void{\n            Buildable(building).build();\n            FlxG.play(BuildSound).proximity(x, y, this, FlxG.width);\n            deselect(building);\n        }\n    }\n}\n"
  },
  {
    "path": "Preloader.as",
    "content": "package\r\n{\r\n\timport org.flixel.system.FlxPreloader;\r\n\r\n\tpublic class Preloader extends FlxPreloader\r\n\t{\r\n\t\tpublic function Preloader()\r\n\t\t{\r\n\t\t\tclassName = \"king\";\r\n\t\t\tsuper();\r\n\t\t}\r\n\t}\r\n}"
  },
  {
    "path": "Reed.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    \n    public class Reed extends FlxSprite{\n        \n        [Embed(source='/assets/gfx/reed.png')]    private var ReedImg:Class;\n        \n        private var weather:Weather;\n        private var weatherChanged:Number = 0;        \n        private var t:Number = 0;\n        \n        public function Reed(X:int, Y:int){\n            super(X,Y);\n            loadGraphic(ReedImg, true, false, 32, 32);\n            \n            this.weather = (FlxG.state as PlayState).weather;\n        }\n        \n        override public function update():void{\n            t += weather.wind;\n            frame = int(3 * (0.5 + 0.5*Math.sin(0.05*t + x)) + 0.3 * Math.sin(0.2*t));\n            /*if (weather.changed > weatherChanged) {\n                weatherChanged = weather.t;\n                var wind:Number = weather.wind;\n                wind = wind * (0.5 + 0.5*Math.sin(x + weather.t*wind*3) + 0.3*Math.sin(x + weather.t*wind*5));\n                frame = int(3*(1-wind))\n            }*/\n        }\n        \n    }\n}"
  },
  {
    "path": "Scaffold.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxGroup;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    \n    public class Scaffold extends FlxSprite{\n        \n        [Embed(source='/assets/gfx/scaffold.png')] public var Img:Class;\n        \n                \n        public function Scaffold(){\n            super(0,0);\n            loadGraphic(Img);\n            offset.x = 4;\n            width = 24;\n        }\n        \n        public function build(over:FlxSprite):Scaffold {\n            revive();\n            x = over.x;\n            y = over.y;\n            return this;\n        }\n    }\n}"
  },
  {
    "path": "Shop.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxGroup;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    \n    public class Shop extends FlxSprite implements Buildable{\n        \n        [Embed(source='/assets/gfx/shop.png')] public var Img:Class;\n        \n        public static const SCYTHES:int = 1;\n        public static const BOWS:int = 2;\n        \n        public var type:int;\n        public var supply:int = 0;\n                \n        public function Shop(X:int, Y:int){\n            super(X,Y+2);\n            if (X > PlayState.GAME_WIDTH/2){\n                type = BOWS;\n            } else {\n                type = SCYTHES;\n            }\n            loadGraphic(Img,true);\n            width = 56;\n            offset.x = 4;\n            x += 4;\n            height = 46;\n            offset.y = 18;\n            y += 18;\n            moves = false;\n            updateAppearance();\n        }\n        \n        override public function update():void{\n            if (supply > 0){\n                FlxG.overlap(this, (FlxG.state as PlayState).characters, equip)\n            }\n        }\n        \n        public function equip(shop:FlxObject, char:FlxObject):void{\n            if (supply <= 0)\n                return;\n            var cit:Citizen = char as Citizen;\n            if (cit.occupation == Citizen.POOR){\n                supply --;\n                if (type == BOWS){\n                    cit.morph(Citizen.HUNTER);\n                } else {\n                    cit.morph(Citizen.FARMER);\n                }\n                updateAppearance();\n            }\n        }\n\n        public function setSupply(s:int):void{\n            supply = s;\n            updateAppearance();\n        }\n        \n        public function updateAppearance():void{\n            frame = supply;\n            if (type == BOWS){\n                frame += 5;\n            }\n        }\n        \n        public function canBuild():Boolean{\n            return (supply < 4);\n        }\n        \n        public function build():void{\n            (FlxG.state as PlayState).boughtItem = true;\n            supply += 1;\n            flicker(0.3);\n            updateAppearance();\n        }\n        \n        \n    }\n}"
  },
  {
    "path": "Sky.as",
    "content": "package{\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    \n    public class Sky extends FlxSprite{\n        \n        private var weather:Weather;\n        private var weatherChanged:Number = 0;\n        \n        public function Sky(weather:Weather):void{\n            this.weather = weather;\n            scrollFactor.x = scrollFactor.y = 0;\n            makeGraphic(FlxG.width,FlxG.height,0x00000000,true);\n        }\n        \n        \n        override public function update():void{\n            if (weather.changed > weatherChanged) {\n                Utils.gradientOverlay(pixels, [weather.sky, weather.horizon, weather.haze],90, 1);\n                dirty = true;\n                weatherChanged = weather.t;\n            }\n        }\n        \n        \n    }\n}"
  },
  {
    "path": "Sparkle.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxParticle;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxSprite;\n    \n    public class Sparkle extends FlxParticle{\n        \n        [Embed(source='/assets/gfx/sparkle.png')]     private var Img:Class;\n        \n        public function Sparkle(){\n            super();\n            loadGraphic(Img,true);\n            addAnimation('splash',[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],30,false);\n        }\n        \n        override public function reset(X:Number, Y:Number):void{\n            super.reset(X,Y);\n            lifespan = 1.0;\n            play('splash', true);\n        }\n    }\n}\n"
  },
  {
    "path": "Splash.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxParticle;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxSprite;\n    \n    public class Splash extends FlxParticle{\n        \n        [Embed(source='/assets/gfx/splash.png')]     private var Img:Class;\n        \n        public function Splash(){\n            super();\n            loadGraphic(Img,true);\n            addAnimation('splash',[0,1,2,3,4],10);\n            \n        }\n        \n        override public function reset(X:Number, Y:Number):void{\n            super.reset(X,Y);\n            lifespan = 0.5;\n            play('splash');\n        }\n    }\n}\n"
  },
  {
    "path": "SunMoon.as",
    "content": "package{\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    \n    public class SunMoon extends Light{\n        \n        [Embed(source='/assets/gfx/sunmoon.png')] public var Img:Class;\n        [Embed(source='/assets/gfx/light_mid.png')] private var LightMidImg:Class;\n        [Embed(source='/assets/gfx/light_reflect_wide.png')] private var LightReflectWideImg:Class;\n        \n\t\tpublic static const ZENITH:Number = 20 // Highest point\n\t\tpublic static const HORIZON:Number = 100 // Sun \"extinguishes\" below horizon\n\t\t\n        private var weatherChanged:Number = 0;\n        \n        public function SunMoon(weather:Weather):void{\n            super(0,0);\n            \n            offset.x = offset.y = 16;\n            \n            scrollFactor.x = scrollFactor.y = 0.0;\n            loadGraphic(Img,true);\n            \n            beam.loadGraphic(LightMidImg);\n            reflected.loadGraphic(LightReflectWideImg);\n            reflected.color = 0xFFfc8f53;\n            \n            beam.blend = 'screen';\n        }\n        \n        override public function update():void{\n\t\t\t/** \n\t\t\t* the timeOfDay works as follows:\n\t\t\t* 0 and 1 are night. 0.5 is mid-day. \n\t\t\t*/\n            if (weather.changed > weatherChanged) {\n                var progressX:Number = (weather.timeOfDay*2+0.5)%1;\n                var progressY:Number = Math.sin(Math.PI*progressX)\n                x = width + (FlxG.width - 2*width) * progressX;\n                y = HORIZON - progressY*(HORIZON-ZENITH);\n                color = weather.sunTint;\n                beam.alpha = progressY * 2;\n                frame = (weather.timeOfDay > 0.25 && weather.timeOfDay < 0.75) ? 0 : 1;\n                dirty = true;\n                beam.drawFrame(true);\n                weatherChanged = weather.t;\n            }\n            super.update();\n        }\n        \n        \n    }\n}"
  },
  {
    "path": "Torch.as",
    "content": "package{\n\n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    \n    public class Torch extends Light{\n        \n        [Embed(source='/assets/gfx/torch.png')] private var TorchImg:Class;\n\n        [Embed(source='/assets/gfx/light_mid.png')] private var LightMidImg:Class;\n        [Embed(source='/assets/gfx/light_reflect_small.png')] private var LightReflectSmallImg:Class;        \n    \n                \n        public function Torch(X:Number, Y:Number){\n            Y += 8;\n            \n            super(X,Y);\n            \n            offset.x = width/2;\n            offset.y = 8;\n            loadGraphic(TorchImg, true, true, 16, 32);\n            beam.loadGraphic(LightMidImg);\n            reflected.loadGraphic(LightReflectSmallImg);\n            reflected.color = 0xFFfc8f53;\n            if (FlxG.random()<0.5){\n                addAnimation('on', [0,1,2,3,4,5,6,7], 6, true);\n            } else {\n                addAnimation('on', [8,9,10,11,12,13,14,15], 6, true);\n            }\n            facing = (FlxG.random() < 0.5) ? LEFT : RIGHT;\n            addAnimationCallback(this.dim);\n            play('on');\n            setLight();\n        }\n        \n        override public function update():void{\n            if (x < playstate.kingdomRight + 64 && x > playstate.kingdomLeft - 64){\n                visible = true;\n            } else {\n                visible = false;\n            }\n            super.update()\n        }\n    }\n}"
  },
  {
    "path": "Treeline.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    \n    public class Treeline extends FlxSprite{\n        \n        [Embed(source='/assets/gfx/treeline.png')]    private var TreelineImg:Class;\n        \n        \n        public function Treeline(X:int, Y:int){\n            super(X,Y);\n            loadGraphic(TreelineImg, false, true, 96, 160);\n            if (X == 0)\n                facing = LEFT;\n        }\n        \n    }\n}"
  },
  {
    "path": "Troll.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxCamera;\n    \n    public class Troll extends FlxSprite{\n        \n        [Embed(source='/assets/gfx/troll.png')]     private var Img:Class;\n        [Embed(source='/assets/gfx/trollbig.png')]     private var ImgBig:Class;\n        \n        public var t:Number = 0;\n        public var goal:Number = 1600;\n        public var hasCoin:Boolean = false;\n        public var hasCrown:Boolean = false;\n        public var wait:Boolean = false;\n        public var retreating:Boolean = false;\n        public var maxSpeed:Number = 20;\n        public var jumpHeight:Number = 100;\n        public var jumpiness:Number = 0.01;\n        public var confusion:Number = 0.01;\n        public var big:Boolean = false;\n        public var safeDistance:Number = 200;\n        private var maxHeightReached:Number = 0;\n        private var jumpCooldown:Number = 0;\n        private var confuseCooldown:Number = 0;\n        \n        private var playstate:PlayState;\n        \n        public function Troll(){\n            super(0,0);\n            maxVelocity.y  = 275;\n            maxVelocity.x = 60;\n            acceleration.y = 900;\n            loadAnims();\n            playstate = (FlxG.state as PlayState);\n            // allowCollisions = UP|DOWN;\n        }\n        \n        override public function reset(X:Number,Y:Number):void{\n            retreating = false;\n            hasCoin = false;\n            wait = true;\n            visible = false;\n            velocity.x = velocity.y = 0;\n            if (! big == playstate.trollBig){\n                big = playstate.trollBig;\n                loadAnims();\n            }\n            X -= width / 2;\n            super.reset(X - width / 2, Y);\n            health = playstate.trollHealth;\n\t\t\tmaxSpeed = playstate.trollMaxSpeed;\n            jumpHeight = playstate.trollJumpHeight;\n\t\t\tjumpiness = playstate.trollJumpiness; \n            jumpCooldown = jumpiness + Math.random() * 2 * jumpiness;\n            confusion = playstate.trollConfusion;\n            confuseCooldown = confusion + Math.random() * 2 * confusion;\n            t = 1;\n\n            if (playstate.trollsNoCollide.remove(this)){\n                playstate.trolls.add(this);\n            }\n        }\n\n        private function loadAnims():void{\n            if (big){\n                // scale.x = scale.y = 2;\n                loadGraphic(ImgBig,true,true,64,64);\n                offset.x = 24;\n                offset.y = 24;\n                width = 16;\n                height = 40;\n                addAnimation('walk',[0,1,2,3,4,5,6,7,8], 7, true);\n                addAnimation('walk_crown',[9,10,11,12,13,14,15,16,17], 7, true);\n                addAnimation('stand',[0],10,true);\n            } else {\n                // scale.x = scale.y = 1;\n                loadGraphic(Img,true,true,32,32);\n                offset.x = 12;\n                offset.y = 12;\n                width = 8;\n                height = 20;\n                addAnimation('walk',[0,1,2,3,4,5,6,7,8],(10+FlxG.random()*5),true);\n                addAnimation('walk_crown',[9,10,11,12,13,14,15,16,17],(10+FlxG.random()*5),true);\n                addAnimation('walk_coin',[18,19,20,21,22,23,24,25,26],(10+FlxG.random()*5),true);\n                addAnimation('stand',[0],10,true);\n            }\n        }\n        \n        public function getsCoin():void{\n            hasCoin = true;\n            retreat();\n        }\n        \n        public function pickup(coin:FlxObject):void{\n            if (!hasCoin && coin.alive && !retreating && !big){\n                coin.kill();\n                hasCoin = true;\n                retreat();\n            }\n        }\n        \n        public function stealCrown():void{\n            hasCrown = true;\n            playstate.panTo(this, 20);\n            retreat();\n        }\n        \n        public function getShot():void{\n            if (hasCrown) return;\n            health --;\n            if (health > 0) {\n                // flicker();\n            } else {\n                Utils.explode(this, playstate.gibs, 1.0);\n                if (hasCoin) {\n                    (playstate.coins.recycle(Coin) as Coin).drop(this);\n                } \n                kill();\n            }\n        }\n\n        override public function kill():void{\n            playstate.trollsNoCollide.remove(this);\n            playstate.trolls.add(this);\n            super.kill();\n        }\n        \n        public function retreat():void{\n            retreating = true;\n            goal = (x < playstate.player.x) ? 0 : FlxG.worldBounds.width;\n            wait = false;\n            playstate.trolls.remove(this);\n            playstate.trollsNoCollide.add(this);\n        }\n\n        public function go():void{\n            wait = false;\n            visible = true;\n            goal = playstate.player.x;\n            if (big) {\n                playstate.trolls.remove(this);\n                playstate.trollsNoCollide.add(this);\n            }\n        }\n        \n        override public function update():void {\n            if (wait){\n                acceleration.x = 0;\n                velocity.x = 0;\n                return;\n            }\n            confuseCooldown -= FlxG.elapsed;\n            jumpCooldown -= FlxG.elapsed;\n            // Check for movement input\n            acceleration.x = 0;\n            t += FlxG.elapsed;\n            if (!hasCoin && t > 1.8){\n                if (retreating || confuseCooldown < 0){\n                    goal = (x < playstate.player.x) ? 0 : FlxG.worldBounds.width;\n                    confuseCooldown = confusion + Math.random() * 2 * confusion;\n                } else {\n                    goal = playstate.player.x;\n                }\n                t = 0\n            } \n                \n            // I don't know why I need this, but apparently trolls can fall of the world.\n            if (x <= 24 || x + width >= FlxG.worldBounds.width - 24){\n                if (retreating) kill();\n            }\n            if (y > 200){\n                // throw new Error(\"TROLL FELL OFF :(\");\n                FlxG.log(\"TROLL FELL \" + x + \" , \" + y)\n                FlxG.log(\"Retreating: \" + retreating);\n                FlxG.log(\"Big: \" + big);\n                FlxG.log(\"Wait: \" + wait);\n                kill();\n            }\n            \n            facing = (goal > x) ? RIGHT : LEFT;\n            \n            if(touching & FLOOR){\n                maxVelocity.x = maxSpeed;\n                // Sprint outside of kingdom.\n                if (x > playstate.kingdomRight + safeDistance || x < playstate.kingdomLeft - safeDistance){\n                    maxVelocity.x += 40;\n                }\n                drag.x = maxVelocity.x*10;\n                if(facing == LEFT){\n                    acceleration.x = -maxVelocity.x*4;\n                } else {\n                    acceleration.x = maxVelocity.x*4;\n                }\n                if (hasCrown)\n                    play('walk_crown');\n                else if (hasCoin)\n                    play('walk_coin');\n                else\n                    play('walk')\n                // Jump\n                if(jumpCooldown < 0){\n                    maxHeightReached = 0;\n                    var v:Number = Math.sqrt(jumpHeight * 2 * acceleration.y)\n                    velocity.y = -v;\n                    maxVelocity.x = maxSpeed * 2;\n                    velocity.x *= 2\n                    jumpCooldown = jumpiness + Math.random() * 2 * jumpiness;\n                }\n            } else {\n                maxHeightReached = Math.max(112 - y, maxHeightReached)\n                drag.x = maxVelocity.x*0.1;\n                maxVelocity.x = maxSpeed * 2;\n                if(facing == LEFT)\n                    acceleration.x = -maxVelocity.x;\n                else\n                    acceleration.x = maxVelocity.x;\n            }\n                        \n            super.update();\n        }\n    }\n}\n"
  },
  {
    "path": "Utils.as",
    "content": "package\n{\n    import flash.display.BitmapData;\n    import flash.display.Shape;\n    import flash.geom.Rectangle;\n    import flash.geom.Matrix;\n    import org.flixel.FlxPoint;\n    import org.flixel.FlxSprite;\n    import org.flixel.FlxParticle;\n    import org.flixel.FlxGroup;\n    import org.flixel.FlxG;\n    \n    public class Utils{\n        \n        public static const DEG_TO_RAD:Number = Math.PI/180;\n\n        public static var ROMAN_VALUES:Array = [1000, 900,  500, 400, 100,  90, 50,  40, 10,  9,   5,  4,   1]\n        public static var ROMAN_LETTERS:Array = ['M',  'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I']\n\n        \n        /**\n         * Shrinks the hitbox (x,y and offset) of given FlxSprite to the pixels that are actually\n         * covered by a greater portion than min{X,Y}Cover of the pixels.\n         */\n        static public function shrinkHitbox(sprite:FlxSprite, minXCover:Number=0, minYCover:Number=0.5):void{\n            var pix:BitmapData = sprite.pixels;\n            var x:int, y:int, sum:int = 0;\n            var minx:int = pix.width;\n            var maxx:int = 0;\n            var miny:int = pix.height;\n            var maxy:int = 0;\n            for (x = 0; x < pix.width; x++){\n                sum = 0\n                for (y = 0; y < pix.height; y++){\n                    if (pix.getPixel32(x,y) > 0x00FFFFFF) sum ++;\n                }\n                if (sum >= minXCover*pix.height) {\n                    minx = Math.min(minx,x);\n                    maxx = Math.max(maxx,x);\n                } \n            }\n            for (y = 0; y < pix.height; y++){\n                sum = 0\n                for (x = 0; x < pix.width; x++){\n                    if (pix.getPixel32(x,y) > 0x00FFFFFF) sum ++;\n                }\n                if (sum >= minYCover*pix.width) {\n                    miny = Math.min(miny,y);\n                    maxy = Math.max(maxy,y);\n                }\n            }\n            sprite.width  = maxx-minx;\n            sprite.height = maxy-miny;\n            sprite.offset.x = minx\n            sprite.offset.y = miny;\n            sprite.x += minx/2;\n            sprite.y += miny/2;\n        }\n\n    \n        static public function findRectanglesWithColor(bitmap:BitmapData, color:uint):Vector.<Rectangle> {\n            var cur:Rectangle;\n            var rects:Vector.<Rectangle> = new Vector.<Rectangle>();\n            var i:int,j:int,k:int;\n            for(i = 0; i < bitmap.height; i++){\n                for(j = 0; j < bitmap.width; j++){\n                    for(k = 0; k < rects.length; k++){\n                        cur = rects[k];\n                        // If we are in a rect, skip to the right side.\n                        if (cur.contains(j,i)){\n                            j = cur.right;\n                            // If we are outside of the image, next line.\n                            if (j >= bitmap.width){\n                                j = 0;\n                                i++;\n                            }\n                        }\n                    }\n                    if (bitmap.getPixel32(j,i) == color){\n                        rects.push(cur = new Rectangle(j,i,1,1));\n                        // Traverse to right\n                        while( bitmap.getPixel32(j,i) == color){\n                            j++;\n                        }\n                        cur.width = j - cur.x;\n                        // Traverse down\n                        while( bitmap.getPixel32(j-1,i) == color){\n                            i++;\n                        }\n                        cur.height = i - cur.y;\n                        // Reset I and J\n                        j = cur.right;\n                        i = cur.y;\n                    }\n                }\n            }\n            return rects;\n        }\n    \n        /**\n         * Replace one color with another in bitmap.\n         */\n        static public function replaceColor(bitmap:BitmapData,fromColor:uint, toColor:uint):void{\n            for (var i:int = 0; i < bitmap.height; i++){\n                for( var j:int = 0; j < bitmap.width; j++){\n                    if (bitmap.getPixel32(j,i) == fromColor){\n                        bitmap.setPixel32(j, i, toColor);\n                    }\n                }\n            }\n        }\n        \n        /**\n         * Fills a bitmap with a gradient with given colors\n         */\n        static public function gradientOverlay(bitmap:BitmapData, colors:Array, rotation:Number=90, chunks:int = 1):void{\n            var matrix:Matrix = new Matrix();\n            matrix.createGradientBox(bitmap.width/chunks, bitmap.height/chunks, rotation*DEG_TO_RAD);\n            var s:Shape      = new Shape();\n            var ratios:Array = new Array(colors.length);\n            var alphas:Array = new Array(colors.length);\n            \n            for (var i:int = 0; i < colors.length; i ++){\n                alphas[i] = (colors[i] >>> 24)/255;\n                ratios[i] = (i * (1/(colors.length-1)))*255;\n            }\n            \n            s.graphics.beginGradientFill(\"linear\", colors, alphas, ratios, matrix, \"pad\", \"rgb\");\n\n            s.graphics.drawRect(0, 0, bitmap.width/chunks, bitmap.height/chunks);\n            \n            if (chunks == 1) {\n                bitmap.draw(s);\n            } else {   \n                var transform:Matrix = new Matrix();\n                var tempBitmap:BitmapData = new BitmapData(bitmap.width/chunks,bitmap.height/chunks,true,0x000000);\n                tempBitmap.draw(s);\n                transform.scale(bitmap.width/tempBitmap.width,bitmap.height/tempBitmap.height);\n                bitmap.draw(tempBitmap,transform);\n            }\n        }\n        \n        /**\n         * Convert a HSV (hue, saturation, lightness) color space value to an RGB color\n         * \n         * @param    h Hue degree, between 0 and 359\n         * @param    s Saturation, between 0.0 (grey) and 1.0\n         * @param    v Value, between 0.0 (black) and 1.0\n         * \n         * @return 32-bit RGB colour value (0xAARRGGBB)\n         */\n        public static function HSVtoRGB(h:Number, s:Number, v:Number):uint\n        {\n            var result:uint;\n            \n            if (s == 0.0)\n            {\n                result = getColor32(255, v * 255, v * 255, v * 255);\n            }\n            else\n            {\n                h = h / 60.0;\n                var f:Number = h - int(h);\n                var p:Number = v * (1.0 - s);\n                var q:Number = v * (1.0 - s * f);\n                var t:Number = v * (1.0 - s * (1.0 - f));\n                \n                switch (int(h))\n                {\n                    case 0:\n                        result = getColor32(255, v * 255, t * 255, p * 255);\n                        break;\n                        \n                    case 1:\n                        result = getColor32(255, q * 255, v * 255, p * 255);\n                        break;\n                        \n                    case 2:\n                        result = getColor32(255, p * 255, v * 255, t * 255);\n                        break;\n                        \n                    case 3:\n                        result = getColor32(255, p * 255, q * 255, v * 255);\n                        break;\n                        \n                    case 4:\n                        result = getColor32(255, t * 255, p * 255, v * 255);\n                        break;\n                        \n                    case 5:\n                        result = getColor32(255, v * 255, p * 255, q * 255);\n                        break;\n                        \n                    default:\n                        FlxG.log(\"FlxColor Error: HSVtoRGB : Unknown color\");\n                }\n            }\n            \n            return result;\n        }\n        \n        \n        public static function RGBtoHSV(color:uint):Object\n        {\n            var rgb:Object = getRGB(color);\n            \n            var red:Number = rgb.red / 255;\n            var green:Number = rgb.green / 255;\n            var blue:Number = rgb.blue / 255;\n            \n            var min:Number = Math.min(red, green, blue);\n            var max:Number = Math.max(red, green, blue);\n            var delta:Number = max - min;\n            var lightness:Number = (max + min) / 2;\n            var hue:Number;\n            var saturation:Number;\n            \n            //  Grey color, no chroma\n            if (delta == 0)\n            {\n                hue = 0;\n                saturation = 0;\n            }\n            else\n            {\n                if (lightness < 0.5)\n                {\n                    saturation = delta / (max + min);\n                }\n                else\n                {\n                    saturation = delta / (2 - max - min);\n                }\n                \n                var delta_r:Number = (((max - red) / 6) + (delta / 2)) / delta;\n                var delta_g:Number = (((max - green) / 6) + (delta / 2)) / delta;\n                var delta_b:Number = (((max - blue) / 6) + (delta / 2)) / delta;\n                \n                if (red == max)\n                {\n                    hue = delta_b - delta_g;\n                }\n                else if (green == max)\n                {\n                    hue = (1 / 3) + delta_r - delta_b;\n                }\n                else if (blue == max)\n                {\n                    hue = (2 / 3) + delta_g - delta_r;\n                }\n                \n                if (hue < 0)\n                {\n                    hue += 1;\n                }\n                \n                if (hue > 1)\n                {\n                    hue -= 1;\n                }\n            }\n            \n            //    Keep the value with 0 to 359\n            hue *= 360;\n            hue = Math.round(hue);\n            \n            //    Testing\n            //saturation *= 100;\n            //lightness *= 100;\n            \n            return { hue: hue, saturation: saturation, lightness: lightness, value: lightness };\n        }\n        \n        public static function interpolateColor(color1:uint, color2:uint, f:Number):uint\n        {\n            var a1:uint = color1 >>> 24;\n            var r1:uint = color1 >> 16 & 0xFF;\n            var g1:uint = color1 >> 8 & 0xFF;\n            var b1:uint = color1 & 0xFF;\n            \n            var a2:uint = color2 >>> 24;\n            var r2:uint = color2 >> 16 & 0xFF;\n            var g2:uint = color2 >> 8 & 0xFF;\n            var b2:uint = color2 & 0xFF;\n            \n            var fi:Number = (1-f);\n            \n            a1 = (fi * a1) + (f * a2);\n            r1 = (fi * r1) + (f * r2);\n            g1 = (fi * g1) + (f * g2);\n            b1 = (fi * b1) + (f * b2);\n            \n            return a1 << 24 | r1 << 16 | g1 << 8 | b1;\n        }\n        \n        public static function interpolateColorAndAlpha(color1:uint, color2:uint, steps:uint, currentStep:uint):uint\n        {\n            var src1:Object = getRGB(color1);\n            var src2:Object = getRGB(color2);\n\n            var a:uint = (((src2.alpha - src1.alpha) * currentStep) / steps) + src1.alpha;\n            var r:uint = (((src2.red - src1.red) * currentStep) / steps) + src1.red;\n            var g:uint = (((src2.green - src1.green) * currentStep) / steps) + src1.green;\n            var b:uint = (((src2.blue - src1.blue) * currentStep) / steps) + src1.blue;\n\n            return getColor32(a, r, g, b);\n        }\n        \n        /**\n         * Return the component parts of a color as an Object with the properties alpha, red, green, blue\n         * \n         * <p>Alpha will only be set if it exist in the given color (0xAARRGGBB)</p>\n         * \n         * @param    color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB)\n         * \n         * @return Object with properties: alpha, red, green, blue\n         */\n        public static function getRGB(color:uint):Object\n        {\n            var alpha:uint = color >>> 24;\n            var red:uint = color >> 16 & 0xFF;\n            var green:uint = color >> 8 & 0xFF;\n            var blue:uint = color & 0xFF;\n            \n            return { alpha: alpha, red: red, green: green, blue: blue };\n        }\n        \n        /**\n         * Given an alpha and 3 color values this will return an integer representation of it\n         * \n         * @param    alpha    The Alpha value (between 0 and 255)\n         * @param    red        The Red channel value (between 0 and 255)\n         * @param    green    The Green channel value (between 0 and 255)\n         * @param    blue    The Blue channel value (between 0 and 255)\n         * \n         * @return    A native color value integer (format: 0xAARRGGBB)\n         */\n        public static function getColor32(alpha:uint, red:uint, green:uint, blue:uint):uint\n        {\n            return alpha << 24 | red << 16 | green << 8 | blue;\n        }\n        \n        \n        public static function explode(object:FlxSprite, group:FlxGroup, portion:Number = 1, gibsize:int=4, rounded:Boolean=true):Vector.<FlxParticle>{\n            var gibs:Vector.<FlxParticle> = new Vector.<FlxParticle>()\n            var gib:FlxParticle;\n\n            for (var x:int = 0; x < object.framePixels.width; x += gibsize){\n                for (var y:int = 0; y < object.framePixels.height; y += gibsize){\n                    if ((object.framePixels.getPixel32(x+gibsize/2,y+gibsize/2) >>> 24) > 0){\n                        if (FlxG.random() < portion){\n                            gib = group.recycle(FlxParticle) as FlxParticle;\n                            if (gib.frameWidth != gibsize || gib.frameHeight != gibsize){\n                                gib.makeGraphic(gibsize,gibsize,0,true);\n                            }\n                            gib.revive();\n\n                            // _flashPoint.x = X;\n                            // _flashPoint.y = Y;\n                            // _flashRect2.width = bitmapData.width;\n                            // _flashRect2.height = bitmapData.height;\n                            // gib.framePixels.copyPixels(object._framePixels,rect,point,null,null,true);\n                            gib.stamp(object, -x, -y);\n                            if (rounded){\n                                gib.framePixels.setPixel32(0,0,0);\n                                gib.framePixels.setPixel32(0,gibsize-1,0);\n                                gib.framePixels.setPixel32(gibsize-1,0,0);\n                                gib.framePixels.setPixel32(gibsize-1,gibsize-1,0);\n                            }\n                            gibs.push(gib);\n                            gib.elasticity = 0.5;\n                            gib.lifespan = 7;\n                            gib.x = object.x - object.offset.x + x;\n                            gib.y = object.y - object.offset.y + y;\n                            gib.acceleration.y = 900;\n                            gib.velocity.x = FlxG.random()*80 - 40;\n                            gib.velocity.y = -130-FlxG.random()*30;\n                        }\n                    }\n                }\n            }\n            return gibs;\n        }\n\n        /** \n        * Returns a roman numeral string\n        */\n        public static function toRoman(n:int):String{\n            var s:String = ''\n            for (var i:int = 0; i < ROMAN_LETTERS.length; i ++){\n                var c:int = Math.floor(n / ROMAN_VALUES[i])\n                n -= c * ROMAN_VALUES[i];\n                while (c > 0){\n                    s += ROMAN_LETTERS[i];\n                    c --;\n                }\n            }\n            return s;\n        }\n    }\n}\n"
  },
  {
    "path": "Wall.as",
    "content": "package\n{\n    import flash.geom.Point;\n    \n    import org.flixel.FlxSprite;\n    import org.flixel.FlxG;\n    import org.flixel.FlxObject;\n    import org.flixel.FlxPoint;\n    \n    public class Wall extends FlxSprite implements Workable, Buildable{\n        \n        [Embed(source='/assets/gfx/wall.png')]    private var WallImg:Class;\n        \n        [Embed(source=\"/assets/sound/hitwall.mp3\")] private var HitwallSound:Class;\n        \n        public const HEIGHT:Array = [11,38,46,54,59]; // Effective Height: [26, 34, 42, 47]\n        public const HEALTH:Array = [2,38,50,60,75];\n        public const HURT_COOLDOWN:Number = 1;\n        public const WORK_BUILD_HEIGHT:int = 10;\n        public const WORK_HEAL_AMOUNT:int = 4;\n        \n        private var playstate:PlayState;\n        public var scaffold:Scaffold = null;\n        \n        public var building:Boolean = false;\n        public var heightToBuild:int = 0;\n        public var baseY:Number;\n        public var stage:int = 0;\n        private var t:Number = 0;\n        \n        public function Wall(X:Number, Y:Number){\n            baseY = Y;\n            super(X,Y);\n            immovable = true;\n            moves = false;\n            solid = false;\n            loadGraphic(WallImg, true, true, 32, 64);\n            addAnimation(\"grow\",[0,1,2,3,4,5,6,7,8,9],1);\n            if (X > 1920){\n                facing = LEFT;\n            }\n            offset.x = 4;\n            width = 24;\n            health = HEALTH[stage];\n            updateAppearance();\n            playstate = FlxG.state as PlayState;\n        }\n        \n        public function build():void{\n            buildTo(stage + 1);\n        }\n\n        public function buildTo(s:int, instant:Boolean=false):void{\n            if (!instant && s < stage) return;\n            building = true;\n            stage = s;\n            heightToBuild = HEIGHT[stage];\n            health = HEALTH[stage];\n            updateAppearance();\n            if (scaffold != null){\n                scaffold.kill();\n            }\n            scaffold = (playstate.indicators.recycle(Scaffold) as Scaffold).build(this);\n            scaffold.y = y - HEIGHT[stage];\n            solid = false;\n            // Kind of hacky this.\n            if (instant){\n                heightToBuild = 1;\n                work(null);\n            }\n            // flicker();\n        }\n        \n        public function work(citizen:Citizen=null):void{\n            if (heightToBuild > 0) {\n                heightToBuild -= WORK_BUILD_HEIGHT;\n                if (heightToBuild <= 0){\n                    heightToBuild = 0;\n                    building = false;\n                    solid = true;\n                    Utils.explode(scaffold, playstate.gibs, 1);\n                    scaffold.kill();\n                    scaffold = null;\n                }\n            } else {\n                if (health < HEALTH[stage]){\n                    health += Math.min(WORK_HEAL_AMOUNT, HEALTH[stage] - health);\n                }\n            }\n            updateAppearance();\n        }\n\n        override public function hurt(Damage:Number):void{\n            if (t > HURT_COOLDOWN){\n                health -= Damage;\n                FlxG.play(HitwallSound).proximity(x, y, playstate.player, FlxG.width)\n                Utils.explode(this, playstate.gibs, 0.1);\n                t = 0;\n            }\n            if (health <= 0 && stage > 0){\n                Utils.explode(this, playstate.gibs, 1.0);\n                stage = 0;\n                health = HEALTH[stage];\n            }\n            health = Math.max(health, HEALTH[0]);\n            updateAppearance();\n        }\n        \n        public function needsWork():Boolean{\n            return ((building || health < HEALTH[stage]) && t < HURT_COOLDOWN);\n        }\n        \n        public function canBuild():Boolean{\n            return (!building && stage < 4)\n        }\n        \n        private function updateAppearance():void{\n            height = HEIGHT[stage] - heightToBuild;\n            y = baseY + 64 - height;\n            offset.y = 64 - HEIGHT[stage];\n            if (health < HEALTH[stage] / 2){\n                frame = stage + 5;\n            } else {\n                frame = stage;\n            }\n        }\n        \n        override public function update():void{\n            t += FlxG.elapsed;\n            if (this.stage > 0 && !building){\n                if (this.x > PlayState.GAME_WIDTH/2){\n                    playstate.kingdomRight = Math.max(playstate.kingdomRight, x)\n                } else {\n                    playstate.kingdomLeft = Math.min(playstate.kingdomLeft, x+width)\n                }\n            }\n        }\n    }\n}"
  },
  {
    "path": "Water.as",
    "content": "package\n{\n    import flash.display.BitmapData;\n    import flash.display.BitmapDataChannel;\n    import flash.filters.DisplacementMapFilter;\n    import flash.filters.DisplacementMapFilterMode;\n    import flash.geom.ColorTransform;\n    import flash.geom.Matrix;\n    import flash.geom.Point;\n    import flash.geom.Rectangle;\n    import org.flixel.FlxSprite;\n    import org.flixel.FlxGroup;\n    import org.flixel.FlxG;\n\n    public class Water extends FlxSprite\n    {\n        \n        public static const NOISE_BIAS:int = 100;\n        public static const WIND_RIPPLE_MULTIPLIER:Number = 25;\n        \n        private var rect:Rectangle = new Rectangle(0, 0, 480, 160);\n        //private var point:Point = new Point(0, 160);\n        private var zeroPoint:Point = new Point(0, 0);\n        private var perlinOffset:Point = new Point(0,0)\n        private var matrix:Matrix = new Matrix();\n        private var transform:ColorTransform;\n        private var noiseRange:ColorTransform;\n        private var displacementFilter:DisplacementMapFilter;\n        private var displacementBitmap:BitmapData;\n        private var baseColor:uint;\n        private var currentBase:uint;\n        private var timer:Number = 0;\n        private var lights:FlxGroup;\n        private var weather:Weather;\n        private var weatherChanged:Number = -1;\n\n        public function Water(x:int,y:int,width:int,height:int,lights:FlxGroup,weather:Weather,baseColor:uint=0xFF686C53,reflectivity:Number=0.3)\n        {\n           \n            // Set height/width/x/y\n            this.x = x;\n            this.y = y;\n            moves = false;\n            scrollFactor.x = 0;\n            \n            transform          = new ColorTransform(1,1,1,reflectivity);\n            rect               = new Rectangle(0,0,width,height);\n            displacementBitmap = new BitmapData(width, height, false, 0);\n            makeGraphic(width,height,baseColor);\n            \n            this.lights = lights;\n            this.weather = weather;\n            this.baseColor = baseColor;\n            \n            // This is the filter that makes the reflection ripple\n            displacementFilter = new DisplacementMapFilter(displacementBitmap, zeroPoint, 1, 2, 256, 256, DisplacementMapFilterMode.COLOR, baseColor, 0.5);\n            \n            // Reduce the range of perlin transform\n        }\n\n        override public function update():void\n        {\n            \n            timer += FlxG.elapsed;\n            if (weather.changed > weatherChanged){\n                currentBase = 0xFF000000 | Utils.interpolateColor(baseColor, weather.darknessColor, weather.darkness)\n                \n                var rippleScale:int = int(weather.wind*WIND_RIPPLE_MULTIPLIER);\n                var xscale:int = rippleScale/2;\n                var yscale:int = rippleScale;\n                noiseRange = new ColorTransform(xscale/128,yscale/128,1,1,(128-xscale+(NOISE_BIAS*xscale/128)),(128-yscale+(NOISE_BIAS*yscale/128)),1,1)\n                weatherChanged = weather.t\n            }\n        }\n\n        override public function draw():void\n        {\n            if (timer > 0.1)\n            { // Update the water ripple\n                perlinOffset.y += 1/5;\n                perlinOffset.x = FlxG.camera.scroll.x*1.5;\n                displacementBitmap.perlinNoise(32, 4, 1, 12312, false, false, 1|2, true, [perlinOffset]);\n                displacementBitmap.colorTransform(rect,noiseRange);\n                // Adjust the base color according to the weather.\n                displacementFilter.color = currentBase;\n                timer = 0;\n            }\n            var px:BitmapData = pixels;\n            matrix.identity();\n            matrix.scale(1, -1);\n            getScreenXY(_point);\n            matrix.translate(-_point.x, _point.y);\n            // Clear the reflection\n            px.fillRect(rect, currentBase);\n            Utils.gradientOverlay(px, [0x00000000,0x66000000], 90, 4);\n            // Flip the screen and copy it to the reflection\n            px.draw(FlxG.camera.buffer, matrix, transform);\n            \n            // Draw the lights\n            var l:Light;\n            for (var i:int = 0; i < lights.length; i++){\n                l = lights.members[i] as Light;\n                l.getScreenXY(_point);\n                if(l.visible && -64 < _point.x && _point.x < FlxG.width + 64){\n                    l.reflected.alpha = weather.darkness * 0.8;\n                    l.reflected.alpha *= Math.min(1.0, (weather.wind * 10));\n                    l.reflected.drawFrame();\n                    stamp(l.reflected, _point.x - l.reflected.width/2 + 4, (y - l.y) * 0.3);\n                }\n            }\n            \n            // Apply the ripple filter\n            px.applyFilter(px, rect, zeroPoint, displacementFilter); \n            dirty = true;\n            super.draw()\n        }\n    }\n}\n"
  },
  {
    "path": "Weather.as",
    "content": "package{\n    \n    import org.flixel.FlxG;\n    \n    import com.quasimondo.geom.ColorMatrix\n    \n    public class Weather extends Object{\n    \n        public var sky:uint           = 0xFF8C8CA6;\n        public var horizon:uint       = 0xFFCF7968;\n        public var haze:uint          = 0xAAf3f1e8;\n        public var darknessColor:uint = 0x88111114;\n        public var darkness:Number    = 1.0;\n        public var contrast:Number    = 0.3;\n        public var saturation:Number  = 1.0\n        public var ambient:uint       = 0x11FF0000;\n        public var wind:Number        = 0.0;\n        public var fog:Number         = 0.5;\n        public var rain:Number        = 0.5;\n        public var timeOfDay:Number   = 0.5;\n        public var sunTint:uint       = 0xFFFFFF;\n        \n        public var ambientTransform:ColorMatrix = new ColorMatrix();\n        \n        public var t:Number        = 0;\n        public var changed:Number  = 0;\n        public var progress:Number = 0;\n        public var ambientAmount:Number = 0;\n        \n        public var tweenStart:Number    = 0;\n        public var tweenDuration:Number = 0.0;\n        public var previousState:Object = WeatherPresets.SUNNY;\n        public var targetState:Object   = WeatherPresets.SUNNY;\n        \n        public function Weather(){\n            setVariables(WeatherPresets.SUNNY);\n        }\n        \n        public function update():void{\n            t += FlxG.elapsed;\n            if (t - changed > 1/30){\n                updateTween();\n                changed = t;\n            }\n        }\n        \n        public function tweenTo(state:Object, d:Number=30):void{\n            targetState = state;\n            if (d == 0){\n                setVariables(state)\n                previousState = state;\n            } else {\n                tweenDuration = d;\n                tweenStart    = t;\n            }\n        }\n        \n        public function updateTween():void{\n            if (targetState === previousState) return;\n            // Compute the tween factor\n            progress = (t - tweenStart)/tweenDuration;\n            if (tweenDuration == 0 || progress >= 1) {\n                previousState = targetState;\n                progress = 1;\n            }\n            setVariables(targetState, previousState, progress);\n        }\n        \n        private function setVariables(target:Object, previous:Object=null, f:Number = 1):void{\n            // Very ugly\n            if (!target.hasOwnProperty('ambientAmount')){\n                target['ambientAmount'] = ((target['ambient'] >> 24) / 0xFF);\n            }\n\n            if (previous === null){\n                previous = target;\n            }\n\n            var fi:Number = 1 - f;\n            // Loop through the variables and tween them\n            for (var v:String in target){\n                // List non-color props here.\n                if (v == 'darkness' || v == 'contrast' || v == 'saturation' || v == 'fog' || v == 'rain' || v == 'wind' || v == 'ambientAmount'){\n                    this[v] = (fi * previous[v]) + (f * target[v]);\n                // timeOfDay is weird and circular.\n                } else if (v == 'timeOfDay'){\n                    if (target[v] > previous[v])\n                        this[v] = (previous[v] + (target[v]-previous[v])*f)%1;\n                    else\n                        this[v] = (previous[v] + (target[v]+1-previous[v])*f)%1;\n                } else {\n                    // Interpolate a color.\n                    this[v] = Utils.interpolateColor(previous[v], target[v], f);\n                }\n            }\n            // Set the other vars\n            ambientTransform.reset();\n\n            ambientTransform.colorize(ambient, ambientAmount);\n            ambientTransform.adjustContrast(contrast);\n            ambientTransform.adjustSaturation(saturation);\n            // Set opacity of the darknessColor to darkness.\n            darknessColor = (darknessColor&0x00FFFFFF) | (uint(0xFF*darkness) << 24) ;\n        }\n        \n    }\n}\n"
  },
  {
    "path": "WeatherPresets.as",
    "content": "// THIS FILE IS AUTOGENERATED, MODIFY weathers.json IN STEAD.\n\npackage {\npublic class WeatherPresets extends Object{\n\tpublic static const NIGHTGREEN:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.45,\n\t\t'sky': 0xFF005EA5,\n\t\t'haze': 0xFFB8F2BB,\n\t\t'sunTint': 0xDDDDFF,\n\t\t'fog': 0.4,\n\t\t'contrast': 0.0,\n\t\t'horizon': 0xFF002E80,\n\t\t'ambient': 0x2254FFAF,\n\t\t'timeOfDay': 0.85,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88263529\n\t}\n\tpublic static const NIGHTFOGGY:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.7,\n\t\t'sky': 0xFF25229d,\n\t\t'haze': 0xFFd5d9ff,\n\t\t'sunTint': 0xffd9c8,\n\t\t'fog': 1.0,\n\t\t'contrast': -0.1,\n\t\t'horizon': 0xFF6a6d55,\n\t\t'ambient': 0x7763709d,\n\t\t'timeOfDay': 0.8,\n\t\t'wind': 0.2,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const NIGHTLONG:Object = {\n\t\t'saturation': 1.0,\n\t\t'darkness': 0.4,\n\t\t'sky': 0xFF7399c8,\n\t\t'sunTint': 0x162039,\n\t\t'haze': 0xFF000000,\n\t\t'fog': 0.0,\n\t\t'wind': 0.1,\n\t\t'horizon': 0xFF7399c8,\n\t\t'ambient': 0x55acc857,\n\t\t'timeOfDay': 0.9,\n\t\t'contrast': 0.3,\n\t\t'darknessColor': 0x88000000\n\t}\n\tpublic static const DAYCLEARCOLD:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFFC9E3EA,\n\t\t'haze': 0x33C9E3EA,\n\t\t'sunTint': 0xF7E9AA,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.2,\n\t\t'horizon': 0xFFC9E3EA,\n\t\t'ambient': 0x33F7E0C3,\n\t\t'timeOfDay': 0.45,\n\t\t'wind': 0.5,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAWNBLEAK:Object = {\n\t\t'saturation': 0.9,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFFC4AD99,\n\t\t'haze': 0xAAf3f1e8,\n\t\t'sunTint': 0xF9B340,\n\t\t'fog': 0.5,\n\t\t'contrast': 0.5,\n\t\t'horizon': 0xFFCECECE,\n\t\t'ambient': 0x22FF84DA,\n\t\t'timeOfDay': 0.31,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAYORANGESKY:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.1,\n\t\t'sky': 0xFFADA290,\n\t\t'haze': 0x445A432C,\n\t\t'sunTint': 0xF9F8E6,\n\t\t'fog': 0.3,\n\t\t'contrast': 0.2,\n\t\t'horizon': 0xFFDCAB4F,\n\t\t'ambient': 0x110E0B22,\n\t\t'timeOfDay': 0.4,\n\t\t'wind': 0.7,\n\t\t'darknessColor': 0x880E0B62\n\t}\n\tpublic static const DAYPASTEL:Object = {\n\t\t'saturation': 1.0,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFF3090F6,\n\t\t'sunTint': 0xF9F8E6,\n\t\t'haze': 0xDD657A8F,\n\t\t'fog': 0.0,\n\t\t'wind': 0.3,\n\t\t'horizon': 0xFFEEEE88,\n\t\t'ambient': 0x44886A00,\n\t\t'timeOfDay': 0.55,\n\t\t'contrast': 1.0,\n\t\t'darknessColor': 0x88000BBB\n\t}\n\tpublic static const DUSKPINK:Object = {\n\t\t'saturation': 0.9,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFF8C8CA6,\n\t\t'haze': 0xAAf3c1e8,\n\t\t'sunTint': 0xF9B340,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.8,\n\t\t'horizon': 0xFFEDC99A,\n\t\t'ambient': 0x44F79A42,\n\t\t'timeOfDay': 0.651,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAWNCLEARORANGE:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFF97A7B4,\n\t\t'haze': 0x88FDB24C,\n\t\t'sunTint': 0xFAFDC9,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.5,\n\t\t'horizon': 0xFFF9A04F,\n\t\t'ambient': 0x11FF0000,\n\t\t'timeOfDay': 0.28,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const EVENINGORANGE:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.1,\n\t\t'sky': 0xFF8BB8E8,\n\t\t'haze': 0xFFFF9068,\n\t\t'sunTint': 0xFFFF7038,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.7,\n\t\t'horizon': 0xFFEDC99A,\n\t\t'ambient': 0x33DE5E37,\n\t\t'timeOfDay': 0.70,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const NIGHTSHINE:Object = {\n\t\t'saturation': 0.5,\n\t\t'darkness': 0.35,\n\t\t'sky': 0xFF000000,\n\t\t'sunTint': 0xF9F8E6,\n\t\t'haze': 0x00886AAA,\n\t\t'fog': 0.0,\n\t\t'wind': 0.2,\n\t\t'horizon': 0xFFAAAAFF,\n\t\t'ambient': 0x00000000,\n\t\t'timeOfDay': 0.9,\n\t\t'contrast': 4.0,\n\t\t'darknessColor': 0x88222255\n\t}\n\tpublic static const EVENINGFOGGY:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.3,\n\t\t'sky': 0xFFd56c47,\n\t\t'haze': 0xFFd5d9ff,\n\t\t'sunTint': 0xffd9c8,\n\t\t'fog': 1.0,\n\t\t'contrast': -0.1,\n\t\t'horizon': 0xFF6a6d55,\n\t\t'ambient': 0x440000FF,\n\t\t'timeOfDay': 0.7,\n\t\t'wind': 0.2,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const NIGHTPURPLE:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.3,\n\t\t'sky': 0xFF57577D,\n\t\t'sunTint': 0xF9F8E6,\n\t\t'haze': 0x88886AAA,\n\t\t'fog': 0.0,\n\t\t'wind': 0.2,\n\t\t'horizon': 0xFF4D4658,\n\t\t'ambient': 0x33886AAA,\n\t\t'timeOfDay': 0.9,\n\t\t'contrast': 1.4,\n\t\t'darknessColor': 0x88990BBB\n\t}\n\tpublic static const EVENINGBLACK:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.3,\n\t\t'sky': 0xFF333333,\n\t\t'haze': 0xFFFF9090,\n\t\t'sunTint': 0xFFFF7038,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.0,\n\t\t'horizon': 0xFFEDC99A,\n\t\t'ambient': 0x339f6b5c,\n\t\t'timeOfDay': 0.70,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const EVENINGMONOTONE:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.3,\n\t\t'sky': 0xFF333333,\n\t\t'haze': 0xFFFF9090,\n\t\t'sunTint': 0xAAAAAA,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.0,\n\t\t'horizon': 0xFFEDEDED,\n\t\t'ambient': 0x33666666,\n\t\t'timeOfDay': 0.70,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const NIGHTCLEAR:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.4,\n\t\t'sky': 0xFF005EA5,\n\t\t'haze': 0x44434e87,\n\t\t'sunTint': 0xDDDDFF,\n\t\t'fog': 0.1,\n\t\t'contrast': -0.1,\n\t\t'horizon': 0xFF002E80,\n\t\t'ambient': 0x110000FF,\n\t\t'timeOfDay': 0.1,\n\t\t'wind': 0.3,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const SUNNY:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFF98BEEC,\n\t\t'haze': 0xCCf3f1e8,\n\t\t'sunTint': 0xfff766,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.8,\n\t\t'horizon': 0xFFC4DAF1,\n\t\t'ambient': 0x44FFBB7F,\n\t\t'timeOfDay': 0.6,\n\t\t'wind': 1.0,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAYBLEAK:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFFA0C2E8,\n\t\t'haze': 0xFFf3f1e8,\n\t\t'sunTint': 0xF7E9AA,\n\t\t'fog': 1.0,\n\t\t'contrast': 0.0,\n\t\t'horizon': 0xFFA6C9ED,\n\t\t'ambient': 0x33F7E0C3,\n\t\t'timeOfDay': 0.45,\n\t\t'wind': 0.5,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const NIGHTREDMOON:Object = {\n\t\t'saturation': 0.9,\n\t\t'darkness': 0.4,\n\t\t'sky': 0xFF142744,\n\t\t'haze': 0x665C5D9E,\n\t\t'sunTint': 0xC73800,\n\t\t'fog': 0.1,\n\t\t'contrast': 0.2,\n\t\t'horizon': 0xFFAD2E21,\n\t\t'ambient': 0x220E0B62,\n\t\t'timeOfDay': 0.1,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x880E0B62\n\t}\n\tpublic static const DAYTEMP:Object = {\n\t\t'saturation': 0.0,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFF6a6d55,\n\t\t'haze': 0xFF999d7c,\n\t\t'sunTint': 0xffffff,\n\t\t'fog': 1.0,\n\t\t'contrast': -0.2,\n\t\t'horizon': 0xFF6a6d55,\n\t\t'ambient': 0xFFFF0000,\n\t\t'timeOfDay': 0.5,\n\t\t'wind': 0.2,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const FOGGY:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFF6a6d55,\n\t\t'haze': 0xFF999d7c,\n\t\t'sunTint': 0xffffff,\n\t\t'fog': 1.0,\n\t\t'contrast': -0.2,\n\t\t'horizon': 0xFF6a6d55,\n\t\t'ambient': 0x330000FF,\n\t\t'timeOfDay': 0.25,\n\t\t'wind': 0.2,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAWNBROWN:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFFC0AFBD,\n\t\t'sunTint': 0xF9F8E6,\n\t\t'haze': 0x99AAAAAA,\n\t\t'fog': 0.2,\n\t\t'wind': 0.2,\n\t\t'horizon': 0xFF94A9B6,\n\t\t'ambient': 0x55AD3200,\n\t\t'timeOfDay': 0.28,\n\t\t'contrast': 0.7,\n\t\t'darknessColor': 0x88222255\n\t}\n\tpublic static const DUSKFOGGY:Object = {\n\t\t'saturation': 0.6,\n\t\t'darkness': 0.25,\n\t\t'sky': 0xFFB29C8F,\n\t\t'sunTint': 0xF9F8E6,\n\t\t'haze': 0x00000000,\n\t\t'fog': 0.8,\n\t\t'wind': 0.4,\n\t\t'horizon': 0xFF3D6BCD,\n\t\t'ambient': 0x330E0B22,\n\t\t'timeOfDay': 0.75,\n\t\t'contrast': 0.1,\n\t\t'darknessColor': 0x880E0B62\n\t}\n\tpublic static const DAWNLIGHTPINK:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.1,\n\t\t'sky': 0xFF8C8CA6,\n\t\t'haze': 0xAAf3f1e8,\n\t\t'sunTint': 0xF9B340,\n\t\t'fog': 0.5,\n\t\t'contrast': 0.5,\n\t\t'horizon': 0xFFCF7968,\n\t\t'ambient': 0x22FF84DA,\n\t\t'timeOfDay': 0.28,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const NIGHTDARK:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.75,\n\t\t'sky': 0xFF002E33,\n\t\t'haze': 0xFF555555,\n\t\t'sunTint': 0x65a2cb,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.4,\n\t\t'horizon': 0xFF002E80,\n\t\t'ambient': 0x4454AACF,\n\t\t'timeOfDay': 0.85,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0xFF263529\n\t}\n\tpublic static const DUSKWARM:Object = {\n\t\t'saturation': 0.9,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFF8BB8E8,\n\t\t'haze': 0x88f3f1e8,\n\t\t'sunTint': 0xF4EED0,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.8,\n\t\t'horizon': 0xFFEDC99A,\n\t\t'ambient': 0x44F79A42,\n\t\t'timeOfDay': 0.651,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAWNEARLY:Object = {\n\t\t'saturation': 0.9,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFFC4AD99,\n\t\t'haze': 0xAAf3f1e8,\n\t\t'sunTint': 0xF9B340,\n\t\t'fog': 0.5,\n\t\t'contrast': 0.5,\n\t\t'horizon': 0xFFCECECE,\n\t\t'ambient': 0x22FF84DA,\n\t\t'timeOfDay': 0.19,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAWNBRIGHT:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.15,\n\t\t'sky': 0xFF57577D,\n\t\t'sunTint': 0xF9F8E6,\n\t\t'haze': 0x00886AAA,\n\t\t'fog': 0.0,\n\t\t'wind': 0.2,\n\t\t'horizon': 0xFFEEEE88,\n\t\t'ambient': 0xff886A00,\n\t\t'timeOfDay': 0.3,\n\t\t'contrast': 1.4,\n\t\t'darknessColor': 0x88000BBB\n\t}\n\tpublic static const DAWNGREY:Object = {\n\t\t'saturation': 0.5,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFFC4AD99,\n\t\t'haze': 0xAAf3f1e8,\n\t\t'sunTint': 0xF9B340,\n\t\t'fog': 0.5,\n\t\t'contrast': 0.5,\n\t\t'horizon': 0xFFCECECE,\n\t\t'ambient': 0x22FF84DA,\n\t\t'timeOfDay': 0.31,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const NIGHTSUPERDARK:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.7,\n\t\t'sky': 0xFF000000,\n\t\t'haze': 0xFFFFFFFF,\n\t\t'sunTint': 0x65a2cb,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.4,\n\t\t'horizon': 0xFF002E80,\n\t\t'ambient': 0x4454AACF,\n\t\t'timeOfDay': 0.85,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0xFF263529\n\t}\n\tpublic static const DUSKCLEAR:Object = {\n\t\t'saturation': 0.9,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFF513744,\n\t\t'haze': 0xAAC9976D,\n\t\t'sunTint': 0xF9B340,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.45,\n\t\t'horizon': 0xFFC69875,\n\t\t'ambient': 0x22360A00,\n\t\t'timeOfDay': 0.651,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const NIGHT:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.4,\n\t\t'sky': 0xFF005EA5,\n\t\t'haze': 0xFF333333,\n\t\t'sunTint': 0xDDDDFF,\n\t\t'fog': 0.2,\n\t\t'contrast': 0.5,\n\t\t'horizon': 0xFF002E80,\n\t\t'ambient': 0x110000FF,\n\t\t'timeOfDay': 0,\n\t\t'wind': 0.2,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAWNTEMP:Object = {\n\t\t'saturation': 0.0,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFF6a6d55,\n\t\t'haze': 0xFF999d7c,\n\t\t'sunTint': 0xffffff,\n\t\t'fog': 1.0,\n\t\t'contrast': -0.2,\n\t\t'horizon': 0xFF6a6d55,\n\t\t'ambient': 0xFFFF0000,\n\t\t'timeOfDay': 0.25,\n\t\t'wind': 0.2,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAYWINDYCLEAR:Object = {\n\t\t'saturation': 1.0,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFF64A3EA,\n\t\t'haze': 0x22f3f1e8,\n\t\t'sunTint': 0xF7E9AA,\n\t\t'fog': 0.0,\n\t\t'contrast': 1.0,\n\t\t'horizon': 0xFF86BAEF,\n\t\t'ambient': 0x33F99100,\n\t\t'timeOfDay': 0.45,\n\t\t'wind': 0.5,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAWN:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFF8C8CA6,\n\t\t'haze': 0x66f3f1e8,\n\t\t'sunTint': 0xff6d40,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.5,\n\t\t'horizon': 0xFFCF7968,\n\t\t'ambient': 0x11FF0000,\n\t\t'timeOfDay': 0.28,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAYSOFT:Object = {\n\t\t'saturation': 0.7,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFFA0C2E8,\n\t\t'haze': 0x22f3f1e8,\n\t\t'sunTint': 0xF7E9AA,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.0,\n\t\t'horizon': 0xFFA6C9ED,\n\t\t'ambient': 0x33F7E0C3,\n\t\t'timeOfDay': 0.45,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const EVENING:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.1,\n\t\t'sky': 0xFFFF7F51,\n\t\t'haze': 0x99FF9068,\n\t\t'sunTint': 0xFFFF7038,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.7,\n\t\t'horizon': 0xFFFFDF54,\n\t\t'ambient': 0x33DE5E37,\n\t\t'timeOfDay': 0.70,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAYMONOCHROME:Object = {\n\t\t'saturation': 0.25,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFF80A2C8,\n\t\t'haze': 0xFFf3f1e8,\n\t\t'sunTint': 0xF7E9AA,\n\t\t'fog': 1.0,\n\t\t'contrast': 0.4,\n\t\t'horizon': 0xFFA6C9ED,\n\t\t'ambient': 0x33F7E0C3,\n\t\t'timeOfDay': 0.45,\n\t\t'wind': 0.5,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAWNREDMOON:Object = {\n\t\t'saturation': 0.9,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFF16549F,\n\t\t'haze': 0xbb5C5D9E,\n\t\t'sunTint': 0xE76833,\n\t\t'fog': 0.1,\n\t\t'contrast': 0.0,\n\t\t'horizon': 0xFFFF9286,\n\t\t'ambient': 0x110E0B22,\n\t\t'timeOfDay': 0.2,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x880E0B62\n\t}\n\tpublic static const DUSKTAN:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.1,\n\t\t'sky': 0xFF52424C,\n\t\t'sunTint': 0xF9F8E6,\n\t\t'haze': 0x55C18F90,\n\t\t'fog': 0.0,\n\t\t'wind': 0.3,\n\t\t'horizon': 0xFFFFBA3B,\n\t\t'ambient': 0xFF886A00,\n\t\t'timeOfDay': 0.7,\n\t\t'contrast': 0.5,\n\t\t'darknessColor': 0x88330B33\n\t}\n\tpublic static const DUSKTEMP:Object = {\n\t\t'saturation': 0.0,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFF6a6d55,\n\t\t'haze': 0xFF999d7c,\n\t\t'sunTint': 0xffffff,\n\t\t'fog': 1.0,\n\t\t'contrast': -0.2,\n\t\t'horizon': 0xFF6a6d55,\n\t\t'ambient': 0xFFFF0000,\n\t\t'timeOfDay': 0.75,\n\t\t'wind': 0.2,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DUSKYELLOW:Object = {\n\t\t'saturation': 0.9,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFF8BB8E8,\n\t\t'haze': 0x88f3f1e8,\n\t\t'sunTint': 0xF4EED0,\n\t\t'fog': 0.0,\n\t\t'contrast': 0.8,\n\t\t'horizon': 0xFFEDC99A,\n\t\t'ambient': 0x44F79A42,\n\t\t'timeOfDay': 0.651,\n\t\t'wind': 0.1,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const NIGHTTEMP:Object = {\n\t\t'saturation': 0.0,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFF6a6d55,\n\t\t'haze': 0xFF999d7c,\n\t\t'sunTint': 0xffffff,\n\t\t'fog': 1.0,\n\t\t'contrast': -0.2,\n\t\t'horizon': 0xFF6a6d55,\n\t\t'ambient': 0xFFFF0000,\n\t\t'timeOfDay': 0.0,\n\t\t'wind': 0.2,\n\t\t'darknessColor': 0x88111114\n\t}\n\tpublic static const DAYDUSTY:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.0,\n\t\t'sky': 0xFF5d9df5,\n\t\t'sunTint': 0xF9F8E6,\n\t\t'haze': 0x99AAAAAA,\n\t\t'fog': 0.2,\n\t\t'wind': 0.2,\n\t\t'horizon': 0xFF94A9B6,\n\t\t'ambient': 0x55f5db04,\n\t\t'timeOfDay': 0.4,\n\t\t'contrast': 0.2,\n\t\t'darknessColor': 0x88222255\n\t}\n\tpublic static const DUSKRED:Object = {\n\t\t'saturation': 0.8,\n\t\t'darkness': 0.2,\n\t\t'sky': 0xFFd06219,\n\t\t'sunTint': 0xf27612,\n\t\t'haze': 0x99AAAAAA,\n\t\t'fog': 0.2,\n\t\t'wind': 0.2,\n\t\t'horizon': 0xFFf2d407,\n\t\t'ambient': 0x55f5db04,\n\t\t'timeOfDay': 0.651,\n\t\t'contrast': 0.1,\n\t\t'darknessColor': 0x88000000\n\t}\n}\n}"
  },
  {
    "path": "Workable.as",
    "content": "package\n{   \n    public interface Workable\n    {\n        function needsWork():Boolean;\n        \n        function work(citizen:Citizen=null):void;\n    }\n}"
  },
  {
    "path": "assets/levels/compiled/fields.oel",
    "content": "<?xml version=\"1.0\" ?><level backdropCloseImg=\"SkylineTreesImg\" backdropFarImg=\"SkylineHillsImg\" waterHeight=\"152\">\n  <width>3840</width>\n  <height>192</height>\n  <backdrop>\n    <Reed x=\"164\" y=\"128\"/>\n    <Reed x=\"196\" y=\"128\"/>\n    <Reed x=\"228\" y=\"128\"/>\n    <Reed x=\"324\" y=\"128\"/>\n    <Reed x=\"356\" y=\"128\"/>\n    <Reed x=\"388\" y=\"128\"/>\n    <Reed x=\"420\" y=\"128\"/>\n    <Reed x=\"528\" y=\"112\"/>\n    <Reed x=\"560\" y=\"112\"/>\n    <Reed x=\"592\" y=\"112\"/>\n    <Reed x=\"656\" y=\"112\"/>\n    <Reed x=\"688\" y=\"112\"/>\n    <Reed x=\"832\" y=\"112\"/>\n    <Reed x=\"864\" y=\"112\"/>\n    <Reed x=\"896\" y=\"112\"/>\n    <Reed x=\"1880\" y=\"124\"/>\n    <Reed x=\"1912\" y=\"124\"/>\n    <Reed x=\"1944\" y=\"124\"/>\n    <Reed x=\"1624\" y=\"124\"/>\n    <Reed x=\"2008\" y=\"124\"/>\n    <Reed x=\"2040\" y=\"124\"/>\n    <Reed x=\"1136\" y=\"112\"/>\n    <Reed x=\"1208\" y=\"112\"/>\n    <Reed x=\"260\" y=\"128\"/>\n    <Reed x=\"292\" y=\"128\"/>\n    <Reed x=\"1976\" y=\"124\"/>\n    <Reed x=\"2072\" y=\"124\"/>\n    <Hill x=\"800\" y=\"128\"/>\n    <Hill x=\"608\" y=\"128\"/>\n    <Hill x=\"508\" y=\"128\"/>\n    <Reed x=\"1168\" y=\"112\"/>\n    <Hill x=\"1104\" y=\"128\"/>\n    <Reed x=\"132\" y=\"128\"/>\n    <Reed x=\"100\" y=\"128\"/>\n    <Reed x=\"68\" y=\"128\"/>\n    <Reed x=\"36\" y=\"128\"/>\n    <Reed x=\"4\" y=\"128\"/>\n    <Reed x=\"1656\" y=\"124\"/>\n    <Reed x=\"1688\" y=\"124\"/>\n    <Reed x=\"1720\" y=\"124\"/>\n    <Reed x=\"1784\" y=\"124\"/>\n    <Reed x=\"1816\" y=\"124\"/>\n    <Reed x=\"1752\" y=\"124\"/>\n    <Reed x=\"1848\" y=\"124\"/>\n  </backdrop>\n  <ground set=\"tiles\" tileHeight=\"32\" tileWidth=\"32\">0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,10,18,1,5,4,3,4,5,2,4,3,4,5,6,14,16,15,15,16,15,17,9,10,8,10,9,8,8,10,9,10,10,9,8,9,11,12,13,14,15,17,10,8,9,10,9,8,10,10,9,11,15,12,16,15,12,12,15,12,15,12,16,15,17,10,10,9,10,8,9,8,9,9,11,12,13,14,16,17,9,10,9,9,10,9,10,8,9,10,9,8,10,10,11,15,16,15,12,15,13,1,3,4,2,6,4,5,2,3,4,5,6,7,8,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n</ground>\n  <objects>\n    <Castle x=\"1852\" y=\"36\"/>\n    <Shop x=\"1720\" y=\"68\"/>\n    <Shop x=\"2044\" y=\"68\"/>\n  </objects>\n  <farmlands>\n    <Farmland x=\"1488\" y=\"104\"/>\n    <Farmland x=\"2152\" y=\"104\"/>\n    <Farmland x=\"1064\" y=\"104\"/>\n    <Farmland x=\"1152\" y=\"104\"/>\n    <Farmland x=\"2300\" y=\"104\"/>\n    <Farmland x=\"2604\" y=\"104\"/>\n    <Farmland x=\"1584\" y=\"104\"/>\n    <Farmland x=\"2368\" y=\"104\"/>\n  </farmlands>\n  <walls>\n    <Wall x=\"1436\" y=\"80\"/>\n    <Wall x=\"2232\" y=\"80\"/>\n    <Wall x=\"2688\" y=\"80\"/>\n    <Wall x=\"996\" y=\"80\"/>\n    <Wall x=\"1812\" y=\"80\"/>\n    <Wall x=\"1996\" y=\"80\"/>\n  </walls>\n  <props>\n    <Treeline x=\"3744\" y=\"0\"/>\n    <Treeline x=\"0\" y=\"0\"/>\n  </props>\n  <lights>\n    <Torch x=\"1292\" y=\"100\"/>\n    <Torch x=\"1468\" y=\"100\"/>\n    <Torch x=\"1656\" y=\"100\"/>\n    <Torch x=\"2136\" y=\"100\"/>\n    <Torch x=\"2280\" y=\"100\"/>\n    <Torch x=\"2436\" y=\"100\"/>\n    <Torch x=\"1132\" y=\"100\"/>\n    <Torch x=\"1040\" y=\"100\"/>\n    <Firefly x=\"348\" y=\"144\"/>\n    <Firefly x=\"412\" y=\"136\"/>\n    <Firefly x=\"292\" y=\"116\"/>\n    <Firefly x=\"444\" y=\"124\"/>\n    <Firefly x=\"624\" y=\"112\"/>\n    <Firefly x=\"692\" y=\"112\"/>\n    <Firefly x=\"640\" y=\"120\"/>\n    <Firefly x=\"568\" y=\"120\"/>\n    <Firefly x=\"1232\" y=\"120\"/>\n    <Firefly x=\"1200\" y=\"112\"/>\n    <Firefly x=\"1268\" y=\"136\"/>\n    <Firefly x=\"1140\" y=\"136\"/>\n    <Firefly x=\"2576\" y=\"140\"/>\n    <Firefly x=\"2624\" y=\"120\"/>\n    <Firefly x=\"2680\" y=\"136\"/>\n    <Firefly x=\"3176\" y=\"136\"/>\n    <Firefly x=\"3132\" y=\"128\"/>\n    <Firefly x=\"3588\" y=\"120\"/>\n    <Firefly x=\"3524\" y=\"140\"/>\n    <Firefly x=\"3452\" y=\"120\"/>\n    <Firefly x=\"3392\" y=\"136\"/>\n    <Firefly x=\"3632\" y=\"144\"/>\n    <Torch x=\"1564\" y=\"100\"/>\n    <Torch x=\"2216\" y=\"100\"/>\n    <Torch x=\"2596\" y=\"100\"/>\n    <Torch x=\"2672\" y=\"100\"/>\n  </lights>\n</level>"
  },
  {
    "path": "assets/levels/compiled/fields_alt.oel",
    "content": "<?xml version=\"1.0\" ?><level backdropCloseImg=\"SkylineTreesImg\" backdropFarImg=\"SkylineHillsImg\" waterHeight=\"152\">\n  <width>3840</width>\n  <height>192</height>\n  <backdrop>\n    <Reed x=\"164\" y=\"128\"/>\n    <Reed x=\"196\" y=\"128\"/>\n    <Reed x=\"228\" y=\"128\"/>\n    <Reed x=\"324\" y=\"128\"/>\n    <Reed x=\"356\" y=\"128\"/>\n    <Reed x=\"388\" y=\"128\"/>\n    <Reed x=\"420\" y=\"128\"/>\n    <Reed x=\"528\" y=\"112\"/>\n    <Reed x=\"560\" y=\"112\"/>\n    <Reed x=\"592\" y=\"112\"/>\n    <Reed x=\"656\" y=\"112\"/>\n    <Reed x=\"688\" y=\"112\"/>\n    <Reed x=\"832\" y=\"112\"/>\n    <Reed x=\"864\" y=\"112\"/>\n    <Reed x=\"896\" y=\"112\"/>\n    <Reed x=\"1880\" y=\"124\"/>\n    <Reed x=\"1912\" y=\"124\"/>\n    <Reed x=\"1944\" y=\"124\"/>\n    <Reed x=\"1624\" y=\"124\"/>\n    <Reed x=\"2008\" y=\"124\"/>\n    <Reed x=\"2040\" y=\"124\"/>\n    <Reed x=\"1136\" y=\"112\"/>\n    <Reed x=\"1208\" y=\"112\"/>\n    <Reed x=\"260\" y=\"128\"/>\n    <Reed x=\"292\" y=\"128\"/>\n    <Reed x=\"1976\" y=\"124\"/>\n    <Reed x=\"2072\" y=\"124\"/>\n    <Hill x=\"800\" y=\"128\"/>\n    <Hill x=\"608\" y=\"128\"/>\n    <Hill x=\"508\" y=\"128\"/>\n    <Reed x=\"1168\" y=\"112\"/>\n    <Hill x=\"1104\" y=\"128\"/>\n    <Reed x=\"132\" y=\"128\"/>\n    <Reed x=\"100\" y=\"128\"/>\n    <Reed x=\"68\" y=\"128\"/>\n    <Reed x=\"36\" y=\"128\"/>\n    <Reed x=\"4\" y=\"128\"/>\n    <Reed x=\"1656\" y=\"124\"/>\n    <Reed x=\"1688\" y=\"124\"/>\n    <Reed x=\"1720\" y=\"124\"/>\n    <Reed x=\"1784\" y=\"124\"/>\n    <Reed x=\"1816\" y=\"124\"/>\n    <Reed x=\"1752\" y=\"124\"/>\n    <Reed x=\"1848\" y=\"124\"/>\n  </backdrop>\n  <ground set=\"tiles\" tileHeight=\"32\" tileWidth=\"32\">0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,10,18,1,5,4,3,4,5,2,4,3,4,5,6,14,16,15,15,16,15,17,9,10,8,10,9,8,8,10,9,10,10,9,8,9,11,12,13,14,15,17,10,8,9,10,9,8,10,10,9,9,8,11,16,15,12,12,15,12,15,12,16,15,17,10,10,9,10,8,9,8,9,9,11,12,13,14,16,17,9,10,9,9,10,9,10,8,9,10,9,8,10,10,11,15,16,15,12,15,13,1,3,4,2,6,4,5,2,3,4,5,6,7,8,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n</ground>\n  <objects>\n    <Castle x=\"1852\" y=\"36\"/>\n    <Shop x=\"1768\" y=\"68\"/>\n    <Shop x=\"2044\" y=\"68\"/>\n  </objects>\n  <farmlands>\n    <Farmland x=\"1508\" y=\"104\"/>\n    <Farmland x=\"2260\" y=\"104\"/>\n    <Farmland x=\"936\" y=\"104\"/>\n    <Farmland x=\"1032\" y=\"104\"/>\n    <Farmland x=\"2712\" y=\"104\"/>\n    <Farmland x=\"2812\" y=\"104\"/>\n    <Torch x=\"2788\" y=\"100\"/>\n    <Torch x=\"3016\" y=\"100\"/>\n    <Farmland x=\"1700\" y=\"104\"/>\n  </farmlands>\n  <walls>\n    <Wall x=\"1420\" y=\"80\"/>\n    <Wall x=\"2388\" y=\"80\"/>\n    <Wall x=\"3044\" y=\"80\"/>\n    <Wall x=\"740\" y=\"80\"/>\n    <Wall x=\"1660\" y=\"80\"/>\n    <Wall x=\"1988\" y=\"80\"/>\n  </walls>\n  <props>\n    <Treeline x=\"3744\" y=\"0\"/>\n    <Treeline x=\"0\" y=\"0\"/>\n  </props>\n  <lights>\n    <Torch x=\"1292\" y=\"100\"/>\n    <Torch x=\"1472\" y=\"100\"/>\n    <Torch x=\"1636\" y=\"100\"/>\n    <Torch x=\"2136\" y=\"100\"/>\n    <Torch x=\"2352\" y=\"100\"/>\n    <Torch x=\"2548\" y=\"100\"/>\n    <Torch x=\"1008\" y=\"100\"/>\n    <Torch x=\"776\" y=\"100\"/>\n    <Firefly x=\"348\" y=\"144\"/>\n    <Firefly x=\"412\" y=\"136\"/>\n    <Firefly x=\"292\" y=\"116\"/>\n    <Firefly x=\"444\" y=\"124\"/>\n    <Firefly x=\"624\" y=\"112\"/>\n    <Firefly x=\"692\" y=\"112\"/>\n    <Firefly x=\"640\" y=\"120\"/>\n    <Firefly x=\"568\" y=\"120\"/>\n    <Firefly x=\"1232\" y=\"120\"/>\n    <Firefly x=\"1200\" y=\"112\"/>\n    <Firefly x=\"1268\" y=\"136\"/>\n    <Firefly x=\"1140\" y=\"136\"/>\n    <Firefly x=\"2572\" y=\"140\"/>\n    <Firefly x=\"2620\" y=\"120\"/>\n    <Firefly x=\"2676\" y=\"136\"/>\n    <Firefly x=\"3176\" y=\"136\"/>\n    <Firefly x=\"3132\" y=\"128\"/>\n    <Firefly x=\"3588\" y=\"120\"/>\n    <Firefly x=\"3524\" y=\"140\"/>\n    <Firefly x=\"3452\" y=\"120\"/>\n    <Firefly x=\"3392\" y=\"136\"/>\n    <Firefly x=\"3632\" y=\"144\"/>\n  </lights>\n</level>"
  },
  {
    "path": "assets/levels/compiled/fields_loose.oel",
    "content": "<?xml version=\"1.0\" ?><level backdropCloseImg=\"SkylineTreesImg\" backdropFarImg=\"SkylineHillsImg\" waterHeight=\"152\">\n  <width>3840</width>\n  <height>192</height>\n  <backdrop>\n    <Reed x=\"164\" y=\"128\"/>\n    <Reed x=\"196\" y=\"128\"/>\n    <Reed x=\"228\" y=\"128\"/>\n    <Reed x=\"324\" y=\"128\"/>\n    <Reed x=\"356\" y=\"128\"/>\n    <Reed x=\"388\" y=\"128\"/>\n    <Reed x=\"420\" y=\"128\"/>\n    <Reed x=\"528\" y=\"112\"/>\n    <Reed x=\"560\" y=\"112\"/>\n    <Reed x=\"592\" y=\"112\"/>\n    <Reed x=\"656\" y=\"112\"/>\n    <Reed x=\"688\" y=\"112\"/>\n    <Reed x=\"832\" y=\"112\"/>\n    <Reed x=\"864\" y=\"112\"/>\n    <Reed x=\"896\" y=\"112\"/>\n    <Reed x=\"1880\" y=\"124\"/>\n    <Reed x=\"1912\" y=\"124\"/>\n    <Reed x=\"1944\" y=\"124\"/>\n    <Reed x=\"1624\" y=\"124\"/>\n    <Reed x=\"2008\" y=\"124\"/>\n    <Reed x=\"2040\" y=\"124\"/>\n    <Reed x=\"1136\" y=\"112\"/>\n    <Reed x=\"1208\" y=\"112\"/>\n    <Reed x=\"260\" y=\"128\"/>\n    <Reed x=\"292\" y=\"128\"/>\n    <Reed x=\"1976\" y=\"124\"/>\n    <Reed x=\"2072\" y=\"124\"/>\n    <Hill x=\"800\" y=\"128\"/>\n    <Hill x=\"608\" y=\"128\"/>\n    <Hill x=\"508\" y=\"128\"/>\n    <Reed x=\"1168\" y=\"112\"/>\n    <Hill x=\"1104\" y=\"128\"/>\n    <Reed x=\"132\" y=\"128\"/>\n    <Reed x=\"100\" y=\"128\"/>\n    <Reed x=\"68\" y=\"128\"/>\n    <Reed x=\"36\" y=\"128\"/>\n    <Reed x=\"4\" y=\"128\"/>\n    <Reed x=\"1656\" y=\"124\"/>\n    <Reed x=\"1688\" y=\"124\"/>\n    <Reed x=\"1720\" y=\"124\"/>\n    <Reed x=\"1784\" y=\"124\"/>\n    <Reed x=\"1816\" y=\"124\"/>\n    <Reed x=\"1752\" y=\"124\"/>\n    <Reed x=\"1848\" y=\"124\"/>\n  </backdrop>\n  <ground set=\"tiles\" tileHeight=\"32\" tileWidth=\"32\">0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,10,18,1,5,4,3,4,5,2,4,3,4,5,6,14,16,15,15,16,15,17,9,10,8,10,9,8,8,10,9,10,10,9,8,9,11,12,13,14,15,17,10,8,9,10,9,8,10,10,9,11,15,12,16,15,12,12,15,12,15,12,16,15,17,10,10,9,10,8,9,8,9,9,11,12,13,14,16,17,9,10,9,9,10,9,10,8,9,10,9,8,10,10,11,15,16,15,12,15,13,1,3,4,2,6,4,5,2,3,4,5,6,7,8,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n</ground>\n  <objects>\n    <Castle x=\"1852\" y=\"36\"/>\n    <Shop x=\"1720\" y=\"68\"/>\n    <Shop x=\"2044\" y=\"68\"/>\n  </objects>\n  <farmlands>\n    <Farmland x=\"1464\" y=\"104\"/>\n    <Farmland x=\"2156\" y=\"104\"/>\n    <Farmland x=\"936\" y=\"104\"/>\n    <Farmland x=\"1032\" y=\"104\"/>\n    <Farmland x=\"2712\" y=\"104\"/>\n    <Farmland x=\"2812\" y=\"104\"/>\n    <Torch x=\"2788\" y=\"100\"/>\n    <Torch x=\"3016\" y=\"100\"/>\n    <Farmland x=\"1552\" y=\"104\"/>\n  </farmlands>\n  <walls>\n    <Wall x=\"1404\" y=\"80\"/>\n    <Wall x=\"2232\" y=\"80\"/>\n    <Wall x=\"3044\" y=\"80\"/>\n    <Wall x=\"740\" y=\"80\"/>\n    <Wall x=\"1812\" y=\"80\"/>\n    <Wall x=\"1988\" y=\"80\"/>\n  </walls>\n  <props>\n    <Treeline x=\"3744\" y=\"0\"/>\n    <Treeline x=\"0\" y=\"0\"/>\n  </props>\n  <lights>\n    <Torch x=\"1292\" y=\"100\"/>\n    <Torch x=\"1440\" y=\"100\"/>\n    <Torch x=\"1636\" y=\"100\"/>\n    <Torch x=\"2136\" y=\"100\"/>\n    <Torch x=\"2352\" y=\"100\"/>\n    <Torch x=\"2548\" y=\"100\"/>\n    <Torch x=\"1008\" y=\"100\"/>\n    <Torch x=\"776\" y=\"100\"/>\n    <Firefly x=\"348\" y=\"144\"/>\n    <Firefly x=\"412\" y=\"136\"/>\n    <Firefly x=\"292\" y=\"116\"/>\n    <Firefly x=\"444\" y=\"124\"/>\n    <Firefly x=\"624\" y=\"112\"/>\n    <Firefly x=\"692\" y=\"112\"/>\n    <Firefly x=\"640\" y=\"120\"/>\n    <Firefly x=\"568\" y=\"120\"/>\n    <Firefly x=\"1232\" y=\"120\"/>\n    <Firefly x=\"1200\" y=\"112\"/>\n    <Firefly x=\"1268\" y=\"136\"/>\n    <Firefly x=\"1140\" y=\"136\"/>\n    <Firefly x=\"2572\" y=\"140\"/>\n    <Firefly x=\"2620\" y=\"120\"/>\n    <Firefly x=\"2676\" y=\"136\"/>\n    <Firefly x=\"3176\" y=\"136\"/>\n    <Firefly x=\"3132\" y=\"128\"/>\n    <Firefly x=\"3588\" y=\"120\"/>\n    <Firefly x=\"3524\" y=\"140\"/>\n    <Firefly x=\"3452\" y=\"120\"/>\n    <Firefly x=\"3392\" y=\"136\"/>\n    <Firefly x=\"3632\" y=\"144\"/>\n  </lights>\n</level>"
  },
  {
    "path": "assets/levels/compiled/fields_old.oel",
    "content": "<?xml version=\"1.0\" ?><level backdropCloseImg=\"SkylineTreesImg\" backdropFarImg=\"SkylineHillsImg\" waterHeight=\"152\">\n  <width>3840</width>\n  <height>192</height>\n  <backdrop>\n    <Reed x=\"164\" y=\"128\"/>\n    <Reed x=\"196\" y=\"128\"/>\n    <Reed x=\"228\" y=\"128\"/>\n    <Reed x=\"324\" y=\"128\"/>\n    <Reed x=\"356\" y=\"128\"/>\n    <Reed x=\"388\" y=\"128\"/>\n    <Reed x=\"420\" y=\"128\"/>\n    <Reed x=\"528\" y=\"112\"/>\n    <Reed x=\"560\" y=\"112\"/>\n    <Reed x=\"592\" y=\"112\"/>\n    <Reed x=\"656\" y=\"112\"/>\n    <Reed x=\"688\" y=\"112\"/>\n    <Reed x=\"832\" y=\"112\"/>\n    <Reed x=\"864\" y=\"112\"/>\n    <Reed x=\"896\" y=\"112\"/>\n    <Reed x=\"1880\" y=\"124\"/>\n    <Reed x=\"1912\" y=\"124\"/>\n    <Reed x=\"1944\" y=\"124\"/>\n    <Reed x=\"1624\" y=\"124\"/>\n    <Reed x=\"2008\" y=\"124\"/>\n    <Reed x=\"2040\" y=\"124\"/>\n    <Reed x=\"1136\" y=\"112\"/>\n    <Reed x=\"1208\" y=\"112\"/>\n    <Reed x=\"260\" y=\"128\"/>\n    <Reed x=\"292\" y=\"128\"/>\n    <Reed x=\"1976\" y=\"124\"/>\n    <Reed x=\"2072\" y=\"124\"/>\n    <Hill x=\"800\" y=\"128\"/>\n    <Hill x=\"608\" y=\"128\"/>\n    <Hill x=\"508\" y=\"128\"/>\n    <Reed x=\"1168\" y=\"112\"/>\n    <Hill x=\"1104\" y=\"128\"/>\n    <Reed x=\"132\" y=\"128\"/>\n    <Reed x=\"100\" y=\"128\"/>\n    <Reed x=\"68\" y=\"128\"/>\n    <Reed x=\"36\" y=\"128\"/>\n    <Reed x=\"4\" y=\"128\"/>\n    <Reed x=\"1656\" y=\"124\"/>\n    <Reed x=\"1688\" y=\"124\"/>\n    <Reed x=\"1720\" y=\"124\"/>\n    <Reed x=\"1784\" y=\"124\"/>\n    <Reed x=\"1816\" y=\"124\"/>\n    <Reed x=\"1752\" y=\"124\"/>\n    <Reed x=\"1848\" y=\"124\"/>\n  </backdrop>\n  <ground set=\"tiles\" tileHeight=\"32\" tileWidth=\"32\">0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,10,18,1,5,4,3,4,5,2,4,3,4,5,6,14,16,15,15,16,15,17,9,10,8,10,9,8,8,10,9,10,10,9,8,9,11,12,13,14,15,17,10,8,9,10,9,8,10,10,9,11,15,12,16,15,12,12,15,12,15,12,16,15,17,10,10,9,10,8,9,8,9,9,11,12,13,14,16,17,9,10,9,9,10,9,10,8,9,10,9,8,10,10,11,15,16,15,12,15,13,1,3,4,2,6,4,5,2,3,4,5,6,7,8,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n</ground>\n  <objects>\n    <Castle x=\"1852\" y=\"36\"/>\n    <Shop x=\"1720\" y=\"68\"/>\n    <Shop x=\"2044\" y=\"68\"/>\n  </objects>\n  <farmlands>\n    <Farmland x=\"1508\" y=\"104\"/>\n    <Farmland x=\"2260\" y=\"104\"/>\n    <Farmland x=\"936\" y=\"104\"/>\n    <Farmland x=\"1032\" y=\"104\"/>\n    <Farmland x=\"2712\" y=\"104\"/>\n    <Farmland x=\"2812\" y=\"104\"/>\n    <Torch x=\"2788\" y=\"100\"/>\n    <Torch x=\"3016\" y=\"100\"/>\n  </farmlands>\n  <walls>\n    <Wall x=\"1420\" y=\"80\"/>\n    <Wall x=\"2388\" y=\"80\"/>\n    <Wall x=\"3044\" y=\"80\"/>\n    <Wall x=\"740\" y=\"80\"/>\n    <Wall x=\"1812\" y=\"80\"/>\n    <Wall x=\"1988\" y=\"80\"/>\n  </walls>\n  <props>\n    <Treeline x=\"3744\" y=\"0\"/>\n    <Treeline x=\"0\" y=\"0\"/>\n  </props>\n  <lights>\n    <Torch x=\"1292\" y=\"100\"/>\n    <Torch x=\"1472\" y=\"100\"/>\n    <Torch x=\"1636\" y=\"100\"/>\n    <Torch x=\"2136\" y=\"100\"/>\n    <Torch x=\"2352\" y=\"100\"/>\n    <Torch x=\"2548\" y=\"100\"/>\n    <Torch x=\"1008\" y=\"100\"/>\n    <Torch x=\"776\" y=\"100\"/>\n    <Firefly x=\"348\" y=\"144\"/>\n    <Firefly x=\"412\" y=\"136\"/>\n    <Firefly x=\"292\" y=\"116\"/>\n    <Firefly x=\"444\" y=\"124\"/>\n    <Firefly x=\"624\" y=\"112\"/>\n    <Firefly x=\"692\" y=\"112\"/>\n    <Firefly x=\"640\" y=\"120\"/>\n    <Firefly x=\"568\" y=\"120\"/>\n    <Firefly x=\"1232\" y=\"120\"/>\n    <Firefly x=\"1200\" y=\"112\"/>\n    <Firefly x=\"1268\" y=\"136\"/>\n    <Firefly x=\"1140\" y=\"136\"/>\n    <Firefly x=\"2572\" y=\"140\"/>\n    <Firefly x=\"2620\" y=\"120\"/>\n    <Firefly x=\"2676\" y=\"136\"/>\n    <Firefly x=\"3176\" y=\"136\"/>\n    <Firefly x=\"3132\" y=\"128\"/>\n    <Firefly x=\"3588\" y=\"120\"/>\n    <Firefly x=\"3524\" y=\"140\"/>\n    <Firefly x=\"3452\" y=\"120\"/>\n    <Firefly x=\"3392\" y=\"136\"/>\n    <Firefly x=\"3632\" y=\"144\"/>\n  </lights>\n</level>"
  },
  {
    "path": "assets/levels/fields.oel",
    "content": "<level backdropFarImg=\"SkylineHillsImg\" backdropCloseImg=\"SkylineTreesImg\" waterHeight=\"152\">\n  <width>3840</width>\n  <height>192</height>\n  <backdrop>\n    <Reed x=\"164\" y=\"128\"/>\n    <Reed x=\"196\" y=\"128\"/>\n    <Reed x=\"228\" y=\"128\"/>\n    <Reed x=\"324\" y=\"128\"/>\n    <Reed x=\"356\" y=\"128\"/>\n    <Reed x=\"388\" y=\"128\"/>\n    <Reed x=\"420\" y=\"128\"/>\n    <Reed x=\"528\" y=\"112\"/>\n    <Reed x=\"560\" y=\"112\"/>\n    <Reed x=\"592\" y=\"112\"/>\n    <Reed x=\"656\" y=\"112\"/>\n    <Reed x=\"688\" y=\"112\"/>\n    <Reed x=\"832\" y=\"112\"/>\n    <Reed x=\"864\" y=\"112\"/>\n    <Reed x=\"896\" y=\"112\"/>\n    <Reed x=\"1880\" y=\"124\"/>\n    <Reed x=\"1912\" y=\"124\"/>\n    <Reed x=\"1944\" y=\"124\"/>\n    <Reed x=\"1624\" y=\"124\"/>\n    <Reed x=\"2008\" y=\"124\"/>\n    <Reed x=\"2040\" y=\"124\"/>\n    <Reed x=\"1136\" y=\"112\"/>\n    <Reed x=\"1208\" y=\"112\"/>\n    <Reed x=\"260\" y=\"128\"/>\n    <Reed x=\"292\" y=\"128\"/>\n    <Reed x=\"1976\" y=\"124\"/>\n    <Reed x=\"2072\" y=\"124\"/>\n    <Hill x=\"800\" y=\"128\"/>\n    <Hill x=\"608\" y=\"128\"/>\n    <Hill x=\"508\" y=\"128\"/>\n    <Reed x=\"1168\" y=\"112\"/>\n    <Hill x=\"1104\" y=\"128\"/>\n    <Reed x=\"132\" y=\"128\"/>\n    <Reed x=\"100\" y=\"128\"/>\n    <Reed x=\"68\" y=\"128\"/>\n    <Reed x=\"36\" y=\"128\"/>\n    <Reed x=\"4\" y=\"128\"/>\n    <Reed x=\"1656\" y=\"124\"/>\n    <Reed x=\"1688\" y=\"124\"/>\n    <Reed x=\"1720\" y=\"124\"/>\n    <Reed x=\"1784\" y=\"124\"/>\n    <Reed x=\"1816\" y=\"124\"/>\n    <Reed x=\"1752\" y=\"124\"/>\n    <Reed x=\"1848\" y=\"124\"/>\n  </backdrop>\n  <ground set=\"tiles\" tileWidth=\"32\" tileHeight=\"32\">\n    <tile id=\"5\" x=\"192\" y=\"128\"/>\n    <tile id=\"8\" x=\"960\" y=\"128\"/>\n    <tile id=\"10\" x=\"992\" y=\"128\"/>\n    <tile id=\"9\" x=\"1024\" y=\"128\"/>\n    <tile id=\"10\" x=\"1056\" y=\"128\"/>\n    <tile id=\"9\" x=\"1184\" y=\"128\"/>\n    <tile id=\"8\" x=\"1152\" y=\"128\"/>\n    <tile id=\"9\" x=\"1120\" y=\"128\"/>\n    <tile id=\"10\" x=\"1088\" y=\"128\"/>\n    <tile id=\"10\" x=\"2176\" y=\"128\"/>\n    <tile id=\"9\" x=\"2208\" y=\"128\"/>\n    <tile id=\"10\" x=\"2240\" y=\"128\"/>\n    <tile id=\"8\" x=\"2272\" y=\"128\"/>\n    <tile id=\"9\" x=\"2304\" y=\"128\"/>\n    <tile id=\"8\" x=\"2336\" y=\"128\"/>\n    <tile id=\"9\" x=\"2368\" y=\"128\"/>\n    <tile id=\"9\" x=\"2400\" y=\"128\"/>\n    <tile id=\"9\" x=\"896\" y=\"128\"/>\n    <tile id=\"8\" x=\"928\" y=\"128\"/>\n    <tile id=\"10\" x=\"864\" y=\"128\"/>\n    <tile id=\"8\" x=\"832\" y=\"128\"/>\n    <tile id=\"10\" x=\"800\" y=\"128\"/>\n    <tile id=\"9\" x=\"768\" y=\"128\"/>\n    <tile id=\"16\" x=\"672\" y=\"128\"/>\n    <tile id=\"15\" x=\"640\" y=\"128\"/>\n    <tile id=\"15\" x=\"608\" y=\"128\"/>\n    <tile id=\"16\" x=\"576\" y=\"128\"/>\n    <tile id=\"14\" x=\"544\" y=\"128\"/>\n    <tile id=\"6\" x=\"512\" y=\"128\"/>\n    <tile id=\"5\" x=\"480\" y=\"128\"/>\n    <tile id=\"3\" x=\"416\" y=\"128\"/>\n    <tile id=\"4\" x=\"448\" y=\"128\"/>\n    <tile id=\"18\" x=\"128\" y=\"128\"/>\n    <tile id=\"10\" x=\"96\" y=\"128\"/>\n    <tile id=\"5\" x=\"320\" y=\"128\"/>\n    <tile id=\"1\" x=\"160\" y=\"128\"/>\n    <tile id=\"4\" x=\"288\" y=\"128\"/>\n    <tile id=\"3\" x=\"256\" y=\"128\"/>\n    <tile id=\"11\" x=\"2432\" y=\"128\"/>\n    <tile id=\"0\" x=\"2848\" y=\"160\"/>\n    <tile id=\"4\" x=\"224\" y=\"128\"/>\n    <tile id=\"2\" x=\"352\" y=\"128\"/>\n    <tile id=\"4\" x=\"384\" y=\"128\"/>\n    <tile id=\"8\" x=\"3712\" y=\"128\"/>\n    <tile id=\"7\" x=\"3680\" y=\"128\"/>\n    <tile id=\"6\" x=\"3648\" y=\"128\"/>\n    <tile id=\"5\" x=\"3616\" y=\"128\"/>\n    <tile id=\"4\" x=\"3584\" y=\"128\"/>\n    <tile id=\"3\" x=\"3552\" y=\"128\"/>\n    <tile id=\"2\" x=\"3520\" y=\"128\"/>\n    <tile id=\"5\" x=\"3488\" y=\"128\"/>\n    <tile id=\"4\" x=\"3456\" y=\"128\"/>\n    <tile id=\"6\" x=\"3424\" y=\"128\"/>\n    <tile id=\"2\" x=\"3392\" y=\"128\"/>\n    <tile id=\"4\" x=\"3360\" y=\"128\"/>\n    <tile id=\"15\" x=\"3232\" y=\"128\"/>\n    <tile id=\"12\" x=\"3200\" y=\"128\"/>\n    <tile id=\"15\" x=\"3168\" y=\"128\"/>\n    <tile id=\"16\" x=\"3136\" y=\"128\"/>\n    <tile id=\"1\" x=\"3296\" y=\"128\"/>\n    <tile id=\"0\" x=\"3296\" y=\"160\"/>\n    <tile id=\"3\" x=\"3328\" y=\"128\"/>\n    <tile id=\"13\" x=\"3264\" y=\"128\"/>\n    <tile id=\"17\" x=\"736\" y=\"128\"/>\n    <tile id=\"15\" x=\"704\" y=\"128\"/>\n    <tile id=\"11\" x=\"3072\" y=\"128\"/>\n    <tile id=\"15\" x=\"3104\" y=\"128\"/>\n    <tile id=\"10\" x=\"3008\" y=\"128\"/>\n    <tile id=\"10\" x=\"3040\" y=\"128\"/>\n    <tile id=\"0\" x=\"3008\" y=\"160\"/>\n    <tile id=\"8\" x=\"2976\" y=\"128\"/>\n    <tile id=\"9\" x=\"2944\" y=\"128\"/>\n    <tile id=\"10\" x=\"2912\" y=\"128\"/>\n    <tile id=\"9\" x=\"2880\" y=\"128\"/>\n    <tile id=\"8\" x=\"2848\" y=\"128\"/>\n    <tile id=\"10\" x=\"2816\" y=\"128\"/>\n    <tile id=\"9\" x=\"2784\" y=\"128\"/>\n    <tile id=\"10\" x=\"2752\" y=\"128\"/>\n    <tile id=\"9\" x=\"2720\" y=\"128\"/>\n    <tile id=\"9\" x=\"2688\" y=\"128\"/>\n    <tile id=\"10\" x=\"2656\" y=\"128\"/>\n    <tile id=\"9\" x=\"2624\" y=\"128\"/>\n    <tile id=\"17\" x=\"2592\" y=\"128\"/>\n    <tile id=\"16\" x=\"2560\" y=\"128\"/>\n    <tile id=\"14\" x=\"2528\" y=\"128\"/>\n    <tile id=\"13\" x=\"2496\" y=\"128\"/>\n    <tile id=\"12\" x=\"2464\" y=\"128\"/>\n    <tile id=\"11\" x=\"1216\" y=\"128\"/>\n    <tile id=\"12\" x=\"1248\" y=\"128\"/>\n    <tile id=\"13\" x=\"1280\" y=\"128\"/>\n    <tile id=\"14\" x=\"1312\" y=\"128\"/>\n    <tile id=\"15\" x=\"1344\" y=\"128\"/>\n    <tile id=\"17\" x=\"1376\" y=\"128\"/>\n    <tile id=\"10\" x=\"1408\" y=\"128\"/>\n    <tile id=\"8\" x=\"1440\" y=\"128\"/>\n    <tile id=\"9\" x=\"1472\" y=\"128\"/>\n    <tile id=\"10\" x=\"1504\" y=\"128\"/>\n    <tile id=\"9\" x=\"1536\" y=\"128\"/>\n    <tile id=\"10\" x=\"1600\" y=\"128\"/>\n    <tile id=\"8\" x=\"1568\" y=\"128\"/>\n    <tile id=\"12\" x=\"1888\" y=\"128\"/>\n    <tile id=\"15\" x=\"1920\" y=\"128\"/>\n    <tile id=\"15\" x=\"2080\" y=\"128\"/>\n    <tile id=\"16\" x=\"2048\" y=\"128\"/>\n    <tile id=\"12\" x=\"2016\" y=\"128\"/>\n    <tile id=\"15\" x=\"1984\" y=\"128\"/>\n    <tile id=\"12\" x=\"1952\" y=\"128\"/>\n    <tile id=\"12\" x=\"1856\" y=\"128\"/>\n    <tile id=\"15\" x=\"1824\" y=\"128\"/>\n    <tile id=\"16\" x=\"1792\" y=\"128\"/>\n    <tile id=\"12\" x=\"1760\" y=\"128\"/>\n    <tile id=\"15\" x=\"1728\" y=\"128\"/>\n    <tile id=\"10\" x=\"2144\" y=\"128\"/>\n    <tile id=\"17\" x=\"2112\" y=\"128\"/>\n    <tile id=\"11\" x=\"1696\" y=\"128\"/>\n    <tile id=\"9\" x=\"1664\" y=\"128\"/>\n    <tile id=\"10\" x=\"1632\" y=\"128\"/>\n    <tile id=\"0\" x=\"3744\" y=\"128\"/>\n    <tile id=\"0\" x=\"3776\" y=\"128\"/>\n    <tile id=\"0\" x=\"3808\" y=\"128\"/>\n    <tile id=\"0\" x=\"0\" y=\"128\"/>\n    <tile id=\"0\" x=\"32\" y=\"128\"/>\n    <tile id=\"0\" x=\"64\" y=\"128\"/>\n    <rect id=\"0\" x=\"2176\" y=\"64\" w=\"384\" h=\"32\"/>\n  </ground>\n  <objects>\n    <Castle x=\"1852\" y=\"36\"/>\n    <Shop x=\"1720\" y=\"68\"/>\n    <Shop x=\"2044\" y=\"68\"/>\n  </objects>\n  <farmlands>\n    <Farmland x=\"1488\" y=\"104\"/>\n    <Farmland x=\"2152\" y=\"104\"/>\n    <Farmland x=\"1064\" y=\"104\"/>\n    <Farmland x=\"1152\" y=\"104\"/>\n    <Farmland x=\"2300\" y=\"104\"/>\n    <Farmland x=\"2604\" y=\"104\"/>\n    <Farmland x=\"1584\" y=\"104\"/>\n    <Farmland x=\"2368\" y=\"104\"/>\n  </farmlands>\n  <walls>\n    <Wall x=\"1436\" y=\"80\"/>\n    <Wall x=\"2232\" y=\"80\"/>\n    <Wall x=\"2688\" y=\"80\"/>\n    <Wall x=\"996\" y=\"80\"/>\n    <Wall x=\"1812\" y=\"80\"/>\n    <Wall x=\"1996\" y=\"80\"/>\n  </walls>\n  <props>\n    <Treeline x=\"3744\" y=\"0\"/>\n    <Treeline x=\"0\" y=\"0\"/>\n  </props>\n  <lights>\n    <Torch x=\"1292\" y=\"100\"/>\n    <Torch x=\"1468\" y=\"100\"/>\n    <Torch x=\"1656\" y=\"100\"/>\n    <Torch x=\"2136\" y=\"100\"/>\n    <Torch x=\"2280\" y=\"100\"/>\n    <Torch x=\"2436\" y=\"100\"/>\n    <Torch x=\"1132\" y=\"100\"/>\n    <Torch x=\"1040\" y=\"100\"/>\n    <Firefly x=\"348\" y=\"144\"/>\n    <Firefly x=\"412\" y=\"136\"/>\n    <Firefly x=\"292\" y=\"116\"/>\n    <Firefly x=\"444\" y=\"124\"/>\n    <Firefly x=\"624\" y=\"112\"/>\n    <Firefly x=\"692\" y=\"112\"/>\n    <Firefly x=\"640\" y=\"120\"/>\n    <Firefly x=\"568\" y=\"120\"/>\n    <Firefly x=\"1232\" y=\"120\"/>\n    <Firefly x=\"1200\" y=\"112\"/>\n    <Firefly x=\"1268\" y=\"136\"/>\n    <Firefly x=\"1140\" y=\"136\"/>\n    <Firefly x=\"2576\" y=\"140\"/>\n    <Firefly x=\"2624\" y=\"120\"/>\n    <Firefly x=\"2680\" y=\"136\"/>\n    <Firefly x=\"3176\" y=\"136\"/>\n    <Firefly x=\"3132\" y=\"128\"/>\n    <Firefly x=\"3588\" y=\"120\"/>\n    <Firefly x=\"3524\" y=\"140\"/>\n    <Firefly x=\"3452\" y=\"120\"/>\n    <Firefly x=\"3392\" y=\"136\"/>\n    <Firefly x=\"3632\" y=\"144\"/>\n    <Torch x=\"1564\" y=\"100\"/>\n    <Torch x=\"2216\" y=\"100\"/>\n    <Torch x=\"2596\" y=\"100\"/>\n    <Torch x=\"2672\" y=\"100\"/>\n  </lights>\n</level>"
  },
  {
    "path": "assets/levels/fields_alt.oel",
    "content": "<level backdropFarImg=\"SkylineHillsImg\" backdropCloseImg=\"SkylineTreesImg\" waterHeight=\"152\">\n  <width>3840</width>\n  <height>192</height>\n  <backdrop>\n    <Reed x=\"164\" y=\"128\"/>\n    <Reed x=\"196\" y=\"128\"/>\n    <Reed x=\"228\" y=\"128\"/>\n    <Reed x=\"324\" y=\"128\"/>\n    <Reed x=\"356\" y=\"128\"/>\n    <Reed x=\"388\" y=\"128\"/>\n    <Reed x=\"420\" y=\"128\"/>\n    <Reed x=\"528\" y=\"112\"/>\n    <Reed x=\"560\" y=\"112\"/>\n    <Reed x=\"592\" y=\"112\"/>\n    <Reed x=\"656\" y=\"112\"/>\n    <Reed x=\"688\" y=\"112\"/>\n    <Reed x=\"832\" y=\"112\"/>\n    <Reed x=\"864\" y=\"112\"/>\n    <Reed x=\"896\" y=\"112\"/>\n    <Reed x=\"1880\" y=\"124\"/>\n    <Reed x=\"1912\" y=\"124\"/>\n    <Reed x=\"1944\" y=\"124\"/>\n    <Reed x=\"1624\" y=\"124\"/>\n    <Reed x=\"2008\" y=\"124\"/>\n    <Reed x=\"2040\" y=\"124\"/>\n    <Reed x=\"1136\" y=\"112\"/>\n    <Reed x=\"1208\" y=\"112\"/>\n    <Reed x=\"260\" y=\"128\"/>\n    <Reed x=\"292\" y=\"128\"/>\n    <Reed x=\"1976\" y=\"124\"/>\n    <Reed x=\"2072\" y=\"124\"/>\n    <Hill x=\"800\" y=\"128\"/>\n    <Hill x=\"608\" y=\"128\"/>\n    <Hill x=\"508\" y=\"128\"/>\n    <Reed x=\"1168\" y=\"112\"/>\n    <Hill x=\"1104\" y=\"128\"/>\n    <Reed x=\"132\" y=\"128\"/>\n    <Reed x=\"100\" y=\"128\"/>\n    <Reed x=\"68\" y=\"128\"/>\n    <Reed x=\"36\" y=\"128\"/>\n    <Reed x=\"4\" y=\"128\"/>\n    <Reed x=\"1656\" y=\"124\"/>\n    <Reed x=\"1688\" y=\"124\"/>\n    <Reed x=\"1720\" y=\"124\"/>\n    <Reed x=\"1784\" y=\"124\"/>\n    <Reed x=\"1816\" y=\"124\"/>\n    <Reed x=\"1752\" y=\"124\"/>\n    <Reed x=\"1848\" y=\"124\"/>\n  </backdrop>\n  <ground set=\"tiles\" tileWidth=\"32\" tileHeight=\"32\">\n    <tile id=\"5\" x=\"192\" y=\"128\"/>\n    <tile id=\"8\" x=\"960\" y=\"128\"/>\n    <tile id=\"10\" x=\"992\" y=\"128\"/>\n    <tile id=\"9\" x=\"1024\" y=\"128\"/>\n    <tile id=\"10\" x=\"1056\" y=\"128\"/>\n    <tile id=\"9\" x=\"1184\" y=\"128\"/>\n    <tile id=\"8\" x=\"1152\" y=\"128\"/>\n    <tile id=\"9\" x=\"1120\" y=\"128\"/>\n    <tile id=\"10\" x=\"1088\" y=\"128\"/>\n    <tile id=\"10\" x=\"2176\" y=\"128\"/>\n    <tile id=\"9\" x=\"2208\" y=\"128\"/>\n    <tile id=\"10\" x=\"2240\" y=\"128\"/>\n    <tile id=\"8\" x=\"2272\" y=\"128\"/>\n    <tile id=\"9\" x=\"2304\" y=\"128\"/>\n    <tile id=\"8\" x=\"2336\" y=\"128\"/>\n    <tile id=\"9\" x=\"2368\" y=\"128\"/>\n    <tile id=\"9\" x=\"2400\" y=\"128\"/>\n    <tile id=\"9\" x=\"896\" y=\"128\"/>\n    <tile id=\"8\" x=\"928\" y=\"128\"/>\n    <tile id=\"10\" x=\"864\" y=\"128\"/>\n    <tile id=\"8\" x=\"832\" y=\"128\"/>\n    <tile id=\"10\" x=\"800\" y=\"128\"/>\n    <tile id=\"9\" x=\"768\" y=\"128\"/>\n    <tile id=\"16\" x=\"672\" y=\"128\"/>\n    <tile id=\"15\" x=\"640\" y=\"128\"/>\n    <tile id=\"15\" x=\"608\" y=\"128\"/>\n    <tile id=\"16\" x=\"576\" y=\"128\"/>\n    <tile id=\"14\" x=\"544\" y=\"128\"/>\n    <tile id=\"6\" x=\"512\" y=\"128\"/>\n    <tile id=\"5\" x=\"480\" y=\"128\"/>\n    <tile id=\"3\" x=\"416\" y=\"128\"/>\n    <tile id=\"4\" x=\"448\" y=\"128\"/>\n    <tile id=\"18\" x=\"128\" y=\"128\"/>\n    <tile id=\"10\" x=\"96\" y=\"128\"/>\n    <tile id=\"5\" x=\"320\" y=\"128\"/>\n    <tile id=\"1\" x=\"160\" y=\"128\"/>\n    <tile id=\"4\" x=\"288\" y=\"128\"/>\n    <tile id=\"3\" x=\"256\" y=\"128\"/>\n    <tile id=\"11\" x=\"2432\" y=\"128\"/>\n    <tile id=\"0\" x=\"2848\" y=\"160\"/>\n    <tile id=\"4\" x=\"224\" y=\"128\"/>\n    <tile id=\"2\" x=\"352\" y=\"128\"/>\n    <tile id=\"4\" x=\"384\" y=\"128\"/>\n    <tile id=\"8\" x=\"3712\" y=\"128\"/>\n    <tile id=\"7\" x=\"3680\" y=\"128\"/>\n    <tile id=\"6\" x=\"3648\" y=\"128\"/>\n    <tile id=\"5\" x=\"3616\" y=\"128\"/>\n    <tile id=\"4\" x=\"3584\" y=\"128\"/>\n    <tile id=\"3\" x=\"3552\" y=\"128\"/>\n    <tile id=\"2\" x=\"3520\" y=\"128\"/>\n    <tile id=\"5\" x=\"3488\" y=\"128\"/>\n    <tile id=\"4\" x=\"3456\" y=\"128\"/>\n    <tile id=\"6\" x=\"3424\" y=\"128\"/>\n    <tile id=\"2\" x=\"3392\" y=\"128\"/>\n    <tile id=\"4\" x=\"3360\" y=\"128\"/>\n    <tile id=\"15\" x=\"3232\" y=\"128\"/>\n    <tile id=\"12\" x=\"3200\" y=\"128\"/>\n    <tile id=\"15\" x=\"3168\" y=\"128\"/>\n    <tile id=\"16\" x=\"3136\" y=\"128\"/>\n    <tile id=\"1\" x=\"3296\" y=\"128\"/>\n    <tile id=\"0\" x=\"3296\" y=\"160\"/>\n    <tile id=\"3\" x=\"3328\" y=\"128\"/>\n    <tile id=\"13\" x=\"3264\" y=\"128\"/>\n    <tile id=\"17\" x=\"736\" y=\"128\"/>\n    <tile id=\"15\" x=\"704\" y=\"128\"/>\n    <tile id=\"11\" x=\"3072\" y=\"128\"/>\n    <tile id=\"15\" x=\"3104\" y=\"128\"/>\n    <tile id=\"10\" x=\"3008\" y=\"128\"/>\n    <tile id=\"10\" x=\"3040\" y=\"128\"/>\n    <tile id=\"0\" x=\"3008\" y=\"160\"/>\n    <tile id=\"8\" x=\"2976\" y=\"128\"/>\n    <tile id=\"9\" x=\"2944\" y=\"128\"/>\n    <tile id=\"10\" x=\"2912\" y=\"128\"/>\n    <tile id=\"9\" x=\"2880\" y=\"128\"/>\n    <tile id=\"8\" x=\"2848\" y=\"128\"/>\n    <tile id=\"10\" x=\"2816\" y=\"128\"/>\n    <tile id=\"9\" x=\"2784\" y=\"128\"/>\n    <tile id=\"10\" x=\"2752\" y=\"128\"/>\n    <tile id=\"9\" x=\"2720\" y=\"128\"/>\n    <tile id=\"9\" x=\"2688\" y=\"128\"/>\n    <tile id=\"10\" x=\"2656\" y=\"128\"/>\n    <tile id=\"9\" x=\"2624\" y=\"128\"/>\n    <tile id=\"17\" x=\"2592\" y=\"128\"/>\n    <tile id=\"16\" x=\"2560\" y=\"128\"/>\n    <tile id=\"14\" x=\"2528\" y=\"128\"/>\n    <tile id=\"13\" x=\"2496\" y=\"128\"/>\n    <tile id=\"12\" x=\"2464\" y=\"128\"/>\n    <tile id=\"11\" x=\"1216\" y=\"128\"/>\n    <tile id=\"12\" x=\"1248\" y=\"128\"/>\n    <tile id=\"13\" x=\"1280\" y=\"128\"/>\n    <tile id=\"14\" x=\"1312\" y=\"128\"/>\n    <tile id=\"15\" x=\"1344\" y=\"128\"/>\n    <tile id=\"17\" x=\"1376\" y=\"128\"/>\n    <tile id=\"10\" x=\"1408\" y=\"128\"/>\n    <tile id=\"8\" x=\"1440\" y=\"128\"/>\n    <tile id=\"9\" x=\"1472\" y=\"128\"/>\n    <tile id=\"10\" x=\"1504\" y=\"128\"/>\n    <tile id=\"9\" x=\"1536\" y=\"128\"/>\n    <tile id=\"10\" x=\"1600\" y=\"128\"/>\n    <tile id=\"8\" x=\"1568\" y=\"128\"/>\n    <tile id=\"12\" x=\"1888\" y=\"128\"/>\n    <tile id=\"15\" x=\"1920\" y=\"128\"/>\n    <tile id=\"15\" x=\"2080\" y=\"128\"/>\n    <tile id=\"16\" x=\"2048\" y=\"128\"/>\n    <tile id=\"12\" x=\"2016\" y=\"128\"/>\n    <tile id=\"15\" x=\"1984\" y=\"128\"/>\n    <tile id=\"12\" x=\"1952\" y=\"128\"/>\n    <tile id=\"12\" x=\"1856\" y=\"128\"/>\n    <tile id=\"15\" x=\"1824\" y=\"128\"/>\n    <tile id=\"16\" x=\"1792\" y=\"128\"/>\n    <tile id=\"10\" x=\"2144\" y=\"128\"/>\n    <tile id=\"17\" x=\"2112\" y=\"128\"/>\n    <tile id=\"9\" x=\"1664\" y=\"128\"/>\n    <tile id=\"10\" x=\"1632\" y=\"128\"/>\n    <tile id=\"0\" x=\"3744\" y=\"128\"/>\n    <tile id=\"0\" x=\"3776\" y=\"128\"/>\n    <tile id=\"0\" x=\"3808\" y=\"128\"/>\n    <tile id=\"0\" x=\"0\" y=\"128\"/>\n    <tile id=\"0\" x=\"32\" y=\"128\"/>\n    <tile id=\"0\" x=\"64\" y=\"128\"/>\n    <rect id=\"0\" x=\"2176\" y=\"64\" w=\"384\" h=\"32\"/>\n    <tile id=\"9\" x=\"1696\" y=\"128\"/>\n    <tile id=\"11\" x=\"1760\" y=\"128\"/>\n    <tile id=\"8\" x=\"1728\" y=\"128\"/>\n  </ground>\n  <objects>\n    <Castle x=\"1852\" y=\"36\"/>\n    <Shop x=\"1768\" y=\"68\"/>\n    <Shop x=\"2044\" y=\"68\"/>\n  </objects>\n  <farmlands>\n    <Farmland x=\"1508\" y=\"104\"/>\n    <Farmland x=\"2260\" y=\"104\"/>\n    <Farmland x=\"936\" y=\"104\"/>\n    <Farmland x=\"1032\" y=\"104\"/>\n    <Farmland x=\"2712\" y=\"104\"/>\n    <Farmland x=\"2812\" y=\"104\"/>\n    <Torch x=\"2788\" y=\"100\"/>\n    <Torch x=\"3016\" y=\"100\"/>\n    <Farmland x=\"1700\" y=\"104\"/>\n  </farmlands>\n  <walls>\n    <Wall x=\"1420\" y=\"80\"/>\n    <Wall x=\"2388\" y=\"80\"/>\n    <Wall x=\"3044\" y=\"80\"/>\n    <Wall x=\"740\" y=\"80\"/>\n    <Wall x=\"1660\" y=\"80\"/>\n    <Wall x=\"1988\" y=\"80\"/>\n  </walls>\n  <props>\n    <Treeline x=\"3744\" y=\"0\"/>\n    <Treeline x=\"0\" y=\"0\"/>\n  </props>\n  <lights>\n    <Torch x=\"1292\" y=\"100\"/>\n    <Torch x=\"1472\" y=\"100\"/>\n    <Torch x=\"1636\" y=\"100\"/>\n    <Torch x=\"2136\" y=\"100\"/>\n    <Torch x=\"2352\" y=\"100\"/>\n    <Torch x=\"2548\" y=\"100\"/>\n    <Torch x=\"1008\" y=\"100\"/>\n    <Torch x=\"776\" y=\"100\"/>\n    <Firefly x=\"348\" y=\"144\"/>\n    <Firefly x=\"412\" y=\"136\"/>\n    <Firefly x=\"292\" y=\"116\"/>\n    <Firefly x=\"444\" y=\"124\"/>\n    <Firefly x=\"624\" y=\"112\"/>\n    <Firefly x=\"692\" y=\"112\"/>\n    <Firefly x=\"640\" y=\"120\"/>\n    <Firefly x=\"568\" y=\"120\"/>\n    <Firefly x=\"1232\" y=\"120\"/>\n    <Firefly x=\"1200\" y=\"112\"/>\n    <Firefly x=\"1268\" y=\"136\"/>\n    <Firefly x=\"1140\" y=\"136\"/>\n    <Firefly x=\"2572\" y=\"140\"/>\n    <Firefly x=\"2620\" y=\"120\"/>\n    <Firefly x=\"2676\" y=\"136\"/>\n    <Firefly x=\"3176\" y=\"136\"/>\n    <Firefly x=\"3132\" y=\"128\"/>\n    <Firefly x=\"3588\" y=\"120\"/>\n    <Firefly x=\"3524\" y=\"140\"/>\n    <Firefly x=\"3452\" y=\"120\"/>\n    <Firefly x=\"3392\" y=\"136\"/>\n    <Firefly x=\"3632\" y=\"144\"/>\n  </lights>\n</level>"
  },
  {
    "path": "assets/levels/fields_loose.oel",
    "content": "<level backdropFarImg=\"SkylineHillsImg\" backdropCloseImg=\"SkylineTreesImg\" waterHeight=\"152\">\n  <width>3840</width>\n  <height>192</height>\n  <backdrop>\n    <Reed x=\"164\" y=\"128\"/>\n    <Reed x=\"196\" y=\"128\"/>\n    <Reed x=\"228\" y=\"128\"/>\n    <Reed x=\"324\" y=\"128\"/>\n    <Reed x=\"356\" y=\"128\"/>\n    <Reed x=\"388\" y=\"128\"/>\n    <Reed x=\"420\" y=\"128\"/>\n    <Reed x=\"528\" y=\"112\"/>\n    <Reed x=\"560\" y=\"112\"/>\n    <Reed x=\"592\" y=\"112\"/>\n    <Reed x=\"656\" y=\"112\"/>\n    <Reed x=\"688\" y=\"112\"/>\n    <Reed x=\"832\" y=\"112\"/>\n    <Reed x=\"864\" y=\"112\"/>\n    <Reed x=\"896\" y=\"112\"/>\n    <Reed x=\"1880\" y=\"124\"/>\n    <Reed x=\"1912\" y=\"124\"/>\n    <Reed x=\"1944\" y=\"124\"/>\n    <Reed x=\"1624\" y=\"124\"/>\n    <Reed x=\"2008\" y=\"124\"/>\n    <Reed x=\"2040\" y=\"124\"/>\n    <Reed x=\"1136\" y=\"112\"/>\n    <Reed x=\"1208\" y=\"112\"/>\n    <Reed x=\"260\" y=\"128\"/>\n    <Reed x=\"292\" y=\"128\"/>\n    <Reed x=\"1976\" y=\"124\"/>\n    <Reed x=\"2072\" y=\"124\"/>\n    <Hill x=\"800\" y=\"128\"/>\n    <Hill x=\"608\" y=\"128\"/>\n    <Hill x=\"508\" y=\"128\"/>\n    <Reed x=\"1168\" y=\"112\"/>\n    <Hill x=\"1104\" y=\"128\"/>\n    <Reed x=\"132\" y=\"128\"/>\n    <Reed x=\"100\" y=\"128\"/>\n    <Reed x=\"68\" y=\"128\"/>\n    <Reed x=\"36\" y=\"128\"/>\n    <Reed x=\"4\" y=\"128\"/>\n    <Reed x=\"1656\" y=\"124\"/>\n    <Reed x=\"1688\" y=\"124\"/>\n    <Reed x=\"1720\" y=\"124\"/>\n    <Reed x=\"1784\" y=\"124\"/>\n    <Reed x=\"1816\" y=\"124\"/>\n    <Reed x=\"1752\" y=\"124\"/>\n    <Reed x=\"1848\" y=\"124\"/>\n  </backdrop>\n  <ground set=\"tiles\" tileWidth=\"32\" tileHeight=\"32\">\n    <tile id=\"5\" x=\"192\" y=\"128\"/>\n    <tile id=\"8\" x=\"960\" y=\"128\"/>\n    <tile id=\"10\" x=\"992\" y=\"128\"/>\n    <tile id=\"9\" x=\"1024\" y=\"128\"/>\n    <tile id=\"10\" x=\"1056\" y=\"128\"/>\n    <tile id=\"9\" x=\"1184\" y=\"128\"/>\n    <tile id=\"8\" x=\"1152\" y=\"128\"/>\n    <tile id=\"9\" x=\"1120\" y=\"128\"/>\n    <tile id=\"10\" x=\"1088\" y=\"128\"/>\n    <tile id=\"10\" x=\"2176\" y=\"128\"/>\n    <tile id=\"9\" x=\"2208\" y=\"128\"/>\n    <tile id=\"10\" x=\"2240\" y=\"128\"/>\n    <tile id=\"8\" x=\"2272\" y=\"128\"/>\n    <tile id=\"9\" x=\"2304\" y=\"128\"/>\n    <tile id=\"8\" x=\"2336\" y=\"128\"/>\n    <tile id=\"9\" x=\"2368\" y=\"128\"/>\n    <tile id=\"9\" x=\"2400\" y=\"128\"/>\n    <tile id=\"9\" x=\"896\" y=\"128\"/>\n    <tile id=\"8\" x=\"928\" y=\"128\"/>\n    <tile id=\"10\" x=\"864\" y=\"128\"/>\n    <tile id=\"8\" x=\"832\" y=\"128\"/>\n    <tile id=\"10\" x=\"800\" y=\"128\"/>\n    <tile id=\"9\" x=\"768\" y=\"128\"/>\n    <tile id=\"16\" x=\"672\" y=\"128\"/>\n    <tile id=\"15\" x=\"640\" y=\"128\"/>\n    <tile id=\"15\" x=\"608\" y=\"128\"/>\n    <tile id=\"16\" x=\"576\" y=\"128\"/>\n    <tile id=\"14\" x=\"544\" y=\"128\"/>\n    <tile id=\"6\" x=\"512\" y=\"128\"/>\n    <tile id=\"5\" x=\"480\" y=\"128\"/>\n    <tile id=\"3\" x=\"416\" y=\"128\"/>\n    <tile id=\"4\" x=\"448\" y=\"128\"/>\n    <tile id=\"18\" x=\"128\" y=\"128\"/>\n    <tile id=\"10\" x=\"96\" y=\"128\"/>\n    <tile id=\"5\" x=\"320\" y=\"128\"/>\n    <tile id=\"1\" x=\"160\" y=\"128\"/>\n    <tile id=\"4\" x=\"288\" y=\"128\"/>\n    <tile id=\"3\" x=\"256\" y=\"128\"/>\n    <tile id=\"11\" x=\"2432\" y=\"128\"/>\n    <tile id=\"0\" x=\"2848\" y=\"160\"/>\n    <tile id=\"4\" x=\"224\" y=\"128\"/>\n    <tile id=\"2\" x=\"352\" y=\"128\"/>\n    <tile id=\"4\" x=\"384\" y=\"128\"/>\n    <tile id=\"8\" x=\"3712\" y=\"128\"/>\n    <tile id=\"7\" x=\"3680\" y=\"128\"/>\n    <tile id=\"6\" x=\"3648\" y=\"128\"/>\n    <tile id=\"5\" x=\"3616\" y=\"128\"/>\n    <tile id=\"4\" x=\"3584\" y=\"128\"/>\n    <tile id=\"3\" x=\"3552\" y=\"128\"/>\n    <tile id=\"2\" x=\"3520\" y=\"128\"/>\n    <tile id=\"5\" x=\"3488\" y=\"128\"/>\n    <tile id=\"4\" x=\"3456\" y=\"128\"/>\n    <tile id=\"6\" x=\"3424\" y=\"128\"/>\n    <tile id=\"2\" x=\"3392\" y=\"128\"/>\n    <tile id=\"4\" x=\"3360\" y=\"128\"/>\n    <tile id=\"15\" x=\"3232\" y=\"128\"/>\n    <tile id=\"12\" x=\"3200\" y=\"128\"/>\n    <tile id=\"15\" x=\"3168\" y=\"128\"/>\n    <tile id=\"16\" x=\"3136\" y=\"128\"/>\n    <tile id=\"1\" x=\"3296\" y=\"128\"/>\n    <tile id=\"0\" x=\"3296\" y=\"160\"/>\n    <tile id=\"3\" x=\"3328\" y=\"128\"/>\n    <tile id=\"13\" x=\"3264\" y=\"128\"/>\n    <tile id=\"17\" x=\"736\" y=\"128\"/>\n    <tile id=\"15\" x=\"704\" y=\"128\"/>\n    <tile id=\"11\" x=\"3072\" y=\"128\"/>\n    <tile id=\"15\" x=\"3104\" y=\"128\"/>\n    <tile id=\"10\" x=\"3008\" y=\"128\"/>\n    <tile id=\"10\" x=\"3040\" y=\"128\"/>\n    <tile id=\"0\" x=\"3008\" y=\"160\"/>\n    <tile id=\"8\" x=\"2976\" y=\"128\"/>\n    <tile id=\"9\" x=\"2944\" y=\"128\"/>\n    <tile id=\"10\" x=\"2912\" y=\"128\"/>\n    <tile id=\"9\" x=\"2880\" y=\"128\"/>\n    <tile id=\"8\" x=\"2848\" y=\"128\"/>\n    <tile id=\"10\" x=\"2816\" y=\"128\"/>\n    <tile id=\"9\" x=\"2784\" y=\"128\"/>\n    <tile id=\"10\" x=\"2752\" y=\"128\"/>\n    <tile id=\"9\" x=\"2720\" y=\"128\"/>\n    <tile id=\"9\" x=\"2688\" y=\"128\"/>\n    <tile id=\"10\" x=\"2656\" y=\"128\"/>\n    <tile id=\"9\" x=\"2624\" y=\"128\"/>\n    <tile id=\"17\" x=\"2592\" y=\"128\"/>\n    <tile id=\"16\" x=\"2560\" y=\"128\"/>\n    <tile id=\"14\" x=\"2528\" y=\"128\"/>\n    <tile id=\"13\" x=\"2496\" y=\"128\"/>\n    <tile id=\"12\" x=\"2464\" y=\"128\"/>\n    <tile id=\"11\" x=\"1216\" y=\"128\"/>\n    <tile id=\"12\" x=\"1248\" y=\"128\"/>\n    <tile id=\"13\" x=\"1280\" y=\"128\"/>\n    <tile id=\"14\" x=\"1312\" y=\"128\"/>\n    <tile id=\"15\" x=\"1344\" y=\"128\"/>\n    <tile id=\"17\" x=\"1376\" y=\"128\"/>\n    <tile id=\"10\" x=\"1408\" y=\"128\"/>\n    <tile id=\"8\" x=\"1440\" y=\"128\"/>\n    <tile id=\"9\" x=\"1472\" y=\"128\"/>\n    <tile id=\"10\" x=\"1504\" y=\"128\"/>\n    <tile id=\"9\" x=\"1536\" y=\"128\"/>\n    <tile id=\"10\" x=\"1600\" y=\"128\"/>\n    <tile id=\"8\" x=\"1568\" y=\"128\"/>\n    <tile id=\"12\" x=\"1888\" y=\"128\"/>\n    <tile id=\"15\" x=\"1920\" y=\"128\"/>\n    <tile id=\"15\" x=\"2080\" y=\"128\"/>\n    <tile id=\"16\" x=\"2048\" y=\"128\"/>\n    <tile id=\"12\" x=\"2016\" y=\"128\"/>\n    <tile id=\"15\" x=\"1984\" y=\"128\"/>\n    <tile id=\"12\" x=\"1952\" y=\"128\"/>\n    <tile id=\"12\" x=\"1856\" y=\"128\"/>\n    <tile id=\"15\" x=\"1824\" y=\"128\"/>\n    <tile id=\"16\" x=\"1792\" y=\"128\"/>\n    <tile id=\"12\" x=\"1760\" y=\"128\"/>\n    <tile id=\"15\" x=\"1728\" y=\"128\"/>\n    <tile id=\"10\" x=\"2144\" y=\"128\"/>\n    <tile id=\"17\" x=\"2112\" y=\"128\"/>\n    <tile id=\"11\" x=\"1696\" y=\"128\"/>\n    <tile id=\"9\" x=\"1664\" y=\"128\"/>\n    <tile id=\"10\" x=\"1632\" y=\"128\"/>\n    <tile id=\"0\" x=\"3744\" y=\"128\"/>\n    <tile id=\"0\" x=\"3776\" y=\"128\"/>\n    <tile id=\"0\" x=\"3808\" y=\"128\"/>\n    <tile id=\"0\" x=\"0\" y=\"128\"/>\n    <tile id=\"0\" x=\"32\" y=\"128\"/>\n    <tile id=\"0\" x=\"64\" y=\"128\"/>\n    <rect id=\"0\" x=\"2176\" y=\"64\" w=\"384\" h=\"32\"/>\n  </ground>\n  <objects>\n    <Castle x=\"1852\" y=\"36\"/>\n    <Shop x=\"1720\" y=\"68\"/>\n    <Shop x=\"2044\" y=\"68\"/>\n  </objects>\n  <farmlands>\n    <Farmland x=\"1464\" y=\"104\"/>\n    <Farmland x=\"2156\" y=\"104\"/>\n    <Farmland x=\"936\" y=\"104\"/>\n    <Farmland x=\"1032\" y=\"104\"/>\n    <Farmland x=\"2712\" y=\"104\"/>\n    <Farmland x=\"2812\" y=\"104\"/>\n    <Torch x=\"2788\" y=\"100\"/>\n    <Torch x=\"3016\" y=\"100\"/>\n    <Farmland x=\"1552\" y=\"104\"/>\n  </farmlands>\n  <walls>\n    <Wall x=\"1404\" y=\"80\"/>\n    <Wall x=\"2232\" y=\"80\"/>\n    <Wall x=\"3044\" y=\"80\"/>\n    <Wall x=\"740\" y=\"80\"/>\n    <Wall x=\"1812\" y=\"80\"/>\n    <Wall x=\"1988\" y=\"80\"/>\n  </walls>\n  <props>\n    <Treeline x=\"3744\" y=\"0\"/>\n    <Treeline x=\"0\" y=\"0\"/>\n  </props>\n  <lights>\n    <Torch x=\"1292\" y=\"100\"/>\n    <Torch x=\"1440\" y=\"100\"/>\n    <Torch x=\"1636\" y=\"100\"/>\n    <Torch x=\"2136\" y=\"100\"/>\n    <Torch x=\"2352\" y=\"100\"/>\n    <Torch x=\"2548\" y=\"100\"/>\n    <Torch x=\"1008\" y=\"100\"/>\n    <Torch x=\"776\" y=\"100\"/>\n    <Firefly x=\"348\" y=\"144\"/>\n    <Firefly x=\"412\" y=\"136\"/>\n    <Firefly x=\"292\" y=\"116\"/>\n    <Firefly x=\"444\" y=\"124\"/>\n    <Firefly x=\"624\" y=\"112\"/>\n    <Firefly x=\"692\" y=\"112\"/>\n    <Firefly x=\"640\" y=\"120\"/>\n    <Firefly x=\"568\" y=\"120\"/>\n    <Firefly x=\"1232\" y=\"120\"/>\n    <Firefly x=\"1200\" y=\"112\"/>\n    <Firefly x=\"1268\" y=\"136\"/>\n    <Firefly x=\"1140\" y=\"136\"/>\n    <Firefly x=\"2572\" y=\"140\"/>\n    <Firefly x=\"2620\" y=\"120\"/>\n    <Firefly x=\"2676\" y=\"136\"/>\n    <Firefly x=\"3176\" y=\"136\"/>\n    <Firefly x=\"3132\" y=\"128\"/>\n    <Firefly x=\"3588\" y=\"120\"/>\n    <Firefly x=\"3524\" y=\"140\"/>\n    <Firefly x=\"3452\" y=\"120\"/>\n    <Firefly x=\"3392\" y=\"136\"/>\n    <Firefly x=\"3632\" y=\"144\"/>\n  </lights>\n</level>"
  },
  {
    "path": "assets/levels/fields_old.oel",
    "content": "<level backdropFarImg=\"SkylineHillsImg\" backdropCloseImg=\"SkylineTreesImg\" waterHeight=\"152\">\n  <width>3840</width>\n  <height>192</height>\n  <backdrop>\n    <Reed x=\"164\" y=\"128\"/>\n    <Reed x=\"196\" y=\"128\"/>\n    <Reed x=\"228\" y=\"128\"/>\n    <Reed x=\"324\" y=\"128\"/>\n    <Reed x=\"356\" y=\"128\"/>\n    <Reed x=\"388\" y=\"128\"/>\n    <Reed x=\"420\" y=\"128\"/>\n    <Reed x=\"528\" y=\"112\"/>\n    <Reed x=\"560\" y=\"112\"/>\n    <Reed x=\"592\" y=\"112\"/>\n    <Reed x=\"656\" y=\"112\"/>\n    <Reed x=\"688\" y=\"112\"/>\n    <Reed x=\"832\" y=\"112\"/>\n    <Reed x=\"864\" y=\"112\"/>\n    <Reed x=\"896\" y=\"112\"/>\n    <Reed x=\"1880\" y=\"124\"/>\n    <Reed x=\"1912\" y=\"124\"/>\n    <Reed x=\"1944\" y=\"124\"/>\n    <Reed x=\"1624\" y=\"124\"/>\n    <Reed x=\"2008\" y=\"124\"/>\n    <Reed x=\"2040\" y=\"124\"/>\n    <Reed x=\"1136\" y=\"112\"/>\n    <Reed x=\"1208\" y=\"112\"/>\n    <Reed x=\"260\" y=\"128\"/>\n    <Reed x=\"292\" y=\"128\"/>\n    <Reed x=\"1976\" y=\"124\"/>\n    <Reed x=\"2072\" y=\"124\"/>\n    <Hill x=\"800\" y=\"128\"/>\n    <Hill x=\"608\" y=\"128\"/>\n    <Hill x=\"508\" y=\"128\"/>\n    <Reed x=\"1168\" y=\"112\"/>\n    <Hill x=\"1104\" y=\"128\"/>\n    <Reed x=\"132\" y=\"128\"/>\n    <Reed x=\"100\" y=\"128\"/>\n    <Reed x=\"68\" y=\"128\"/>\n    <Reed x=\"36\" y=\"128\"/>\n    <Reed x=\"4\" y=\"128\"/>\n    <Reed x=\"1656\" y=\"124\"/>\n    <Reed x=\"1688\" y=\"124\"/>\n    <Reed x=\"1720\" y=\"124\"/>\n    <Reed x=\"1784\" y=\"124\"/>\n    <Reed x=\"1816\" y=\"124\"/>\n    <Reed x=\"1752\" y=\"124\"/>\n    <Reed x=\"1848\" y=\"124\"/>\n  </backdrop>\n  <ground set=\"tiles\" tileWidth=\"32\" tileHeight=\"32\">\n    <tile id=\"5\" x=\"192\" y=\"128\"/>\n    <tile id=\"8\" x=\"960\" y=\"128\"/>\n    <tile id=\"10\" x=\"992\" y=\"128\"/>\n    <tile id=\"9\" x=\"1024\" y=\"128\"/>\n    <tile id=\"10\" x=\"1056\" y=\"128\"/>\n    <tile id=\"9\" x=\"1184\" y=\"128\"/>\n    <tile id=\"8\" x=\"1152\" y=\"128\"/>\n    <tile id=\"9\" x=\"1120\" y=\"128\"/>\n    <tile id=\"10\" x=\"1088\" y=\"128\"/>\n    <tile id=\"10\" x=\"2176\" y=\"128\"/>\n    <tile id=\"9\" x=\"2208\" y=\"128\"/>\n    <tile id=\"10\" x=\"2240\" y=\"128\"/>\n    <tile id=\"8\" x=\"2272\" y=\"128\"/>\n    <tile id=\"9\" x=\"2304\" y=\"128\"/>\n    <tile id=\"8\" x=\"2336\" y=\"128\"/>\n    <tile id=\"9\" x=\"2368\" y=\"128\"/>\n    <tile id=\"9\" x=\"2400\" y=\"128\"/>\n    <tile id=\"9\" x=\"896\" y=\"128\"/>\n    <tile id=\"8\" x=\"928\" y=\"128\"/>\n    <tile id=\"10\" x=\"864\" y=\"128\"/>\n    <tile id=\"8\" x=\"832\" y=\"128\"/>\n    <tile id=\"10\" x=\"800\" y=\"128\"/>\n    <tile id=\"9\" x=\"768\" y=\"128\"/>\n    <tile id=\"16\" x=\"672\" y=\"128\"/>\n    <tile id=\"15\" x=\"640\" y=\"128\"/>\n    <tile id=\"15\" x=\"608\" y=\"128\"/>\n    <tile id=\"16\" x=\"576\" y=\"128\"/>\n    <tile id=\"14\" x=\"544\" y=\"128\"/>\n    <tile id=\"6\" x=\"512\" y=\"128\"/>\n    <tile id=\"5\" x=\"480\" y=\"128\"/>\n    <tile id=\"3\" x=\"416\" y=\"128\"/>\n    <tile id=\"4\" x=\"448\" y=\"128\"/>\n    <tile id=\"18\" x=\"128\" y=\"128\"/>\n    <tile id=\"10\" x=\"96\" y=\"128\"/>\n    <tile id=\"5\" x=\"320\" y=\"128\"/>\n    <tile id=\"1\" x=\"160\" y=\"128\"/>\n    <tile id=\"4\" x=\"288\" y=\"128\"/>\n    <tile id=\"3\" x=\"256\" y=\"128\"/>\n    <tile id=\"11\" x=\"2432\" y=\"128\"/>\n    <tile id=\"0\" x=\"2848\" y=\"160\"/>\n    <tile id=\"4\" x=\"224\" y=\"128\"/>\n    <tile id=\"2\" x=\"352\" y=\"128\"/>\n    <tile id=\"4\" x=\"384\" y=\"128\"/>\n    <tile id=\"8\" x=\"3712\" y=\"128\"/>\n    <tile id=\"7\" x=\"3680\" y=\"128\"/>\n    <tile id=\"6\" x=\"3648\" y=\"128\"/>\n    <tile id=\"5\" x=\"3616\" y=\"128\"/>\n    <tile id=\"4\" x=\"3584\" y=\"128\"/>\n    <tile id=\"3\" x=\"3552\" y=\"128\"/>\n    <tile id=\"2\" x=\"3520\" y=\"128\"/>\n    <tile id=\"5\" x=\"3488\" y=\"128\"/>\n    <tile id=\"4\" x=\"3456\" y=\"128\"/>\n    <tile id=\"6\" x=\"3424\" y=\"128\"/>\n    <tile id=\"2\" x=\"3392\" y=\"128\"/>\n    <tile id=\"4\" x=\"3360\" y=\"128\"/>\n    <tile id=\"15\" x=\"3232\" y=\"128\"/>\n    <tile id=\"12\" x=\"3200\" y=\"128\"/>\n    <tile id=\"15\" x=\"3168\" y=\"128\"/>\n    <tile id=\"16\" x=\"3136\" y=\"128\"/>\n    <tile id=\"1\" x=\"3296\" y=\"128\"/>\n    <tile id=\"0\" x=\"3296\" y=\"160\"/>\n    <tile id=\"3\" x=\"3328\" y=\"128\"/>\n    <tile id=\"13\" x=\"3264\" y=\"128\"/>\n    <tile id=\"17\" x=\"736\" y=\"128\"/>\n    <tile id=\"15\" x=\"704\" y=\"128\"/>\n    <tile id=\"11\" x=\"3072\" y=\"128\"/>\n    <tile id=\"15\" x=\"3104\" y=\"128\"/>\n    <tile id=\"10\" x=\"3008\" y=\"128\"/>\n    <tile id=\"10\" x=\"3040\" y=\"128\"/>\n    <tile id=\"0\" x=\"3008\" y=\"160\"/>\n    <tile id=\"8\" x=\"2976\" y=\"128\"/>\n    <tile id=\"9\" x=\"2944\" y=\"128\"/>\n    <tile id=\"10\" x=\"2912\" y=\"128\"/>\n    <tile id=\"9\" x=\"2880\" y=\"128\"/>\n    <tile id=\"8\" x=\"2848\" y=\"128\"/>\n    <tile id=\"10\" x=\"2816\" y=\"128\"/>\n    <tile id=\"9\" x=\"2784\" y=\"128\"/>\n    <tile id=\"10\" x=\"2752\" y=\"128\"/>\n    <tile id=\"9\" x=\"2720\" y=\"128\"/>\n    <tile id=\"9\" x=\"2688\" y=\"128\"/>\n    <tile id=\"10\" x=\"2656\" y=\"128\"/>\n    <tile id=\"9\" x=\"2624\" y=\"128\"/>\n    <tile id=\"17\" x=\"2592\" y=\"128\"/>\n    <tile id=\"16\" x=\"2560\" y=\"128\"/>\n    <tile id=\"14\" x=\"2528\" y=\"128\"/>\n    <tile id=\"13\" x=\"2496\" y=\"128\"/>\n    <tile id=\"12\" x=\"2464\" y=\"128\"/>\n    <tile id=\"11\" x=\"1216\" y=\"128\"/>\n    <tile id=\"12\" x=\"1248\" y=\"128\"/>\n    <tile id=\"13\" x=\"1280\" y=\"128\"/>\n    <tile id=\"14\" x=\"1312\" y=\"128\"/>\n    <tile id=\"15\" x=\"1344\" y=\"128\"/>\n    <tile id=\"17\" x=\"1376\" y=\"128\"/>\n    <tile id=\"10\" x=\"1408\" y=\"128\"/>\n    <tile id=\"8\" x=\"1440\" y=\"128\"/>\n    <tile id=\"9\" x=\"1472\" y=\"128\"/>\n    <tile id=\"10\" x=\"1504\" y=\"128\"/>\n    <tile id=\"9\" x=\"1536\" y=\"128\"/>\n    <tile id=\"10\" x=\"1600\" y=\"128\"/>\n    <tile id=\"8\" x=\"1568\" y=\"128\"/>\n    <tile id=\"12\" x=\"1888\" y=\"128\"/>\n    <tile id=\"15\" x=\"1920\" y=\"128\"/>\n    <tile id=\"15\" x=\"2080\" y=\"128\"/>\n    <tile id=\"16\" x=\"2048\" y=\"128\"/>\n    <tile id=\"12\" x=\"2016\" y=\"128\"/>\n    <tile id=\"15\" x=\"1984\" y=\"128\"/>\n    <tile id=\"12\" x=\"1952\" y=\"128\"/>\n    <tile id=\"12\" x=\"1856\" y=\"128\"/>\n    <tile id=\"15\" x=\"1824\" y=\"128\"/>\n    <tile id=\"16\" x=\"1792\" y=\"128\"/>\n    <tile id=\"12\" x=\"1760\" y=\"128\"/>\n    <tile id=\"15\" x=\"1728\" y=\"128\"/>\n    <tile id=\"10\" x=\"2144\" y=\"128\"/>\n    <tile id=\"17\" x=\"2112\" y=\"128\"/>\n    <tile id=\"11\" x=\"1696\" y=\"128\"/>\n    <tile id=\"9\" x=\"1664\" y=\"128\"/>\n    <tile id=\"10\" x=\"1632\" y=\"128\"/>\n    <tile id=\"0\" x=\"3744\" y=\"128\"/>\n    <tile id=\"0\" x=\"3776\" y=\"128\"/>\n    <tile id=\"0\" x=\"3808\" y=\"128\"/>\n    <tile id=\"0\" x=\"0\" y=\"128\"/>\n    <tile id=\"0\" x=\"32\" y=\"128\"/>\n    <tile id=\"0\" x=\"64\" y=\"128\"/>\n    <rect id=\"0\" x=\"2176\" y=\"64\" w=\"384\" h=\"32\"/>\n  </ground>\n  <objects>\n    <Castle x=\"1852\" y=\"36\"/>\n    <Shop x=\"1720\" y=\"68\"/>\n    <Shop x=\"2044\" y=\"68\"/>\n  </objects>\n  <farmlands>\n    <Farmland x=\"1508\" y=\"104\"/>\n    <Farmland x=\"2260\" y=\"104\"/>\n    <Farmland x=\"936\" y=\"104\"/>\n    <Farmland x=\"1032\" y=\"104\"/>\n    <Farmland x=\"2712\" y=\"104\"/>\n    <Farmland x=\"2812\" y=\"104\"/>\n    <Torch x=\"2788\" y=\"100\"/>\n    <Torch x=\"3016\" y=\"100\"/>\n  </farmlands>\n  <walls>\n    <Wall x=\"1420\" y=\"80\"/>\n    <Wall x=\"2388\" y=\"80\"/>\n    <Wall x=\"3044\" y=\"80\"/>\n    <Wall x=\"740\" y=\"80\"/>\n    <Wall x=\"1812\" y=\"80\"/>\n    <Wall x=\"1988\" y=\"80\"/>\n  </walls>\n  <props>\n    <Treeline x=\"3744\" y=\"0\"/>\n    <Treeline x=\"0\" y=\"0\"/>\n  </props>\n  <lights>\n    <Torch x=\"1292\" y=\"100\"/>\n    <Torch x=\"1472\" y=\"100\"/>\n    <Torch x=\"1636\" y=\"100\"/>\n    <Torch x=\"2136\" y=\"100\"/>\n    <Torch x=\"2352\" y=\"100\"/>\n    <Torch x=\"2548\" y=\"100\"/>\n    <Torch x=\"1008\" y=\"100\"/>\n    <Torch x=\"776\" y=\"100\"/>\n    <Firefly x=\"348\" y=\"144\"/>\n    <Firefly x=\"412\" y=\"136\"/>\n    <Firefly x=\"292\" y=\"116\"/>\n    <Firefly x=\"444\" y=\"124\"/>\n    <Firefly x=\"624\" y=\"112\"/>\n    <Firefly x=\"692\" y=\"112\"/>\n    <Firefly x=\"640\" y=\"120\"/>\n    <Firefly x=\"568\" y=\"120\"/>\n    <Firefly x=\"1232\" y=\"120\"/>\n    <Firefly x=\"1200\" y=\"112\"/>\n    <Firefly x=\"1268\" y=\"136\"/>\n    <Firefly x=\"1140\" y=\"136\"/>\n    <Firefly x=\"2572\" y=\"140\"/>\n    <Firefly x=\"2620\" y=\"120\"/>\n    <Firefly x=\"2676\" y=\"136\"/>\n    <Firefly x=\"3176\" y=\"136\"/>\n    <Firefly x=\"3132\" y=\"128\"/>\n    <Firefly x=\"3588\" y=\"120\"/>\n    <Firefly x=\"3524\" y=\"140\"/>\n    <Firefly x=\"3452\" y=\"120\"/>\n    <Firefly x=\"3392\" y=\"136\"/>\n    <Firefly x=\"3632\" y=\"144\"/>\n  </lights>\n</level>"
  },
  {
    "path": "assets/levels/ogmoconfig.oep",
    "content": "<project>\n    <name>Kingdom</name>\n    <settings>\n        <defaultWidth>3840</defaultWidth>\n        <defaultHeight>192</defaultHeight>\n        <workingDirectory>../gfx</workingDirectory>\n    </settings>\n    <values>\n        <string name=\"backdropFarImg\" default=\"SkylineImg\"/>\n        <string name=\"backdropCloseImg\" default=\"SkylineImg\"/>\n        <integer name=\"waterHeight\" default=\"230\" min=\"0\" max=\"384\"/>\n    </values>\n    <tilesets>\n        <tileset name=\"tiles\" image=\"tiles.png\" tileWidth=\"32\" tileHeight=\"32\" />\n    </tilesets>\n    <objects>\n        <object name=\"Player\" image=\"king.png\" width=\"64\" height=\"64\" imageWidth=\"64\" limit=\"1\"/>\n        <object name=\"Citizen\" image=\"citizen.png\" width=\"32\" height=\"32\" imageWidth=\"32\"/>\n        <object name=\"Troll\" image=\"troll.png\" width=\"32\" height=\"32\" imageWidth=\"32\"/>\n        <object name=\"Bunny\" image=\"bunny.png\" width=\"16\" height=\"16\" imageWidth=\"16\"/>\n        <object name=\"Treeline\" image=\"treeline.png\" width=\"96\" height=\"160\" />\n        <object name=\"Castle\" image=\"castle.png\" width=\"128\" height=\"96\"/>\n        <object name=\"Reed\" image=\"reed.png\" width=\"32\" height=\"32\" imageWidth=\"32\"/>\n        <object name=\"Hill\" image=\"hill.png\" width=\"160\" height=\"32\"/>\n        <object name=\"Farmland\" image=\"farmland.png\" width=\"64\" height=\"32\" imageWidth=\"64\" imageHeight=\"32\"/>\n        <object name=\"Wall\" image=\"wall.png\" width=\"32\" height=\"64\" imageWidth=\"32\" imageHeight=\"64\"/>\n        <object name=\"Torch\" image=\"torch.png\" width=\"16\" height=\"32\" imageWidth=\"16\" imageHeight=\"32\"/>\n        <object name=\"Shop\" image=\"shop.png\" width=\"64\" height=\"64\" imageWidth=\"64\"/>\n        <object name=\"Firefly\" image=\"firefly.png\" width=\"4\" height=\"4\" imageWidth=\"4\"/>\n    </objects>\n    <layers>\n        <objects name=\"backdrop\" gridSize=\"4\"/>\n        <tiles name=\"ground\"  gridSize=\"32\" exportTileSize=\"true\" exportTileIDs=\"true\"/>\n        <objects name=\"objects\" gridSize=\"4\"/>\n        <objects name=\"farmlands\" gridSize=\"4\"/>\n        <objects name=\"walls\" gridSize=\"4\"/>\n        <objects name=\"props\" gridSize=\"4\"/>\n        <objects name=\"lights\" gridSize=\"4\"/>\n    </layers>\n</project>"
  },
  {
    "path": "assets/sound/build.bfxrsound",
    "content": "2,0.5,,0.0781,0.3599,0.1093,0.3,0.413,,,,,,,,,0.125,0.6214,,,,,,,,1,,,,,,,masterVolume"
  },
  {
    "path": "assets/sound/hit.bfxrsound",
    "content": "1,0.5,,0.0695,,0.1577,0.3,0.4565,,-0.515,,,,,,,,,,,,,,,,1,,,0.2087,,,,masterVolume"
  },
  {
    "path": "assets/sound/hitbig.bfxrsound",
    "content": "1.0413,0.5,0.175,0.295,0.055,0.13,0.22,0.53,,-0.36,0.0402,,0.0232,,,0.0081,,,,0.0451,,,,,,1,-0.0025,,0.2087,,,,masterVolume"
  },
  {
    "path": "assets/sound/hitcitizen.bfxrsound",
    "content": "2,0.21,0.11,0.035,,0.265,0.185,0.155,,-0.2099,-0.0625,0.0402,,0.165,,0.0375,0.0148,0.0419,0.0449,,,-0.0012,0.0103,-0.0678,0.0435,0.958,-0.0205,0.0185,0.1,-0.0265,,-0.0264,masterVolume,attackTime,sustainTime,decayTime,compressionAmount,startFrequency,minFrequency,slide,overtones"
  },
  {
    "path": "assets/sound/hitwall.bfxrsound",
    "content": "1,0.2,,0.0695,0.395,0.23,0.3,0.4565,,-0.395,,0.395,,0.12,0.415,,,,,,,,,0.2649,-0.145,0.35,-0.155,,0.2087,,0.25,-0.045,masterVolume"
  },
  {
    "path": "assets/sound/pickup.bfxrsound",
    "content": "2,0.5,,0.055,0.5256,0.2387,0.3,0.55,,,,,,,,,0.4,0.6179,,,,,,,,1,,,,,,,masterVolume"
  },
  {
    "path": "assets/sound/powerup.bfxrsound",
    "content": "1,0.32,,0.195,,0.45,0.3,0.14,,0.1997,,,,,,,,,,,,,,,,1,,,,,,,masterVolume"
  },
  {
    "path": "assets/sound/stolen.bfxrsound",
    "content": ",0.29,,0.515,0.165,0.25,0.3,0.13,,-0.175,,,,,,,,,,,0.1867,,,,0.195,1,,,0.1,0.2649,0.375,0.03,masterVolume"
  },
  {
    "path": "assets/sound/throw.bfxrsound",
    "content": "2,0.5,0.12,0.065,0.165,0.165,0.3,0.45,,0.2299,0.03,,,,,,,,,,,,,,,1,,,,,,,masterVolume"
  },
  {
    "path": "com/quasimondo/geom/ColorMatrix.as",
    "content": "/*\n\n\tColorMatrix Class v2.41\n\n\treleased under MIT License (X11)\n\thttp://www.opensource.org/licenses/mit-license.php\n\n\tAuthor: Mario Klingemann\n\thttp://www.quasimondo.com\n\t\n\t\n\tBig parts of this class are based on information found in\n\t\"Matrix Operations for Image Processing\"\n\tby Paul Haeberli\n\thttp://web.archive.org/web/20060110044204/http://www.sgi.com/misc/grafica/matrix/\n\t\n\tMatrix factors for the applyColorDeficiency() method\n\thave been copied from http://www.nofunc.com/Color_Matrix_Library/ \n\t\t\t\n\t\n\tCopyright (c) 2006-2010 Mario Klingemann\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n*/\n\n// Changes in v1.1:\n// Changed the RGB to luminance constants\n// Added colorize() method\n\n// Changes in v1.2:\n// Added clone() \n// Added randomize() \n// Added blend() \n// Added \"filter\" property\n\n// Changes in v1.3:\n// Added invertAlpha()\n// Added thresholdAlpha()\n\n// Changes in v1.4:\n// Added luminance2Alpha()\n\n//Changes in v1.5\n// Added rotateX();\n// Added rotateY();\n// Added rotateZ();\n// Added shearZ();\n\n//changes in v2.0\n// AS3 optimizations\n// Added setMultiplicators()\n// Added clearChannels()\n// Added rotateHue()\n// Added transformVector()\n// Added applyMatrix()\n// Added rotateRed()\n// Added rotateGreen()\n// Added rotateBlue()\n// Added shearRed()\n// Added shearGreen()\n// Added shearBlue()\n\n//changes in v2.1\n// Added applyColorDeficiency()\n\n//changes in v2.2\n// Added applyFilter()\n\n//changes in v2.3\n// Added threshold_rgb()\n// Added RGB2YUV()\n// Added YUV2RGB()\n// Added invertMatrix()\n// Added normalize()\n// Added fitRange()\n// Added toString()\n\n// fixed factor in threshold\n\n//changes in v2.4\n// Added autoDesaturate()\n\n//changes in v2.41\n// Added several default values to methods\n\npackage com.quasimondo.geom {\n\t\n    import __AS3__.vec.Vector;\n    \n    import flash.display.BitmapData;\n    import flash.filters.ColorMatrixFilter;\n    import flash.geom.Matrix3D;\n    import flash.geom.Point;\n\n    public class ColorMatrix {\n    \t\n    \tpublic static const COLOR_DEFICIENCY_TYPES:Array = [\n\t\t\t\t\t\t\t\t\t\t\t\t\t    \t'Protanopia',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Protanomaly',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Deuteranopia',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Deuteranomaly',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Tritanopia',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Tritanomaly',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Achromatopsia',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Achromatomaly' ];\n    \t\n\t\t// Estimated occurences of color deficiencies:\n    \t// Protanopia: 1.32%\n    \t// Protanomaly: 1.32%\n    \t// Deuteranopia: 1.21%\n    \t// Deuteranomaly: 5.35%\n    \t// Tritanopia: 0.031%\n    \t// Tritanomaly: 0.0002%\n    \t// Achromatopsia: 0.00002%\n    \t// Achromatomaly: 0.00002%\n    \t\n    \t\n    \t// RGB to Luminance conversion constants as found on\n\t\t// Charles A. Poynton's colorspace-faq:\n\t\t// http://www.faqs.org/faqs/graphics/colorspace-faq/\n\t\t\n\t\tprivate static const LUMA_R:Number = 0.212671;\n\t\tprivate static const LUMA_G:Number = 0.71516;\n        private static const LUMA_B:Number = 0.072169;\n\t\t\n\t\t\n\t\t// There seem different standards for converting RGB\n\t\t// values to Luminance. This is the one by Paul Haeberli:\n\t\t\n\t\tprivate static const LUMA_R2:Number = 0.3086;\n\t\tprivate static const LUMA_G2:Number = 0.6094;\n\t\tprivate static const LUMA_B2:Number = 0.0820;\n\t\t\n\t\t\n\t\t\n\t\tprivate static const ONETHIRD:Number = 1 / 3;\n       \n        private static const IDENTITY:Array = [1,0,0,0,0,\n\t\t\t\t\t\t\t\t\t\t\t 0,1,0,0,0,\n\t\t\t\t\t\t\t\t\t\t\t 0,0,1,0,0,\n\t\t\t\t\t\t\t\t\t\t\t 0,0,0,1,0];\n\t\t\n\t\t\n\t\tprivate static const RAD:Number = Math.PI / 180;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tpublic var matrix:Array;\n\t\t\n\t\tprivate var preHue:ColorMatrix;\n\t\tprivate var postHue:ColorMatrix;\n\t\tprivate var hueInitialized:Boolean;\n\t\t\n\t\t/*\n\t   Function: ColorMatrix\n\t   \n\t\t  Constructor\n\n\t   Parameters:\n\n\t\t  mat - if omitted matrix gets initialized with an\n\t\t\t\tidentity matrix. Alternatively it can be \n\t\t\t\tinitialized with another ColorMatrix or \n\t\t\t\tan array (there is currently no check \n\t\t\t\tif the array is valid. A correct array \n\t\t\t\tcontains 20 elements.)\n\t\t\t\t\n\t\t\t\t\n\t\t*/\n\n\t\tpublic function ColorMatrix ( mat:Object = null )\n\t\t{\n\t\t\t\n\t\t\tif (mat is ColorMatrix )\n\t\t\t{\n\t\t\t\tmatrix = mat.matrix.concat();\n\t\t\t} else if (mat is Array )\n\t\t\t{\n\t\t\t\tmatrix = mat.concat();\n\t\t\t} else \n\t\t\t{\n\t\t\t\treset();\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t/*\n\t   Function: reset\n\n\t\t  resets the matrix to the neutral identity matrix. Applying this\n\t\t  matrix to an image will not make any changes to it.\n\n\t   Parameters:\n\n\t\t  none\n\t\t  \n\t\tReturns:\n\t\t\n\t\t\tnothing\n\t\t*/\n\t\t\n\t\tpublic function reset():void\n\t\t{\n\t\t\tmatrix = IDENTITY.concat();\n\t\t}\n\t\t\n\t\t\n\t\tpublic function clone():ColorMatrix\n\t\t{\n\t\t\treturn new ColorMatrix( matrix );\n\t\t}\n\t\t\n\t\tpublic function invert():void\n\t\t{\n\t\t\tconcat([ -1 ,  0,  0, 0, 255,\n\t\t\t\t\t  0 , -1,  0, 0, 255,\n\t\t\t\t\t  0 ,  0, -1, 0, 255,\n\t\t\t\t\t  0,   0,  0, 1,   0]);\n\t\t}\n\t\t\n\t\t/*\n\t   Function: adjustSaturation\n\n\t\t  changes the saturation\n\n\t   Parameters:\n\n\t\t  s - typical values come in the range 0.0 ... 2.0 where\n\t\t\t\t\t 0.0 means 0% Saturation\n\t\t\t\t\t 0.5 means 50% Saturation\n\t\t\t\t\t 1.0 is 100% Saturation (aka no change)\n\t\t\t\t\t 2.0 is 200% Saturation\n\t\t\t\t\t \n\t\t\t\t\t Other values outside of this range are possible\n\t\t\t\t\t -1.0 will invert the hue but keep the luminance\n\t\t\t\t\t\t\t\n\t\t  \n\t\tReturns:\n\t\t\n\t\t\tnothing\n\t\t\t\t\n\t\t\t\t\n\t\t*/\n\t\t\n\t\tpublic function adjustSaturation( s:Number = 1 ):void{\n            \n            var sInv:Number;\n            var irlum:Number;\n            var iglum:Number;\n            var iblum:Number;\n            \n            sInv = (1 - s);\n            irlum = (sInv * LUMA_R);\n            iglum = (sInv * LUMA_G);\n            iblum = (sInv * LUMA_B);\n            \n            concat([(irlum + s), iglum, iblum, 0, 0, \n            \t\tirlum, (iglum + s), iblum, 0, 0, \n            \t\tirlum, iglum, (iblum + s), 0, 0, \n            \t\t0, 0, 0, 1, 0]);\n        \n        }\n        \n        \n        /*\n\t   Function: adjustContrast\n\n\t\t  changes the contrast\n\n\t   Parameters:\n\n\t\t  s - typical values come in the range -1.0 ... 1.0 where\n\t\t\t\t\t -1.0 means no contrast (grey)\n\t\t\t\t\t 0 means no change\n\t\t\t\t\t 1.0 is high contrast\n\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t  \n\t\tReturns:\n\t\t\n\t\t\tnothing\n\t\t\t\t\n\t\t\t\t\n\t\t*/\n\t\t\n\t\tpublic function adjustContrast( r:Number = 0, g:Number = NaN, b:Number = NaN ):void\n\t\t{\n\t\t\tif (isNaN(g)) g = r;\n\t\t\tif (isNaN(b)) b = r;\n\t\t\tr += 1;\n\t\t\tg += 1;\n\t\t\tb += 1;\n\t\t\t\n\t\t\tconcat([r, 0, 0, 0, (128 * (1 - r)), \n\t\t\t\t\t0, g, 0, 0, (128 * (1 - g)), \n\t\t\t\t\t0, 0, b, 0, (128 * (1 - b)), \n\t\t\t\t\t0, 0, 0, 1, 0]);\n\t\t}\n\t\t  \n\t\t\n\t\tpublic function adjustBrightness(r:Number = 0, g:Number=NaN, b:Number=NaN):void\n \t\t{\n            if (isNaN(g)) g = r;\n            if (isNaN(b)) b = r;\n            concat([1, 0, 0, 0, r, \n            \t\t0, 1, 0, 0, g, \n            \t\t0, 0, 1, 0, b, \n            \t\t0, 0, 0, 1, 0]);\n        }\n        \n        public function toGreyscale( r:Number = LUMA_R, g:Number = LUMA_G, b:Number = LUMA_B ):void\n \t\t{\n            concat([r, g, b, 0, 0, \n            \t\tr, g, b, 0, 0, \n            \t\tr, g, b, 0, 0, \n            \t\t0, 0, 0, 1, 0]);\n        }\n        \n        \n        public function adjustHue( degrees:Number = 0 ):void\n        {\n            degrees *= RAD;\n            var cos:Number = Math.cos(degrees);\n            var sin:Number = Math.sin(degrees);\n            concat([((LUMA_R + (cos * (1 - LUMA_R))) + (sin * -(LUMA_R))), ((LUMA_G + (cos * -(LUMA_G))) + (sin * -(LUMA_G))), ((LUMA_B + (cos * -(LUMA_B))) + (sin * (1 - LUMA_B))), 0, 0, \n            \t\t((LUMA_R + (cos * -(LUMA_R))) + (sin * 0.143)), ((LUMA_G + (cos * (1 - LUMA_G))) + (sin * 0.14)), ((LUMA_B + (cos * -(LUMA_B))) + (sin * -0.283)), 0, 0, \n            \t\t((LUMA_R + (cos * -(LUMA_R))) + (sin * -((1 - LUMA_R)))), ((LUMA_G + (cos * -(LUMA_G))) + (sin * LUMA_G)), ((LUMA_B + (cos * (1 - LUMA_B))) + (sin * LUMA_B)), 0, 0, \n            \t\t0, 0, 0, 1, 0]);\n        }\n        \n        \n\t\tpublic function rotateHue( degrees:Number = 0 ):void\n        {\n\t\t\tinitHue();\n\t\t\t\n\t\t\tconcat( preHue.matrix );\n\t\t\trotateBlue( degrees );\n\t\t\tconcat( postHue.matrix );\n\t\t\n\t\t}\n\n        public function luminance2Alpha():void\n        {\n            concat([0, 0, 0, 0, 255, \n            \t\t0, 0, 0, 0, 255, \n            \t\t0, 0, 0, 0, 255, \n            \t\tLUMA_R, LUMA_G, LUMA_B, 0, 0]);\n        }\n        \n        public function adjustAlphaContrast( amount:Number = 0 ):void\n        {\n            amount += 1;\n            concat([1, 0, 0, 0, 0, \n            \t\t0, 1, 0, 0, 0, \n            \t\t0, 0, 1, 0, 0, \n            \t\t0, 0, 0, amount, (128 * (1 - amount))]);\n        }\n        \n        public function colorize( rgb:uint, amount:Number = -1 ):void\n        {\n            var a:Number;\n            var r:Number;\n            var g:Number;\n            var b:Number;\n            var inv_amount:Number;\n            \n            a = ((rgb >> 24) / 0xFF);\n            r = (((rgb >> 16) & 0xFF) / 0xFF);\n            g = (((rgb >> 8) & 0xFF) / 0xFF);\n            b = ((rgb & 0xFF) / 0xFF);\n            \n            if (amount == -1){\n                amount = a;\n            }\n            inv_amount = (1 - amount);\n            \n            concat([(inv_amount + ((amount * r) * LUMA_R)), ((amount * r) * LUMA_G), ((amount * r) * LUMA_B), 0, 0, \n            \t\t((amount * g) * LUMA_R), (inv_amount + ((amount * g) * LUMA_G)), ((amount * g) * LUMA_B), 0, 0, \n            \t\t((amount * b) * LUMA_R), ((amount * b) * LUMA_G), (inv_amount + ((amount * b) * LUMA_B)), 0, 0, \n            \t\t0, 0, 0, 1, 0]);\n        }\n        \n        \n      \tpublic function setChannels( r:int = 1, g:int = 2, b:int = 4, a:int = 8 ):void\n        {\n           var rf:Number = ((((((r & 1) == 1)) ? 1 : 0 + (((r & 2) == 2)) ? 1 : 0) + (((r & 4) == 4)) ? 1 : 0) + (((r & 8) == 8)) ? 1 : 0);\n            if (rf > 0){\n                rf = (1 / rf);\n            };\n            var gf:Number = ((((((g & 1) == 1)) ? 1 : 0 + (((g & 2) == 2)) ? 1 : 0) + (((g & 4) == 4)) ? 1 : 0) + (((g & 8) == 8)) ? 1 : 0);\n            if (gf > 0){\n                gf = (1 / gf);\n            };\n            var bf:Number = ((((((b & 1) == 1)) ? 1 : 0 + (((b & 2) == 2)) ? 1 : 0) + (((b & 4) == 4)) ? 1 : 0) + (((b & 8) == 8)) ? 1 : 0);\n            if (bf > 0){\n                bf = (1 / bf);\n            };\n            var af:Number = ((((((a & 1) == 1)) ? 1 : 0 + (((a & 2) == 2)) ? 1 : 0) + (((a & 4) == 4)) ? 1 : 0) + (((a & 8) == 8)) ? 1 : 0);\n            if (af > 0){\n                af = (1 / af);\n            };\n            concat([(((r & 1) == 1)) ? rf : 0, (((r & 2) == 2)) ? rf : 0, (((r & 4) == 4)) ? rf : 0, (((r & 8) == 8)) ? rf : 0, 0, (((g & 1) == 1)) ? gf : 0, (((g & 2) == 2)) ? gf : 0, (((g & 4) == 4)) ? gf : 0, (((g & 8) == 8)) ? gf : 0, 0, (((b & 1) == 1)) ? bf : 0, (((b & 2) == 2)) ? bf : 0, (((b & 4) == 4)) ? bf : 0, (((b & 8) == 8)) ? bf : 0, 0, (((a & 1) == 1)) ? af : 0, (((a & 2) == 2)) ? af : 0, (((a & 4) == 4)) ? af : 0, (((a & 8) == 8)) ? af : 0, 0]);\n        }\n        \n        \n        public function blend( mat:ColorMatrix, amount:Number ):void\n        {\n            var inv_amount:Number = (1 - amount);\n            var i:int = 0;\n            while (i < 20) \n            {\n                matrix[i] = ((inv_amount * Number(matrix[i])) + (amount * Number(mat.matrix[i])));\n                i++;\n            };\n        }\n        \n        public function average( r:Number = ONETHIRD, g:Number = ONETHIRD, b:Number = ONETHIRD ):void\n        {\n            concat([r, g, b, 0, 0, \n            \t\tr, g, b, 0, 0, \n            \t\tr, g, b, 0, 0, \n            \t\t0, 0, 0, 1, 0]);\n        }\n        \n       \tpublic function threshold(threshold:Number, factor:Number=256):void\n        {\n            concat([(LUMA_R * factor), (LUMA_G * factor), (LUMA_B * factor), 0, (-(factor-1) * threshold), \n            \t\t(LUMA_R * factor), (LUMA_G * factor), (LUMA_B * factor), 0, (-(factor-1) * threshold), \n            \t\t(LUMA_R * factor), (LUMA_G * factor), (LUMA_B * factor), 0, (-(factor-1) * threshold), \n            \t\t0, 0, 0, 1, 0]);\n        }\n        \n        public function threshold_rgb(threshold:Number, factor:Number=256):void\n        {\n            concat([factor, 0, 0, 0, (-(factor-1) * threshold), \n            \t\t0, factor, 0, 0, (-(factor-1) * threshold), \n            \t\t0,  0, factor, 0, (-(factor-1) * threshold), \n            \t\t0, 0, 0, 1, 0]);\n        }\n        \n        public function desaturate():void\n        {\n\t\t\tconcat([LUMA_R, LUMA_G, LUMA_B, 0, 0, \n            \t\tLUMA_R, LUMA_G, LUMA_B, 0, 0, \n            \t\tLUMA_R, LUMA_G, LUMA_B, 0, 0, \n            \t\t0, 0, 0, 1, 0]);\n        }\n        \n\t\tpublic function randomize( amount:Number = 1, normalize:Boolean = false ):void\n        {\n            var inv_amount:Number = (1 - amount);\n            var r1:Number = (inv_amount + (amount * (Math.random() - Math.random())));\n            var g1:Number = (amount * (Math.random() - Math.random()));\n            var b1:Number = (amount * (Math.random() - Math.random()));\n            var o1:Number = ((amount * 0xFF) * (Math.random() - Math.random()));\n            var r2:Number = (amount * (Math.random() - Math.random()));\n            var g2:Number = (inv_amount + (amount * (Math.random() - Math.random())));\n            var b2:Number = (amount * (Math.random() - Math.random()));\n            var o2:Number = ((amount * 0xFF) * (Math.random() - Math.random()));\n            var r3:Number = (amount * (Math.random() - Math.random()));\n            var g3:Number = (amount * (Math.random() - Math.random()));\n            var b3:Number = (inv_amount + (amount * (Math.random() - Math.random())));\n            var o3:Number = ((amount * 0xFF) * (Math.random() - Math.random()));\n           \n            concat([r1, g1, b1, 0, o1, \n            \t\tr2, g2, b2, 0, o2, \n            \t\tr3, g3, b3, 0, o3, \n            \t\t0, 0, 0, 1, 0]);\n\t\t\t\t\t\n\t\t\tif ( normalize ) this.normalize();\n        }\n\t\t\n        public function setMultiplicators( red:Number = 1, green:Number = 1, blue:Number = 1, alpha:Number = 1 ):void\n\t\t{\n\t\t\tvar mat:Array =  new Array ( red, 0, 0, 0, 0,\n\t\t\t\t\t\t\t\t\t 0, green, 0, 0, 0,\n\t\t\t\t\t\t\t\t\t 0, 0, blue, 0, 0,\n\t\t\t\t\t\t\t\t\t 0, 0, 0, alpha, 0 );\n\t\t\t\n\t\t\tconcat(mat);\n\t\t}\n\t\t\n\t\tpublic function clearChannels( red:Boolean = false, green:Boolean = false, blue:Boolean = false, alpha:Boolean = false ):void\n\t\t{\n\t\t\tif ( red )\n\t\t\t{\n\t\t\t\tmatrix[0] = matrix[1] = matrix[2] = matrix[3] = matrix[4] = 0;\n\t\t\t}\n\t\t\tif ( green )\n\t\t\t{\n\t\t\t\tmatrix[5] = matrix[6] = matrix[7] = matrix[8] = matrix[9] = 0;\n\t\t\t}\n\t\t\tif ( blue )\n\t\t\t{\n\t\t\t\tmatrix[10] = matrix[11] = matrix[12] = matrix[13] = matrix[14] = 0;\n\t\t\t}\n\t\t\tif ( alpha )\n\t\t\t{\n\t\t\t\tmatrix[15] = matrix[16] = matrix[17] = matrix[18] = matrix[19] = 0;\n\t\t\t}\n\t\t}\n        \n        public function thresholdAlpha( threshold:Number = 0.5, factor:Number = 256):void\n        {\n            concat([1, 0, 0, 0, 0, \n            \t\t0, 1, 0, 0, 0, \n            \t\t0, 0, 1, 0, 0, \n            \t\t0, 0, 0, factor, (-factor * threshold)]);\n        }\n        \n        public function averageRGB2Alpha():void\n        {\n            concat([0, 0, 0, 0, 255, \n            \t\t0, 0, 0, 0, 255, \n            \t\t0, 0, 0, 0, 255, \n            \t\tONETHIRD, ONETHIRD, ONETHIRD, 0, 0]);\n        }\n        \n        public function invertAlpha():void\n        {\n            concat([1, 0, 0, 0, 0, \n            \t\t0, 1, 0, 0, 0, \n            \t\t0, 0, 1, 0, 0, \n            \t\t0, 0, 0, -1, 255]);\n        }\n        \n        public function rgb2Alpha( r:Number = ONETHIRD, g:Number = ONETHIRD, b:Number = ONETHIRD ):void\n        {\n            concat([0, 0, 0, 0, 255, \n            \t\t0, 0, 0, 0, 255, \n            \t\t0, 0, 0, 0, 255, \n            \t\tr, g, b, 0, 0]);\n        }\n        \n        public function setAlpha( alpha:Number = 1 ):void\n        {\n            concat([1, 0, 0, 0, 0, \n            \t\t0, 1, 0, 0, 0, \n            \t\t0, 0, 1, 0, 0, \n            \t\t0, 0, 0, alpha, 0]);\n        }\n        \n\t\tpublic function get filter():ColorMatrixFilter\n        {\n            return new ColorMatrixFilter( matrix );\n        }\n        \n        public function applyFilter( bitmapData:BitmapData ):void\n        {\n        \tbitmapData.applyFilter( bitmapData, bitmapData.rect, new Point(), filter );\n\t\t}\n        \n        public function concat( mat:Array ):void\n\t\t{\n\t\t\tvar temp:Array = [];\n\t\t\tvar i:int = 0;\n\t\t\tvar x:int, y:int;\n\t\t\tfor (y = 0; y < 4; y++ )\n\t\t\t{\n\t\t\t\t\n\t\t\t\tfor (x = 0; x < 5; x++ )\n\t\t\t\t{\n\t\t\t\t\ttemp[ int( i + x) ] =  Number(mat[i  ])      * Number(matrix[x]) + \n\t\t\t\t\t\t\t\t   \t\t   Number(mat[int(i+1)]) * Number(matrix[int(x +  5)]) + \n\t\t\t\t\t\t\t\t   \t\t   Number(mat[int(i+2)]) * Number(matrix[int(x + 10)]) + \n\t\t\t\t\t\t\t\t   \t\t   Number(mat[int(i+3)]) * Number(matrix[int(x + 15)]) +\n\t\t\t\t\t\t\t\t   \t\t   (x == 4 ? Number(mat[int(i+4)]) : 0);\n\t\t\t\t}\n\t\t\t\ti+=5;\n\t\t\t}\n\t\t\t\n\t\t\tmatrix = temp;\n\t\t\t\n\t\t}\n\t\t\n\t\tpublic function rotateRed( degrees:Number = 0 ):void\n        {\n          \trotateColor( degrees, 2, 1 ); \n        }\n        \n        public function rotateGreen( degrees:Number = 0 ):void\n        {\n            rotateColor( degrees, 0, 2 ); \n        }\n        \n        public function rotateBlue( degrees:Number = 0 ):void\n        {\n           rotateColor( degrees, 1, 0 ); \n        }\n        \n        public function normalize():void\n        {\n        \tfor ( var i:int = 0; i < 4; i++ )\n        \t{\n        \t\tvar sum:Number = 0;\n        \t\n        \t\tfor ( var j:int = 0; j < 4; j++ )\n        \t\t{\n        \t\t\tsum += matrix[i*5+j] * matrix[i*5+j];\n        \t\t}\n        \t\t\n        \t\tsum = 1 / Math.sqrt( sum );\n        \t\tif ( sum != 1 )\n        \t\t{\n        \t\t\tfor ( j = 0; j < 4; j++ )\n        \t\t\t{\n        \t\t\t\tmatrix[i*5+j] *= sum;\n        \t\t\t}\n        \t\t}\n\t\t\t}\n        }\n        \n        public function fitRange():void\n        {\n        \tfor ( var i:int = 0; i < 4; i++ )\n        \t{\n        \t\tvar minFactor:Number = 0;\n        \t\tvar maxFactor:Number = 0;\n        \t\t\n        \t\tfor ( var j:int = 0; j < 4; j++ )\n        \t\t{\n        \t\t\tif ( matrix[int(i*5+j)] < 0 ) minFactor += matrix[int(i*5+j)]; \n        \t\t\telse maxFactor += matrix[int(i*5+j)];\n        \t\t}\n        \t\t\n        \t\tvar range:Number =  maxFactor * 255 - minFactor * 255;\n        \t\tvar rangeCorrection:Number = 255 / range;\n        \t\t\n        \t\tif ( rangeCorrection != 1 )\n        \t\t{\n        \t\t\tfor ( j = 0; j < 4; j++ )\n        \t\t\t{\n        \t\t\t\tmatrix[int(i*5+j)] *= rangeCorrection;\n        \t\t\t}\n        \t\t}\n        \t\t\n        \t\tminFactor = 0;\n        \t\tmaxFactor = 0;\n        \t\t\n        \t\tfor ( j = 0; j < 4; j++ )\n        \t\t{\n        \t\t\tif ( matrix[int(i*5+j)] < 0 ) minFactor += matrix[int(i*5+j)]; \n        \t\t\telse maxFactor += matrix[int(i*5+j)];\n        \t\t}\n        \t\t\n        \t\tvar worstMin:Number = minFactor * 255;\n        \t\tvar worstMax:Number = maxFactor * 255;\n        \t\t\n        \t\tmatrix[int(i*5+4)] = - ( worstMin + ( worstMax - worstMin ) * 0.5 - 127.5 );\n        \t}\n        }\n        \n        public function shearRed( green:Number, blue:Number ):void\n        {\n        \tshearColor( 0, 1, green, 2, blue );\n        }\n        \n        public function shearGreen( red:Number, blue:Number ):void\n        {\n        \tshearColor( 1, 0, red, 2, blue );\n        }\n        \n        public function shearBlue( red:Number, green:Number ):void\n        {\n        \tshearColor( 2, 0, red, 1, green );\n        }\n        \n\t\tpublic function applyColorDeficiency( type:String ):void\n\t\t{\n\t\t\tswitch ( type )\n\t\t\t{\n       \t\t\tcase 'Protanopia':\n       \t\t\t\tconcat([0.567,0.433,0,0,0, 0.558,0.442,0,0,0, 0,0.242,0.758,0,0, 0,0,0,1,0]);\n       \t\t\t\tbreak;\n                case 'Protanomaly':\n                \tconcat([0.817,0.183,0,0,0, 0.333,0.667,0,0,0, 0,0.125,0.875,0,0, 0,0,0,1,0]);\n                \tbreak;\n                case 'Deuteranopia':\n               \t \tconcat([0.625,0.375,0,0,0, 0.7,0.3,0,0,0, 0,0.3,0.7,0,0, 0,0,0,1,0]);\n               \t \tbreak;\n                case 'Deuteranomaly':\n                \tconcat([0.8,0.2,0,0,0, 0.258,0.742,0,0,0, 0,0.142,0.858,0,0, 0,0,0,1,0]);\n                \tbreak;\n                case 'Tritanopia':\n                \tconcat([0.95,0.05,0,0,0, 0,0.433,0.567,0,0, 0,0.475,0.525,0,0, 0,0,0,1,0]);\n                \tbreak;\n                case 'Tritanomaly':\n                \tconcat([0.967,0.033,0,0,0, 0,0.733,0.267,0,0, 0,0.183,0.817,0,0, 0,0,0,1,0]);\n                \tbreak;\n                case 'Achromatopsia':\n               \t \tconcat([0.299,0.587,0.114,0,0, 0.299,0.587,0.114,0,0, 0.299,0.587,0.114,0,0, 0,0,0,1,0]);\n               \t \tbreak;\n                case 'Achromatomaly':\n                \tconcat([0.618,0.320,0.062,0,0, 0.163,0.775,0.062,0,0, 0.163,0.320,0.516,0,0, 0,0,0,1,0]);\n                \tbreak;\n                \n\t\t\t}\n    \n\t\t}\n\t\t\n\t\tpublic function RGB2YUV():void\n\t\t{\n\t\t\tconcat([ 0.29900,  0.58700,  0.11400, 0, 0,\n\t\t\t\t\t-0.16874, -0.33126,  0.50000, 0, 128,\n\t\t\t\t\t 0.50000, -0.41869, -0.08131, 0, 128,\n\t\t\t\t\t 0      ,  0      ,  0      , 1, 0  ]);\n\t\t\t\t\t \n\t\t}\n\t\t\n\t\tpublic function YUV2RGB():void\n\t\t{\n\t\t\tconcat([ 1                 , -0.000007154783816076815, 1.4019975662231445    , 0, -179.45477266423404,\n\t\t\t\t\t 1                 , -0.3441331386566162     , -0.7141380310058594   , 0,  135.45870971679688,\n\t\t\t\t\t 1                 ,  1.7720025777816772     , 0.00001542569043522235, 0, -226.8183044444304,\n\t\t\t\t\t 0                 ,  0                      , 0                     , 1,    0  ]);\n\t\t\t\t\t \n\t\t}\n\t\t\n\t\t\n\t\tpublic function RGB2YIQ():void\n\t\t{\n\t\t\tconcat([ 0.2990,  0.5870,  0.1140, 0, 0,\n\t\t\t\t\t 0.595716, -0.274453, -0.321263, 0, 128,\n\t\t\t\t\t 0.211456, -0.522591, -0.311135, 0, 128,\n\t\t\t\t\t 0       , 0        ,  0       , 1, 0  ]);\n\t\t}\t\n\t\t\n\t\t/*\n\t\tpublic function YIQ2RGB():void\n\t\t{\n\t\t\tconcat([ 1, \t\t\t   ,-0.000007154783816076815, 1.4019975662231445    , 0, -179.45477266423404,\n\t\t\t\t\t 1                 , -0.3441331386566162     , -0.7141380310058594   , 0,  135.45870971679688,\n\t\t\t\t\t 1                 ,  1.7720025777816772     , 0.00001542569043522235, 0, -226.8183044444304,\n\t\t\t\t\t 0                 ,  0                      , 0                     , 1,    0  ]);\n\t\t\t\t\t \n\t\t}\n\t\t*/\t\t\n\t\t\n\t\tpublic function autoDesaturate( bitmapData:BitmapData, stretchLevels:Boolean = false, outputToBlueOnly:Boolean = false ):void\n\t\t{\n\t\t\tvar histogram:Vector.<Vector.<Number>> = bitmapData.histogram(bitmapData.rect );\n\t\t\t\n\t\t\tvar sum_r:Number = 0;\n\t\t\tvar sum_g:Number = 0;\n\t\t\tvar sum_b:Number = 0;\n\t\t\tvar min:Number;\n\t\t\tvar max:Number;\n\t\t\tvar minFound:Boolean = false;\n\t\t\tfor ( var i:int = 0; i < 256; i++ )\n\t\t\t{\n\t\t\t\tsum_r += histogram[0][i] * i;\n\t\t\t\tsum_g += histogram[1][i] * i;\n\t\t\t\tsum_b += histogram[2][i] * i;\n\t\t\t\tif ( stretchLevels )\n\t\t\t\t{\n\t\t\t\t\tif ( histogram[0][i] != 0 || histogram[1][i] != 0 || histogram[2][i] != 0 )\n\t\t\t\t\t{\n\t\t\t\t\t\tmax = i\n\t\t\t\t\t\tif ( !minFound )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmin = i;\n\t\t\t\t\t\t\tminFound = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tvar total:Number = sum_r + sum_g + sum_b;\n\t\t\tif ( total == 0 )\n\t\t\t{\n\t\t\t\ttotal = 3;\n\t\t\t\tsum_r = sum_g = sum_b = 3;\n\t\t\t}\n\t\t\t\n\t\t\tsum_r /= total;\n\t\t\tsum_g /= total;\n\t\t\tsum_b /= total;\n\t\t\t\n\t\t\tvar offset:Number = 0;\n\t\t\tif ( stretchLevels && max - min < 255) \n\t\t\t{\n\t\t\t\tvar f:Number = 256 / ((max - min) + 1);\n\t\t\t\tsum_r *= f;\n\t\t\t\tsum_g *= f;\n\t\t\t\tsum_b *= f;\n\t\t\t\toffset = -min;\n\t\t\t}\n\t\t\t\n\t\t\tf = 1 / Math.sqrt(sum_r * sum_r + sum_g * sum_g + sum_b * sum_b);\n\t\t\tsum_r *= f;\n\t\t\tsum_g *= f;\n\t\t\tsum_b *= f;\n\t\t\t\n\t\t\tif ( !outputToBlueOnly )\n\t\t\t\tconcat([sum_r,sum_g,sum_b,0,offset,\n\t\t\t\t\t\tsum_r,sum_g,sum_b,0,offset,\n\t\t\t\t\t\tsum_r,sum_g,sum_b,0,offset,\n\t\t\t\t\t\t0,0,0,1,0]);\n\t\t\telse\n\t\t\t\tconcat([0,0,0,0,0,\n\t\t\t\t\t0,0,0,0,0,\n\t\t\t\t\tsum_r,sum_g,sum_b,0,offset,\n\t\t\t\t\t0,0,0,1,0]);\n\t\t\t\n\t\t}\n\n\t\t\n\t\tpublic function invertMatrix():Boolean\n\t\t{\n\t\t\tvar coeffs:Matrix3D = new Matrix3D( Vector.<Number>( [matrix[0],matrix[1],matrix[2],matrix[3],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  matrix[5],matrix[6],matrix[7],matrix[8],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  matrix[10],matrix[11],matrix[12],matrix[13],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  matrix[15],matrix[16],matrix[17],matrix[18]]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  ) );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  \n\t\t\tvar check:Boolean = coeffs.invert();\n\t\t\tif (!check) return false;\n\t\t\t\n\t\t\tmatrix[0] = coeffs.rawData[0]; \n\t\t\tmatrix[1] = coeffs.rawData[1]; \n\t\t\tmatrix[2] = coeffs.rawData[2]; \n\t\t\tmatrix[3] = coeffs.rawData[3]; \n\t\t\tvar tmp1:Number = -( coeffs.rawData[0] * matrix[4] + coeffs.rawData[1] * matrix[9] + coeffs.rawData[2] * matrix[14] + coeffs.rawData[3] * matrix[15] );\n\t\t\t \n\t\t\tmatrix[5] = coeffs.rawData[4]; \n\t\t\tmatrix[6] = coeffs.rawData[5]; \n\t\t\tmatrix[7] = coeffs.rawData[6]; \n\t\t\tmatrix[8] = coeffs.rawData[7]; \n\t\t\tvar tmp2:Number = -( coeffs.rawData[4] * matrix[4] + coeffs.rawData[5] * matrix[9] + coeffs.rawData[6] * matrix[14] + coeffs.rawData[7] * matrix[15] );\n\t\t\t\n\t\t\tmatrix[10] = coeffs.rawData[8]; \n\t\t\tmatrix[11] = coeffs.rawData[9]; \n\t\t\tmatrix[12] = coeffs.rawData[10]; \n\t\t\tmatrix[13] = coeffs.rawData[11]; \n\t\t\tvar tmp3:Number = -( coeffs.rawData[8] * matrix[4] + coeffs.rawData[9] * matrix[9] + coeffs.rawData[10] * matrix[14] + coeffs.rawData[11] * matrix[15] );\n\t\t\t\n\t\t\tmatrix[15] = coeffs.rawData[12]; \n\t\t\tmatrix[16] = coeffs.rawData[13]; \n\t\t\tmatrix[17] = coeffs.rawData[14]; \n\t\t\tmatrix[18] = coeffs.rawData[15]; \n\t\t\tvar tmp4:Number = -( coeffs.rawData[12] * matrix[4] + coeffs.rawData[13] * matrix[9] + coeffs.rawData[14] * matrix[14] + coeffs.rawData[15] * matrix[15] );\n\t\t\t\n\t\t\tmatrix[4] = tmp1;\n\t\t\tmatrix[9] = tmp2;\n\t\t\tmatrix[14] = tmp3;\n\t\t\tmatrix[19] = tmp4;\n\t\t\t\n\t\t\treturn true;\n\t\t}\n\t\t\n        public function applyMatrix( rgba:uint ):uint\n        {\n        \tvar a:Number = ( rgba >>> 24 ) & 0xff;\n        \tvar r:Number = ( rgba >>> 16 ) & 0xff;\n        \tvar g:Number = ( rgba >>> 8 ) & 0xff;\n       \t\tvar b:Number =  rgba & 0xff;\n       \t\t\n       \t\tvar r2:int = 0.5 + r * matrix[0] + g * matrix[1] + b * matrix[2] + a * matrix[3] + matrix[4];\n       \t\tvar g2:int = 0.5 + r * matrix[5] + g * matrix[6] + b * matrix[7] + a * matrix[8] + matrix[9];\n       \t\tvar b2:int = 0.5 + r * matrix[10] + g * matrix[11] + b * matrix[12] + a * matrix[13] + matrix[14];\n       \t\tvar a2:int = 0.5 + r * matrix[15] + g * matrix[16] + b * matrix[17] + a * matrix[18] + matrix[19];\n       \t\t\n       \t\tif ( a2 < 0 ) a2 = 0;\n       \t\tif ( a2 > 255 ) a2 = 255;\n       \t\tif ( r2 < 0 ) r2 = 0;\n       \t\tif ( r2 > 255 ) r2 = 255;\n       \t\tif ( g2 < 0 ) g2 = 0;\n       \t\tif ( g2 > 255 ) g2 = 255;\n       \t\tif ( b2 < 0 ) b2 = 0;\n       \t\tif ( b2 > 255 ) b2 = 255;\n       \t\t\n       \t\treturn a2<<24 | r2<<16 | g2<<8 | b2;\n        }\n        \n        \n        public function transformVector( values:Array ):void\n        {\n        \tif ( values.length != 4) return;\n        \t\n        \tvar r:Number = values[0] * matrix[0] + values[1] * matrix[1] + values[2] * matrix[2] + values[3] * matrix[3] + matrix[4];\n       \t\tvar g:Number = values[0] * matrix[5] + values[1] * matrix[6] + values[2] * matrix[7] + values[3] * matrix[8] + matrix[9];\n       \t\tvar b:Number = values[0] * matrix[10] + values[1] * matrix[11] + values[2] * matrix[12] + values[3] * matrix[13] + matrix[14];\n       \t\tvar a:Number = values[0] * matrix[15] + values[1] * matrix[16] + values[2] * matrix[17] + values[3] * matrix[18] + matrix[19];\n       \t\t\n       \t\tvalues[0] = r;\n       \t\tvalues[1] = g;\n       \t\tvalues[2] = b;\n       \t\tvalues[3] = a;\n       \t}\n        \n        \n\t\tprivate function initHue():void\n\t\t{\n\t\t\t\n\t\t\t//var greenRotation:Number = 35.0;\n\t\t\tvar greenRotation:Number = 39.182655;\n\n\t\t\tif (!hueInitialized)\n\t\t\t{\n\t\t\t\thueInitialized = true;\n\t\t\t\tpreHue = new ColorMatrix();\n\t\t\t\tpreHue.rotateRed( 45 );\n\t\t\t\tpreHue.rotateGreen(- greenRotation );\n\t\n\t\t\t\tvar lum:Array = [ LUMA_R2, LUMA_G2, LUMA_B2, 1.0 ];\n\t\n\t\t\t\tpreHue.transformVector(lum);\n\t\n\t\t\t\tvar red:Number = lum[0] / lum[2];\n\t\t\t\tvar green:Number = lum[1] / lum[2];\n\t\n\t\t\t\tpreHue.shearBlue(red, green);\n\t\n\t\t\t\tpostHue = new ColorMatrix();\n\t\t\t\tpostHue.shearBlue( -red, -green);\n\t\t\t\tpostHue.rotateGreen(greenRotation);\n\t\t\t\tpostHue.rotateRed(- 45.0 );\n\t\t\t}\n\t\t\t\n  \t\t}\n\t\t\n\t\tprivate function rotateColor( degrees:Number, x:int, y:int ):void\n        {\n        \t  degrees *= RAD;\n\t          var mat:Array = IDENTITY.concat();\n\t\t\t  mat[ x + x * 5 ] = mat[ y + y * 5 ] = Math.cos( degrees );\n\t\t\t  mat[ y + x * 5 ] = Math.sin( degrees );\n\t\t\t  mat[ x + y * 5 ] = -Math.sin( degrees );\n\t\t\t  concat( mat );\n        }\n\t\t\n\t\tprivate function shearColor( x:int, y1:int, d1:Number, y2:int, d2:Number ):void\n\t\t{\n\t\t\tvar mat:Array = IDENTITY.concat();\n\t\t\tmat[ y1 + x * 5 ] = d1;\n\t\t\tmat[ y2 + x * 5 ] = d2;\n\t\t \tconcat( mat );\n\t\t}\n\t\n  \t\n  \t\tpublic function toString():String\n  \t\t{\n  \t\t\treturn matrix.toString();\n  \t\t}\n  \t}\n}"
  },
  {
    "path": "convert_sounds.sh",
    "content": "#! /bin/bash\nfor i in assets/sound/*.{wav,aiff}; \ndo echo \"converting $i ...\"; \nfilename=$(basename \"$i\")\nfilename=\"${filename%.*}\"\nsox \"$i\" assets/sound/${filename}.mp3 rate 44100 reverse silence 1 0.005 0.1% reverse; \ndone\n"
  },
  {
    "path": "convert_tiles.py",
    "content": "#!/usr/bin/python\n\nimport os, sys\nfrom xml.dom import minidom\n\n#--------------------------------------\nBASE_PATH = os.path.dirname(__file__)\nMAP_SRC_DIR = os.path.join(BASE_PATH, 'assets/levels')\nMAP_COMPILED_DIR = os.path.join(BASE_PATH, 'assets/levels/compiled')\nTILE_LAYER_NAMES = [\"ground\"]\n#--------------------------------------\n\ndef compile_levels():\n    \"\"\"\n    Flatten OGMO's XML tilemaps into comma-separated strings. This is\n    done in order to cut down processing at runtime - parsing tilemap\n    data from a list of xml nodes into a CSV is too costly to do at\n    runtime without noticeable lag.\n    \"\"\"\n    \n    for ogmo_filename in [x for x in os.listdir(MAP_SRC_DIR) if x.endswith('.oel')]:\n        ogmo_path = os.path.join(MAP_SRC_DIR, ogmo_filename)\n        ogmo_flattened_path = os.path.join(MAP_COMPILED_DIR, ogmo_filename)\n\n        if os.path.exists(ogmo_flattened_path):\n            if os.path.getmtime(ogmo_flattened_path) > os.path.getmtime(ogmo_path):\n                sys.stdout.write(\"--%s up to date\\n\" % ogmo_flattened_path)\n                continue\n        \n        flatten_ogmo_tilemaps(ogmo_path, ogmo_flattened_path)\n\ndef flatten_ogmo_tilemaps(ogmo_path, ogmo_flattened_path):\n    ogmo_dom = minidom.parse(ogmo_path)\n\n    map_data = dict(ogmo_dom.getElementsByTagName('level')[0].attributes.items())\n    map_data['width'] = ogmo_dom.getElementsByTagName('width')[0].firstChild.data\n    map_data['height'] = ogmo_dom.getElementsByTagName('height')[0].firstChild.data\n    \n    # load tiles\n    for tile_layer_name in TILE_LAYER_NAMES:\n        map_data[tile_layer_name] = dict(ogmo_dom.getElementsByTagName(tile_layer_name)[0].attributes.items())\n        map_data[tile_layer_name]['tiles'] = ''\n\n        tileWidth = int(map_data[tile_layer_name]['tileWidth'])\n        tileHeight = int(map_data[tile_layer_name]['tileHeight'])\n        widthInTiles = int(map_data['width']) / tileWidth\n        heightInTiles = int(map_data['height']) / tileHeight\n\n        tiles = {}\n        for tileNode in ogmo_dom.getElementsByTagName(tile_layer_name)[0].getElementsByTagName('tile'):\n            tileId = tileNode.getAttribute('id')\n            tileX = int(tileNode.getAttribute('x')) / tileWidth\n            tileY = int(tileNode.getAttribute('y')) / tileHeight\n            tiles[str(tileX) + '@' + str(tileY)] = tileId\n\n        for y in range(0, heightInTiles):\n            for x in range(0, widthInTiles):\n                tileId = tiles.get(str(x) + '@' + str(y), '0')\n                map_data[tile_layer_name]['tiles'] += tileId\n                map_data[tile_layer_name]['tiles'] += \",\"\n            map_data[tile_layer_name]['tiles'] += \"\\n\"\n\n        # clear out old tiles node & add a new flattened one\n        ogmo_dom.getElementsByTagName(tile_layer_name)[0].childNodes[:] = [] # shorcut to clear all child nodes\n        flattenedTextNode = ogmo_dom.createTextNode(map_data[tile_layer_name]['tiles'])\n        ogmo_dom.getElementsByTagName(tile_layer_name)[0].appendChild(flattenedTextNode)\n\n    f = open(ogmo_flattened_path, 'w')\n    f.write(ogmo_dom.toxml())\n    f.close()\n    \nif __name__ == '__main__':\n    compile_levels()"
  },
  {
    "path": "convert_weather.py",
    "content": "#! /usr/bin/env python\n\nimport json\nimport re\n\nWEATHER_RX = r'public static const ([A-Z_]*):Object = ({[^\\}]*})'\nPROP_RX = r':([^,\\n]*)([,\\n])'\n\n# weatherfile = open('Weather.as').read()\n# jsonfile = open(\"weathers.json\",'w')\n\n# weathers = {}\n# for a in re.findall(WEATHER_RX, weatherfile, re.DOTALL):\n#     print a[0]\n#     w = re.sub(PROP_RX, r':\"\\1\"\\2', a[1])\n#     w = w.replace(\"'\",'\"')\n#     weathers[a[0]] = json.loads(w)\n#     \n# json.dump(weathers, jsonfile, indent=2)\n# \n\npresets = open('WeatherPresets.as', 'w')\n\npresets.write(\"// THIS FILE IS AUTOGENERATED, MODIFY weathers.json IN STEAD.\\n\\n\")\npresets.write(\"package {\\n\")\npresets.write(\"public class WeatherPresets extends Object{\\n\")\n\nweathers = json.load(open('weathers.json'))\n\nprint \"Found: \\n- \" + '\\n- '.join(sorted(weathers.keys()))\n\nfor weather, content in weathers.items():\n    presets.write(\"\\tpublic static const %s:Object = {\\n\" % (weather))\n    presets.write(',\\n'.join([\"\\t\\t'%s': %s\" % (key,val) for key, val in content.items()]))\n    presets.write('\\n\\t}\\n')\n    \n    \npresets.write(\"}\\n}\")"
  },
  {
    "path": "king.as",
    "content": "package\r\n{\r\n\timport org.flixel.*;\r\n\t\r\n\t[SWF(width=\"864\", height=\"480\", backgroundColor=\"#000000\")]\r\n\t[Frame(factoryClass=\"Preloader\")]\r\n\tpublic class king extends FlxGame\r\n\t{\t\r\n\t\tpublic static const VERSION:String = 'v1.1.3';\r\n\r\n\t\tpublic function king()\r\n\t\t{\t\t\t\r\n\t\t\tsuper(288,160,MenuState,3, 60, 60, false);\r\n\t\t\tFlxG.debug = true;\r\n\t\t}\r\n\r\n\t}\r\n}\r\n"
  },
  {
    "path": "org/flixel/FlxBasic.as",
    "content": "package org.flixel\n{\t\n\t/**\n\t * This is a useful \"generic\" Flixel object.\n\t * Both <code>FlxObject</code> and <code>FlxGroup</code> extend this class,\n\t * as do the plugins.  Has no size, position or graphical data.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxBasic\n\t{\n\t\tstatic internal var _ACTIVECOUNT:uint;\n\t\tstatic internal var _VISIBLECOUNT:uint;\n\n\t\t/**\n\t\t * IDs seem like they could be pretty useful, huh?\n\t\t * They're not actually used for anything yet though.\n\t\t */\n\t\tpublic var ID:int;\n\t\t/**\n\t\t * Controls whether <code>update()</code> and <code>draw()</code> are automatically called by FlxState/FlxGroup.\n\t\t */\n\t\tpublic var exists:Boolean;\n\t\t/**\n\t\t * Controls whether <code>update()</code> is automatically called by FlxState/FlxGroup.\n\t\t */\n\t\tpublic var active:Boolean;\n\t\t/**\n\t\t * Controls whether <code>draw()</code> is automatically called by FlxState/FlxGroup.\n\t\t */\n\t\tpublic var visible:Boolean;\n\t\t/**\n\t\t * Useful state for many game objects - \"dead\" (!alive) vs alive.\n\t\t * <code>kill()</code> and <code>revive()</code> both flip this switch (along with exists, but you can override that).\n\t\t */\n\t\tpublic var alive:Boolean;\n\t\t/**\n\t\t * An array of camera objects that this object will use during <code>draw()</code>.\n\t\t * This value will initialize itself during the first draw to automatically\n\t\t * point at the main camera list out in <code>FlxG</code> unless you already set it.\n\t\t * You can also change it afterward too, very flexible!\n\t\t */\n\t\tpublic var cameras:Array;\n\t\t/**\n\t\t * Setting this to true will prevent the object from appearing\n\t\t * when the visual debug mode in the debugger overlay is toggled on.\n\t\t */\n\t\tpublic var ignoreDrawDebug:Boolean;\n\t\t\n\t\t/**\n\t\t * Instantiate the basic flixel object.\n\t\t */\n\t\tpublic function FlxBasic()\n\t\t{\n\t\t\tID = -1;\n\t\t\texists = true;\n\t\t\tactive = true;\n\t\t\tvisible = true;\n\t\t\talive = true;\n\t\t\tignoreDrawDebug = false;\n\t\t}\n\n\t\t/**\n\t\t * Override this function to null out variables or manually call\n\t\t * <code>destroy()</code> on class members if necessary.\n\t\t * Don't forget to call <code>super.destroy()</code>!\n\t\t */\n\t\tpublic function destroy():void {}\n\t\t\n\t\t/**\n\t\t * Pre-update is called right before <code>update()</code> on each object in the game loop.\n\t\t */\n\t\tpublic function preUpdate():void\n\t\t{\n\t\t\t_ACTIVECOUNT++;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Override this function to update your class's position and appearance.\n\t\t * This is where most of your game rules and behavioral code will go.\n\t\t */\n\t\tpublic function update():void\n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Post-update is called right after <code>update()</code> on each object in the game loop.\n\t\t */\n\t\tpublic function postUpdate():void\n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Override this function to control how the object is drawn.\n\t\t * Overriding <code>draw()</code> is rarely necessary, but can be very useful.\n\t\t */\n\t\tpublic function draw():void\n\t\t{\n\t\t\tif(cameras == null)\n\t\t\t\tcameras = FlxG.cameras;\n\t\t\tvar camera:FlxCamera;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = cameras.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tcamera = cameras[i++];\n\t\t\t\t_VISIBLECOUNT++;\n\t\t\t\tif(FlxG.visualDebug && !ignoreDrawDebug)\n\t\t\t\t\tdrawDebug(camera);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Override this function to draw custom \"debug mode\" graphics to the\n\t\t * specified camera while the debugger's visual mode is toggled on.\n\t\t * \n\t\t * @param\tCamera\tWhich camera to draw the debug visuals to.\n\t\t */\n\t\tpublic function drawDebug(Camera:FlxCamera=null):void\n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Handy function for \"killing\" game objects.\n\t\t * Default behavior is to flag them as nonexistent AND dead.\n\t\t * However, if you want the \"corpse\" to remain in the game,\n\t\t * like to animate an effect or whatever, you should override this,\n\t\t * setting only alive to false, and leaving exists true.\n\t\t */\n\t\tpublic function kill():void\n\t\t{\n\t\t\talive = false;\n\t\t\texists = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Handy function for bringing game objects \"back to life\". Just sets alive and exists back to true.\n\t\t * In practice, this function is most often called by <code>FlxObject.reset()</code>.\n\t\t */\n\t\tpublic function revive():void\n\t\t{\n\t\t\talive = true;\n\t\t\texists = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Convert object to readable string name.  Useful for debugging, save games, etc.\n\t\t */\n\t\tpublic function toString():String\n\t\t{\n\t\t\treturn FlxU.getClassName(this,true);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxButton.as",
    "content": "package org.flixel\n{\n\timport flash.events.MouseEvent;\n\t\n\t/**\n\t * A simple button class that calls a function when clicked by the mouse.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxButton extends FlxSprite\n\t{\n\t\t[Embed(source=\"data/button.png\")] protected var ImgDefaultButton:Class;\n\t\t[Embed(source=\"data/beep.mp3\")] protected var SndBeep:Class;\n\t\t\n\t\t/**\n\t\t * Used with public variable <code>status</code>, means not highlighted or pressed.\n\t\t */\n\t\tstatic public var NORMAL:uint = 0;\n\t\t/**\n\t\t * Used with public variable <code>status</code>, means highlighted (usually from mouse over).\n\t\t */\n\t\tstatic public var HIGHLIGHT:uint = 1;\n\t\t/**\n\t\t * Used with public variable <code>status</code>, means pressed (usually from mouse click).\n\t\t */\n\t\tstatic public var PRESSED:uint = 2;\n\t\t\n\t\t/**\n\t\t * The text that appears on the button.\n\t\t */\n\t\tpublic var label:FlxText;\n\t\t/**\n\t\t * Controls the offset (from top left) of the text from the button.\n\t\t */\n\t\tpublic var labelOffset:FlxPoint;\n\t\t/**\n\t\t * This function is called when the button is released.\n\t\t * We recommend assigning your main button behavior to this function\n\t\t * via the <code>FlxButton</code> constructor.\n\t\t */\n\t\tpublic var onUp:Function;\n\t\t/**\n\t\t * This function is called when the button is pressed down.\n\t\t */\n\t\tpublic var onDown:Function;\n\t\t/**\n\t\t * This function is called when the mouse goes over the button.\n\t\t */\n\t\tpublic var onOver:Function;\n\t\t/**\n\t\t * This function is called when the mouse leaves the button area.\n\t\t */\n\t\tpublic var onOut:Function;\n\t\t/**\n\t\t * Shows the current state of the button.\n\t\t */\n\t\tpublic var status:uint;\n\t\t/**\n\t\t * Set this to play a sound when the mouse goes over the button.\n\t\t * We recommend using the helper function setSounds()!\n\t\t */\n\t\tpublic var soundOver:FlxSound;\n\t\t/**\n\t\t * Set this to play a sound when the mouse leaves the button.\n\t\t * We recommend using the helper function setSounds()!\n\t\t */\n\t\tpublic var soundOut:FlxSound;\n\t\t/**\n\t\t * Set this to play a sound when the button is pressed down.\n\t\t * We recommend using the helper function setSounds()!\n\t\t */\n\t\tpublic var soundDown:FlxSound;\n\t\t/**\n\t\t * Set this to play a sound when the button is released.\n\t\t * We recommend using the helper function setSounds()!\n\t\t */\n\t\tpublic var soundUp:FlxSound;\n\n\t\t/**\n\t\t * Used for checkbox-style behavior.\n\t\t */\n\t\tprotected var _onToggle:Boolean;\n\t\t\n\t\t/**\n\t\t * Tracks whether or not the button is currently pressed.\n\t\t */\n\t\tprotected var _pressed:Boolean;\n\t\t/**\n\t\t * Whether or not the button has initialized itself yet.\n\t\t */\n\t\tprotected var _initialized:Boolean;\n\t\t\n\t\t/**\n\t\t * Creates a new <code>FlxButton</code> object with a gray background\n\t\t * and a callback function on the UI thread.\n\t\t * \n\t\t * @param\tX\t\t\tThe X position of the button.\n\t\t * @param\tY\t\t\tThe Y position of the button.\n\t\t * @param\tLabel\t\tThe text that you want to appear on the button.\n\t\t * @param\tOnClick\t\tThe function to call whenever the button is clicked.\n\t\t */\n\t\tpublic function FlxButton(X:Number=0,Y:Number=0,Label:String=null,OnClick:Function=null)\n\t\t{\n\t\t\tsuper(X,Y);\n\t\t\tif(Label != null)\n\t\t\t{\n\t\t\t\tlabel = new FlxText(0,0,80,Label);\n\t\t\t\tlabel.setFormat(null,8,0x333333,\"center\");\n\t\t\t\tlabelOffset = new FlxPoint(-1,3);\n\t\t\t}\n\t\t\tloadGraphic(ImgDefaultButton,true,false,80,20);\n\t\t\t\n\t\t\tonUp = OnClick;\n\t\t\tonDown = null;\n\t\t\tonOut = null;\n\t\t\tonOver = null;\n\t\t\t\n\t\t\tsoundOver = null;\n\t\t\tsoundOut = null;\n\t\t\tsoundDown = null;\n\t\t\tsoundUp = null;\n\n\t\t\tstatus = NORMAL;\n\t\t\t_onToggle = false;\n\t\t\t_pressed = false;\n\t\t\t_initialized = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by the game state when state is changed (if this object belongs to the state)\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tif(FlxG.stage != null)\n\t\t\t\tFlxG.stage.removeEventListener(MouseEvent.MOUSE_UP, handleMouseUp);\n\t\t\tif(label != null)\n\t\t\t{\n\t\t\t\tlabel.destroy();\n\t\t\t\tlabel = null;\n\t\t\t}\n\t\t\tonUp = null;\n\t\t\tonDown = null;\n\t\t\tonOut = null;\n\t\t\tonOver = null;\n\t\t\tif(soundOver != null)\n\t\t\t\tsoundOver.destroy();\n\t\t\tif(soundOut != null)\n\t\t\t\tsoundOut.destroy();\n\t\t\tif(soundDown != null)\n\t\t\t\tsoundDown.destroy();\n\t\t\tif(soundUp != null)\n\t\t\t\tsoundUp.destroy();\n\t\t\tsuper.destroy();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Since button uses its own mouse handler for thread reasons,\n\t\t * we run a little pre-check here to make sure that we only add\n\t\t * the mouse handler when it is actually safe to do so.\n\t\t */\n\t\toverride public function preUpdate():void\n\t\t{\n\t\t\tsuper.preUpdate();\n\t\t\t\n\t\t\tif(!_initialized)\n\t\t\t{\n\t\t\t\tif(FlxG.stage != null)\n\t\t\t\t{\n\t\t\t\t\tFlxG.stage.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);\n\t\t\t\t\t_initialized = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by the game loop automatically, handles mouseover and click detection.\n\t\t */\n\t\toverride public function update():void\n\t\t{\n\t\t\tupdateButton(); //Basic button logic\n\n\t\t\t//Default button appearance is to simply update\n\t\t\t// the label appearance based on animation frame.\n\t\t\tif(label == null)\n\t\t\t\treturn;\n\t\t\tswitch(frame)\n\t\t\t{\n\t\t\t\tcase HIGHLIGHT:\t//Extra behavior to accomodate checkbox logic.\n\t\t\t\t\tlabel.alpha = 1.0;\n\t\t\t\t\tbreak;\n\t\t\t\tcase PRESSED:\n\t\t\t\t\tlabel.alpha = 0.5;\n\t\t\t\t\tlabel.y++;\n\t\t\t\t\tbreak;\n\t\t\t\tcase NORMAL:\n\t\t\t\tdefault:\n\t\t\t\t\tlabel.alpha = 0.8;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Basic button update logic\n\t\t */\n\t\tprotected function updateButton():void\n\t\t{\n\t\t\t//Figure out if the button is highlighted or pressed or what\n\t\t\t// (ignore checkbox behavior for now).\n\t\t\tif(FlxG.mouse.visible)\n\t\t\t{\n\t\t\t\tif(cameras == null)\n\t\t\t\t\tcameras = FlxG.cameras;\n\t\t\t\tvar camera:FlxCamera;\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar l:uint = cameras.length;\n\t\t\t\tvar offAll:Boolean = true;\n\t\t\t\twhile(i < l)\n\t\t\t\t{\n\t\t\t\t\tcamera = cameras[i++] as FlxCamera;\n\t\t\t\t\tFlxG.mouse.getWorldPosition(camera,_point);\n\t\t\t\t\tif(overlapsPoint(_point,true,camera))\n\t\t\t\t\t{\n\t\t\t\t\t\toffAll = false;\n\t\t\t\t\t\tif(FlxG.mouse.justPressed())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus = PRESSED;\n\t\t\t\t\t\t\tif(onDown != null)\n\t\t\t\t\t\t\t\tonDown();\n\t\t\t\t\t\t\tif(soundDown != null)\n\t\t\t\t\t\t\t\tsoundDown.play(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(status == NORMAL)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus = HIGHLIGHT;\n\t\t\t\t\t\t\tif(onOver != null)\n\t\t\t\t\t\t\t\tonOver();\n\t\t\t\t\t\t\tif(soundOver != null)\n\t\t\t\t\t\t\t\tsoundOver.play(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(offAll)\n\t\t\t\t{\n\t\t\t\t\tif(status != NORMAL)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(onOut != null)\n\t\t\t\t\t\t\tonOut();\n\t\t\t\t\t\tif(soundOut != null)\n\t\t\t\t\t\t\tsoundOut.play(true);\n\t\t\t\t\t}\n\t\t\t\t\tstatus = NORMAL;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t\t//Then if the label and/or the label offset exist,\n\t\t\t// position them to match the button.\n\t\t\tif(label != null)\n\t\t\t{\n\t\t\t\tlabel.x = x;\n\t\t\t\tlabel.y = y;\n\t\t\t}\n\t\t\tif(labelOffset != null)\n\t\t\t{\n\t\t\t\tlabel.x += labelOffset.x;\n\t\t\t\tlabel.y += labelOffset.y;\n\t\t\t}\n\t\t\t\n\t\t\t//Then pick the appropriate frame of animation\n\t\t\tif((status == HIGHLIGHT) && _onToggle)\n\t\t\t\tframe = NORMAL;\n\t\t\telse\n\t\t\t\tframe = status;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Just draws the button graphic and text label to the screen.\n\t\t */\n\t\toverride public function draw():void\n\t\t{\n\t\t\tsuper.draw();\n\t\t\tif(label != null)\n\t\t\t{\n\t\t\t\tlabel.scrollFactor = scrollFactor;\n\t\t\t\tlabel.cameras = cameras;\n\t\t\t\tlabel.draw();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Updates the size of the text field to match the button.\n\t\t */\n\t\toverride protected function resetHelpers():void\n\t\t{\n\t\t\tsuper.resetHelpers();\n\t\t\tif(label != null)\n\t\t\t\tlabel.width = width;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set sounds to play during mouse-button interactions.\n\t\t * These operations can be done manually as well, and the public\n\t\t * sound variables can be used after this for more fine-tuning,\n\t\t * such as positional audio, etc.\n\t\t * \n\t\t * @param SoundOver\t\t\tWhat embedded sound effect to play when the mouse goes over the button. Default is null, or no sound.\n\t\t * @param SoundOverVolume\tHow load the that sound should be.\n\t\t * @param SoundOut\t\t\tWhat embedded sound effect to play when the mouse leaves the button area. Default is null, or no sound.\n\t\t * @param SoundOutVolume\tHow load the that sound should be.\n\t\t * @param SoundDown\t\t\tWhat embedded sound effect to play when the mouse presses the button down. Default is null, or no sound.\n\t\t * @param SoundDownVolume\tHow load the that sound should be.\n\t\t * @param SoundUp\t\t\tWhat embedded sound effect to play when the mouse releases the button. Default is null, or no sound.\n\t\t * @param SoundUpVolume\t\tHow load the that sound should be.\n\t\t */\n\t\tpublic function setSounds(SoundOver:Class=null, SoundOverVolume:Number=1.0, SoundOut:Class=null, SoundOutVolume:Number=1.0, SoundDown:Class=null, SoundDownVolume:Number=1.0, SoundUp:Class=null, SoundUpVolume:Number=1.0):void\n\t\t{\n\t\t\tif(SoundOver != null)\n\t\t\t\tsoundOver = FlxG.loadSound(SoundOver, SoundOverVolume);\n\t\t\tif(SoundOut != null)\n\t\t\t\tsoundOut = FlxG.loadSound(SoundOut, SoundOutVolume);\n\t\t\tif(SoundDown != null)\n\t\t\t\tsoundDown = FlxG.loadSound(SoundDown, SoundDownVolume);\n\t\t\tif(SoundUp != null)\n\t\t\t\tsoundUp = FlxG.loadSound(SoundUp, SoundUpVolume);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Use this to toggle checkbox-style behavior.\n\t\t */\n\t\tpublic function get on():Boolean\n\t\t{\n\t\t\treturn _onToggle;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set on(On:Boolean):void\n\t\t{\n\t\t\t_onToggle = On;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function for handling the actual callback call (for UI thread dependent calls like <code>FlxU.openURL()</code>).\n\t\t */\n\t\tprotected function handleMouseUp(event:MouseEvent):void\n\t\t{\n\t\t\tif(!exists || !visible || !active || (status != PRESSED))\n\t\t\t\treturn;\n\t\t\tif(onUp != null)\n\t\t\t\tonUp();\n\t\t\tif(soundUp != null)\n\t\t\t\tsoundUp.play(true);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxCamera.as",
    "content": "package org.flixel\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Sprite;\n\timport flash.geom.ColorTransform;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\n\t/**\n\t * The camera class is used to display the game's visuals in the Flash player.\n\t * By default one camera is created automatically, that is the same size as the Flash player.\n\t * You can add more cameras or even replace the main camera using utilities in <code>FlxG</code>.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class FlxCamera extends FlxBasic\n\t{\n\t\t/**\n\t\t * Camera \"follow\" style preset: camera has no deadzone, just tracks the focus object directly.\n\t\t */\n\t\tstatic public const STYLE_LOCKON:uint = 0;\n\t\t/**\n\t\t * Camera \"follow\" style preset: camera deadzone is narrow but tall.\n\t\t */\n\t\tstatic public const STYLE_PLATFORMER:uint = 1;\n\t\t/**\n\t\t * Camera \"follow\" style preset: camera deadzone is a medium-size square around the focus object.\n\t\t */\n\t\tstatic public const STYLE_TOPDOWN:uint = 2;\n\t\t/**\n\t\t * Camera \"follow\" style preset: camera deadzone is a small square around the focus object.\n\t\t */\n\t\tstatic public const STYLE_TOPDOWN_TIGHT:uint = 3;\n\t\t\n\t\t/**\n\t\t * Camera \"shake\" effect preset: shake camera on both the X and Y axes.\n\t\t */\n\t\tstatic public const SHAKE_BOTH_AXES:uint = 0;\n\t\t/**\n\t\t * Camera \"shake\" effect preset: shake camera on the X axis only.\n\t\t */\n\t\tstatic public const SHAKE_HORIZONTAL_ONLY:uint = 1;\n\t\t/**\n\t\t * Camera \"shake\" effect preset: shake camera on the Y axis only.\n\t\t */\n\t\tstatic public const SHAKE_VERTICAL_ONLY:uint = 2;\n\t\t\n\t\t/**\n\t\t * While you can alter the zoom of each camera after the fact,\n\t\t * this variable determines what value the camera will start at when created.\n\t\t */\n\t\tstatic public var defaultZoom:Number;\n\t\t\n\t\t/**\n\t\t * The X position of this camera's display.  Zoom does NOT affect this number.\n\t\t * Measured in pixels from the left side of the flash window.\n\t\t */\n\t\tpublic var x:Number;\n\t\t/**\n\t\t * The Y position of this camera's display.  Zoom does NOT affect this number.\n\t\t * Measured in pixels from the top of the flash window.\n\t\t */\n\t\tpublic var y:Number;\n\t\t/**\n\t\t * How wide the camera display is, in game pixels.\n\t\t */\n\t\tpublic var width:uint;\n\t\t/**\n\t\t * How tall the camera display is, in game pixels.\n\t\t */\n\t\tpublic var height:uint;\n\t\t/**\n\t\t * Tells the camera to follow this <code>FlxObject</code> object around.\n\t\t */\n\t\tpublic var target:FlxObject;\n\t\t/**\n\t\t * You can assign a \"dead zone\" to the camera in order to better control its movement.\n\t\t * The camera will always keep the focus object inside the dead zone,\n\t\t * unless it is bumping up against the bounds rectangle's edges.\n\t\t * The deadzone's coordinates are measured from the camera's upper left corner in game pixels.\n\t\t * For rapid prototyping, you can use the preset deadzones (e.g. <code>STYLE_PLATFORMER</code>) with <code>follow()</code>.\n\t\t */\n\t\tpublic var deadzone:FlxRect;\n\t\t/**\n\t\t * The edges of the camera's range, i.e. where to stop scrolling.\n\t\t * Measured in game pixels and world coordinates.\n\t\t */\n\t\tpublic var bounds:FlxRect;\n\t\t\n\t\t/**\n\t\t * Stores the basic parallax scrolling values.\n\t\t */\n\t\tpublic var scroll:FlxPoint;\n\t\t/**\n\t\t * The actual bitmap data of the camera display itself.\n\t\t */\n\t\tpublic var buffer:BitmapData;\n\t\t/**\n\t\t * The natural background color of the camera. Defaults to FlxG.bgColor.\n\t\t * NOTE: can be transparent for crazy FX!\n\t\t */\n\t\tpublic var bgColor:uint;\n\t\t/**\n\t\t * Sometimes it's easier to just work with a <code>FlxSprite</code> than it is to work\n\t\t * directly with the <code>BitmapData</code> buffer.  This sprite reference will\n\t\t * allow you to do exactly that.\n\t\t */\n\t\tpublic var screen:FlxSprite;\n\t\t\n\t\t/**\n\t\t * Indicates how far the camera is zoomed in.\n\t\t */\n\t\tprotected var _zoom:Number;\n\t\t/**\n\t\t * Internal, to help avoid costly allocations.\n\t\t */\n\t\tprotected var _point:FlxPoint;\n\t\t/**\n\t\t * Internal, help with color transforming the flash bitmap.\n\t\t */\n\t\tprotected var _color:uint;\n\t\t\n\t\t/**\n\t\t * Internal, used to render buffer to screen space.\n\t\t */\n\t\tprotected var _flashBitmap:Bitmap;\n\t\t/**\n\t\t * Internal, used to render buffer to screen space.\n\t\t */\n\t\tinternal var _flashSprite:Sprite;\n\t\t/**\n\t\t * Internal, used to render buffer to screen space.\n\t\t */\n\t\tinternal var _flashOffsetX:Number;\n\t\t/**\n\t\t * Internal, used to render buffer to screen space.\n\t\t */\n\t\tinternal var _flashOffsetY:Number;\n\t\t/**\n\t\t * Internal, used to render buffer to screen space.\n\t\t */\n\t\tprotected var _flashRect:Rectangle;\n\t\t/**\n\t\t * Internal, used to render buffer to screen space.\n\t\t */\n\t\tprotected var _flashPoint:Point;\n\t\t/**\n\t\t * Internal, used to control the \"flash\" special effect.\n\t\t */\n\t\tprotected var _fxFlashColor:uint;\n\t\t/**\n\t\t * Internal, used to control the \"flash\" special effect.\n\t\t */\n\t\tprotected var _fxFlashDuration:Number;\n\t\t/**\n\t\t * Internal, used to control the \"flash\" special effect.\n\t\t */\n\t\tprotected var _fxFlashComplete:Function;\n\t\t/**\n\t\t * Internal, used to control the \"flash\" special effect.\n\t\t */\n\t\tprotected var _fxFlashAlpha:Number;\n\t\t/**\n\t\t * Internal, used to control the \"fade\" special effect.\n\t\t */\n\t\tprotected var _fxFadeColor:uint;\n\t\t/**\n\t\t * Internal, used to control the \"fade\" special effect.\n\t\t */\n\t\tprotected var _fxFadeDuration:Number;\n\t\t/**\n\t\t * Internal, used to control the \"fade\" special effect.\n\t\t */\n\t\tprotected var _fxFadeComplete:Function;\n\t\t/**\n\t\t * Internal, used to control the \"fade\" special effect.\n\t\t */\n\t\tprotected var _fxFadeAlpha:Number;\n\t\t/**\n\t\t * Internal, used to control the \"shake\" special effect.\n\t\t */\n\t\tprotected var _fxShakeIntensity:Number;\n\t\t/**\n\t\t * Internal, used to control the \"shake\" special effect.\n\t\t */\n\t\tprotected var _fxShakeDuration:Number;\n\t\t/**\n\t\t * Internal, used to control the \"shake\" special effect.\n\t\t */\n\t\tprotected var _fxShakeComplete:Function;\n\t\t/**\n\t\t * Internal, used to control the \"shake\" special effect.\n\t\t */\n\t\tprotected var _fxShakeOffset:FlxPoint;\n\t\t/**\n\t\t * Internal, used to control the \"shake\" special effect.\n\t\t */\n\t\tprotected var _fxShakeDirection:uint;\n\t\t/**\n\t\t * Internal helper variable for doing better wipes/fills between renders.\n\t\t */\n\t\tprotected var _fill:BitmapData;\n\t\t\n\t\t/**\n\t\t * Instantiates a new camera at the specified location, with the specified size and zoom level.\n\t\t * \n\t\t * @param X\t\t\tX location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.\n\t\t * @param Y\t\t\tY location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.\n\t\t * @param Width\t\tThe width of the camera display in pixels.\n\t\t * @param Height\tThe height of the camera display in pixels.\n\t\t * @param Zoom\t\tThe initial zoom level of the camera.  A zoom level of 2 will make all pixels display at 2x resolution.\n\t\t */\n\t\tpublic function FlxCamera(X:int,Y:int,Width:int,Height:int,Zoom:Number=0)\n\t\t{\n\t\t\tx = X;\n\t\t\ty = Y;\n\t\t\twidth = Width;\n\t\t\theight = Height;\n\t\t\ttarget = null;\n\t\t\tdeadzone = null;\n\t\t\tscroll = new FlxPoint();\n\t\t\t_point = new FlxPoint();\n\t\t\tbounds = null;\n\t\t\tscreen = new FlxSprite();\n\t\t\tscreen.makeGraphic(width,height,0,true);\n\t\t\tscreen.setOriginToCorner();\n\t\t\tbuffer = screen.pixels;\n\t\t\tbgColor = FlxG.bgColor;\n\t\t\t_color = 0xffffff;\n\n\t\t\t_flashBitmap = new Bitmap(buffer);\n\t\t\t_flashBitmap.x = -width*0.5;\n\t\t\t_flashBitmap.y = -height*0.5;\n\t\t\t_flashSprite = new Sprite();\n\t\t\tzoom = Zoom; //sets the scale of flash sprite, which in turn loads flashoffset values\n\t\t\t_flashOffsetX = width*0.5*zoom;\n\t\t\t_flashOffsetY = height*0.5*zoom;\n\t\t\t_flashSprite.x = x + _flashOffsetX;\n\t\t\t_flashSprite.y = y + _flashOffsetY;\n\t\t\t_flashSprite.addChild(_flashBitmap);\n\t\t\t_flashRect = new Rectangle(0,0,width,height);\n\t\t\t_flashPoint = new Point();\n\t\t\t\n\t\t\t_fxFlashColor = 0;\n\t\t\t_fxFlashDuration = 0.0;\n\t\t\t_fxFlashComplete = null;\n\t\t\t_fxFlashAlpha = 0.0;\n\t\t\t\n\t\t\t_fxFadeColor = 0;\n\t\t\t_fxFadeDuration = 0.0;\n\t\t\t_fxFadeComplete = null;\n\t\t\t_fxFadeAlpha = 0.0;\n\t\t\t\n\t\t\t_fxShakeIntensity = 0.0;\n\t\t\t_fxShakeDuration = 0.0;\n\t\t\t_fxShakeComplete = null;\n\t\t\t_fxShakeOffset = new FlxPoint();\n\t\t\t_fxShakeDirection = 0;\n\t\t\t\n\t\t\t_fill = new BitmapData(width,height,true,0);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tscreen.destroy();\n\t\t\tscreen = null;\n\t\t\ttarget = null;\n\t\t\tscroll = null;\n\t\t\tdeadzone = null;\n\t\t\tbounds = null;\n\t\t\tbuffer = null;\n\t\t\t_flashBitmap = null;\n\t\t\t_flashRect = null;\n\t\t\t_flashPoint = null;\n\t\t\t_fxFlashComplete = null;\n\t\t\t_fxFadeComplete = null;\n\t\t\t_fxShakeComplete = null;\n\t\t\t_fxShakeOffset = null;\n\t\t\t_fill = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Updates the camera scroll as well as special effects like screen-shake or fades.\n\t\t */\n\t\toverride public function update():void\n\t\t{\n\t\t\t//Either follow the object closely, \n\t\t\t//or doublecheck our deadzone and update accordingly.\n\t\t\tif(target != null)\n\t\t\t{\n\t\t\t\tif(deadzone == null)\n\t\t\t\t\tfocusOn(target.getMidpoint(_point));\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvar edge:Number;\n\t\t\t\t\tvar targetX:Number = target.x + ((target.x > 0)?0.0000001:-0.0000001);\n\t\t\t\t\tvar targetY:Number = target.y + ((target.y > 0)?0.0000001:-0.0000001);\n\t\t\t\t\t\n\t\t\t\t\tedge = targetX - deadzone.x;\n\t\t\t\t\tif(scroll.x > edge)\n\t\t\t\t\t\tscroll.x = edge;\n\t\t\t\t\tedge = targetX + target.width - deadzone.x - deadzone.width;\n\t\t\t\t\tif(scroll.x < edge)\n\t\t\t\t\t\tscroll.x = edge;\n\t\t\t\t\t\n\t\t\t\t\tedge = targetY - deadzone.y;\n\t\t\t\t\tif(scroll.y > edge)\n\t\t\t\t\t\tscroll.y = edge;\n\t\t\t\t\tedge = targetY + target.height - deadzone.y - deadzone.height;\n\t\t\t\t\tif(scroll.y < edge)\n\t\t\t\t\t\tscroll.y = edge;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//Make sure we didn't go outside the camera's bounds\n\t\t\tif(bounds != null)\n\t\t\t{\n\t\t\t\tif(scroll.x < bounds.left)\n\t\t\t\t\tscroll.x = bounds.left;\n\t\t\t\tif(scroll.x > bounds.right - width)\n\t\t\t\t\tscroll.x = bounds.right - width;\n\t\t\t\tif(scroll.y < bounds.top)\n\t\t\t\t\tscroll.y = bounds.top;\n\t\t\t\tif(scroll.y > bounds.bottom - height)\n\t\t\t\t\tscroll.y = bounds.bottom - height;\n\t\t\t}\n\t\t\t\n\t\t\t//Update the \"flash\" special effect\n\t\t\tif(_fxFlashAlpha > 0.0)\n\t\t\t{\n\t\t\t\t_fxFlashAlpha -= FlxG.elapsed/_fxFlashDuration;\n\t\t\t\tif((_fxFlashAlpha <= 0) && (_fxFlashComplete != null))\n\t\t\t\t\t_fxFlashComplete();\n\t\t\t}\n\t\t\t\n\t\t\t//Update the \"fade\" special effect\n\t\t\tif((_fxFadeAlpha > 0.0) && (_fxFadeAlpha < 1.0))\n\t\t\t{\n\t\t\t\t_fxFadeAlpha += FlxG.elapsed/_fxFadeDuration;\n\t\t\t\tif(_fxFadeAlpha >= 1.0)\n\t\t\t\t{\n\t\t\t\t\t_fxFadeAlpha = 1.0;\n\t\t\t\t\tif(_fxFadeComplete != null)\n\t\t\t\t\t\t_fxFadeComplete();\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//Update the \"shake\" special effect\n\t\t\tif(_fxShakeDuration > 0)\n\t\t\t{\n\t\t\t\t_fxShakeDuration -= FlxG.elapsed;\n\t\t\t\tif(_fxShakeDuration <= 0)\n\t\t\t\t{\n\t\t\t\t\t_fxShakeOffset.make();\n\t\t\t\t\tif(_fxShakeComplete != null)\n\t\t\t\t\t\t_fxShakeComplete();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif((_fxShakeDirection == SHAKE_BOTH_AXES) || (_fxShakeDirection == SHAKE_HORIZONTAL_ONLY))\n\t\t\t\t\t\t_fxShakeOffset.x = (FlxG.random()*_fxShakeIntensity*width*2-_fxShakeIntensity*width)*_zoom;\n\t\t\t\t\tif((_fxShakeDirection == SHAKE_BOTH_AXES) || (_fxShakeDirection == SHAKE_VERTICAL_ONLY))\n\t\t\t\t\t\t_fxShakeOffset.y = (FlxG.random()*_fxShakeIntensity*height*2-_fxShakeIntensity*height)*_zoom;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Tells this camera object what <code>FlxObject</code> to track.\n\t\t * \n\t\t * @param\tTarget\t\tThe object you want the camera to track.  Set to null to not follow anything.\n\t\t * @param\tStyle\t\tLeverage one of the existing \"deadzone\" presets.  If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling <code>follow()</code>.\n\t\t */\n\t\tpublic function follow(Target:FlxObject, Style:uint=STYLE_LOCKON):void\n\t\t{\n\t\t\ttarget = Target;\n\t\t\tvar helper:Number;\n\t\t\tswitch(Style)\n\t\t\t{\n\t\t\t\tcase STYLE_PLATFORMER:\n\t\t\t\t\tvar w:Number = width/8;\n\t\t\t\t\tvar h:Number = height/3;\n\t\t\t\t\tdeadzone = new FlxRect((width-w)/2,(height-h)/2 - h*0.25,w,h);\n\t\t\t\t\tbreak;\n\t\t\t\tcase STYLE_TOPDOWN:\n\t\t\t\t\thelper = FlxU.max(width,height)/4;\n\t\t\t\t\tdeadzone = new FlxRect((width-helper)/2,(height-helper)/2,helper,helper);\n\t\t\t\t\tbreak;\n\t\t\t\tcase STYLE_TOPDOWN_TIGHT:\n\t\t\t\t\thelper = FlxU.max(width,height)/8;\n\t\t\t\t\tdeadzone = new FlxRect((width-helper)/2,(height-helper)/2,helper,helper);\n\t\t\t\t\tbreak;\n\t\t\t\tcase STYLE_LOCKON:\n\t\t\t\tdefault:\n\t\t\t\t\tdeadzone = null;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Move the camera focus to this location instantly.\n\t\t * \n\t\t * @param\tPoint\t\tWhere you want the camera to focus.\n\t\t */\n\t\tpublic function focusOn(Point:FlxPoint):void\n\t\t{\n\t\t\tPoint.x += (Point.x > 0)?0.0000001:-0.0000001;\n\t\t\tPoint.y += (Point.y > 0)?0.0000001:-0.0000001;\n\t\t\tscroll.make(Point.x - width*0.5,Point.y - height*0.5);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Specify the boundaries of the level or where the camera is allowed to move.\n\t\t * \n\t\t * @param\tX\t\t\t\tThe smallest X value of your level (usually 0).\n\t\t * @param\tY\t\t\t\tThe smallest Y value of your level (usually 0).\n\t\t * @param\tWidth\t\t\tThe largest X value of your level (usually the level width).\n\t\t * @param\tHeight\t\t\tThe largest Y value of your level (usually the level height).\n\t\t * @param\tUpdateWorld\t\tWhether the global quad-tree's dimensions should be updated to match (default: false).\n\t\t */\n\t\tpublic function setBounds(X:Number=0, Y:Number=0, Width:Number=0, Height:Number=0, UpdateWorld:Boolean=false):void\n\t\t{\n\t\t\tif(bounds == null)\n\t\t\t\tbounds = new FlxRect();\n\t\t\tbounds.make(X,Y,Width,Height);\n\t\t\tif(UpdateWorld)\n\t\t\t\tFlxG.worldBounds.copyFrom(bounds);\n\t\t\tupdate();\n\t\t}\n\t\t\n\t\t/**\n\t\t * The screen is filled with this color and gradually returns to normal.\n\t\t * \n\t\t * @param\tColor\t\tThe color you want to use.\n\t\t * @param\tDuration\tHow long it takes for the flash to fade.\n\t\t * @param\tOnComplete\tA function you want to run when the flash finishes.\n\t\t * @param\tForce\t\tForce the effect to reset.\n\t\t */\n\t\tpublic function flash(Color:uint=0xffffffff, Duration:Number=1, OnComplete:Function=null, Force:Boolean=false):void\n\t\t{\n\t\t\tif(!Force && (_fxFlashAlpha > 0.0))\n\t\t\t\treturn;\n\t\t\t_fxFlashColor = Color;\n\t\t\tif(Duration <= 0)\n\t\t\t\tDuration = Number.MIN_VALUE;\n\t\t\t_fxFlashDuration = Duration;\n\t\t\t_fxFlashComplete = OnComplete;\n\t\t\t_fxFlashAlpha = 1.0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The screen is gradually filled with this color.\n\t\t * \n\t\t * @param\tColor\t\tThe color you want to use.\n\t\t * @param\tDuration\tHow long it takes for the fade to finish.\n\t\t * @param\tOnComplete\tA function you want to run when the fade finishes.\n\t\t * @param\tForce\t\tForce the effect to reset.\n\t\t */\n\t\tpublic function fade(Color:uint=0xff000000, Duration:Number=1, OnComplete:Function=null, Force:Boolean=false):void\n\t\t{\n\t\t\tif(!Force && (_fxFadeAlpha > 0.0))\n\t\t\t\treturn;\n\t\t\t_fxFadeColor = Color;\n\t\t\tif(Duration <= 0)\n\t\t\t\tDuration = Number.MIN_VALUE;\n\t\t\t_fxFadeDuration = Duration;\n\t\t\t_fxFadeComplete = OnComplete;\n\t\t\t_fxFadeAlpha = Number.MIN_VALUE;\n\t\t}\n\t\t\n\t\t/**\n\t\t * A simple screen-shake effect.\n\t\t * \n\t\t * @param\tIntensity\tPercentage of screen size representing the maximum distance that the screen can move while shaking.\n\t\t * @param\tDuration\tThe length in seconds that the shaking effect should last.\n\t\t * @param\tOnComplete\tA function you want to run when the shake effect finishes.\n\t\t * @param\tForce\t\tForce the effect to reset (default = true, unlike flash() and fade()!).\n\t\t * @param\tDirection\tWhether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).\n\t\t */\n\t\tpublic function shake(Intensity:Number=0.05, Duration:Number=0.5, OnComplete:Function=null, Force:Boolean=true, Direction:uint=SHAKE_BOTH_AXES):void\n\t\t{\n\t\t\tif(!Force && ((_fxShakeOffset.x != 0) || (_fxShakeOffset.y != 0)))\n\t\t\t\treturn;\n\t\t\t_fxShakeIntensity = Intensity;\n\t\t\t_fxShakeDuration = Duration;\n\t\t\t_fxShakeComplete = OnComplete;\n\t\t\t_fxShakeDirection = Direction;\n\t\t\t_fxShakeOffset.make();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Just turns off all the camera effects instantly.\n\t\t */\n\t\tpublic function stopFX():void\n\t\t{\n\t\t\t_fxFlashAlpha = 0.0;\n\t\t\t_fxFadeAlpha = 0.0;\n\t\t\t_fxShakeDuration = 0;\n\t\t\t_flashSprite.x = x + width*0.5;\n\t\t\t_flashSprite.y = y + height*0.5;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Copy the bounds, focus object, and deadzone info from an existing camera.\n\t\t * \n\t\t * @param\tCamera\tThe camera you want to copy from.\n\t\t * \n\t\t * @return\tA reference to this <code>FlxCamera</code> object.\n\t\t */\n\t\tpublic function copyFrom(Camera:FlxCamera):FlxCamera\n\t\t{\n\t\t\tif(Camera.bounds == null)\n\t\t\t\tbounds = null;\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(bounds == null)\n\t\t\t\t\tbounds = new FlxRect();\n\t\t\t\tbounds.copyFrom(Camera.bounds);\n\t\t\t}\n\t\t\ttarget = Camera.target;\n\t\t\tif(target != null)\n\t\t\t{\n\t\t\t\tif(Camera.deadzone == null)\n\t\t\t\t\tdeadzone = null;\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(deadzone == null)\n\t\t\t\t\t\tdeadzone = new FlxRect();\n\t\t\t\t\tdeadzone.copyFrom(Camera.deadzone);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The zoom level of this camera. 1 = 1:1, 2 = 2x zoom, etc.\n\t\t */\n\t\tpublic function get zoom():Number\n\t\t{\n\t\t\treturn _zoom;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set zoom(Zoom:Number):void\n\t\t{\n\t\t\tif(Zoom == 0)\n\t\t\t\t_zoom = defaultZoom;\n\t\t\telse\n\t\t\t\t_zoom = Zoom;\n\t\t\tsetScale(_zoom,_zoom);\n\t\t}\n\t\t\n\t\t/**\n\t\t * The alpha value of this camera display (a Number between 0.0 and 1.0).\n\t\t */\n\t\tpublic function get alpha():Number\n\t\t{\n\t\t\treturn _flashBitmap.alpha;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set alpha(Alpha:Number):void\n\t\t{\n\t\t\t_flashBitmap.alpha = Alpha;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The angle of the camera display (in degrees).\n\t\t * Currently yields weird display results,\n\t\t * since cameras aren't nested in an extra display object yet.\n\t\t */\n\t\tpublic function get angle():Number\n\t\t{\n\t\t\treturn _flashSprite.rotation;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set angle(Angle:Number):void\n\t\t{\n\t\t\t_flashSprite.rotation = Angle;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The color tint of the camera display.\n\t\t */\n\t\tpublic function get color():uint\n\t\t{\n\t\t\treturn _color;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set color(Color:uint):void\n\t\t{\n\t\t\t_color = Color;\n\t\t\tvar colorTransform:ColorTransform = _flashBitmap.transform.colorTransform;\n\t\t\tcolorTransform.redMultiplier = (_color>>16)*0.00392;\n\t\t\tcolorTransform.greenMultiplier = (_color>>8&0xff)*0.00392;\n\t\t\tcolorTransform.blueMultiplier = (_color&0xff)*0.00392;\n\t\t\t_flashBitmap.transform.colorTransform = colorTransform;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Whether the camera display is smooth and filtered, or chunky and pixelated.\n\t\t * Default behavior is chunky-style.\n\t\t */\n\t\tpublic function get antialiasing():Boolean\n\t\t{\n\t\t\treturn _flashBitmap.smoothing;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set antialiasing(Antialiasing:Boolean):void\n\t\t{\n\t\t\t_flashBitmap.smoothing = Antialiasing;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The scale of the camera object, irrespective of zoom.\n\t\t * Currently yields weird display results,\n\t\t * since cameras aren't nested in an extra display object yet.\n\t\t */\n\t\tpublic function getScale():FlxPoint\n\t\t{\n\t\t\treturn _point.make(_flashSprite.scaleX,_flashSprite.scaleY);\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function setScale(X:Number,Y:Number):void\n\t\t{\n\t\t\t_flashSprite.scaleX = X;\n\t\t\t_flashSprite.scaleY = Y;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fetches a reference to the Flash <code>Sprite</code> object\n\t\t * that contains the camera display in the Flash display list.\n\t\t * Uses include 3D projection, advanced display list modification, and more.\n\t\t * NOTE: We don't recommend modifying this directly unless you are\n\t\t * fairly experienced.  For simple changes to the camera display,\n\t\t * like scaling, rotation, and color tinting, we recommend\n\t\t * using the existing <code>FlxCamera</code> variables.\n\t\t * \n\t\t * @return\tA Flash <code>Sprite</code> object containing the camera display.\n\t\t */\n\t\tpublic function getContainerSprite():Sprite\n\t\t{\n\t\t\treturn _flashSprite;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fill the camera with the specified color.\n\t\t * \n\t\t * @param\tColor\t\tThe color to fill with in 0xAARRGGBB hex format.\n\t\t * @param\tBlendAlpha\tWhether to blend the alpha value or just wipe the previous contents.  Default is true.\n\t\t */\n\t\tpublic function fill(Color:uint,BlendAlpha:Boolean=true):void\n\t\t{\n\t\t\t_fill.fillRect(_flashRect,Color);\n\t\t\tbuffer.copyPixels(_fill,_flashRect,_flashPoint,null,null,BlendAlpha);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal helper function, handles the actual drawing of all the special effects.\n\t\t */\n\t\tinternal function drawFX():void\n\t\t{\n\t\t\tvar alphaComponent:Number;\n\t\t\t\n\t\t\t//Draw the \"flash\" special effect onto the buffer\n\t\t\tif(_fxFlashAlpha > 0.0)\n\t\t\t{\n\t\t\t\talphaComponent = _fxFlashColor>>24;\n\t\t\t\tfill((uint(((alphaComponent <= 0)?0xff:alphaComponent)*_fxFlashAlpha)<<24)+(_fxFlashColor&0x00ffffff));\n\t\t\t}\n\t\t\t\n\t\t\t//Draw the \"fade\" special effect onto the buffer\n\t\t\tif(_fxFadeAlpha > 0.0)\n\t\t\t{\n\t\t\t\talphaComponent = _fxFadeColor>>24;\n\t\t\t\tfill((uint(((alphaComponent <= 0)?0xff:alphaComponent)*_fxFadeAlpha)<<24)+(_fxFadeColor&0x00ffffff));\n\t\t\t}\n\t\t\t\n\t\t\tif((_fxShakeOffset.x != 0) || (_fxShakeOffset.y != 0))\n\t\t\t{\n\t\t\t\t_flashSprite.x = x + _flashOffsetX + _fxShakeOffset.x;\n\t\t\t\t_flashSprite.y = y + _flashOffsetY + _fxShakeOffset.y;\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxEmitter.as",
    "content": "package org.flixel\n{\n\n\t/**\n\t * <code>FlxEmitter</code> is a lightweight particle emitter.\n\t * It can be used for one-time explosions or for\n\t * continuous fx like rain and fire.  <code>FlxEmitter</code>\n\t * is not optimized or anything; all it does is launch\n\t * <code>FlxParticle</code> objects out at set intervals\n\t * by setting their positions and velocities accordingly.\n\t * It is easy to use and relatively efficient,\n\t * relying on <code>FlxGroup</code>'s RECYCLE POWERS.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxEmitter extends FlxGroup\n\t{\n\t\t/**\n\t\t * The X position of the top left corner of the emitter in world space.\n\t\t */\n\t\tpublic var x:Number;\n\t\t/**\n\t\t * The Y position of the top left corner of emitter in world space.\n\t\t */\n\t\tpublic var y:Number;\n\t\t/**\n\t\t * The width of the emitter.  Particles can be randomly generated from anywhere within this box.\n\t\t */\n\t\tpublic var width:Number;\n\t\t/**\n\t\t * The height of the emitter.  Particles can be randomly generated from anywhere within this box.\n\t\t */\n\t\tpublic var height:Number;\n\t\t/**\n\t\t * The minimum possible velocity of a particle.\n\t\t * The default value is (-100,-100).\n\t\t */\n\t\tpublic var minParticleSpeed:FlxPoint;\n\t\t/**\n\t\t * The maximum possible velocity of a particle.\n\t\t * The default value is (100,100).\n\t\t */\n\t\tpublic var maxParticleSpeed:FlxPoint;\n\t\t/**\n\t\t * The X and Y drag component of particles launched from the emitter.\n\t\t */\n\t\tpublic var particleDrag:FlxPoint;\n\t\t/**\n\t\t * The minimum possible angular velocity of a particle.  The default value is -360.\n\t\t * NOTE: rotating particles are more expensive to draw than non-rotating ones!\n\t\t */\n\t\tpublic var minRotation:Number;\n\t\t/**\n\t\t * The maximum possible angular velocity of a particle.  The default value is 360.\n\t\t * NOTE: rotating particles are more expensive to draw than non-rotating ones!\n\t\t */\n\t\tpublic var maxRotation:Number;\n\t\t/**\n\t\t * Sets the <code>acceleration.y</code> member of each particle to this value on launch.\n\t\t */\n\t\tpublic var gravity:Number;\n\t\t/**\n\t\t * Determines whether the emitter is currently emitting particles.\n\t\t * It is totally safe to directly toggle this.\n\t\t */\n\t\tpublic var on:Boolean;\n\t\t/**\n\t\t * How often a particle is emitted (if emitter is started with Explode == false).\n\t\t */\n\t\tpublic var frequency:Number;\n\t\t/**\n\t\t * How long each particle lives once it is emitted.\n\t\t * Set lifespan to 'zero' for particles to live forever.\n\t\t */\n\t\tpublic var lifespan:Number;\n\t\t/**\n\t\t * How much each particle should bounce.  1 = full bounce, 0 = no bounce.\n\t\t */\n\t\tpublic var bounce:Number;\n\t\t/**\n\t\t * Set your own particle class type here.\n\t\t * Default is <code>FlxParticle</code>.\n\t\t */\n\t\tpublic var particleClass:Class;\n\t\t/**\n\t\t * Internal helper for deciding how many particles to launch.\n\t\t */\n\t\tprotected var _quantity:uint;\n\t\t/**\n\t\t * Internal helper for the style of particle emission (all at once, or one at a time).\n\t\t */\n\t\tprotected var _explode:Boolean;\n\t\t/**\n\t\t * Internal helper for deciding when to launch particles or kill them.\n\t\t */\n\t\tprotected var _timer:Number;\n\t\t/**\n\t\t * Internal counter for figuring out how many particles to launch.\n\t\t */\n\t\tprotected var _counter:uint;\n\t\t/**\n\t\t * Internal point object, handy for reusing for memory mgmt purposes.\n\t\t */\n\t\tprotected var _point:FlxPoint;\n\t\t\n\t\t/**\n\t\t * Creates a new <code>FlxEmitter</code> object at a specific position.\n\t\t * Does NOT automatically generate or attach particles!\n\t\t * \n\t\t * @param\tX\t\tThe X position of the emitter.\n\t\t * @param\tY\t\tThe Y position of the emitter.\n\t\t * @param\tSize\tOptional, specifies a maximum capacity for this emitter.\n\t\t */\n\t\tpublic function FlxEmitter(X:Number=0, Y:Number=0, Size:Number=0)\n\t\t{\n\t\t\tsuper(Size);\n\t\t\tx = X;\n\t\t\ty = Y;\n\t\t\twidth = 0;\n\t\t\theight = 0;\n\t\t\tminParticleSpeed = new FlxPoint(-100,-100);\n\t\t\tmaxParticleSpeed = new FlxPoint(100,100);\n\t\t\tminRotation = -360;\n\t\t\tmaxRotation = 360;\n\t\t\tgravity = 0;\n\t\t\tparticleClass = null;\n\t\t\tparticleDrag = new FlxPoint();\n\t\t\tfrequency = 0.1;\n\t\t\tlifespan = 3;\n\t\t\tbounce = 0;\n\t\t\t_quantity = 0;\n\t\t\t_counter = 0;\n\t\t\t_explode = true;\n\t\t\ton = false;\n\t\t\t_point = new FlxPoint();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tminParticleSpeed = null;\n\t\t\tmaxParticleSpeed = null;\n\t\t\tparticleDrag = null;\n\t\t\tparticleClass = null;\n\t\t\t_point = null;\n\t\t\tsuper.destroy();\n\t\t}\n\t\t\n\t\t/**\n\t\t * This function generates a new array of particle sprites to attach to the emitter.\n\t\t * \n\t\t * @param\tGraphics\t\tIf you opted to not pre-configure an array of FlxSprite objects, you can simply pass in a particle image or sprite sheet.\n\t\t * @param\tQuantity\t\tThe number of particles to generate when using the \"create from image\" option.\n\t\t * @param\tBakedRotations\tHow many frames of baked rotation to use (boosts performance).  Set to zero to not use baked rotations.\n\t\t * @param\tMultiple\t\tWhether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!).\n\t\t * @param\tCollide\t\t\tWhether the particles should be flagged as not 'dead' (non-colliding particles are higher performance).  0 means no collisions, 0-1 controls scale of particle's bounding box.\n\t\t * \n\t\t * @return\tThis FlxEmitter instance (nice for chaining stuff together, if you're into that).\n\t\t */\n\t\tpublic function makeParticles(Graphics:Class, Quantity:uint=50, BakedRotations:uint=16, Multiple:Boolean=false, Collide:Number=0.8):FlxEmitter\n\t\t{\n\t\t\tmaxSize = Quantity;\n\t\t\t\n\t\t\tvar totalFrames:uint = 1;\n\t\t\tif(Multiple)\n\t\t\t{ \n\t\t\t\tvar sprite:FlxSprite = new FlxSprite();\n\t\t\t\tsprite.loadGraphic(Graphics,true);\n\t\t\t\ttotalFrames = sprite.frames;\n\t\t\t\tsprite.destroy();\n\t\t\t}\n\n\t\t\tvar randomFrame:uint;\n\t\t\tvar particle:FlxParticle;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < Quantity)\n\t\t\t{\n\t\t\t\tif(particleClass == null)\n\t\t\t\t\tparticle = new FlxParticle();\n\t\t\t\telse\n\t\t\t\t\tparticle = new particleClass();\n\t\t\t\tif(Multiple)\n\t\t\t\t{\n\t\t\t\t\trandomFrame = FlxG.random()*totalFrames;\n\t\t\t\t\tif(BakedRotations > 0)\n\t\t\t\t\t\tparticle.loadRotatedGraphic(Graphics,BakedRotations,randomFrame);\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tparticle.loadGraphic(Graphics,true);\n\t\t\t\t\t\tparticle.frame = randomFrame;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(BakedRotations > 0)\n\t\t\t\t\t\tparticle.loadRotatedGraphic(Graphics,BakedRotations);\n\t\t\t\t\telse\n\t\t\t\t\t\tparticle.loadGraphic(Graphics);\n\t\t\t\t}\n\t\t\t\tif(Collide > 0)\n\t\t\t\t{\n\t\t\t\t\tparticle.width *= Collide;\n\t\t\t\t\tparticle.height *= Collide;\n\t\t\t\t\tparticle.centerOffsets();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tparticle.allowCollisions = FlxObject.NONE;\n\t\t\t\tparticle.exists = false;\n\t\t\t\tadd(particle);\n\t\t\t\ti++;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called automatically by the game loop, decides when to launch particles and when to \"die\".\n\t\t */\n\t\toverride public function update():void\n\t\t{\n\t\t\tif(on)\n\t\t\t{\n\t\t\t\tif(_explode)\n\t\t\t\t{\n\t\t\t\t\ton = false;\n\t\t\t\t\tvar i:uint = 0;\n\t\t\t\t\tvar l:uint = _quantity;\n\t\t\t\t\tif((l <= 0) || (l > length))\n\t\t\t\t\t\tl = length;\n\t\t\t\t\twhile(i < l)\n\t\t\t\t\t{\n\t\t\t\t\t\temitParticle();\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t\t_quantity = 0;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_timer += FlxG.elapsed;\n\t\t\t\t\twhile((frequency > 0) && (_timer > frequency) && on)\n\t\t\t\t\t{\n\t\t\t\t\t\t_timer -= frequency;\n\t\t\t\t\t\temitParticle();\n\t\t\t\t\t\tif((_quantity > 0) && (++_counter >= _quantity))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ton = false;\n\t\t\t\t\t\t\t_quantity = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tsuper.update();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to turn off all the particles and the emitter.\n\t\t */\n\t\toverride public function kill():void\n\t\t{\n\t\t\ton = false;\n\t\t\tsuper.kill();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to start emitting particles.\n\t\t * \n\t\t * @param\tExplode\t\tWhether the particles should all burst out at once.\n\t\t * @param\tLifespan\tHow long each particle lives once emitted. 0 = forever.\n\t\t * @param\tFrequency\tIgnored if Explode is set to true. Frequency is how often to emit a particle. 0 = never emit, 0.1 = 1 particle every 0.1 seconds, 5 = 1 particle every 5 seconds.\n\t\t * @param\tQuantity\tHow many particles to launch. 0 = \"all of the particles\".\n\t\t */\n\t\tpublic function start(Explode:Boolean=true,Lifespan:Number=0,Frequency:Number=0.1,Quantity:uint=0):void\n\t\t{\n\t\t\trevive();\n\t\t\tvisible = true;\n\t\t\ton = true;\n\t\t\t\n\t\t\t_explode = Explode;\n\t\t\tlifespan = Lifespan;\n\t\t\tfrequency = Frequency;\n\t\t\t_quantity += Quantity;\n\t\t\t\n\t\t\t_counter = 0;\n\t\t\t_timer = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * This function can be used both internally and externally to emit the next particle.\n\t\t */\n\t\tpublic function emitParticle():void\n\t\t{\n\t\t\tvar particle:FlxParticle = recycle(FlxParticle) as FlxParticle;\n\t\t\tparticle.lifespan = lifespan;\n\t\t\tparticle.elasticity = bounce;\n\t\t\tparticle.reset(x - (particle.width>>1) + FlxG.random()*width, y - (particle.height>>1) + FlxG.random()*height);\n\t\t\tparticle.visible = true;\n\t\t\t\n\t\t\tif(minParticleSpeed.x != maxParticleSpeed.x)\n\t\t\t\tparticle.velocity.x = minParticleSpeed.x + FlxG.random()*(maxParticleSpeed.x-minParticleSpeed.x);\n\t\t\telse\n\t\t\t\tparticle.velocity.x = minParticleSpeed.x;\n\t\t\tif(minParticleSpeed.y != maxParticleSpeed.y)\n\t\t\t\tparticle.velocity.y = minParticleSpeed.y + FlxG.random()*(maxParticleSpeed.y-minParticleSpeed.y);\n\t\t\telse\n\t\t\t\tparticle.velocity.y = minParticleSpeed.y;\n\t\t\tparticle.acceleration.y = gravity;\n\t\t\t\n\t\t\tif(minRotation != maxRotation)\n\t\t\t\tparticle.angularVelocity = minRotation + FlxG.random()*(maxRotation-minRotation);\n\t\t\telse\n\t\t\t\tparticle.angularVelocity = minRotation;\n\t\t\tif(particle.angularVelocity != 0)\n\t\t\t\tparticle.angle = FlxG.random()*360-180;\n\t\t\t\n\t\t\tparticle.drag.x = particleDrag.x;\n\t\t\tparticle.drag.y = particleDrag.y;\n\t\t\tparticle.onEmit();\n\t\t}\n\t\t\n\t\t/**\n\t\t * A more compact way of setting the width and height of the emitter.\n\t\t * \n\t\t * @param\tWidth\tThe desired width of the emitter (particles are spawned randomly within these dimensions).\n\t\t * @param\tHeight\tThe desired height of the emitter.\n\t\t */\n\t\tpublic function setSize(Width:uint,Height:uint):void\n\t\t{\n\t\t\twidth = Width;\n\t\t\theight = Height;\n\t\t}\n\t\t\n\t\t/**\n\t\t * A more compact way of setting the X velocity range of the emitter.\n\t\t * \n\t\t * @param\tMin\t\tThe minimum value for this range.\n\t\t * @param\tMax\t\tThe maximum value for this range.\n\t\t */\n\t\tpublic function setXSpeed(Min:Number=0,Max:Number=0):void\n\t\t{\n\t\t\tminParticleSpeed.x = Min;\n\t\t\tmaxParticleSpeed.x = Max;\n\t\t}\n\t\t\n\t\t/**\n\t\t * A more compact way of setting the Y velocity range of the emitter.\n\t\t * \n\t\t * @param\tMin\t\tThe minimum value for this range.\n\t\t * @param\tMax\t\tThe maximum value for this range.\n\t\t */\n\t\tpublic function setYSpeed(Min:Number=0,Max:Number=0):void\n\t\t{\n\t\t\tminParticleSpeed.y = Min;\n\t\t\tmaxParticleSpeed.y = Max;\n\t\t}\n\t\t\n\t\t/**\n\t\t * A more compact way of setting the angular velocity constraints of the emitter.\n\t\t * \n\t\t * @param\tMin\t\tThe minimum value for this range.\n\t\t * @param\tMax\t\tThe maximum value for this range.\n\t\t */\n\t\tpublic function setRotation(Min:Number=0,Max:Number=0):void\n\t\t{\n\t\t\tminRotation = Min;\n\t\t\tmaxRotation = Max;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Change the emitter's midpoint to match the midpoint of a <code>FlxObject</code>.\n\t\t * \n\t\t * @param\tObject\t\tThe <code>FlxObject</code> that you want to sync up with.\n\t\t */\n\t\tpublic function at(Object:FlxObject):void\n\t\t{\n\t\t\tObject.getMidpoint(_point);\n\t\t\tx = _point.x - (width>>1);\n\t\t\ty = _point.y - (height>>1);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxG.as",
    "content": "package org.flixel\n{\n\timport flash.display.BitmapData;\n\timport flash.display.Graphics;\n\timport flash.display.Sprite;\n\timport flash.display.Stage;\n\timport flash.geom.Matrix;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.plugin.DebugPathDisplay;\n\timport org.flixel.plugin.TimerManager;\n\timport org.flixel.system.FlxDebugger;\n\timport org.flixel.system.FlxQuadTree;\n\timport org.flixel.system.input.*;\n\t\n\t/**\n\t * This is a global helper class full of useful functions for audio,\n\t * input, basic info, and the camera system among other things.\n\t * Utilities for maths and color and things can be found in <code>FlxU</code>.\n\t * <code>FlxG</code> is specifically for Flixel-specific properties.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxG\n\t{\n\t\t/**\n\t\t * If you build and maintain your own version of flixel,\n\t\t * you can give it your own name here.\n\t\t */\n\t\tstatic public var LIBRARY_NAME:String = \"flixel\";\n\t\t/**\n\t\t * Assign a major version to your library.\n\t\t * Appears before the decimal in the console.\n\t\t */\n\t\tstatic public var LIBRARY_MAJOR_VERSION:uint = 2;\n\t\t/**\n\t\t * Assign a minor version to your library.\n\t\t * Appears after the decimal in the console.\n\t\t */\n\t\tstatic public var LIBRARY_MINOR_VERSION:uint = 55;\n\t\t\n\t\t/**\n\t\t * Debugger overlay layout preset: Wide but low windows at the bottom of the screen.\n\t\t */\n\t\tstatic public const DEBUGGER_STANDARD:uint = 0;\n\t\t/**\n\t\t * Debugger overlay layout preset: Tiny windows in the screen corners.\n\t\t */\n\t\tstatic public const DEBUGGER_MICRO:uint = 1;\n\t\t/**\n\t\t * Debugger overlay layout preset: Large windows taking up bottom half of screen.\n\t\t */\n\t\tstatic public const DEBUGGER_BIG:uint = 2;\n\t\t/**\n\t\t * Debugger overlay layout preset: Wide but low windows at the top of the screen.\n\t\t */\n\t\tstatic public const DEBUGGER_TOP:uint = 3;\n\t\t/**\n\t\t * Debugger overlay layout preset: Large windows taking up left third of screen.\n\t\t */\n\t\tstatic public const DEBUGGER_LEFT:uint = 4;\n\t\t/**\n\t\t * Debugger overlay layout preset: Large windows taking up right third of screen.\n\t\t */\n\t\tstatic public const DEBUGGER_RIGHT:uint = 5;\n\t\t\n\t\t/**\n\t\t * Some handy color presets.  Less glaring than pure RGB full values.\n\t\t * Primarily used in the visual debugger mode for bounding box displays.\n\t\t * Red is used to indicate an active, movable, solid object.\n\t\t */\n\t\tstatic public const RED:uint = 0xffff0012;\n\t\t/**\n\t\t * Green is used to indicate solid but immovable objects.\n\t\t */\n\t\tstatic public const GREEN:uint = 0xff00f225;\n\t\t/**\n\t\t * Blue is used to indicate non-solid objects.\n\t\t */\n\t\tstatic public const BLUE:uint = 0xff0090e9;\n\t\t/**\n\t\t * Pink is used to indicate objects that are only partially solid, like one-way platforms.\n\t\t */\n\t\tstatic public const PINK:uint = 0xfff01eff;\n\t\t/**\n\t\t * White... for white stuff.\n\t\t */\n\t\tstatic public const WHITE:uint = 0xffffffff;\n\t\t/**\n\t\t * And black too.\n\t\t */\n\t\tstatic public const BLACK:uint = 0xff000000;\n\n\t\t/**\n\t\t * Internal tracker for game object.\n\t\t */\n\t\tstatic internal var _game:FlxGame;\n\t\t/**\n\t\t * Handy shared variable for implementing your own pause behavior.\n\t\t */\n\t\tstatic public var paused:Boolean;\n\t\t/**\n\t\t * Whether you are running in Debug or Release mode.\n\t\t * Set automatically by <code>FlxPreloader</code> during startup.\n\t\t */\n\t\tstatic public var debug:Boolean;\n\t\t\n\t\t/**\n\t\t * Represents the amount of time in seconds that passed since last frame.\n\t\t */\n\t\tstatic public var elapsed:Number;\n\t\t/**\n\t\t * How fast or slow time should pass in the game; default is 1.0.\n\t\t */\n\t\tstatic public var timeScale:Number;\n\t\t/**\n\t\t * The width of the screen in game pixels.\n\t\t */\n\t\tstatic public var width:uint;\n\t\t/**\n\t\t * The height of the screen in game pixels.\n\t\t */\n\t\tstatic public var height:uint;\n\t\t/**\n\t\t * The dimensions of the game world, used by the quad tree for collisions and overlap checks.\n\t\t */\n\t\tstatic public var worldBounds:FlxRect;\n\t\t/**\n\t\t * How many times the quad tree should divide the world on each axis.\n\t\t * Generally, sparse collisions can have fewer divisons,\n\t\t * while denser collision activity usually profits from more.\n\t\t * Default value is 6.\n\t\t */\n\t\tstatic public var worldDivisions:uint;\n\t\t/**\n\t\t * Whether to show visual debug displays or not.\n\t\t * Default = false.\n\t\t */\n\t\tstatic public var visualDebug:Boolean;\n\t\t/**\n\t\t * Setting this to true will disable/skip stuff that isn't necessary for mobile platforms like Android. [BETA]\n\t\t */\n\t\tstatic public var mobile:Boolean; \n\t\t/**\n\t\t * The global random number generator seed (for deterministic behavior in recordings and saves).\n\t\t */\n\t\tstatic public var globalSeed:Number;\n\t\t/**\n\t\t * <code>FlxG.levels</code> and <code>FlxG.scores</code> are generic\n\t\t * global variables that can be used for various cross-state stuff.\n\t\t */\n\t\tstatic public var levels:Array;\n\t\tstatic public var level:int;\n\t\tstatic public var scores:Array;\n\t\tstatic public var score:int;\n\t\t/**\n\t\t * <code>FlxG.saves</code> is a generic bucket for storing\n\t\t * FlxSaves so you can access them whenever you want.\n\t\t */\n\t\tstatic public var saves:Array; \n\t\tstatic public var save:int;\n\n\t\t/**\n\t\t * A reference to a <code>FlxMouse</code> object.  Important for input!\n\t\t */\n\t\tstatic public var mouse:Mouse;\n\t\t/**\n\t\t * A reference to a <code>FlxKeyboard</code> object.  Important for input!\n\t\t */\n\t\tstatic public var keys:Keyboard;\n\t\t\n\t\t/**\n\t\t * A handy container for a background music object.\n\t\t */\n\t\tstatic public var music:FlxSound;\n\t\t/**\n\t\t * A list of all the sounds being played in the game.\n\t\t */\n\t\tstatic public var sounds:FlxGroup;\n\t\t/**\n\t\t * Whether or not the game sounds are muted.\n\t\t */\n\t\tstatic public var mute:Boolean;\n\t\t/**\n\t\t * Internal volume level, used for global sound control.\n\t\t */\n\t\tstatic protected var _volume:Number;\n\n\t\t/**\n\t\t * An array of <code>FlxCamera</code> objects that are used to draw stuff.\n\t\t * By default flixel creates one camera the size of the screen.\n\t\t */\n\t\tstatic public var cameras:Array;\n\t\t/**\n\t\t * By default this just refers to the first entry in the cameras array\n\t\t * declared above, but you can do what you like with it.\n\t\t */\n\t\tstatic public var camera:FlxCamera;\n\t\t/**\n\t\t * Allows you to possibly slightly optimize the rendering process IF\n\t\t * you are not doing any pre-processing in your game state's <code>draw()</code> call.\n\t\t * @default false\n\t\t */\n\t\tstatic public var useBufferLocking:Boolean;\n\t\t/**\n\t\t * Internal helper variable for clearing the cameras each frame.\n\t\t */\n\t\tstatic protected var _cameraRect:Rectangle;\n\t\t\n\t\t/**\n\t\t * An array container for plugins.\n\t\t * By default flixel uses a couple of plugins:\n\t\t * DebugPathDisplay, and TimerManager.\n\t\t */\n\t\t static public var plugins:Array;\n\t\t \n\t\t/**\n\t\t * Set this hook to get a callback whenever the volume changes.\n\t\t * Function should take the form <code>myVolumeHandler(Volume:Number)</code>.\n\t\t */\n\t\tstatic public var volumeHandler:Function;\n\t\t\n\t\t/**\n\t\t * Useful helper objects for doing Flash-specific rendering.\n\t\t * Primarily used for \"debug visuals\" like drawing bounding boxes directly to the screen buffer.\n\t\t */\n\t\tstatic public var flashGfxSprite:Sprite;\n\t\tstatic public var flashGfx:Graphics;\n\n\t\t/**\n\t\t * Internal storage system to prevent graphics from being used repeatedly in memory.\n\t\t */\n\t\tstatic protected var _cache:Object;\n\n\t\tstatic public function getLibraryName():String\n\t\t{\n\t\t\treturn FlxG.LIBRARY_NAME + \" v\" + FlxG.LIBRARY_MAJOR_VERSION + \".\" + FlxG.LIBRARY_MINOR_VERSION;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Log data to the debugger.\n\t\t * \n\t\t * @param\tData\t\tAnything you want to log to the console.\n\t\t */\n\t\tstatic public function log(Data:Object):void\n\t\t{\n\t\t\tif((_game != null) && (_game._debugger != null))\n\t\t\t\t_game._debugger.log.add((Data == null)?\"ERROR: null object\":((Data is Array)?FlxU.formatArray(Data as Array):Data.toString()));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Add a variable to the watch list in the debugger.\n\t\t * This lets you see the value of the variable all the time.\n\t\t * \n\t\t * @param\tAnyObject\t\tA reference to any object in your game, e.g. Player or Robot or this.\n\t\t * @param\tVariableName\tThe name of the variable you want to watch, in quotes, as a string: e.g. \"speed\" or \"health\".\n\t\t * @param\tDisplayName\t\tOptional, display your own string instead of the class name + variable name: e.g. \"enemy count\".\n\t\t */\n\t\tstatic public function watch(AnyObject:Object,VariableName:String,DisplayName:String=null):void\n\t\t{\n\t\t\tif((_game != null) && (_game._debugger != null))\n\t\t\t\t_game._debugger.watch.add(AnyObject,VariableName,DisplayName);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Remove a variable from the watch list in the debugger.\n\t\t * Don't pass a Variable Name to remove all watched variables for the specified object.\n\t\t * \n\t\t * @param\tAnyObject\t\tA reference to any object in your game, e.g. Player or Robot or this.\n\t\t * @param\tVariableName\tThe name of the variable you want to watch, in quotes, as a string: e.g. \"speed\" or \"health\".\n\t\t */\n\t\tstatic public function unwatch(AnyObject:Object,VariableName:String=null):void\n\t\t{\n\t\t\tif((_game != null) && (_game._debugger != null))\n\t\t\t\t_game._debugger.watch.remove(AnyObject,VariableName);\n\t\t}\n\t\t\n\t\t/**\n\t\t * How many times you want your game to update each second.\n\t\t * More updates usually means better collisions and smoother motion.\n\t\t * NOTE: This is NOT the same thing as the Flash Player framerate!\n\t\t */\n\t\tstatic public function get framerate():Number\n\t\t{\n\t\t\treturn 1000/_game._step;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tstatic public function set framerate(Framerate:Number):void\n\t\t{\n\t\t\t_game._step = 1000/Framerate;\n\t\t\tif(_game._maxAccumulation < _game._step)\n\t\t\t\t_game._maxAccumulation = _game._step;\n\t\t}\n\t\t\n\t\t/**\n\t\t * How many times you want your game to update each second.\n\t\t * More updates usually means better collisions and smoother motion.\n\t\t * NOTE: This is NOT the same thing as the Flash Player framerate!\n\t\t */\n\t\tstatic public function get flashFramerate():Number\n\t\t{\n\t\t\tif(_game.root != null)\n\t\t\t\treturn _game.stage.frameRate;\n\t\t\telse\n\t\t\t\treturn 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tstatic public function set flashFramerate(Framerate:Number):void\n\t\t{\n\t\t\t_game._flashFramerate = Framerate;\n\t\t\tif(_game.root != null)\n\t\t\t\t_game.stage.frameRate = _game._flashFramerate;\n\t\t\t_game._maxAccumulation = 2000/_game._flashFramerate - 1;\n\t\t\tif(_game._maxAccumulation < _game._step)\n\t\t\t\t_game._maxAccumulation = _game._step;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Switch to full-screen display.\n\t\t */\n\t\tstatic public function fullscreen():void\n\t\t{\n\t\t\tFlxG.stage.displayState = \"fullScreen\";\n\t\t\tvar fsw:uint = FlxG.width*FlxG.camera.zoom;\n\t\t\tvar fsh:uint = FlxG.height*FlxG.camera.zoom;\n\t\t\tFlxG.camera.x = (FlxG.stage.fullScreenWidth - fsw)/2;\n\t\t\tFlxG.camera.y = (FlxG.stage.fullScreenHeight - fsh)/2;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Generates a random number.  Deterministic, meaning safe\n\t\t * to use if you want to record replays in random environments.\n\t\t * \n\t\t * @return\tA <code>Number</code> between 0 and 1.\n\t\t */\n\t\tstatic public function random():Number\n\t\t{\n\t\t\treturn globalSeed = FlxU.srand(globalSeed);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Shuffles the entries in an array into a new random order.\n\t\t * <code>FlxG.shuffle()</code> is deterministic and safe for use with replays/recordings.\n\t\t * HOWEVER, <code>FlxU.shuffle()</code> is NOT deterministic and unsafe for use with replays/recordings.\n\t\t * \n\t\t * @param\tA\t\t\t\tA Flash <code>Array</code> object containing...stuff.\n\t\t * @param\tHowManyTimes\tHow many swaps to perform during the shuffle operation.  Good rule of thumb is 2-4 times as many objects are in the list.\n\t\t * \n\t\t * @return\tThe same Flash <code>Array</code> object that you passed in in the first place.\n\t\t */\n\t\tstatic public function shuffle(Objects:Array,HowManyTimes:uint):Array\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\tvar index1:uint;\n\t\t\tvar index2:uint;\n\t\t\tvar object:Object;\n\t\t\twhile(i < HowManyTimes)\n\t\t\t{\n\t\t\t\tindex1 = FlxG.random()*Objects.length;\n\t\t\t\tindex2 = FlxG.random()*Objects.length;\n\t\t\t\tobject = Objects[index2];\n\t\t\t\tObjects[index2] = Objects[index1];\n\t\t\t\tObjects[index1] = object;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\treturn Objects;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fetch a random entry from the given array.\n\t\t * Will return null if random selection is missing, or array has no entries.\n\t\t * <code>FlxG.getRandom()</code> is deterministic and safe for use with replays/recordings.\n\t\t * HOWEVER, <code>FlxU.getRandom()</code> is NOT deterministic and unsafe for use with replays/recordings.\n\t\t * \n\t\t * @param\tObjects\t\tA Flash array of objects.\n\t\t * @param\tStartIndex\tOptional offset off the front of the array. Default value is 0, or the beginning of the array.\n\t\t * @param\tLength\t\tOptional restriction on the number of values you want to randomly select from.\n\t\t * \n\t\t * @return\tThe random object that was selected.\n\t\t */\n\t\tstatic public function getRandom(Objects:Array,StartIndex:uint=0,Length:uint=0):Object\n\t\t{\n\t\t\tif(Objects != null)\n\t\t\t{\n\t\t\t\tvar l:uint = Length;\n\t\t\t\tif((l == 0) || (l > Objects.length - StartIndex))\n\t\t\t\t\tl = Objects.length - StartIndex;\n\t\t\t\tif(l > 0)\n\t\t\t\t\treturn Objects[StartIndex + uint(FlxG.random()*l)];\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Load replay data from a string and play it back.\n\t\t * \n\t\t * @param\tData\t\tThe replay that you want to load.\n\t\t * @param\tState\t\tOptional parameter: if you recorded a state-specific demo or cutscene, pass a new instance of that state here.\n\t\t * @param\tCancelKeys\tOptional parameter: an array of string names of keys (see FlxKeyboard) that can be pressed to cancel the playback, e.g. [\"ESCAPE\",\"ENTER\"].  Also accepts 2 custom key names: \"ANY\" and \"MOUSE\" (fairly self-explanatory I hope!).\n\t\t * @param\tTimeout\t\tOptional parameter: set a time limit for the replay.  CancelKeys will override this if pressed.\n\t\t * @param\tCallback\tOptional parameter: if set, called when the replay finishes.  Running to the end, CancelKeys, and Timeout will all trigger Callback(), but only once, and CancelKeys and Timeout will NOT call FlxG.stopReplay() if Callback is set!\n\t\t */\n\t\tstatic public function loadReplay(Data:String,State:FlxState=null,CancelKeys:Array=null,Timeout:Number=0,Callback:Function=null):void\n\t\t{\n\t\t\t_game._replay.load(Data);\n\t\t\tif(State == null)\n\t\t\t\tFlxG.resetGame();\n\t\t\telse\n\t\t\t\tFlxG.switchState(State);\n\t\t\t_game._replayCancelKeys = CancelKeys;\n\t\t\t_game._replayTimer = Timeout*1000;\n\t\t\t_game._replayCallback = Callback;\n\t\t\t_game._replayRequested = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Resets the game or state and replay requested flag.\n\t\t * \n\t\t * @param\tStandardMode\tIf true, reload entire game, else just reload current game state.\n\t\t */\n\t\tstatic public function reloadReplay(StandardMode:Boolean=true):void\n\t\t{\n\t\t\tif(StandardMode)\n\t\t\t\tFlxG.resetGame();\n\t\t\telse\n\t\t\t\tFlxG.resetState();\n\t\t\tif(_game._replay.frameCount > 0)\n\t\t\t\t_game._replayRequested = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops the current replay.\n\t\t */\n\t\tstatic public function stopReplay():void\n\t\t{\n\t\t\t_game._replaying = false;\n\t\t\tif(_game._debugger != null)\n\t\t\t\t_game._debugger.vcr.stopped();\n\t\t\tresetInput();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Resets the game or state and requests a new recording.\n\t\t * \n\t\t * @param\tStandardMode\tIf true, reset the entire game, else just reset the current state.\n\t\t */\n\t\tstatic public function recordReplay(StandardMode:Boolean=true):void\n\t\t{\n\t\t\tif(StandardMode)\n\t\t\t\tFlxG.resetGame();\n\t\t\telse\n\t\t\t\tFlxG.resetState();\n\t\t\t_game._recordingRequested = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stop recording the current replay and return the replay data.\n\t\t * \n\t\t * @return\tThe replay data in simple ASCII format (see <code>FlxReplay.save()</code>).\n\t\t */\n\t\tstatic public function stopRecording():String\n\t\t{\n\t\t\t_game._recording = false;\n\t\t\tif(_game._debugger != null)\n\t\t\t\t_game._debugger.vcr.stopped();\n\t\t\treturn _game._replay.save();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Request a reset of the current game state.\n\t\t */\n\t\tstatic public function resetState():void\n\t\t{\n\t\t\t_game._requestedState = new (FlxU.getClass(FlxU.getClassName(_game._state,false)))();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Like hitting the reset button on a game console, this will re-launch the game as if it just started.\n\t\t */\n\t\tstatic public function resetGame():void\n\t\t{\n\t\t\t_game._requestedReset = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Reset the input helper objects (useful when changing screens or states)\n\t\t */\n\t\tstatic public function resetInput():void\n\t\t{\n\t\t\tkeys.reset();\n\t\t\tmouse.reset();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set up and play a looping background soundtrack.\n\t\t * \n\t\t * @param\tMusic\t\tThe sound file you want to loop in the background.\n\t\t * @param\tVolume\t\tHow loud the sound should be, from 0 to 1.\n\t\t */\n\t\tstatic public function playMusic(Music:Class,Volume:Number=1.0):void\n\t\t{\n\t\t\tif(music == null)\n\t\t\t\tmusic = new FlxSound();\n\t\t\telse if(music.active)\n\t\t\t\tmusic.stop();\n\t\t\tmusic.loadEmbedded(Music,true);\n\t\t\tmusic.volume = Volume;\n\t\t\tmusic.survive = true;\n\t\t\tmusic.play();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new sound object.\n\t\t * \n\t\t * @param\tEmbeddedSound\tThe embedded sound resource you want to play.  To stream, use the optional URL parameter instead.\n\t\t * @param\tVolume\t\t\tHow loud to play it (0 to 1).\n\t\t * @param\tLooped\t\t\tWhether to loop this sound.\n\t\t * @param\tAutoDestroy\t\tWhether to destroy this sound when it finishes playing.  Leave this value set to \"false\" if you want to re-use this <code>FlxSound</code> instance.\n\t\t * @param\tAutoPlay\t\tWhether to play the sound.\n\t\t * @param\tURL\t\t\t\tLoad a sound from an external web resource instead.  Only used if EmbeddedSound = null.\n\t\t * \n\t\t * @return\tA <code>FlxSound</code> object.\n\t\t */\n\t\tstatic public function loadSound(EmbeddedSound:Class=null,Volume:Number=1.0,Looped:Boolean=false,AutoDestroy:Boolean=false,AutoPlay:Boolean=false,URL:String=null):FlxSound\n\t\t{\n\t\t\tif((EmbeddedSound == null) && (URL == null))\n\t\t\t{\n\t\t\t\tFlxG.log(\"WARNING: FlxG.loadSound() requires either\\nan embedded sound or a URL to work.\");\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tvar sound:FlxSound = sounds.recycle(FlxSound) as FlxSound;\n\t\t\tif(EmbeddedSound != null)\n\t\t\t\tsound.loadEmbedded(EmbeddedSound,Looped,AutoDestroy);\n\t\t\telse\n\t\t\t\tsound.loadStream(URL,Looped,AutoDestroy);\n\t\t\tsound.volume = Volume;\n\t\t\tif(AutoPlay)\n\t\t\t\tsound.play();\n\t\t\treturn sound;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new sound object from an embedded <code>Class</code> object.\n\t\t * NOTE: Just calls FlxG.loadSound() with AutoPlay == true.\n\t\t * \n\t\t * @param\tEmbeddedSound\tThe sound you want to play.\n\t\t * @param\tVolume\t\t\tHow loud to play it (0 to 1).\n\t\t * @param\tLooped\t\t\tWhether to loop this sound.\n\t\t * @param\tAutoDestroy\t\tWhether to destroy this sound when it finishes playing.  Leave this value set to \"false\" if you want to re-use this <code>FlxSound</code> instance.\n\t\t * \n\t\t * @return\tA <code>FlxSound</code> object.\n\t\t */\n\t\tstatic public function play(EmbeddedSound:Class,Volume:Number=1.0,Looped:Boolean=false,AutoDestroy:Boolean=true):FlxSound\n\t\t{\n\t\t\treturn FlxG.loadSound(EmbeddedSound,Volume,Looped,AutoDestroy,true);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new sound object from a URL.\n\t\t * NOTE: Just calls FlxG.loadSound() with AutoPlay == true.\n\t\t * \n\t\t * @param\tURL\t\tThe URL of the sound you want to play.\n\t\t * @param\tVolume\tHow loud to play it (0 to 1).\n\t\t * @param\tLooped\tWhether or not to loop this sound.\n\t\t * @param\tAutoDestroy\t\tWhether to destroy this sound when it finishes playing.  Leave this value set to \"false\" if you want to re-use this <code>FlxSound</code> instance.\n\t\t * \n\t\t * @return\tA FlxSound object.\n\t\t */\n\t\tstatic public function stream(URL:String,Volume:Number=1.0,Looped:Boolean=false,AutoDestroy:Boolean=true):FlxSound\n\t\t{\n\t\t\treturn FlxG.loadSound(null,Volume,Looped,AutoDestroy,true,URL);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set <code>volume</code> to a number between 0 and 1 to change the global volume.\n\t\t * \n\t\t * @default 0.5\n\t\t */\n\t\t static public function get volume():Number\n\t\t {\n\t\t\t return _volume;\n\t\t }\n\t\t \n\t\t/**\n\t\t * @private\n\t\t */\n\t\tstatic public function set volume(Volume:Number):void\n\t\t{\n\t\t\t_volume = Volume;\n\t\t\tif(_volume < 0)\n\t\t\t\t_volume = 0;\n\t\t\telse if(_volume > 1)\n\t\t\t\t_volume = 1;\n\t\t\tif(volumeHandler != null)\n\t\t\t\tvolumeHandler(FlxG.mute?0:_volume);\n\t\t}\n\n\t\t/**\n\t\t * Called by FlxGame on state changes to stop and destroy sounds.\n\t\t * \n\t\t * @param\tForceDestroy\t\tKill sounds even if they're flagged <code>survive</code>.\n\t\t */\n\t\tstatic internal function destroySounds(ForceDestroy:Boolean=false):void\n\t\t{\n\t\t\tif((music != null) && (ForceDestroy || !music.survive))\n\t\t\t{\n\t\t\t\tmusic.destroy();\n\t\t\t\tmusic = null;\n\t\t\t}\n\t\t\tvar i:uint = 0;\n\t\t\tvar sound:FlxSound;\n\t\t\tvar l:uint = sounds.members.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tsound = sounds.members[i++] as FlxSound;\n\t\t\t\tif((sound != null) && (ForceDestroy || !sound.survive))\n\t\t\t\t\tsound.destroy();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by the game loop to make sure the sounds get updated each frame.\n\t\t */\n\t\tstatic internal function updateSounds():void\n\t\t{\n\t\t\tif((music != null) && music.active)\n\t\t\t\tmusic.update();\n\t\t\tif((sounds != null) && sounds.active)\n\t\t\t\tsounds.update();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Pause all sounds currently playing.\n\t\t */\n\t\tstatic public function pauseSounds():void\n\t\t{\n\t\t\tif((music != null) && music.exists && music.active)\n\t\t\t\tmusic.pause();\n\t\t\tvar i:uint = 0;\n\t\t\tvar sound:FlxSound;\n\t\t\tvar l:uint = sounds.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tsound = sounds.members[i++] as FlxSound;\n\t\t\t\tif((sound != null) && sound.exists && sound.active)\n\t\t\t\t\tsound.pause();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Resume playing existing sounds.\n\t\t */\n\t\tstatic public function resumeSounds():void\n\t\t{\n\t\t\tif((music != null) && music.exists)\n\t\t\t\tmusic.play();\n\t\t\tvar i:uint = 0;\n\t\t\tvar sound:FlxSound;\n\t\t\tvar l:uint = sounds.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tsound = sounds.members[i++] as FlxSound;\n\t\t\t\tif((sound != null) && sound.exists)\n\t\t\t\t\tsound.resume();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Check the local bitmap cache to see if a bitmap with this key has been loaded already.\n\t\t *\n\t\t * @param\tKey\t\tThe string key identifying the bitmap.\n\t\t * \n\t\t * @return\tWhether or not this file can be found in the cache.\n\t\t */\n\t\tstatic public function checkBitmapCache(Key:String):Boolean\n\t\t{\n\t\t\treturn (_cache[Key] != undefined) && (_cache[Key] != null);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Generates a new <code>BitmapData</code> object (a colored square) and caches it.\n\t\t * \n\t\t * @param\tWidth\tHow wide the square should be.\n\t\t * @param\tHeight\tHow high the square should be.\n\t\t * @param\tColor\tWhat color the square should be (0xAARRGGBB)\n\t\t * @param\tUnique\tEnsures that the bitmap data uses a new slot in the cache.\n\t\t * @param\tKey\t\tForce the cache to use a specific Key to index the bitmap.\n\t\t * \n\t\t * @return\tThe <code>BitmapData</code> we just created.\n\t\t */\n\t\tstatic public function createBitmap(Width:uint, Height:uint, Color:uint, Unique:Boolean=false, Key:String=null):BitmapData\n\t\t{\n\t\t\tif(Key == null)\n\t\t\t{\n\t\t\t\tKey = Width+\"x\"+Height+\":\"+Color;\n\t\t\t\tif(Unique && checkBitmapCache(Key))\n\t\t\t\t{\n\t\t\t\t\tvar inc:uint = 0;\n\t\t\t\t\tvar ukey:String;\n\t\t\t\t\tdo\n\t\t\t\t\t{\n\t\t\t\t\t\tukey = Key + inc++;\n\t\t\t\t\t} while(checkBitmapCache(ukey));\n\t\t\t\t\tKey = ukey;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(!checkBitmapCache(Key))\n\t\t\t\t_cache[Key] = new BitmapData(Width,Height,true,Color);\n\t\t\treturn _cache[Key];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Loads a bitmap from a file, caches it, and generates a horizontally flipped version if necessary.\n\t\t * \n\t\t * @param\tGraphic\t\tThe image file that you want to load.\n\t\t * @param\tReverse\t\tWhether to generate a flipped version.\n\t\t * @param\tUnique\t\tEnsures that the bitmap data uses a new slot in the cache.\n\t\t * @param\tKey\t\t\tForce the cache to use a specific Key to index the bitmap.\n\t\t * \n\t\t * @return\tThe <code>BitmapData</code> we just created.\n\t\t */\n\t\tstatic public function addBitmap(Graphic:Class, Reverse:Boolean=false, Unique:Boolean=false, Key:String=null):BitmapData\n\t\t{\n\t\t\tvar needReverse:Boolean = false;\n\t\t\tif(Key == null)\n\t\t\t{\n\t\t\t\tKey = String(Graphic)+(Reverse?\"_REVERSE_\":\"\");\n\t\t\t\tif(Unique && checkBitmapCache(Key))\n\t\t\t\t{\n\t\t\t\t\tvar inc:uint = 0;\n\t\t\t\t\tvar ukey:String;\n\t\t\t\t\tdo\n\t\t\t\t\t{\n\t\t\t\t\t\tukey = Key + inc++;\n\t\t\t\t\t} while(checkBitmapCache(ukey));\n\t\t\t\t\tKey = ukey;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//If there is no data for this key, generate the requested graphic\n\t\t\tif(!checkBitmapCache(Key))\n\t\t\t{\n\t\t\t\t_cache[Key] = (new Graphic).bitmapData;\n\t\t\t\tif(Reverse)\n\t\t\t\t\tneedReverse = true;\n\t\t\t}\n\t\t\tvar pixels:BitmapData = _cache[Key];\n\t\t\tif(!needReverse && Reverse && (pixels.width == (new Graphic).bitmapData.width))\n\t\t\t\tneedReverse = true;\n\t\t\tif(needReverse)\n\t\t\t{\n\t\t\t\tvar newPixels:BitmapData = new BitmapData(pixels.width<<1,pixels.height,true,0x00000000);\n\t\t\t\tnewPixels.draw(pixels);\n\t\t\t\tvar mtx:Matrix = new Matrix();\n\t\t\t\tmtx.scale(-1,1);\n\t\t\t\tmtx.translate(newPixels.width,0);\n\t\t\t\tnewPixels.draw(pixels,mtx);\n\t\t\t\tpixels = newPixels;\n\t\t\t\t_cache[Key] = pixels;\n\t\t\t}\n\t\t\treturn pixels;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Dumps the cache's image references.\n\t\t */\n\t\tstatic public function clearBitmapCache():void\n\t\t{\n\t\t\t_cache = new Object();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Read-only: retrieves the Flash stage object (required for event listeners)\n\t\t * Will be null if it's not safe/useful yet.\n\t\t */\n\t\tstatic public function get stage():Stage\n\t\t{\n\t\t\tif(_game.root != null)\n\t\t\t\treturn _game.stage;\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Read-only: access the current game state from anywhere.\n\t\t */\n\t\tstatic public function get state():FlxState\n\t\t{\n\t\t\treturn _game._state;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Switch from the current game state to the one specified here.\n\t\t */\n\t\tstatic public function switchState(State:FlxState):void\n\t\t{\n\t\t\t_game._requestedState = State;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Change the way the debugger's windows are laid out.\n\t\t * \n\t\t * @param\tLayout\t\tSee the presets above (e.g. <code>DEBUGGER_MICRO</code>, etc).\n\t\t */\n\t\tstatic public function setDebuggerLayout(Layout:uint):void\n\t\t{\n\t\t\tif(_game._debugger != null)\n\t\t\t\t_game._debugger.setLayout(Layout);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Just resets the debugger windows to whatever the last selected layout was (<code>DEBUGGER_STANDARD</code> by default).\n\t\t */\n\t\tstatic public function resetDebuggerLayout():void\n\t\t{\n\t\t\tif(_game._debugger != null)\n\t\t\t\t_game._debugger.resetLayout();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Add a new camera object to the game.\n\t\t * Handy for PiP, split-screen, etc.\n\t\t * \n\t\t * @param\tNewCamera\tThe camera you want to add.\n\t\t * \n\t\t * @return\tThis <code>FlxCamera</code> instance.\n\t\t */\n\t\tstatic public function addCamera(NewCamera:FlxCamera):FlxCamera\n\t\t{\n\t\t\tFlxG._game.addChildAt(NewCamera._flashSprite,FlxG._game.getChildIndex(FlxG._game._mouse));\n\t\t\tFlxG.cameras.push(NewCamera);\n\t\t\treturn NewCamera;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Remove a camera from the game.\n\t\t * \n\t\t * @param\tCamera\tThe camera you want to remove.\n\t\t * @param\tDestroy\tWhether to call destroy() on the camera, default value is true.\n\t\t */\n\t\tstatic public function removeCamera(Camera:FlxCamera,Destroy:Boolean=true):void\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tFlxG._game.removeChild(Camera._flashSprite);\n\t\t\t}\n\t\t\tcatch(E:Error)\n\t\t\t{\n\t\t\t\tFlxG.log(\"Error removing camera, not part of game.\");\n\t\t\t}\n\t\t\tif(Destroy)\n\t\t\t\tCamera.destroy();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Dumps all the current cameras and resets to just one camera.\n\t\t * Handy for doing split-screen especially.\n\t\t * \n\t\t * @param\tNewCamera\tOptional; specify a specific camera object to be the new main camera.\n\t\t */\n\t\tstatic public function resetCameras(NewCamera:FlxCamera=null):void\n\t\t{\n\t\t\tvar cam:FlxCamera;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = cameras.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tcam = FlxG.cameras[i++] as FlxCamera;\n\t\t\t\tFlxG._game.removeChild(cam._flashSprite);\n\t\t\t\tcam.destroy();\n\t\t\t}\n\t\t\tFlxG.cameras.length = 0;\n\t\t\t\n\t\t\tif(NewCamera == null)\n\t\t\t\tNewCamera = new FlxCamera(0,0,FlxG.width,FlxG.height)\n\t\t\tFlxG.camera = FlxG.addCamera(NewCamera);\n\t\t}\n\t\t\n\t\t/**\n\t\t * All screens are filled with this color and gradually return to normal.\n\t\t * \n\t\t * @param\tColor\t\tThe color you want to use.\n\t\t * @param\tDuration\tHow long it takes for the flash to fade.\n\t\t * @param\tOnComplete\tA function you want to run when the flash finishes.\n\t\t * @param\tForce\t\tForce the effect to reset.\n\t\t */\n\t\tstatic public function flash(Color:uint=0xffffffff, Duration:Number=1, OnComplete:Function=null, Force:Boolean=false):void\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = FlxG.cameras.length;\n\t\t\twhile(i < l)\n\t\t\t\t(FlxG.cameras[i++] as FlxCamera).flash(Color,Duration,OnComplete,Force);\n\t\t}\n\t\t\n\t\t/**\n\t\t * The screen is gradually filled with this color.\n\t\t * \n\t\t * @param\tColor\t\tThe color you want to use.\n\t\t * @param\tDuration\tHow long it takes for the fade to finish.\n\t\t * @param\tOnComplete\tA function you want to run when the fade finishes.\n\t\t * @param\tForce\t\tForce the effect to reset.\n\t\t */\n\t\tstatic public function fade(Color:uint=0xff000000, Duration:Number=1, OnComplete:Function=null, Force:Boolean=false):void\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = FlxG.cameras.length;\n\t\t\twhile(i < l)\n\t\t\t\t(FlxG.cameras[i++] as FlxCamera).fade(Color,Duration,OnComplete,Force);\n\t\t}\n\t\t\n\t\t/**\n\t\t * A simple screen-shake effect.\n\t\t * \n\t\t * @param\tIntensity\tPercentage of screen size representing the maximum distance that the screen can move while shaking.\n\t\t * @param\tDuration\tThe length in seconds that the shaking effect should last.\n\t\t * @param\tOnComplete\tA function you want to run when the shake effect finishes.\n\t\t * @param\tForce\t\tForce the effect to reset (default = true, unlike flash() and fade()!).\n\t\t * @param\tDirection\tWhether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).  Default value is SHAKE_BOTH_AXES (0).\n\t\t */\n\t\tstatic public function shake(Intensity:Number=0.05, Duration:Number=0.5, OnComplete:Function=null, Force:Boolean=true, Direction:uint=0):void\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = FlxG.cameras.length;\n\t\t\twhile(i < l)\n\t\t\t\t(FlxG.cameras[i++] as FlxCamera).shake(Intensity,Duration,OnComplete,Force,Direction);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Get and set the background color of the game.\n\t\t * Get functionality is equivalent to FlxG.camera.bgColor.\n\t\t * Set functionality sets the background color of all the current cameras.\n\t\t */\n\t\tstatic public function get bgColor():uint\n\t\t{\n\t\t\tif(FlxG.camera == null)\n\t\t\t\treturn 0xff000000;\n\t\t\telse\n\t\t\t\treturn FlxG.camera.bgColor;\n\t\t}\n\t\t\n\t\tstatic public function set bgColor(Color:uint):void\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = FlxG.cameras.length;\n\t\t\twhile(i < l)\n\t\t\t\t(FlxG.cameras[i++] as FlxCamera).bgColor = Color;\n\t\t}\n\n\t\t/**\n\t\t * Call this function to see if one <code>FlxObject</code> overlaps another.\n\t\t * Can be called with one object and one group, or two groups, or two objects,\n\t\t * whatever floats your boat! For maximum performance try bundling a lot of objects\n\t\t * together using a <code>FlxGroup</code> (or even bundling groups together!).\n\t\t * \n\t\t * <p>NOTE: does NOT take objects' scrollfactor into account, all overlaps are checked in world space.</p>\n\t\t * \n\t\t * @param\tObjectOrGroup1\tThe first object or group you want to check.\n\t\t * @param\tObjectOrGroup2\tThe second object or group you want to check.  If it is the same as the first, flixel knows to just do a comparison within that group.\n\t\t * @param\tNotifyCallback\tA function with two <code>FlxObject</code> parameters - e.g. <code>myOverlapFunction(Object1:FlxObject,Object2:FlxObject)</code> - that is called if those two objects overlap.\n\t\t * @param\tProcessCallback\tA function with two <code>FlxObject</code> parameters - e.g. <code>myOverlapFunction(Object1:FlxObject,Object2:FlxObject)</code> - that is called if those two objects overlap.  If a ProcessCallback is provided, then NotifyCallback will only be called if ProcessCallback returns true for those objects!\n\t\t * \n\t\t * @return\tWhether any oevrlaps were detected.\n\t\t */\n\t\tstatic public function overlap(ObjectOrGroup1:FlxBasic=null,ObjectOrGroup2:FlxBasic=null,NotifyCallback:Function=null,ProcessCallback:Function=null):Boolean\n\t\t{\n\t\t\tif(ObjectOrGroup1 == null)\n\t\t\t\tObjectOrGroup1 = FlxG.state;\n\t\t\tif(ObjectOrGroup2 === ObjectOrGroup1)\n\t\t\t\tObjectOrGroup2 = null;\n\t\t\tFlxQuadTree.divisions = FlxG.worldDivisions;\n\t\t\tvar quadTree:FlxQuadTree = new FlxQuadTree(FlxG.worldBounds.x,FlxG.worldBounds.y,FlxG.worldBounds.width,FlxG.worldBounds.height);\n\t\t\tquadTree.load(ObjectOrGroup1,ObjectOrGroup2,NotifyCallback,ProcessCallback);\n\t\t\tvar result:Boolean = quadTree.execute();\n\t\t\tquadTree.destroy();\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to see if one <code>FlxObject</code> collides with another.\n\t\t * Can be called with one object and one group, or two groups, or two objects,\n\t\t * whatever floats your boat! For maximum performance try bundling a lot of objects\n\t\t * together using a <code>FlxGroup</code> (or even bundling groups together!).\n\t\t * \n\t\t * <p>This function just calls FlxG.overlap and presets the ProcessCallback parameter to FlxObject.separate.\n\t\t * To create your own collision logic, write your own ProcessCallback and use FlxG.overlap to set it up.</p>\n\t\t * \n\t\t * <p>NOTE: does NOT take objects' scrollfactor into account, all overlaps are checked in world space.</p>\n\t\t * \n\t\t * @param\tObjectOrGroup1\tThe first object or group you want to check.\n\t\t * @param\tObjectOrGroup2\tThe second object or group you want to check.  If it is the same as the first, flixel knows to just do a comparison within that group.\n\t\t * @param\tNotifyCallback\tA function with two <code>FlxObject</code> parameters - e.g. <code>myOverlapFunction(Object1:FlxObject,Object2:FlxObject)</code> - that is called if those two objects overlap.\n\t\t * \n\t\t * @return\tWhether any objects were successfully collided/separated.\n\t\t */\n\t\tstatic public function collide(ObjectOrGroup1:FlxBasic=null, ObjectOrGroup2:FlxBasic=null, NotifyCallback:Function=null):Boolean\n\t\t{\n\t\t\treturn overlap(ObjectOrGroup1,ObjectOrGroup2,NotifyCallback,FlxObject.separate);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adds a new plugin to the global plugin array.\n\t\t * \n\t\t * @param\tPlugin\tAny object that extends FlxBasic. Useful for managers and other things.  See org.flixel.plugin for some examples!\n\t\t * \n\t\t * @return\tThe same <code>FlxBasic</code>-based plugin you passed in.\n\t\t */\n\t\tstatic public function addPlugin(Plugin:FlxBasic):FlxBasic\n\t\t{\n\t\t\t//Don't add repeats\n\t\t\tvar pluginList:Array = FlxG.plugins;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = pluginList.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tif(pluginList[i++].toString() == Plugin.toString())\n\t\t\t\t\treturn Plugin;\n\t\t\t}\n\t\t\t\n\t\t\t//no repeats! safe to add a new instance of this plugin\n\t\t\tpluginList.push(Plugin);\n\t\t\treturn Plugin;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Retrieves a plugin based on its class name from the global plugin array.\n\t\t * \n\t\t * @param\tClassType\tThe class name of the plugin you want to retrieve. See the <code>FlxPath</code> or <code>FlxTimer</code> constructors for example usage.\n\t\t * \n\t\t * @return\tThe plugin object, or null if no matching plugin was found.\n\t\t */\n\t\tstatic public function getPlugin(ClassType:Class):FlxBasic\n\t\t{\n\t\t\tvar pluginList:Array = FlxG.plugins;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = pluginList.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tif(pluginList[i] is ClassType)\n\t\t\t\t\treturn plugins[i];\n\t\t\t\ti++;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes an instance of a plugin from the global plugin array.\n\t\t * \n\t\t * @param\tPlugin\tThe plugin instance you want to remove.\n\t\t * \n\t\t * @return\tThe same <code>FlxBasic</code>-based plugin you passed in.\n\t\t */\n\t\tstatic public function removePlugin(Plugin:FlxBasic):FlxBasic\n\t\t{\n\t\t\t//Don't add repeats\n\t\t\tvar pluginList:Array = FlxG.plugins;\n\t\t\tvar i:int = pluginList.length-1;\n\t\t\twhile(i >= 0)\n\t\t\t{\n\t\t\t\tif(pluginList[i] == Plugin)\n\t\t\t\t\tpluginList.splice(i,1);\n\t\t\t\ti--;\n\t\t\t}\n\t\t\treturn Plugin;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes an instance of a plugin from the global plugin array.\n\t\t * \n\t\t * @param\tClassType\tThe class name of the plugin type you want removed from the array.\n\t\t * \n\t\t * @return\tWhether or not at least one instance of this plugin type was removed.\n\t\t */\n\t\tstatic public function removePluginType(ClassType:Class):Boolean\n\t\t{\n\t\t\t//Don't add repeats\n\t\t\tvar results:Boolean = false;\n\t\t\tvar pluginList:Array = FlxG.plugins;\n\t\t\tvar i:int = pluginList.length-1;\n\t\t\twhile(i >= 0)\n\t\t\t{\n\t\t\t\tif(pluginList[i] is ClassType)\n\t\t\t\t{\n\t\t\t\t\tpluginList.splice(i,1);\n\t\t\t\t\tresults = true;\n\t\t\t\t}\n\t\t\t\ti--;\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by <code>FlxGame</code> to set up <code>FlxG</code> during <code>FlxGame</code>'s constructor.\n\t\t */\n\t\tstatic internal function init(Game:FlxGame,Width:uint,Height:uint,Zoom:Number):void\n\t\t{\n\t\t\tFlxG._game = Game;\n\t\t\tFlxG.width = Width;\n\t\t\tFlxG.height = Height;\n\t\t\t\n\t\t\tFlxG.mute = false;\n\t\t\tFlxG._volume = 0.5;\n\t\t\tFlxG.sounds = new FlxGroup();\n\t\t\tFlxG.volumeHandler = null;\n\t\t\t\n\t\t\tFlxG.clearBitmapCache();\n\t\t\t\n\t\t\tif(flashGfxSprite == null)\n\t\t\t{\n\t\t\t\tflashGfxSprite = new Sprite();\n\t\t\t\tflashGfx = flashGfxSprite.graphics;\n\t\t\t}\n\n\t\t\tFlxCamera.defaultZoom = Zoom;\n\t\t\tFlxG._cameraRect = new Rectangle();\n\t\t\tFlxG.cameras = new Array();\n\t\t\tuseBufferLocking = false;\n\t\t\t\n\t\t\tplugins = new Array();\n\t\t\taddPlugin(new DebugPathDisplay());\n\t\t\taddPlugin(new TimerManager());\n\t\t\t\n\t\t\tFlxG.mouse = new Mouse(FlxG._game._mouse);\n\t\t\tFlxG.keys = new Keyboard();\n\t\t\tFlxG.mobile = false;\n\n\t\t\tFlxG.levels = new Array();\n\t\t\tFlxG.scores = new Array();\n\t\t\tFlxG.visualDebug = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called whenever the game is reset, doesn't have to do quite as much work as the basic initialization stuff.\n\t\t */\n\t\tstatic internal function reset():void\n\t\t{\n\t\t\tFlxG.clearBitmapCache();\n\t\t\tFlxG.resetInput();\n\t\t\tFlxG.destroySounds(true);\n\t\t\tFlxG.levels.length = 0;\n\t\t\tFlxG.scores.length = 0;\n\t\t\tFlxG.level = 0;\n\t\t\tFlxG.score = 0;\n\t\t\tFlxG.paused = false;\n\t\t\tFlxG.timeScale = 1.0;\n\t\t\tFlxG.elapsed = 0;\n\t\t\tFlxG.globalSeed = Math.random();\n\t\t\tFlxG.worldBounds = new FlxRect(-10,-10,FlxG.width+20,FlxG.height+20);\n\t\t\tFlxG.worldDivisions = 6;\n\t\t\tvar debugPathDisplay:DebugPathDisplay = FlxG.getPlugin(DebugPathDisplay) as DebugPathDisplay;\n\t\t\tif(debugPathDisplay != null)\n\t\t\t\tdebugPathDisplay.clear();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by the game object to update the keyboard and mouse input tracking objects.\n\t\t */\n\t\tstatic internal function updateInput():void\n\t\t{\n\t\t\tFlxG.keys.update();\n\t\t\tif(!_game._debuggerUp || !_game._debugger.hasMouse)\n\t\t\t\tFlxG.mouse.update(FlxG._game.mouseX,FlxG._game.mouseY);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by the game object to lock all the camera buffers and clear them for the next draw pass.\n\t\t */\n\t\tstatic internal function lockCameras():void\n\t\t{\n\t\t\tvar cam:FlxCamera;\n\t\t\tvar cams:Array = FlxG.cameras;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = cams.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tcam = cams[i++] as FlxCamera;\n\t\t\t\tif((cam == null) || !cam.exists || !cam.visible)\n\t\t\t\t\tcontinue;\n\t\t\t\tif(useBufferLocking)\n\t\t\t\t\tcam.buffer.lock();\n\t\t\t\tcam.fill(cam.bgColor);\n\t\t\t\tcam.screen.dirty = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by the game object to draw the special FX and unlock all the camera buffers.\n\t\t */\n\t\tstatic internal function unlockCameras():void\n\t\t{\n\t\t\tvar cam:FlxCamera;\n\t\t\tvar cams:Array = FlxG.cameras;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = cams.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tcam = cams[i++] as FlxCamera;\n\t\t\t\tif((cam == null) || !cam.exists || !cam.visible)\n\t\t\t\t\tcontinue;\n\t\t\t\tcam.drawFX();\n\t\t\t\tif(useBufferLocking)\n\t\t\t\t\tcam.buffer.unlock();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by the game object to update the cameras and their tracking/special effects logic.\n\t\t */\n\t\tstatic internal function updateCameras():void\n\t\t{\n\t\t\tvar cam:FlxCamera;\n\t\t\tvar cams:Array = FlxG.cameras;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = cams.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tcam = cams[i++] as FlxCamera;\n\t\t\t\tif((cam != null) && cam.exists)\n\t\t\t\t{\n\t\t\t\t\tif(cam.active)\n\t\t\t\t\t\tcam.update();\n\t\t\t\t\tcam._flashSprite.x = cam.x + cam._flashOffsetX;\n\t\t\t\t\tcam._flashSprite.y = cam.y + cam._flashOffsetY;\n\t\t\t\t\tcam._flashSprite.visible = cam.visible;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Used by the game object to call <code>update()</code> on all the plugins.\n\t\t */\n\t\tstatic internal function updatePlugins():void\n\t\t{\n\t\t\tvar plugin:FlxBasic;\n\t\t\tvar pluginList:Array = FlxG.plugins;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = pluginList.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tplugin = pluginList[i++] as FlxBasic;\n\t\t\t\tif(plugin.exists && plugin.active)\n\t\t\t\t\tplugin.update();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Used by the game object to call <code>draw()</code> on all the plugins.\n\t\t */\n\t\tstatic internal function drawPlugins():void\n\t\t{\n\t\t\tvar plugin:FlxBasic;\n\t\t\tvar pluginList:Array = FlxG.plugins;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = pluginList.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tplugin = pluginList[i++] as FlxBasic;\n\t\t\t\tif(plugin.exists && plugin.visible)\n\t\t\t\t\tplugin.draw();\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxGame.as",
    "content": "package org.flixel\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Graphics;\n\timport flash.display.Sprite;\n\timport flash.display.StageAlign;\n\timport flash.display.StageScaleMode;\n\timport flash.events.*;\n\timport flash.geom.Point;\n\timport flash.text.AntiAliasType;\n\timport flash.text.GridFitType;\n\timport flash.text.TextField;\n\timport flash.text.TextFormat;\n\timport flash.ui.Mouse;\n\timport flash.utils.Timer;\n\timport flash.utils.getTimer;\n\t\n\timport org.flixel.plugin.TimerManager;\n\timport org.flixel.system.FlxDebugger;\n\timport org.flixel.system.FlxReplay;\n\n\t/**\n\t * FlxGame is the heart of all flixel games, and contains a bunch of basic game loops and things.\n\t * It is a long and sloppy file that you shouldn't have to worry about too much!\n\t * It is basically only used to create your game object in the first place,\n\t * after that FlxG and FlxState have all the useful stuff you actually need.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxGame extends Sprite\n\t{\n\t\t[Embed(source=\"data/nokiafc22.ttf\",fontFamily=\"system\",embedAsCFF=\"false\")] protected var junk:String;\n\t\t[Embed(source=\"data/beep.mp3\")] protected var SndBeep:Class;\n\t\t[Embed(source=\"data/logo.png\")] protected var ImgLogo:Class;\n\n\t\t/**\n\t\t * Sets 0, -, and + to control the global volume sound volume.\n\t\t * @default true\n\t\t */\n\t\tpublic var useSoundHotKeys:Boolean;\n\t\t/**\n\t\t * Tells flixel to use the default system mouse cursor instead of custom Flixel mouse cursors.\n\t\t * @default false\n\t\t */\n\t\tpublic var useSystemCursor:Boolean;\n\t\t/**\n\t\t * Initialize and allow the flixel debugger overlay even in release mode.\n\t\t * Also useful if you don't use FlxPreloader!\n\t\t * @default false\n\t\t */\n\t\tpublic var forceDebugger:Boolean;\n\n\t\t/**\n\t\t * Current game state.\n\t\t */\n\t\tinternal var _state:FlxState;\n\t\t/**\n\t\t * Mouse cursor.\n\t\t */\n\t\tinternal var _mouse:Sprite;\n\t\t\n\t\t/**\n\t\t * Class type of the initial/first game state for the game, usually MenuState or something like that.\n\t\t */\n\t\tprotected var _iState:Class;\n\t\t/**\n\t\t * Whether the game object's basic initialization has finished yet.\n\t\t */\n\t\tprotected var _created:Boolean;\n\t\t\n\t\t/**\n\t\t * Total number of milliseconds elapsed since game start.\n\t\t */\n\t\tprotected var _total:uint;\n\t\t/**\n\t\t * Total number of milliseconds elapsed since last update loop.\n\t\t * Counts down as we step through the game loop.\n\t\t */\n\t\tprotected var _accumulator:int;\n\t\t/**\n\t\t * Whether the Flash player lost focus.\n\t\t */\n\t\tprotected var _lostFocus:Boolean;\n\t\t/**\n\t\t * Milliseconds of time per step of the game loop.  FlashEvent.g. 60 fps = 16ms.\n\t\t */\n\t\tinternal var _step:uint;\n\t\t/**\n\t\t * Framerate of the Flash player (NOT the game loop). Default = 30.\n\t\t */\n\t\tinternal var _flashFramerate:uint;\n\t\t/**\n\t\t * Max allowable accumulation (see _accumulator).\n\t\t * Should always (and automatically) be set to roughly 2x the flash player framerate.\n\t\t */\n\t\tinternal var _maxAccumulation:uint;\n\t\t/**\n\t\t * If a state change was requested, the new state object is stored here until we switch to it.\n\t\t */\n\t\tinternal var _requestedState:FlxState;\n\t\t/**\n\t\t * A flag for keeping track of whether a game reset was requested or not.\n\t\t */\n\t\tinternal var _requestedReset:Boolean;\n\n\t\t/**\n\t\t * The \"focus lost\" screen (see <code>createFocusScreen()</code>).\n\t\t */\n\t\tprotected var _focus:Sprite;\n\t\t/**\n\t\t * The sound tray display container (see <code>createSoundTray()</code>).\n\t\t */\n\t\tprotected var _soundTray:Sprite;\n\t\t/**\n\t\t * Helps us auto-hide the sound tray after a volume change.\n\t\t */\n\t\tprotected var _soundTrayTimer:Number;\n\t\t/**\n\t\t * Helps display the volume bars on the sound tray.\n\t\t */\n\t\tprotected var _soundTrayBars:Array;\n\t\t/**\n\t\t * The debugger overlay object.\n\t\t */\n\t\tinternal var _debugger:FlxDebugger;\n\t\t/**\n\t\t * A handy boolean that keeps track of whether the debugger exists and is currently visible.\n\t\t */\n\t\tinternal var _debuggerUp:Boolean;\n\t\t\n\t\t/**\n\t\t * Container for a game replay object.\n\t\t */\n\t\tinternal var _replay:FlxReplay;\n\t\t/**\n\t\t * Flag for whether a playback of a recording was requested.\n\t\t */\n\t\tinternal var _replayRequested:Boolean;\n\t\t/**\n\t\t * Flag for whether a new recording was requested.\n\t\t */\n\t\tinternal var _recordingRequested:Boolean;\n\t\t/**\n\t\t * Flag for whether a replay is currently playing.\n\t\t */\n\t\tinternal var _replaying:Boolean;\n\t\t/**\n\t\t * Flag for whether a new recording is being made.\n\t\t */\n\t\tinternal var _recording:Boolean;\n\t\t/**\n\t\t * Array that keeps track of keypresses that can cancel a replay.\n\t\t * Handy for skipping cutscenes or getting out of attract modes!\n\t\t */\n\t\tinternal var _replayCancelKeys:Array;\n\t\t/**\n\t\t * Helps time out a replay if necessary.\n\t\t */\n\t\tinternal var _replayTimer:int;\n\t\t/**\n\t\t * This function, if set, is triggered when the callback stops playing.\n\t\t */\n\t\tinternal var _replayCallback:Function;\n\n\t\t/**\n\t\t * Instantiate a new game object.\n\t\t * \n\t\t * @param\tGameSizeX\t\tThe width of your game in game pixels, not necessarily final display pixels (see Zoom).\n\t\t * @param\tGameSizeY\t\tThe height of your game in game pixels, not necessarily final display pixels (see Zoom).\n\t\t * @param\tInitialState\tThe class name of the state you want to create and switch to first (e.g. MenuState).\n\t\t * @param\tZoom\t\t\tThe default level of zoom for the game's cameras (e.g. 2 = all pixels are now drawn at 2x).  Default = 1.\n\t\t * @param\tGameFramerate\tHow frequently the game should update (default is 60 times per second).\n\t\t * @param\tFlashFramerate\tSets the actual display framerate for Flash player (default is 30 times per second).\n\t\t * @param\tUseSystemCursor\tWhether to use the default OS mouse pointer, or to use custom flixel ones.\n\t\t */\n\t\tpublic function FlxGame(GameSizeX:uint,GameSizeY:uint,InitialState:Class,Zoom:Number=1,GameFramerate:uint=60,FlashFramerate:uint=30,UseSystemCursor:Boolean=false)\n\t\t{\n\t\t\t//super high priority init stuff (focus, mouse, etc)\n\t\t\t_lostFocus = false;\n\t\t\t_focus = new Sprite();\n\t\t\t_focus.visible = false;\n\t\t\t_soundTray = new Sprite();\n\t\t\t_mouse = new Sprite()\n\t\t\t\n\t\t\t//basic display and update setup stuff\n\t\t\tFlxG.init(this,GameSizeX,GameSizeY,Zoom);\n\t\t\tFlxG.framerate = GameFramerate;\n\t\t\tFlxG.flashFramerate = FlashFramerate;\n\t\t\t_accumulator = _step;\n\t\t\t_total = 0;\n\t\t\t_state = null;\n\t\t\tuseSoundHotKeys = true;\n\t\t\tuseSystemCursor = UseSystemCursor;\n\t\t\tif(!useSystemCursor)\n\t\t\t\tflash.ui.Mouse.hide();\n\t\t\tforceDebugger = false;\n\t\t\t_debuggerUp = false;\n\t\t\t\n\t\t\t//replay data\n\t\t\t_replay = new FlxReplay();\n\t\t\t_replayRequested = false;\n\t\t\t_recordingRequested = false;\n\t\t\t_replaying = false;\n\t\t\t_recording = false;\n\t\t\t\n\t\t\t//then get ready to create the game object for real\n\t\t\t_iState = InitialState;\n\t\t\t_requestedState = null;\n\t\t\t_requestedReset = true;\n\t\t\t_created = false;\n\t\t\taddEventListener(Event.ENTER_FRAME, create);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Makes the little volume tray slide out.\n\t\t * \n\t\t * @param\tSilent\tWhether or not it should beep.\n\t\t */\n\t\tinternal function showSoundTray(Silent:Boolean=false):void\n\t\t{\n\t\t\tif(!Silent)\n\t\t\t\tFlxG.play(SndBeep);\n\t\t\t_soundTrayTimer = 1;\n\t\t\t_soundTray.y = 0;\n\t\t\t_soundTray.visible = true;\n\t\t\tvar globalVolume:uint = Math.round(FlxG.volume*10);\n\t\t\tif(FlxG.mute)\n\t\t\t\tglobalVolume = 0;\n\t\t\tfor (var i:uint = 0; i < _soundTrayBars.length; i++)\n\t\t\t{\n\t\t\t\tif(i < globalVolume) _soundTrayBars[i].alpha = 1;\n\t\t\t\telse _soundTrayBars[i].alpha = 0.5;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Internal event handler for input and focus.\n\t\t * \n\t\t * @param\tFlashEvent\tFlash keyboard event.\n\t\t */\n\t\tprotected function handleKeyUp(FlashEvent:KeyboardEvent):void\n\t\t{\n\t\t\tif(_debuggerUp && _debugger.watch.editing)\n\t\t\t\treturn;\n\t\t\tif(!FlxG.mobile)\n\t\t\t{\n\t\t\t\tif((_debugger != null) && ((FlashEvent.keyCode == 192) || (FlashEvent.keyCode == 220)))\n\t\t\t\t{\n\t\t\t\t\t_debugger.visible = !_debugger.visible;\n\t\t\t\t\t_debuggerUp = _debugger.visible;\n\t\t\t\t\tif(_debugger.visible)\n\t\t\t\t\t\tflash.ui.Mouse.show();\n\t\t\t\t\telse if(!useSystemCursor)\n\t\t\t\t\t\tflash.ui.Mouse.hide();\n\t\t\t\t\t//_console.toggle();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif(useSoundHotKeys)\n\t\t\t\t{\n\t\t\t\t\tvar c:int = FlashEvent.keyCode;\n\t\t\t\t\tvar code:String = String.fromCharCode(FlashEvent.charCode);\n\t\t\t\t\tswitch(c)\n\t\t\t\t\t{\n\t\t\t\t\t\tcase 48:\n\t\t\t\t\t\tcase 96:\n\t\t\t\t\t\t\tFlxG.mute = !FlxG.mute;\n\t\t\t\t\t\t\tif(FlxG.volumeHandler != null)\n\t\t\t\t\t\t\t\tFlxG.volumeHandler(FlxG.mute?0:FlxG.volume);\n\t\t\t\t\t\t\tshowSoundTray();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tcase 109:\n\t\t\t\t\t\tcase 189:\n\t\t\t\t\t\t\tFlxG.mute = false;\n\t\t\t\t    \t\tFlxG.volume = FlxG.volume - 0.1;\n\t\t\t\t    \t\tshowSoundTray();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tcase 107:\n\t\t\t\t\t\tcase 187:\n\t\t\t\t\t\t\tFlxG.mute = false;\n\t\t\t\t    \t\tFlxG.volume = FlxG.volume + 0.1;\n\t\t\t\t    \t\tshowSoundTray();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(_replaying)\n\t\t\t\treturn;\n\t\t\tFlxG.keys.handleKeyUp(FlashEvent);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal event handler for input and focus.\n\t\t * \n\t\t * @param\tFlashEvent\tFlash keyboard event.\n\t\t */\n\t\tprotected function handleKeyDown(FlashEvent:KeyboardEvent):void\n\t\t{\n\t\t\tif(_debuggerUp && _debugger.watch.editing)\n\t\t\t\treturn;\n\t\t\tif(_replaying && (_replayCancelKeys != null) && (_debugger == null) && (FlashEvent.keyCode != 192) && (FlashEvent.keyCode != 220))\n\t\t\t{\n\t\t\t\tvar cancel:Boolean = false;\n\t\t\t\tvar replayCancelKey:String;\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar l:uint = _replayCancelKeys.length;\n\t\t\t\twhile(i < l)\n\t\t\t\t{\n\t\t\t\t\treplayCancelKey = _replayCancelKeys[i++];\n\t\t\t\t\tif((replayCancelKey == \"ANY\") || (FlxG.keys.getKeyCode(replayCancelKey) == FlashEvent.keyCode))\n\t\t\t\t\t{\n\t\t\t\t\t\tif(_replayCallback != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_replayCallback();\n\t\t\t\t\t\t\t_replayCallback = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tFlxG.stopReplay();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tFlxG.keys.handleKeyDown(FlashEvent);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal event handler for input and focus.\n\t\t * \n\t\t * @param\tFlashEvent\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseDown(FlashEvent:MouseEvent):void\n\t\t{\n\t\t\tif(_debuggerUp)\n\t\t\t{\n\t\t\t\tif(_debugger.hasMouse)\n\t\t\t\t\treturn;\n\t\t\t\tif(_debugger.watch.editing)\n\t\t\t\t\t_debugger.watch.submit();\n\t\t\t}\n\t\t\tif(_replaying && (_replayCancelKeys != null))\n\t\t\t{\n\t\t\t\tvar replayCancelKey:String;\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar l:uint = _replayCancelKeys.length;\n\t\t\t\twhile(i < l)\n\t\t\t\t{\n\t\t\t\t\treplayCancelKey = _replayCancelKeys[i++] as String;\n\t\t\t\t\tif((replayCancelKey == \"MOUSE\") || (replayCancelKey == \"ANY\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tif(_replayCallback != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_replayCallback();\n\t\t\t\t\t\t\t_replayCallback = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tFlxG.stopReplay();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tFlxG.mouse.handleMouseDown(FlashEvent);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal event handler for input and focus.\n\t\t * \n\t\t * @param\tFlashEvent\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseUp(FlashEvent:MouseEvent):void\n\t\t{\n\t\t\tif((_debuggerUp && _debugger.hasMouse) || _replaying)\n\t\t\t\treturn;\n\t\t\tFlxG.mouse.handleMouseUp(FlashEvent);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal event handler for input and focus.\n\t\t * \n\t\t * @param\tFlashEvent\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseWheel(FlashEvent:MouseEvent):void\n\t\t{\n\t\t\tif((_debuggerUp && _debugger.hasMouse) || _replaying)\n\t\t\t\treturn;\n\t\t\tFlxG.mouse.handleMouseWheel(FlashEvent);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal event handler for input and focus.\n\t\t * \n\t\t * @param\tFlashEvent\tFlash event.\n\t\t */\n\t\tprotected function onFocus(FlashEvent:Event=null):void\n\t\t{\n\t\t\tif(!_debuggerUp && !useSystemCursor)\n\t\t\t\tflash.ui.Mouse.hide();\n\t\t\tFlxG.resetInput();\n\t\t\t_lostFocus = _focus.visible = false;\n\t\t\tstage.frameRate = _flashFramerate;\n\t\t\tFlxG.resumeSounds();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal event handler for input and focus.\n\t\t * \n\t\t * @param\tFlashEvent\tFlash event.\n\t\t */\n\t\tprotected function onFocusLost(FlashEvent:Event=null):void\n\t\t{\n\t\t\tif((x != 0) || (y != 0))\n\t\t\t{\n\t\t\t\tx = 0;\n\t\t\t\ty = 0;\n\t\t\t}\n\t\t\tflash.ui.Mouse.show();\n\t\t\t_lostFocus = _focus.visible = true;\n\t\t\tstage.frameRate = 10;\n\t\t\tFlxG.pauseSounds();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Handles the onEnterFrame call and figures out how many updates and draw calls to do.\n\t\t * \n\t\t * @param\tFlashEvent\tFlash event.\n\t\t */\n\t\tprotected function onEnterFrame(FlashEvent:Event=null):void\n\t\t{\t\t\t\n\t\t\tvar mark:uint = getTimer();\n\t\t\tvar elapsedMS:uint = mark-_total;\n\t\t\t_total = mark;\n\t\t\tupdateSoundTray(elapsedMS);\n\t\t\tif(!_lostFocus)\n\t\t\t{\n\t\t\t\tif((_debugger != null) && _debugger.vcr.paused)\n\t\t\t\t{\n\t\t\t\t\tif(_debugger.vcr.stepRequested)\n\t\t\t\t\t{\n\t\t\t\t\t\t_debugger.vcr.stepRequested = false;\n\t\t\t\t\t\tstep();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_accumulator += elapsedMS;\n\t\t\t\t\tif(_accumulator > _maxAccumulation)\n\t\t\t\t\t\t_accumulator = _maxAccumulation;\n\t\t\t\t\twhile(_accumulator >= _step)\n\t\t\t\t\t{\n\t\t\t\t\t\tstep();\n\t\t\t\t\t\t_accumulator = _accumulator - _step; \n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tFlxBasic._VISIBLECOUNT = 0;\n\t\t\t\tdraw();\n\t\t\t\t\n\t\t\t\tif(_debuggerUp)\n\t\t\t\t{\n\t\t\t\t\t_debugger.perf.flash(elapsedMS);\n\t\t\t\t\t_debugger.perf.visibleObjects(FlxBasic._VISIBLECOUNT);\n\t\t\t\t\t_debugger.perf.update();\n\t\t\t\t\t_debugger.watch.update();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * If there is a state change requested during the update loop,\n\t\t * this function handles actual destroying the old state and related processes,\n\t\t * and calls creates on the new state and plugs it into the game object.\n\t\t */\n\t\tprotected function switchState():void\n\t\t{ \n\t\t\t//Basic reset stuff\n\t\t\tFlxG.resetCameras();\n\t\t\tFlxG.resetInput();\n\t\t\tFlxG.destroySounds();\n\t\t\tFlxG.clearBitmapCache();\n\t\t\t\n\t\t\t//Clear the debugger overlay's Watch window\n\t\t\tif(_debugger != null)\n\t\t\t\t_debugger.watch.removeAll();\n\t\t\t\n\t\t\t//Clear any timers left in the timer manager\n\t\t\tvar timerManager:TimerManager = FlxTimer.manager;\n\t\t\tif(timerManager != null)\n\t\t\t\ttimerManager.clear();\n\t\t\t\n\t\t\t//Destroy the old state (if there is an old state)\n\t\t\tif(_state != null)\n\t\t\t\t_state.destroy();\n\t\t\t\n\t\t\t//Finally assign and create the new state\n\t\t\t_state = _requestedState;\n\t\t\t_state.create();\n\t\t}\n\t\t\n\t\t/**\n\t\t * This is the main game update logic section.\n\t\t * The onEnterFrame() handler is in charge of calling this\n\t\t * the appropriate number of times each frame.\n\t\t * This block handles state changes, replays, all that good stuff.\n\t\t */\n\t\tprotected function step():void\n\t\t{\n\t\t\t//handle game reset request\n\t\t\tif(_requestedReset)\n\t\t\t{\n\t\t\t\t_requestedReset = false;\n\t\t\t\t_requestedState = new _iState();\n\t\t\t\t_replayTimer = 0;\n\t\t\t\t_replayCancelKeys = null;\n\t\t\t\tFlxG.reset();\n\t\t\t}\n\t\t\t\n\t\t\t//handle replay-related requests\n\t\t\tif(_recordingRequested)\n\t\t\t{\n\t\t\t\t_recordingRequested = false;\n\t\t\t\t_replay.create(FlxG.globalSeed);\n\t\t\t\t_recording = true;\n\t\t\t\tif(_debugger != null)\n\t\t\t\t{\n\t\t\t\t\t_debugger.vcr.recording();\n\t\t\t\t\tFlxG.log(\"FLIXEL: starting new flixel gameplay record.\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(_replayRequested)\n\t\t\t{\n\t\t\t\t_replayRequested = false;\n\t\t\t\t_replay.rewind();\n\t\t\t\tFlxG.globalSeed = _replay.seed;\n\t\t\t\tif(_debugger != null)\n\t\t\t\t\t_debugger.vcr.playing();\n\t\t\t\t_replaying = true;\n\t\t\t}\n\t\t\t\n\t\t\t//handle state switching requests\n\t\t\tif(_state != _requestedState)\n\t\t\t\tswitchState();\n\t\t\t\n\t\t\t//finally actually step through the game physics\n\t\t\tFlxBasic._ACTIVECOUNT = 0;\n\t\t\tif(_replaying)\n\t\t\t{\n\t\t\t\t_replay.playNextFrame();\n\t\t\t\tif(_replayTimer > 0)\n\t\t\t\t{\n\t\t\t\t\t_replayTimer -= _step;\n\t\t\t\t\tif(_replayTimer <= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(_replayCallback != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_replayCallback();\n\t\t\t\t\t\t\t_replayCallback = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tFlxG.stopReplay();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(_replaying && _replay.finished)\n\t\t\t\t{\n\t\t\t\t\tFlxG.stopReplay();\n\t\t\t\t\tif(_replayCallback != null)\n\t\t\t\t\t{\n\t\t\t\t\t\t_replayCallback();\n\t\t\t\t\t\t_replayCallback = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(_debugger != null)\n\t\t\t\t\t_debugger.vcr.updateRuntime(_step);\n\t\t\t}\n\t\t\telse\n\t\t\t\tFlxG.updateInput();\n\t\t\tif(_recording)\n\t\t\t{\n\t\t\t\t_replay.recordFrame();\n\t\t\t\tif(_debugger != null)\n\t\t\t\t\t_debugger.vcr.updateRuntime(_step);\n\t\t\t}\n\t\t\tupdate();\n\t\t\tFlxG.mouse.wheel = 0;\n\t\t\tif(_debuggerUp)\n\t\t\t\t_debugger.perf.activeObjects(FlxBasic._ACTIVECOUNT);\n\t\t}\n\n\t\t/**\n\t\t * This function just updates the soundtray object.\n\t\t */\n\t\tprotected function updateSoundTray(MS:Number):void\n\t\t{\n\t\t\t//animate stupid sound tray thing\n\t\t\t\n\t\t\tif(_soundTray != null)\n\t\t\t{\n\t\t\t\tif(_soundTrayTimer > 0)\n\t\t\t\t\t_soundTrayTimer -= MS/1000;\n\t\t\t\telse if(_soundTray.y > -_soundTray.height)\n\t\t\t\t{\n\t\t\t\t\t_soundTray.y -= (MS/1000)*FlxG.height*2;\n\t\t\t\t\tif(_soundTray.y <= -_soundTray.height)\n\t\t\t\t\t{\n\t\t\t\t\t\t_soundTray.visible = false;\n\t\t\t\t\t\t\n\t\t\t\t\t\t//Save sound preferences\n\t\t\t\t\t\tvar soundPrefs:FlxSave = new FlxSave();\n\t\t\t\t\t\tif(soundPrefs.bind(\"flixel\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(soundPrefs.data.sound == null)\n\t\t\t\t\t\t\t\tsoundPrefs.data.sound = new Object;\n\t\t\t\t\t\t\tsoundPrefs.data.sound.mute = FlxG.mute;\n\t\t\t\t\t\t\tsoundPrefs.data.sound.volume = FlxG.volume;\n\t\t\t\t\t\t\tsoundPrefs.close();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * This function is called by step() and updates the actual game state.\n\t\t * May be called multiple times per \"frame\" or draw call.\n\t\t */\n\t\tprotected function update():void\n\t\t{\t\t\t\n\t\t\tvar mark:uint = getTimer();\n\t\t\t\n            \n            \n\t\t\tFlxG.elapsed = FlxG.timeScale*(_step/1000);\n\t\t\tFlxG.updateSounds();\n\t\t\tFlxG.updatePlugins();\n\t\t\t_state.update();\n\t\t\tFlxG.updateCameras();\n\t\t\t\n\t\t\tif(_debuggerUp)\n\t\t\t\t_debugger.perf.flixelUpdate(getTimer()-mark);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Goes through the game state and draws all the game objects and special effects.\n\t\t */\n\t\tprotected function draw():void\n\t\t{\n            var w:Number = FlxG.width * FlxG.camera.zoom;\n            var h:Number = FlxG.height * FlxG.camera.zoom;\n\t\t\t/* keep aspect ratio (letter/pillarBox) */\n\t\t\tif (FlxG.stage.stageWidth / FlxG.stage.stageHeight < (w / h)) {\n\t\t\t\t// letter-box\n\t\t\t\tscaleX = (FlxG.stage.stageWidth / w);\n\t\t\t    scaleY = ((h / w * FlxG.stage.stageWidth) / h);\n\n\t\t\t}else {\n\t\t\t\t// pillar-box\n\t\t\t\tscaleX = ((w / h * FlxG.stage.stageHeight) / w);\n\t\t\t\tscaleY = (FlxG.stage.stageHeight / h);\n\t\t\t}\n\n\t\t\tx = Math.round((FlxG.stage.stageWidth / 2) - (w * scaleX / 2));\n\t\t\ty = Math.round((FlxG.stage.stageHeight / 2) - (h * scaleY / 2));\n            \n            \n\t\t\tvar mark:uint = getTimer();\n\t\t\tFlxG.lockCameras();\n\t\t\t_state.draw();\n\t\t\tFlxG.drawPlugins();\n\t\t\tFlxG.unlockCameras();\n\t\t\tif(_debuggerUp)\n\t\t\t\t_debugger.perf.flixelDraw(getTimer()-mark);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Used to instantiate the guts of the flixel game object once we have a valid reference to the root.\n\t\t * \n\t\t * @param\tFlashEvent\tJust a Flash system event, not too important for our purposes.\n\t\t */\n\t\tprotected function create(FlashEvent:Event):void\n\t\t{\n\t\t\tif(root == null)\n\t\t\t\treturn;\n\t\t\tremoveEventListener(Event.ENTER_FRAME, create);\n\t\t\t_total = getTimer();\n\t\t\t\n\t\t\t//Set up the view window and double buffering\n\t\t\tstage.scaleMode = StageScaleMode.NO_SCALE;\n            stage.align = StageAlign.TOP_LEFT;\n            stage.frameRate = _flashFramerate;\n\t\t\t\n\t\t\t//Add basic input event listeners and mouse container\n\t\t\tstage.addEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown);\n\t\t\tstage.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);\n\t\t\tstage.addEventListener(MouseEvent.MOUSE_WHEEL, handleMouseWheel);\n\t\t\tstage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);\n\t\t\tstage.addEventListener(KeyboardEvent.KEY_UP, handleKeyUp);\n\t\t\taddChild(_mouse);\n\t\t\t\n\t\t\t//Let mobile devs opt out of unnecessary overlays.\n\t\t\tif(!FlxG.mobile)\n\t\t\t{\n\t\t\t\t//Debugger overlay\n\t\t\t\tif(FlxG.debug || forceDebugger)\n\t\t\t\t{\n\t\t\t\t\t_debugger = new FlxDebugger(FlxG.width*FlxCamera.defaultZoom,FlxG.height*FlxCamera.defaultZoom);\n\t\t\t\t\taddChild(_debugger);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//Volume display tab\n\t\t\t\tcreateSoundTray();\n\t\t\t\t\n\t\t\t\t//Focus gained/lost monitoring\n\t\t\t\tstage.addEventListener(Event.DEACTIVATE, onFocusLost);\n\t\t\t\tstage.addEventListener(Event.ACTIVATE, onFocus);\n\t\t\t\tcreateFocusScreen();\n\t\t\t}\n\t\t\t\n\t\t\t//Finally, set up an event for the actual game loop stuff.\n\t\t\taddEventListener(Event.ENTER_FRAME, onEnterFrame);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets up the \"sound tray\", the little volume meter that pops down sometimes.\n\t\t */\n\t\tprotected function createSoundTray():void\n\t\t{\n\t\t\t_soundTray.visible = false;\n\t\t\t_soundTray.scaleX = 2;\n\t\t\t_soundTray.scaleY = 2;\n\t\t\tvar tmp:Bitmap = new Bitmap(new BitmapData(80,30,true,0x7F000000));\n\t\t\t_soundTray.x = (FlxG.width/2)*FlxCamera.defaultZoom-(tmp.width/2)*_soundTray.scaleX;\n\t\t\t_soundTray.addChild(tmp);\n\t\t\t\n\t\t\tvar text:TextField = new TextField();\n\t\t\ttext.width = tmp.width;\n\t\t\ttext.height = tmp.height;\n\t\t\ttext.multiline = true;\n\t\t\ttext.wordWrap = true;\n\t\t\ttext.selectable = false;\n\t\t\ttext.embedFonts = true;\n\t\t\ttext.antiAliasType = AntiAliasType.NORMAL;\n\t\t\ttext.gridFitType = GridFitType.PIXEL;\n\t\t\ttext.defaultTextFormat = new TextFormat(\"system\",8,0xffffff,null,null,null,null,null,\"center\");;\n\t\t\t_soundTray.addChild(text);\n\t\t\ttext.text = \"VOLUME\";\n\t\t\ttext.y = 16;\n\t\t\t\n\t\t\tvar bx:uint = 10;\n\t\t\tvar by:uint = 14;\n\t\t\t_soundTrayBars = new Array();\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < 10)\n\t\t\t{\n\t\t\t\ttmp = new Bitmap(new BitmapData(4,++i,false,0xffffff));\n\t\t\t\ttmp.x = bx;\n\t\t\t\ttmp.y = by;\n\t\t\t\t_soundTrayBars.push(_soundTray.addChild(tmp));\n\t\t\t\tbx += 6;\n\t\t\t\tby--;\n\t\t\t}\n\t\t\t\n\t\t\t_soundTray.y = -_soundTray.height;\n\t\t\t_soundTray.visible = false;\n\t\t\taddChild(_soundTray);\n\t\t\t\n\t\t\t//load saved sound preferences for this game if they exist\n\t\t\tvar soundPrefs:FlxSave = new FlxSave();\n\t\t\tif(soundPrefs.bind(\"flixel\") && (soundPrefs.data.sound != null))\n\t\t\t{\n\t\t\t\tif(soundPrefs.data.sound.volume != null)\n\t\t\t\t\tFlxG.volume = soundPrefs.data.sound.volume;\n\t\t\t\tif(soundPrefs.data.sound.mute != null)\n\t\t\t\t\tFlxG.mute = soundPrefs.data.sound.mute;\n\t\t\t\tsoundPrefs.destroy();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets up the darkened overlay with the big white \"play\" button that appears when a flixel game loses focus.\n\t\t */\n\t\tprotected function createFocusScreen():void\n\t\t{\n\t\t\tvar gfx:Graphics = _focus.graphics;\n\t\t\tvar screenWidth:uint = FlxG.width*FlxCamera.defaultZoom;\n\t\t\tvar screenHeight:uint = FlxG.height*FlxCamera.defaultZoom;\n\t\t\t\n\t\t\t//draw transparent black backdrop\n\t\t\tgfx.moveTo(0,0);\n\t\t\tgfx.beginFill(0,0.5);\n\t\t\tgfx.lineTo(screenWidth,0);\n\t\t\tgfx.lineTo(screenWidth,screenHeight);\n\t\t\tgfx.lineTo(0,screenHeight);\n\t\t\tgfx.lineTo(0,0);\n\t\t\tgfx.endFill();\n\t\t\t\n\t\t\t//draw white arrow\n\t\t\tvar halfWidth:uint = screenWidth/2;\n\t\t\tvar halfHeight:uint = screenHeight/2;\n\t\t\tvar helper:uint = FlxU.min(halfWidth,halfHeight)/3;\n\t\t\tgfx.moveTo(halfWidth-helper,halfHeight-helper);\n\t\t\tgfx.beginFill(0xffffff,0.65);\n\t\t\tgfx.lineTo(halfWidth+helper,halfHeight);\n\t\t\tgfx.lineTo(halfWidth-helper,halfHeight+helper);\n\t\t\tgfx.lineTo(halfWidth-helper,halfHeight-helper);\n\t\t\tgfx.endFill();\n\t\t\t\n\t\t\tvar logo:Bitmap = new ImgLogo();\n\t\t\tlogo.scaleX = int(helper/10);\n\t\t\tif(logo.scaleX < 1)\n\t\t\t\tlogo.scaleX = 1;\n\t\t\tlogo.scaleY = logo.scaleX;\n\t\t\tlogo.x -= logo.scaleX;\n\t\t\tlogo.alpha = 0.35;\n\t\t\t_focus.addChild(logo);\n\n\t\t\taddChild(_focus);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxGroup.as",
    "content": "package org.flixel\n{\n\t/**\n\t * This is an organizational class that can update and render a bunch of <code>FlxBasic</code>s.\n\t * NOTE: Although <code>FlxGroup</code> extends <code>FlxBasic</code>, it will not automatically\n\t * add itself to the global collisions quad tree, it will only add its members.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxGroup extends FlxBasic\n\t{\n\t\t/**\n\t\t * Use with <code>sort()</code> to sort in ascending order.\n\t\t */\n\t\tstatic public const ASCENDING:int = -1;\n\t\t/**\n\t\t * Use with <code>sort()</code> to sort in descending order.\n\t\t */\n\t\tstatic public const DESCENDING:int = 1;\n\t\t\n\t\t/**\n\t\t * Array of all the <code>FlxBasic</code>s that exist in this group.\n\t\t */\n\t\tpublic var members:Array;\n\t\t/**\n\t\t * The number of entries in the members array.\n\t\t * For performance and safety you should check this variable\n\t\t * instead of members.length unless you really know what you're doing!\n\t\t */\n\t\tpublic var length:Number;\n\n\t\t/**\n\t\t * Internal tracker for the maximum capacity of the group.\n\t\t * Default is 0, or no max capacity.\n\t\t */\n\t\tprotected var _maxSize:uint;\n\t\t/**\n\t\t * Internal helper variable for recycling objects a la <code>FlxEmitter</code>.\n\t\t */\n\t\tprotected var _marker:uint;\n\t\t\n\t\t/**\n\t\t * Helper for sort.\n\t\t */\n\t\tprotected var _sortIndex:String;\n\t\t/**\n\t\t * Helper for sort.\n\t\t */\n\t\tprotected var _sortOrder:int;\n\n\t\t/**\n\t\t * Constructor\n\t\t */\n\t\tpublic function FlxGroup(MaxSize:uint=0)\n\t\t{\n\t\t\tsuper();\n\t\t\tmembers = new Array();\n\t\t\tlength = 0;\n\t\t\t_maxSize = MaxSize;\n\t\t\t_marker = 0;\n\t\t\t_sortIndex = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Override this function to handle any deleting or \"shutdown\" type operations you might need,\n\t\t * such as removing traditional Flash children like Sprite objects.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tif(members != null)\n\t\t\t{\n\t\t\t\tvar basic:FlxBasic;\n\t\t\t\tvar i:uint = 0;\n\t\t\t\twhile(i < length)\n\t\t\t\t{\n\t\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\t\tif(basic != null)\n\t\t\t\t\t\tbasic.destroy();\n\t\t\t\t}\n\t\t\t\tmembers.length = 0;\n\t\t\t\tmembers = null;\n\t\t\t}\n\t\t\t_sortIndex = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Just making sure we don't increment the active objects count.\n\t\t */\n\t\toverride public function preUpdate():void\n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Automatically goes through and calls update on everything you added.\n\t\t */\n\t\toverride public function update():void\n\t\t{\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < length)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif((basic != null) && basic.exists && basic.active)\n\t\t\t\t{\n\t\t\t\t\tbasic.preUpdate();\n\t\t\t\t\tbasic.update();\n\t\t\t\t\tbasic.postUpdate();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Automatically goes through and calls render on everything you added.\n\t\t */\n\t\toverride public function draw():void\n\t\t{\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < length)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif((basic != null) && basic.exists && basic.visible)\n\t\t\t\t\tbasic.draw();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * The maximum capacity of this group.  Default is 0, meaning no max capacity, and the group can just grow.\n\t\t */\n\t\tpublic function get maxSize():uint\n\t\t{\n\t\t\treturn _maxSize;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set maxSize(Size:uint):void\n\t\t{\n\t\t\t_maxSize = Size;\n\t\t\tif(_marker >= _maxSize)\n\t\t\t\t_marker = 0;\n\t\t\tif((_maxSize == 0) || (members == null) || (_maxSize >= members.length))\n\t\t\t\treturn;\n\t\t\t\n\t\t\t//If the max size has shrunk, we need to get rid of some objects\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = _maxSize;\n\t\t\tvar l:uint = members.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif(basic != null)\n\t\t\t\t\tbasic.destroy();\n\t\t\t}\n\t\t\tlength = members.length = _maxSize;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adds a new <code>FlxBasic</code> subclass (FlxBasic, FlxSprite, Enemy, etc) to the group.\n\t\t * FlxGroup will try to replace a null member of the array first.\n\t\t * Failing that, FlxGroup will add it to the end of the member array,\n\t\t * assuming there is room for it, and doubling the size of the array if necessary.\n\t\t *\n\t\t * <p>WARNING: If the group has a maxSize that has already been met,\n\t\t * the object will NOT be added to the group!</p>\n\t\t *\n\t\t * @param\tObject\t\tThe object you want to add to the group.\n\t\t *\n\t\t * @return\tThe same <code>FlxBasic</code> object that was passed in.\n\t\t */\n\t\tpublic function add(Object:FlxBasic):FlxBasic\n\t\t{\n\t\t\t//Don't bother adding an object twice.\n\t\t\tif(members.indexOf(Object) >= 0)\n\t\t\t\treturn Object;\n\t\t\t\n\t\t\t//First, look for a null entry where we can add the object.\n\t\t\tvar i:int = 0;\n\t\t\tvar l:uint = members.length;\n\t\t\tfor (i = 0; i < l; i++){\n\t\t\t// while(i < l){\n\t\t\t\tif(members[i] == null)\n\t\t\t\t{\n\t\t\t\t\tmembers[i] = Object;\n\t\t\t\t\tif(i >= length)\n\t\t\t\t\t\tlength = i+1;\n\t\t\t\t\treturn Object;\n\t\t\t\t}\n\t\t\t\t// i++;\n\t\t\t}\n\t\t\t\n\t\t\t//Failing that, expand the array (if we can) and add the object.\n\t\t\tif(_maxSize > 0)\n\t\t\t{\n\t\t\t\tif(members.length >= _maxSize)\n\t\t\t\t\treturn Object;\n\t\t\t\telse if(members.length * 2 <= _maxSize)\n\t\t\t\t\tmembers.length *= 2;\n\t\t\t\telse\n\t\t\t\t\tmembers.length = _maxSize;\n\t\t\t}\n\t\t\telse\n\t\t\t\tmembers.length *= 2;\n\t\t\t\n\t\t\t//If we made it this far, then we successfully grew the group,\n\t\t\t//and we can go ahead and add the object at the first open slot.\n\t\t\tmembers[i] = Object;\n\t\t\tlength = i+1;\n\t\t\treturn Object;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Recycling is designed to help you reuse game objects without always re-allocating or \"newing\" them.\n\t\t * \n\t\t * <p>If you specified a maximum size for this group (like in FlxEmitter),\n\t\t * then recycle will employ what we're calling \"rotating\" recycling.\n\t\t * Recycle() will first check to see if the group is at capacity yet.\n\t\t * If group is not yet at capacity, recycle() returns a new object.\n\t\t * If the group IS at capacity, then recycle() just returns the next object in line.</p>\n\t\t * \n\t\t * <p>If you did NOT specify a maximum size for this group,\n\t\t * then recycle() will employ what we're calling \"grow-style\" recycling.\n\t\t * Recycle() will return either the first object with exists == false,\n\t\t * or, finding none, add a new object to the array,\n\t\t * doubling the size of the array if necessary.</p>\n\t\t * \n\t\t * <p>WARNING: If this function needs to create a new object,\n\t\t * and no object class was provided, it will return null\n\t\t * instead of a valid object!</p>\n\t\t * \n\t\t * @param\tObjectClass\t\tThe class type you want to recycle (e.g. FlxSprite, EvilRobot, etc). Do NOT \"new\" the class in the parameter!\n\t\t * \n\t\t * @return\tA reference to the object that was created.  Don't forget to cast it back to the Class you want (e.g. myObject = myGroup.recycle(myObjectClass) as myObjectClass;).\n\t\t */\n\t\tpublic function recycle(ObjectClass:Class=null):FlxBasic\n\t\t{\n\t\t\tvar basic:FlxBasic;\n\t\t\tif(_maxSize > 0)\n\t\t\t{\n\t\t\t\tif(length < _maxSize)\n\t\t\t\t{\n\t\t\t\t\tif(ObjectClass == null)\n\t\t\t\t\t\treturn null;\n\t\t\t\t\treturn add(new ObjectClass() as FlxBasic);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tbasic = members[_marker++];\n\t\t\t\t\tif(_marker >= _maxSize)\n\t\t\t\t\t\t_marker = 0;\n\t\t\t\t\treturn basic;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbasic = getFirstAvailable(ObjectClass);\n\t\t\t\tif(basic != null)\n\t\t\t\t\treturn basic;\n\t\t\t\tif(ObjectClass == null)\n\t\t\t\t\treturn null;\n\t\t\t\treturn add(new ObjectClass() as FlxBasic);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes an object from the group.\n\t\t * \n\t\t * @param\tObject\tThe <code>FlxBasic</code> you want to remove.\n\t\t * @param\tSplice\tWhether the object should be cut from the array entirely or not.\n\t\t * \n\t\t * @return\tThe removed object.\n\t\t */\n\t\tpublic function remove(Object:FlxBasic,Splice:Boolean=false):FlxBasic\n\t\t{\n\t\t\tvar index:int = members.indexOf(Object);\n\t\t\tif((index < 0) || (index >= members.length))\n\t\t\t\treturn null;\n\t\t\tif(Splice)\n\t\t\t{\n\t\t\t\tmembers.splice(index,1);\n\t\t\t\tlength--;\n\t\t\t}\n\t\t\telse\n\t\t\t\tmembers[index] = null;\n\t\t\treturn Object;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Replaces an existing <code>FlxBasic</code> with a new one.\n\t\t * \n\t\t * @param\tOldObject\tThe object you want to replace.\n\t\t * @param\tNewObject\tThe new object you want to use instead.\n\t\t * \n\t\t * @return\tThe new object.\n\t\t */\n\t\tpublic function replace(OldObject:FlxBasic,NewObject:FlxBasic):FlxBasic\n\t\t{\n\t\t\tvar index:int = members.indexOf(OldObject);\n\t\t\tif((index < 0) || (index >= members.length))\n\t\t\t\treturn null;\n\t\t\tmembers[index] = NewObject;\n\t\t\treturn NewObject;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to sort the group according to a particular value and order.\n\t\t * For example, to sort game objects for Zelda-style overlaps you might call\n\t\t * <code>myGroup.sort(\"y\",ASCENDING)</code> at the bottom of your\n\t\t * <code>FlxState.update()</code> override.  To sort all existing objects after\n\t\t * a big explosion or bomb attack, you might call <code>myGroup.sort(\"exists\",DESCENDING)</code>.\n\t\t * \n\t\t * @param\tIndex\tThe <code>String</code> name of the member variable you want to sort on.  Default value is \"y\".\n\t\t * @param\tOrder\tA <code>FlxGroup</code> constant that defines the sort order.  Possible values are <code>ASCENDING</code> and <code>DESCENDING</code>.  Default value is <code>ASCENDING</code>.  \n\t\t */\n\t\tpublic function sort(Index:String=\"y\",Order:int=ASCENDING):void\n\t\t{\n\t\t\t_sortIndex = Index;\n\t\t\t_sortOrder = Order;\n\t\t\tmembers.sort(sortHandler);\n\t\t}\n\n\t\t/**\n\t\t * Go through and set the specified variable to the specified value on all members of the group.\n\t\t * \n\t\t * @param\tVariableName\tThe string representation of the variable name you want to modify, for example \"visible\" or \"scrollFactor\".\n\t\t * @param\tValue\t\t\tThe value you want to assign to that variable.\n\t\t * @param\tRecurse\t\t\tDefault value is true, meaning if <code>setAll()</code> encounters a member that is a group, it will call <code>setAll()</code> on that group rather than modifying its variable.\n\t\t */\n\t\tpublic function setAll(VariableName:String,Value:Object,Recurse:Boolean=true):void\n\t\t{\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < length)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif(basic != null)\n\t\t\t\t{\n\t\t\t\t\tif(Recurse && (basic is FlxGroup))\n\t\t\t\t\t\t(basic as FlxGroup).setAll(VariableName,Value,Recurse);\n\t\t\t\t\telse\n\t\t\t\t\t\tbasic[VariableName] = Value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Go through and call the specified function on all members of the group.\n\t\t * Currently only works on functions that have no required parameters.\n\t\t * \n\t\t * @param\tFunctionName\tThe string representation of the function you want to call on each object, for example \"kill()\" or \"init()\".\n\t\t * @param\tRecurse\t\t\tDefault value is true, meaning if <code>callAll()</code> encounters a member that is a group, it will call <code>callAll()</code> on that group rather than calling the group's function.\n\t\t */ \n\t\tpublic function callAll(FunctionName:String,Recurse:Boolean=true):void\n\t\t{\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < length)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif(basic != null)\n\t\t\t\t{\n\t\t\t\t\tif(Recurse && (basic is FlxGroup))\n\t\t\t\t\t\t(basic as FlxGroup).callAll(FunctionName,Recurse);\n\t\t\t\t\telse\n\t\t\t\t\t\tbasic[FunctionName]();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to retrieve the first object with exists == false in the group.\n\t\t * This is handy for recycling in general, e.g. respawning enemies.\n\t\t * \n\t\t * @param\tObjectClass\t\tAn optional parameter that lets you narrow the results to instances of this particular class.\n\t\t * \n\t\t * @return\tA <code>FlxBasic</code> currently flagged as not existing.\n\t\t */\n\t\tpublic function getFirstAvailable(ObjectClass:Class=null):FlxBasic\n\t\t{\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < length)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif((basic != null) && !basic.exists && ((ObjectClass == null) || (basic is ObjectClass)))\n\t\t\t\t\treturn basic;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to retrieve the first index set to 'null'.\n\t\t * Returns -1 if no index stores a null object.\n\t\t * \n\t\t * @return\tAn <code>int</code> indicating the first null slot in the group.\n\t\t */\n\t\tpublic function getFirstNull():int\n\t\t{\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = members.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tif(members[i] == null)\n\t\t\t\t\treturn i;\n\t\t\t\telse\n\t\t\t\t\ti++;\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to retrieve the first object with exists == true in the group.\n\t\t * This is handy for checking if everything's wiped out, or choosing a squad leader, etc.\n\t\t * \n\t\t * @return\tA <code>FlxBasic</code> currently flagged as existing.\n\t\t */\n\t\tpublic function getFirstExtant():FlxBasic\n\t\t{\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < length)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif((basic != null) && basic.exists)\n\t\t\t\t\treturn basic;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to retrieve the first object with dead == false in the group.\n\t\t * This is handy for checking if everything's wiped out, or choosing a squad leader, etc.\n\t\t * \n\t\t * @return\tA <code>FlxBasic</code> currently flagged as not dead.\n\t\t */\n\t\tpublic function getFirstAlive():FlxBasic\n\t\t{\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < length)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif((basic != null) && basic.exists && basic.alive)\n\t\t\t\t\treturn basic;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to retrieve the first object with dead == true in the group.\n\t\t * This is handy for checking if everything's wiped out, or choosing a squad leader, etc.\n\t\t * \n\t\t * @return\tA <code>FlxBasic</code> currently flagged as dead.\n\t\t */\n\t\tpublic function getFirstDead():FlxBasic\n\t\t{\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < length)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif((basic != null) && !basic.alive)\n\t\t\t\t\treturn basic;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to find out how many members of the group are not dead.\n\t\t * \n\t\t * @return\tThe number of <code>FlxBasic</code>s flagged as not dead.  Returns -1 if group is empty.\n\t\t */\n\t\tpublic function countLiving():int\n\t\t{\n\t\t\tvar count:int = -1;\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < length)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif(basic != null)\n\t\t\t\t{\n\t\t\t\t\tif(count < 0)\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\tif(basic.exists && basic.alive)\n\t\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn count;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to find out how many members of the group are dead.\n\t\t * \n\t\t * @return\tThe number of <code>FlxBasic</code>s flagged as dead.  Returns -1 if group is empty.\n\t\t */\n\t\tpublic function countDead():int\n\t\t{\n\t\t\tvar count:int = -1;\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < length)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif(basic != null)\n\t\t\t\t{\n\t\t\t\t\tif(count < 0)\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\tif(!basic.alive)\n\t\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn count;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns a member at random from the group.\n\t\t * \n\t\t * @param\tStartIndex\tOptional offset off the front of the array. Default value is 0, or the beginning of the array.\n\t\t * @param\tLength\t\tOptional restriction on the number of values you want to randomly select from.\n\t\t * \n\t\t * @return\tA <code>FlxBasic</code> from the members list.\n\t\t */\n\t\tpublic function getRandom(StartIndex:uint=0,Length:uint=0):FlxBasic\n\t\t{\n\t\t\tif(Length == 0)\n\t\t\t\tLength = length;\n\t\t\treturn FlxG.getRandom(members,StartIndex,Length) as FlxBasic;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Remove all instances of <code>FlxBasic</code> subclass (FlxSprite, FlxBlock, etc) from the list.\n\t\t * WARNING: does not destroy() or kill() any of these objects!\n\t\t */\n\t\tpublic function clear():void\n\t\t{\n\t\t\tlength = members.length = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Calls kill on the group's members and then on the group itself.\n\t\t */\n\t\toverride public function kill():void\n\t\t{\n\t\t\tvar basic:FlxBasic;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < length)\n\t\t\t{\n\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\tif((basic != null) && basic.exists)\n\t\t\t\t\tbasic.kill();\n\t\t\t}\n\t\t\tsuper.kill();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Helper function for the sort process.\n\t\t * \n\t\t * @param \tObj1\tThe first object being sorted.\n\t\t * @param\tObj2\tThe second object being sorted.\n\t\t * \n\t\t * @return\tAn integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2).\n\t\t */\n\t\tprotected function sortHandler(Obj1:FlxBasic,Obj2:FlxBasic):int\n\t\t{\n\t\t\tif(Obj1[_sortIndex] < Obj2[_sortIndex])\n\t\t\t\treturn _sortOrder;\n\t\t\telse if(Obj1[_sortIndex] > Obj2[_sortIndex])\n\t\t\t\treturn -_sortOrder;\n\t\t\treturn 0;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxInputText.as",
    "content": "package org.flixel\n{\n\timport flash.text.TextField;\n\timport org.flixel.*;\n\timport flash.events.Event;\n\timport flash.text.TextFieldType;\n\t\n\t/**\n\tFlxInputText v0.92, Input text field extension for Flixel\n\t(author Nitram_cero, Martin Sebastian Wain)\n\t(slight modification by Wurmy, seems to work on version 2.34 of Flixel)\n\t(little insignificant update by Tyranus, now works with scroll)\n\t(minor 2.5. update by Kevin Prein)\n\t(minor update by Mr_Walrus, IDE-friendly and plays nicer with Flixel)\n\n\tNew members:\n\t\tgetText()\n\t\tsetMaxLength()\n\t\t\n\t\tbackgroundColor\n\t\tborderColor\n\t\tbackgroundVisible\n\t\tborderVisible\n\t\t\n\t\tforceUpperCase\n\t\tfilterMode\n\t\tcustomFilterPattern\n\t\n\tCopyright (c) 2009 Martin Sebastian Wain\n\tLicense: Creative Commons Attribution 3.0 United States\n\t(http://creativecommons.org/licenses/by/3.0/us/)\n\t\n\t(A tiny \"single line comment\" reference in the source code is more than sufficient as attribution :)\n\t */\n\t\n\tpublic class FlxInputText extends FlxText {\n\t\t\n\t\tstatic public const NO_FILTER:uint\t\t\t\t= 0;\n\t\tstatic public const ONLY_ALPHA:uint\t\t\t\t= 1;\n\t\tstatic public const ONLY_NUMERIC:uint\t\t\t= 2;\n\t\tstatic public const ONLY_ALPHANUMERIC:uint\t\t= 3;\n\t\tstatic public const CUSTOM_FILTER:uint\t\t\t= 4;\n\t\t\n\t\t//@desc\t\tDefines what text to filter. It can be NO_FILTER, ONLY_ALPHA, ONLY_NUMERIC, ONLY_ALPHA_NUMERIC or CUSTOM_FILTER\n\t\t//\t\t\t(Remember to append \"FlxInputText.\" as a prefix to those constants)\n\t\tpublic var filterMode:uint = NO_FILTER;\n\t\t\n\t\t//@desc\t\tThis regular expression will filter out (remove) everything that matches. This is activated by setting filterMode = FlxInputText.CUSTOM_FILTER.\n\t\tpublic var customFilterPattern:RegExp = /[]*/g;\n\t\t\n\t\t//@desc\t\tIf this is set to true, text typed is forced to be uppercase\n\t\tpublic var forceUpperCase:Boolean = false;\n\t\t\n\t\t/**\n\t\t * Input field class that \"fits in\" with Flixel's workflow\n\t\t * \n\t\t * @param\tX\t\t\t\tThe X position of the text.\n\t\t * @param\tY\t\t\t\tThe Y position of the text.\n\t\t * @param\tWidth\t\t\tThe width of the text box.\n\t\t * @param\tText\t\t\tThe text to be displayed.\n\t\t * @param\tColor\t\t\tThe text color.\n\t\t * @param\tFont\t\t\tThe text font.\n\t\t * @param\tSize\t\t\tThe width of the text box.\n\t\t * @param\tJustification\tHow to center the text with with regards to the box.\n\t\t */\n\t\tpublic function FlxInputText(X:Number, Y:Number, Width:uint, Height:uint, Text:String, Color:uint=0x000000, Font:String=null, Size:uint=8, Justification:String=null)\n\t\t{\n\t\t\t//super(X, Y, Width, Height, Text, Color, Font, Size, Justification, Angle);\n\t\t\tsuper(X, Y, Width, Text);\n            setFormat(Font, Size)\n\t\t\t\n\t\t\t_textField.selectable = true;\n\t\t\t_textField.type = TextFieldType.INPUT;\n\t\t\t_textField.background = false;\n\t\t\t_textField.backgroundColor = (~Color) & 0xffffff;\n\t\t\t_textField.textColor = Color;\n\t\t\t_textField.border = true;\n\t\t\t_textField.borderColor = Color;\n\t\t\t_textField.height = Height;\n\t\t\tthis.height = Height;\n\t\t\t\n\t\t\t_textField.x = X;\n\t\t\t_textField.y = Y;\n\t\t\t_textField.addEventListener(Event.CHANGE, onTextChange);\n\t\t\t\n\t\t\tFlxG.stage.addChild(_textField);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Override the draw function so that the flash object shows, not the FlxSprite\n\t\t */\n\t\toverride public function draw():void \n\t\t{\n\t\t\t\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up after ourselves\n\t\t */\n\t\toverride public function destroy():void \n\t\t{\n\t\t\t_textField.removeEventListener(Event.CHANGE, onTextChange);\n\t\t\tFlxG.stage.removeChild(_textField);\n\t\t\tsuper.destroy();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Handles the text of the object being changed,\n\t\t * checks it against the text field filters\n\t\t * @param\tevent\n\t\t */\n\t\tprivate function onTextChange(event:Event):void\n\t\t{\n\t\t\tif(forceUpperCase)\n\t\t\t\t_textField.text = _textField.text.toUpperCase();\n\t\t\t\t\n\t\t\tif(filterMode != NO_FILTER) {\n\t\t\t\tvar pattern:RegExp;\n\t\t\t\tswitch(filterMode) {\n\t\t\t\t\tcase ONLY_ALPHA:\t\tpattern = /[^a-zA-Z]*/g;\t\tbreak;\n\t\t\t\t\tcase ONLY_NUMERIC:\t\tpattern = /[^0-9]*/g;\t\t\tbreak;\n\t\t\t\t\tcase ONLY_ALPHANUMERIC:\tpattern = /[^a-zA-Z0-9]*/g;\t\tbreak;\n\t\t\t\t\tcase CUSTOM_FILTER:\t\tpattern = customFilterPattern;\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(\"FlxInputText: Unknown filterMode (\"+filterMode+\")\");\n\t\t\t\t}\n\t\t\t\t_textField.text = _textField.text.replace(pattern, \"\");\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * The color of the background of the text box\n\t\t */\n\t\tpublic function get backgroundColor():uint\t\t\t\t\t\n\t\t{ \n\t\t\treturn _textField.backgroundColor; \n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set backgroundColor(Color:uint):void\n\t\t{ \n\t\t\t_textField.backgroundColor = Color; \n\t\t}\n\t\t\n\t\t/**\n\t\t * The color of the border around the text box.\n\t\t */\n\t\tpublic function get borderColor():uint\n\t\t{ \n\t\t\treturn _textField.borderColor; \n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set borderColor(Color:uint):void\n\t\t{ \n\t\t\t_textField.borderColor = Color; \n\t\t}\n\t\t\n\t\t/**\n\t\t * Whether the textbox has a background.\n\t\t */\n\t\tpublic function get backgroundVisible():Boolean\t\n\t\t{\n\t\t\treturn _textField.background;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set backgroundVisible(Enabled:Boolean):void\t\n\t\t{\n\t\t\t_textField.background = Enabled; \n\t\t}\n\t\t\n\t\t/**\n\t\t * Whether the textbox has a border.\n\t\t */\n\t\tpublic function get borderVisible():Boolean\n\t\t{ \n\t\t\treturn _textField.border;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set borderVisible(Enabled:Boolean):void\n\t\t{ \n\t\t\t_textField.border = Enabled; \n\t\t}\n\t\t\n\t\t/**\n\t\t * The read-only flash object text field, compare this to \n\t\t * stage.focus to see if this text box is selected.\n\t\t */\n\t\tpublic function get textField():TextField \n\t\t{\n\t\t\treturn _textField;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the maximum length for the field (e.g. \"3\" \n\t\t * for Arcade type hi-score initials)\n\t\t * @param\tLength\t\tThe maximum length. 0 means unlimited.\n\t\t */\n\t\tpublic function setMaxLength(Length:uint):void\n\t\t{\n\t\t\t_textField.maxChars = Length;\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/FlxObject.as",
    "content": "package org.flixel\n{\n\timport flash.display.Graphics;\n\timport flash.display.Sprite;\n\timport flash.geom.Point;\n\t\n\timport org.flixel.FlxBasic;\n\t\n\t/**\n\t * This is the base class for most of the display objects (<code>FlxSprite</code>, <code>FlxText</code>, etc).\n\t * It includes some basic attributes about game objects, including retro-style flickering,\n\t * basic state information, sizes, scrolling, and basic physics and motion.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxObject extends FlxBasic\n\t{\n\t\t/**\n\t\t * Generic value for \"left\" Used by <code>facing</code>, <code>allowCollisions</code>, and <code>touching</code>.\n\t\t */\n\t\tstatic public const LEFT:uint\t= 0x0001;\n\t\t/**\n\t\t * Generic value for \"right\" Used by <code>facing</code>, <code>allowCollisions</code>, and <code>touching</code>.\n\t\t */\n\t\tstatic public const RIGHT:uint\t= 0x0010;\n\t\t/**\n\t\t * Generic value for \"up\" Used by <code>facing</code>, <code>allowCollisions</code>, and <code>touching</code>.\n\t\t */\n\t\tstatic public const UP:uint\t\t= 0x0100;\n\t\t/**\n\t\t * Generic value for \"down\" Used by <code>facing</code>, <code>allowCollisions</code>, and <code>touching</code>.\n\t\t */\n\t\tstatic public const DOWN:uint\t= 0x1000;\n\t\t\n\t\t/**\n\t\t * Special-case constant meaning no collisions, used mainly by <code>allowCollisions</code> and <code>touching</code>.\n\t\t */\n\t\tstatic public const NONE:uint\t= 0;\n\t\t/**\n\t\t * Special-case constant meaning up, used mainly by <code>allowCollisions</code> and <code>touching</code>.\n\t\t */\n\t\tstatic public const CEILING:uint= UP;\n\t\t/**\n\t\t * Special-case constant meaning down, used mainly by <code>allowCollisions</code> and <code>touching</code>.\n\t\t */\n\t\tstatic public const FLOOR:uint\t= DOWN;\n\t\t/**\n\t\t * Special-case constant meaning only the left and right sides, used mainly by <code>allowCollisions</code> and <code>touching</code>.\n\t\t */\n\t\tstatic public const WALL:uint\t= LEFT | RIGHT;\n\t\t/**\n\t\t * Special-case constant meaning any direction, used mainly by <code>allowCollisions</code> and <code>touching</code>.\n\t\t */\n\t\tstatic public const ANY:uint\t= LEFT | RIGHT | UP | DOWN;\n\t\t\n\t\t/**\n\t\t * Handy constant used during collision resolution (see <code>separateX()</code> and <code>separateY()</code>).\n\t\t */\n\t\tstatic public const OVERLAP_BIAS:Number = 4;\n\t\t\n\t\t/**\n\t\t * Path behavior controls: move from the start of the path to the end then stop.\n\t\t */\n\t\tstatic public const PATH_FORWARD:uint\t\t\t= 0x000000;\n\t\t/**\n\t\t * Path behavior controls: move from the end of the path to the start then stop.\n\t\t */\n\t\tstatic public const PATH_BACKWARD:uint\t\t\t= 0x000001;\n\t\t/**\n\t\t * Path behavior controls: move from the start of the path to the end then directly back to the start, and start over.\n\t\t */\n\t\tstatic public const PATH_LOOP_FORWARD:uint\t\t= 0x000010;\n\t\t/**\n\t\t * Path behavior controls: move from the end of the path to the start then directly back to the end, and start over.\n\t\t */\n\t\tstatic public const PATH_LOOP_BACKWARD:uint\t\t= 0x000100;\n\t\t/**\n\t\t * Path behavior controls: move from the start of the path to the end then turn around and go back to the start, over and over.\n\t\t */\n\t\tstatic public const PATH_YOYO:uint\t\t\t\t= 0x001000;\n\t\t/**\n\t\t * Path behavior controls: ignores any vertical component to the path data, only follows side to side.\n\t\t */\n\t\tstatic public const PATH_HORIZONTAL_ONLY:uint\t= 0x010000;\n\t\t/**\n\t\t * Path behavior controls: ignores any horizontal component to the path data, only follows up and down.\n\t\t */\n\t\tstatic public const PATH_VERTICAL_ONLY:uint\t\t= 0x100000;\n\t\t\n\t\t/**\n\t\t * X position of the upper left corner of this object in world space.\n\t\t */\n\t\tpublic var x:Number;\n\t\t/**\n\t\t * Y position of the upper left corner of this object in world space.\n\t\t */\n\t\tpublic var y:Number;\n\t\t/**\n\t\t * The width of this object.\n\t\t */\n\t\tpublic var width:Number;\n\t\t/**\n\t\t * The height of this object.\n\t\t */\n\t\tpublic var height:Number;\n\n\t\t/**\n\t\t * Whether an object will move/alter position after a collision.\n\t\t */\n\t\tpublic var immovable:Boolean;\n\t\t\n\t\t/**\n\t\t * The basic speed of this object.\n\t\t */\n\t\tpublic var velocity:FlxPoint;\n\t\t/**\n\t\t * The virtual mass of the object. Default value is 1.\n\t\t * Currently only used with <code>elasticity</code> during collision resolution.\n\t\t * Change at your own risk; effects seem crazy unpredictable so far!\n\t\t */\n\t\tpublic var mass:Number;\n\t\t/**\n\t\t * The bounciness of this object.  Only affects collisions.  Default value is 0, or \"not bouncy at all.\"\n\t\t */\n\t\tpublic var elasticity:Number;\n\t\t/**\n\t\t * How fast the speed of this object is changing.\n\t\t * Useful for smooth movement and gravity.\n\t\t */\n\t\tpublic var acceleration:FlxPoint;\n\t\t/**\n\t\t * This isn't drag exactly, more like deceleration that is only applied\n\t\t * when acceleration is not affecting the sprite.\n\t\t */\n\t\tpublic var drag:FlxPoint;\n\t\t/**\n\t\t * If you are using <code>acceleration</code>, you can use <code>maxVelocity</code> with it\n\t\t * to cap the speed automatically (very useful!).\n\t\t */\n\t\tpublic var maxVelocity:FlxPoint;\n\t\t/**\n\t\t * Set the angle of a sprite to rotate it.\n\t\t * WARNING: rotating sprites decreases rendering\n\t\t * performance for this sprite by a factor of 10x!\n\t\t */\n\t\tpublic var angle:Number;\n\t\t/**\n\t\t * This is how fast you want this sprite to spin.\n\t\t */\n\t\tpublic var angularVelocity:Number;\n\t\t/**\n\t\t * How fast the spin speed should change.\n\t\t */\n\t\tpublic var angularAcceleration:Number;\n\t\t/**\n\t\t * Like <code>drag</code> but for spinning.\n\t\t */\n\t\tpublic var angularDrag:Number;\n\t\t/**\n\t\t * Use in conjunction with <code>angularAcceleration</code> for fluid spin speed control.\n\t\t */\n\t\tpublic var maxAngular:Number;\n\t\t/**\n\t\t * Should always represent (0,0) - useful for different things, for avoiding unnecessary <code>new</code> calls.\n\t\t */\n\t\tstatic protected const _pZero:FlxPoint = new FlxPoint();\n\t\t\n\t\t/**\n\t\t * A point that can store numbers from 0 to 1 (for X and Y independently)\n\t\t * that governs how much this object is affected by the camera subsystem.\n\t\t * 0 means it never moves, like a HUD element or far background graphic.\n\t\t * 1 means it scrolls along a the same speed as the foreground layer.\n\t\t * scrollFactor is initialized as (1,1) by default.\n\t\t */\n\t\tpublic var scrollFactor:FlxPoint;\n\t\t/**\n\t\t * Internal helper used for retro-style flickering.\n\t\t */\n\t\tprotected var _flicker:Boolean;\n\t\t/**\n\t\t * Internal helper used for retro-style flickering.\n\t\t */\n\t\tprotected var _flickerTimer:Number;\n\t\t/**\n\t\t * Handy for storing health percentage or armor points or whatever.\n\t\t */\n\t\tpublic var health:Number;\n\t\t/**\n\t\t * This is just a pre-allocated x-y point container to be used however you like\n\t\t */\n\t\tprotected var _point:FlxPoint;\n\t\t/**\n\t\t * This is just a pre-allocated rectangle container to be used however you like\n\t\t */\n\t\tprotected var _rect:FlxRect;\n\t\t/**\n\t\t * Set this to false if you want to skip the automatic motion/movement stuff (see <code>updateMotion()</code>).\n\t\t * FlxObject and FlxSprite default to true.\n\t\t * FlxText, FlxTileblock, FlxTilemap and FlxSound default to false.\n\t\t */\n\t\tpublic var moves:Boolean;\n\t\t/**\n\t\t * Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts.\n\t\t * Use bitwise operators to check the values stored here, or use touching(), justStartedTouching(), etc.\n\t\t * You can even use them broadly as boolean values if you're feeling saucy!\n\t\t */\n\t\tpublic var touching:uint;\n\t\t/**\n\t\t * Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts from the previous game loop step.\n\t\t * Use bitwise operators to check the values stored here, or use touching(), justStartedTouching(), etc.\n\t\t * You can even use them broadly as boolean values if you're feeling saucy!\n\t\t */\n\t\tpublic var wasTouching:uint;\n\t\t/**\n\t\t * Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions.\n\t\t * Use bitwise operators to check the values stored here.\n\t\t * Useful for things like one-way platforms (e.g. allowCollisions = UP;)\n\t\t * The accessor \"solid\" just flips this variable between NONE and ANY.\n\t\t */\n\t\tpublic var allowCollisions:uint;\n\t\t\n\t\t/**\n\t\t * Important variable for collision processing.\n\t\t * By default this value is set automatically during <code>preUpdate()</code>.\n\t\t */\n\t\tpublic var last:FlxPoint;\n\t\t\n\t\t/**\n\t\t * A reference to a path object.  Null by default, assigned by <code>followPath()</code>.\n\t\t */\n\t\tpublic var path:FlxPath;\n\t\t/**\n\t\t * The speed at which the object is moving on the path.\n\t\t * When an object completes a non-looping path circuit,\n\t\t * the pathSpeed will be zeroed out, but the <code>path</code> reference\n\t\t * will NOT be nulled out.  So <code>pathSpeed</code> is a good way\n\t\t * to check if this object is currently following a path or not.\n\t\t */\n\t\tpublic var pathSpeed:Number;\n\t\t/**\n\t\t * The angle in degrees between this object and the next node, where 0 is directly upward, and 90 is to the right.\n\t\t */\n\t\tpublic var pathAngle:Number;\n\t\t/**\n\t\t * Internal helper, tracks which node of the path this object is moving toward.\n\t\t */\n\t\tprotected var _pathNodeIndex:int;\n\t\t/**\n\t\t * Internal tracker for path behavior flags (like looping, horizontal only, etc).\n\t\t */\n\t\tprotected var _pathMode:uint;\n\t\t/**\n\t\t * Internal helper for node navigation, specifically yo-yo and backwards movement.\n\t\t */\n\t\tprotected var _pathInc:int;\n\t\t/**\n\t\t * Internal flag for whether the object's angle should be adjusted to the path angle during path follow behavior.\n\t\t */\n\t\tprotected var _pathRotate:Boolean;\n\t\t/**\n\t\t * Internal flag for whether the object's should stop once it has reached the end of the path.\n\t\t */\n\t\tprotected var _pathAutoStop:Boolean;\n\t\t\n\t\t/**\n\t\t * Instantiates a <code>FlxObject</code>.\n\t\t * \n\t\t * @param\tX\t\tThe X-coordinate of the point in space.\n\t\t * @param\tY\t\tThe Y-coordinate of the point in space.\n\t\t * @param\tWidth\tDesired width of the rectangle.\n\t\t * @param\tHeight\tDesired height of the rectangle.\n\t\t */\n\t\tpublic function FlxObject(X:Number=0,Y:Number=0,Width:Number=0,Height:Number=0)\n\t\t{\n\t\t\tx = X;\n\t\t\ty = Y;\n\t\t\tlast = new FlxPoint(x,y);\n\t\t\twidth = Width;\n\t\t\theight = Height;\n\t\t\tmass = 1.0;\n\t\t\telasticity = 0.0;\n\t\t\t\n\t\t\thealth = 1;\n\n\t\t\timmovable = false;\n\t\t\tmoves = true;\n\t\t\t\n\t\t\ttouching = NONE;\n\t\t\twasTouching = NONE;\n\t\t\tallowCollisions = ANY;\n\t\t\t\n\t\t\tvelocity = new FlxPoint();\n\t\t\tacceleration = new FlxPoint();\n\t\t\tdrag = new FlxPoint();\n\t\t\tmaxVelocity = new FlxPoint(10000,10000);\n\t\t\t\n\t\t\tangle = 0;\n\t\t\tangularVelocity = 0;\n\t\t\tangularAcceleration = 0;\n\t\t\tangularDrag = 0;\n\t\t\tmaxAngular = 10000;\n\t\t\t\n\t\t\tscrollFactor = new FlxPoint(1.0,1.0);\n\t\t\t_flicker = false;\n\t\t\t_flickerTimer = 0;\n\t\t\t\n\t\t\t_point = new FlxPoint();\n\t\t\t_rect = new FlxRect();\n\t\t\t\n\t\t\tpath = null;\n\t\t\tpathSpeed = 0;\n\t\t\tpathAngle = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Override this function to null out variables or\n\t\t * manually call destroy() on class members if necessary.\n\t\t * Don't forget to call super.destroy()!\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tvelocity = null;\n\t\t\tacceleration = null;\n\t\t\tdrag = null;\n\t\t\tmaxVelocity = null;\n\t\t\tscrollFactor = null;\n\t\t\t_point = null;\n\t\t\t_rect = null;\n\t\t\tlast = null;\n\t\t\tcameras = null;\n\t\t\tif(path != null)\n\t\t\t\tpath.destroy();\n\t\t\tpath = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Pre-update is called right before <code>update()</code> on each object in the game loop.\n\t\t * In <code>FlxObject</code> it controls the flicker timer,\n\t\t * tracking the last coordinates for collision purposes,\n\t\t * and checking if the object is moving along a path or not.\n\t\t */\n\t\toverride public function preUpdate():void\n\t\t{\n\t\t\t_ACTIVECOUNT++;\n\t\t\t\n\t\t\tif(_flickerTimer != 0)\n\t\t\t{\n\t\t\t\tif(_flickerTimer > 0)\n\t\t\t\t{\n\t\t\t\t\t_flickerTimer = _flickerTimer - FlxG.elapsed;\n\t\t\t\t\tif(_flickerTimer <= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t_flickerTimer = 0;\n\t\t\t\t\t\t_flicker = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tlast.x = x;\n\t\t\tlast.y = y;\n\t\t\t\n\t\t\tif((path != null) && (pathSpeed != 0) && (path.nodes[_pathNodeIndex] != null))\n\t\t\t\tupdatePathMotion();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Post-update is called right after <code>update()</code> on each object in the game loop.\n\t\t * In <code>FlxObject</code> this function handles integrating the objects motion\n\t\t * based on the velocity and acceleration settings, and tracking/clearing the <code>touching</code> flags.\n\t\t */\n\t\toverride public function postUpdate():void\n\t\t{\n\t\t\tif(moves)\n\t\t\t\tupdateMotion();\n\t\t\t\n\t\t\twasTouching = touching;\n\t\t\ttouching = NONE;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function for updating the position and speed of this object.\n\t\t * Useful for cases when you need to update this but are buried down in too many supers.\n\t\t * Does a slightly fancier-than-normal integration to help with higher fidelity framerate-independenct motion.\n\t\t */\n\t\tprotected function updateMotion():void\n\t\t{\n\t\t\tvar delta:Number;\n\t\t\tvar velocityDelta:Number;\n\n\t\t\tvelocityDelta = (FlxU.computeVelocity(angularVelocity,angularAcceleration,angularDrag,maxAngular) - angularVelocity)/2;\n\t\t\tangularVelocity += velocityDelta; \n\t\t\tangle += angularVelocity*FlxG.elapsed;\n\t\t\tangularVelocity += velocityDelta;\n\t\t\t\n\t\t\tvelocityDelta = (FlxU.computeVelocity(velocity.x,acceleration.x,drag.x,maxVelocity.x) - velocity.x)/2;\n\t\t\tvelocity.x += velocityDelta;\n\t\t\tdelta = velocity.x*FlxG.elapsed;\n\t\t\tvelocity.x += velocityDelta;\n\t\t\tx += delta;\n\t\t\t\n\t\t\tvelocityDelta = (FlxU.computeVelocity(velocity.y,acceleration.y,drag.y,maxVelocity.y) - velocity.y)/2;\n\t\t\tvelocity.y += velocityDelta;\n\t\t\tdelta = velocity.y*FlxG.elapsed;\n\t\t\tvelocity.y += velocityDelta;\n\t\t\ty += delta;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Rarely called, and in this case just increments the visible objects count and calls <code>drawDebug()</code> if necessary.\n\t\t */\n\t\toverride public function draw():void\n\t\t{\n\t\t\tif(cameras == null)\n\t\t\t\tcameras = FlxG.cameras;\n\t\t\tvar camera:FlxCamera;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = cameras.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tcamera = cameras[i++];\n\t\t\t\tif(!onScreen(camera))\n\t\t\t\t\tcontinue;\n\t\t\t\t_VISIBLECOUNT++;\n\t\t\t\tif(FlxG.visualDebug && !ignoreDrawDebug)\n\t\t\t\t\tdrawDebug(camera);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Override this function to draw custom \"debug mode\" graphics to the\n\t\t * specified camera while the debugger's visual mode is toggled on.\n\t\t * \n\t\t * @param\tCamera\tWhich camera to draw the debug visuals to.\n\t\t */\n\t\toverride public function drawDebug(Camera:FlxCamera=null):void\n\t\t{\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\n\t\t\t//get bounding box coordinates\n\t\t\tvar boundingBoxX:Number = x - int(Camera.scroll.x*scrollFactor.x); //copied from getScreenXY()\n\t\t\tvar boundingBoxY:Number = y - int(Camera.scroll.y*scrollFactor.y);\n\t\t\tboundingBoxX = int(boundingBoxX + ((boundingBoxX > 0)?0.0000001:-0.0000001));\n\t\t\tboundingBoxY = int(boundingBoxY + ((boundingBoxY > 0)?0.0000001:-0.0000001));\n\t\t\tvar boundingBoxWidth:int = (width != int(width))?width:width-1;\n\t\t\tvar boundingBoxHeight:int = (height != int(height))?height:height-1;\n\n\t\t\t//fill static graphics object with square shape\n\t\t\tvar gfx:Graphics = FlxG.flashGfx;\n\t\t\tgfx.clear();\n\t\t\tgfx.moveTo(boundingBoxX,boundingBoxY);\n\t\t\tvar boundingBoxColor:uint;\n\t\t\tif(allowCollisions)\n\t\t\t{\n\t\t\t\tif(allowCollisions != ANY)\n\t\t\t\t\tboundingBoxColor = FlxG.PINK;\n\t\t\t\tif(immovable)\n\t\t\t\t\tboundingBoxColor = FlxG.GREEN;\n\t\t\t\telse\n\t\t\t\t\tboundingBoxColor = FlxG.RED;\n\t\t\t}\n\t\t\telse\n\t\t\t\tboundingBoxColor = FlxG.BLUE;\n\t\t\tgfx.lineStyle(1,boundingBoxColor,0.5);\n\t\t\tgfx.lineTo(boundingBoxX+boundingBoxWidth,boundingBoxY);\n\t\t\tgfx.lineTo(boundingBoxX+boundingBoxWidth,boundingBoxY+boundingBoxHeight);\n\t\t\tgfx.lineTo(boundingBoxX,boundingBoxY+boundingBoxHeight);\n\t\t\tgfx.lineTo(boundingBoxX,boundingBoxY);\n\t\t\t\n\t\t\t//draw graphics shape to camera buffer\n\t\t\tCamera.buffer.draw(FlxG.flashGfxSprite);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to give this object a path to follow.\n\t\t * If the path does not have at least one node in it, this function\n\t\t * will log a warning message and return.\n\t\t * \n\t\t * @param\tPath\t\tThe <code>FlxPath</code> you want this object to follow.\n\t\t * @param\tSpeed\t\tHow fast to travel along the path in pixels per second.\n\t\t * @param\tMode\t\tOptional, controls the behavior of the object following the path using the path behavior constants.  Can use multiple flags at once, for example PATH_YOYO|PATH_HORIZONTAL_ONLY will make an object move back and forth along the X axis of the path only.\n\t\t * @param\tAutoRotate\tAutomatically point the object toward the next node.  Assumes the graphic is pointing upward.  Default behavior is false, or no automatic rotation.\n\t\t * @param\tStopWhenFinished\tAutomatically stop the player from moving once they have reached the final node in the path. Default is \"false\" just so it won't conflict with code written for previous versions.\n\t\t */\n\t\tpublic function followPath(Path:FlxPath,Speed:Number=100,Mode:uint=PATH_FORWARD,AutoRotate:Boolean=false,StopWhenFinished:Boolean=false):void\n\t\t{\n\t\t\tif(Path.nodes.length <= 0)\n\t\t\t{\n\t\t\t\tFlxG.log(\"WARNING: Paths need at least one node in them to be followed.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tpath = Path;\n\t\t\tpathSpeed = FlxU.abs(Speed);\n\t\t\t_pathMode = Mode;\n\t\t\t_pathRotate = AutoRotate;\n\t\t\t_pathAutoStop = StopWhenFinished;\n\t\t\t\n\t\t\t//get starting node\n\t\t\tif((_pathMode == PATH_BACKWARD) || (_pathMode == PATH_LOOP_BACKWARD))\n\t\t\t{\n\t\t\t\t_pathNodeIndex = path.nodes.length-1;\n\t\t\t\t_pathInc = -1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_pathNodeIndex = 0;\n\t\t\t\t_pathInc = 1;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Tells this object to stop following the path its on.\n\t\t * \n\t\t * @param\tDestroyPath\t\tTells this function whether to call destroy on the path object.  Default value is false.\n\t\t */\n\t\tpublic function stopFollowingPath(DestroyPath:Boolean=false,StopMoving:Boolean=false):void\n\t\t{\n\t\t\tpathSpeed = 0;\n\t\t\t\n\t\t\tif (StopMoving)\n\t\t\t{\n\t\t\t\tvelocity.x = 0;\n\t\t\t\tvelocity.y = 0;\n\t\t\t}\n\t\t\t\n\t\t\tif(DestroyPath && (path != null))\n\t\t\t{\n\t\t\t\tpath.destroy();\n\t\t\t\tpath = null;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function that decides what node in the path to aim for next based on the behavior flags.\n\t\t * \n\t\t * @return\tThe node (a <code>FlxPoint</code> object) we are aiming for next.\n\t\t */\n\t\tprotected function advancePath(Snap:Boolean=true):FlxPoint\n\t\t{\n\t\t\tif(Snap)\n\t\t\t{\n\t\t\t\tvar oldNode:FlxPoint = path.nodes[_pathNodeIndex];\n\t\t\t\tif(oldNode != null)\n\t\t\t\t{\n\t\t\t\t\tif((_pathMode & PATH_VERTICAL_ONLY) == 0)\n\t\t\t\t\t\tx = oldNode.x - width*0.5;\n\t\t\t\t\tif((_pathMode & PATH_HORIZONTAL_ONLY) == 0)\n\t\t\t\t\t\ty = oldNode.y - height*0.5;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t_pathNodeIndex += _pathInc;\n\t\t\t\n\t\t\tif((_pathMode & PATH_BACKWARD) > 0)\n\t\t\t{\n\t\t\t\tif(_pathNodeIndex < 0)\n\t\t\t\t{\n\t\t\t\t\t_pathNodeIndex = 0;\n\t\t\t\t\tstopFollowingPath(false, _pathAutoStop);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if((_pathMode & PATH_LOOP_FORWARD) > 0)\n\t\t\t{\n\t\t\t\tif(_pathNodeIndex >= path.nodes.length)\n\t\t\t\t\t_pathNodeIndex = 0;\n\t\t\t}\n\t\t\telse if((_pathMode & PATH_LOOP_BACKWARD) > 0)\n\t\t\t{\n\t\t\t\tif(_pathNodeIndex < 0)\n\t\t\t\t{\n\t\t\t\t\t_pathNodeIndex = path.nodes.length-1;\n\t\t\t\t\tif(_pathNodeIndex < 0)\n\t\t\t\t\t\t_pathNodeIndex = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if((_pathMode & PATH_YOYO) > 0)\n\t\t\t{\n\t\t\t\tif(_pathInc > 0)\n\t\t\t\t{\n\t\t\t\t\tif(_pathNodeIndex >= path.nodes.length)\n\t\t\t\t\t{\n\t\t\t\t\t\t_pathNodeIndex = path.nodes.length-2;\n\t\t\t\t\t\tif(_pathNodeIndex < 0)\n\t\t\t\t\t\t\t_pathNodeIndex = 0;\n\t\t\t\t\t\t_pathInc = -_pathInc;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if(_pathNodeIndex < 0)\n\t\t\t\t{\n\t\t\t\t\t_pathNodeIndex = 1;\n\t\t\t\t\tif(_pathNodeIndex >= path.nodes.length)\n\t\t\t\t\t\t_pathNodeIndex = path.nodes.length-1;\n\t\t\t\t\tif(_pathNodeIndex < 0)\n\t\t\t\t\t\t_pathNodeIndex = 0;\n\t\t\t\t\t_pathInc = -_pathInc;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(_pathNodeIndex >= path.nodes.length)\n\t\t\t\t{\n\t\t\t\t\t_pathNodeIndex = path.nodes.length-1;\n\t\t\t\t\tstopFollowingPath(false, _pathAutoStop);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn path.nodes[_pathNodeIndex];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function for moving the object along the path.\n\t\t * Generally this function is called automatically by <code>preUpdate()</code>.\n\t\t * The first half of the function decides if the object can advance to the next node in the path,\n\t\t * while the second half handles actually picking a velocity toward the next node.\n\t\t */\n\t\tprotected function updatePathMotion():void\n\t\t{\n\t\t\t//first check if we need to be pointing at the next node yet\n\t\t\t_point.x = x + width*0.5;\n\t\t\t_point.y = y + height*0.5;\n\t\t\tvar node:FlxPoint = path.nodes[_pathNodeIndex];\n\t\t\tvar deltaX:Number = node.x - _point.x;\n\t\t\tvar deltaY:Number = node.y - _point.y;\n\t\t\t\n\t\t\tvar horizontalOnly:Boolean = (_pathMode & PATH_HORIZONTAL_ONLY) > 0;\n\t\t\tvar verticalOnly:Boolean = (_pathMode & PATH_VERTICAL_ONLY) > 0;\n\t\t\t\n\t\t\tif(horizontalOnly)\n\t\t\t{\n\t\t\t\tif(((deltaX>0)?deltaX:-deltaX) < pathSpeed*FlxG.elapsed)\n\t\t\t\t\tnode = advancePath();\n\t\t\t}\n\t\t\telse if(verticalOnly)\n\t\t\t{\n\t\t\t\tif(((deltaY>0)?deltaY:-deltaY) < pathSpeed*FlxG.elapsed)\n\t\t\t\t\tnode = advancePath();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(Math.sqrt(deltaX*deltaX + deltaY*deltaY) < pathSpeed*FlxG.elapsed)\n\t\t\t\t\tnode = advancePath();\n\t\t\t}\n\t\t\t\n\t\t\t//then just move toward the current node at the requested speed\n\t\t\tif(pathSpeed != 0)\n\t\t\t{\n\t\t\t\t//set velocity based on path mode\n\t\t\t\t_point.x = x + width*0.5;\n\t\t\t\t_point.y = y + height*0.5;\n\t\t\t\tif(horizontalOnly || (_point.y == node.y))\n\t\t\t\t{\n\t\t\t\t\tvelocity.x = (_point.x < node.x)?pathSpeed:-pathSpeed;\n\t\t\t\t\tif(velocity.x < 0)\n\t\t\t\t\t\tpathAngle = -90;\n\t\t\t\t\telse\n\t\t\t\t\t\tpathAngle = 90;\n\t\t\t\t\tif(!horizontalOnly)\n\t\t\t\t\t\tvelocity.y = 0;\n\t\t\t\t}\n\t\t\t\telse if(verticalOnly || (_point.x == node.x))\n\t\t\t\t{\n\t\t\t\t\tvelocity.y = (_point.y < node.y)?pathSpeed:-pathSpeed;\n\t\t\t\t\tif(velocity.y < 0)\n\t\t\t\t\t\tpathAngle = 0;\n\t\t\t\t\telse\n\t\t\t\t\t\tpathAngle = 180;\n\t\t\t\t\tif(!verticalOnly)\n\t\t\t\t\t\tvelocity.x = 0;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tpathAngle = FlxU.getAngle(_point,node);\n\t\t\t\t\tFlxU.rotatePoint(0,pathSpeed,0,0,pathAngle,velocity);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//then set object rotation if necessary\n\t\t\t\tif(_pathRotate)\n\t\t\t\t{\n\t\t\t\t\tangularVelocity = 0;\n\t\t\t\t\tangularAcceleration = 0;\n\t\t\t\t\tangle = pathAngle;\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t}\n\t\t\n\t\t/**\n\t\t * Checks to see if some <code>FlxObject</code> overlaps this <code>FlxObject</code> or <code>FlxGroup</code>.\n\t\t * If the group has a LOT of things in it, it might be faster to use <code>FlxG.overlaps()</code>.\n\t\t * WARNING: Currently tilemaps do NOT support screen space overlap checks!\n\t\t * \n\t\t * @param\tObjectOrGroup\tThe object or group being tested.\n\t\t * @param\tInScreenSpace\tWhether to take scroll factors into account when checking for overlap.  Default is false, or \"only compare in world space.\"\n\t\t * @param\tCamera\t\t\tSpecify which game camera you want.  If null getScreenXY() will just grab the first global camera.\n\t\t * \n\t\t * @return\tWhether or not the two objects overlap.\n\t\t */\n\t\tpublic function overlaps(ObjectOrGroup:FlxBasic,InScreenSpace:Boolean=false,Camera:FlxCamera=null):Boolean\n\t\t{\n\t\t\tif(ObjectOrGroup is FlxGroup)\n\t\t\t{\n\t\t\t\tvar results:Boolean = false;\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar members:Array = (ObjectOrGroup as FlxGroup).members;\n\t\t\t\twhile(i < length)\n\t\t\t\t{\n\t\t\t\t\tif(overlaps(members[i++],InScreenSpace,Camera))\n\t\t\t\t\t\tresults = true;\n\t\t\t\t}\n\t\t\t\treturn results;\n\t\t\t}\n\t\t\t\n\t\t\tif(ObjectOrGroup is FlxTilemap)\n\t\t\t{\n\t\t\t\t//Since tilemap's have to be the caller, not the target, to do proper tile-based collisions,\n\t\t\t\t// we redirect the call to the tilemap overlap here.\n\t\t\t\treturn (ObjectOrGroup as FlxTilemap).overlaps(this,InScreenSpace,Camera);\n\t\t\t}\n\t\t\t\n\t\t\tvar object:FlxObject = ObjectOrGroup as FlxObject;\n\t\t\tif(!InScreenSpace)\n\t\t\t{\n\t\t\t\treturn\t(object.x + object.width > x) && (object.x < x + width) &&\n\t\t\t\t\t\t(object.y + object.height > y) && (object.y < y + height);\n\t\t\t}\n\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\tvar objectScreenPos:FlxPoint = object.getScreenXY(null,Camera);\n\t\t\tgetScreenXY(_point,Camera);\n\t\t\treturn\t(objectScreenPos.x + object.width > _point.x) && (objectScreenPos.x < _point.x + width) &&\n\t\t\t\t\t(objectScreenPos.y + object.height > _point.y) && (objectScreenPos.y < _point.y + height);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Checks to see if this <code>FlxObject</code> were located at the given position, would it overlap the <code>FlxObject</code> or <code>FlxGroup</code>?\n\t\t * This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size into account.\n\t\t * WARNING: Currently tilemaps do NOT support screen space overlap checks!\n\t\t * \n\t\t * @param\tX\t\t\t\tThe X position you want to check.  Pretends this object (the caller, not the parameter) is located here.\n\t\t * @param\tY\t\t\t\tThe Y position you want to check.  Pretends this object (the caller, not the parameter) is located here.\n\t\t * @param\tObjectOrGroup\tThe object or group being tested.\n\t\t * @param\tInScreenSpace\tWhether to take scroll factors into account when checking for overlap.  Default is false, or \"only compare in world space.\"\n\t\t * @param\tCamera\t\t\tSpecify which game camera you want.  If null getScreenXY() will just grab the first global camera.\n\t\t * \n\t\t * @return\tWhether or not the two objects overlap.\n\t\t */\n\t\tpublic function overlapsAt(X:Number,Y:Number,ObjectOrGroup:FlxBasic,InScreenSpace:Boolean=false,Camera:FlxCamera=null):Boolean\n\t\t{\n\t\t\tif(ObjectOrGroup is FlxGroup)\n\t\t\t{\n\t\t\t\tvar results:Boolean = false;\n\t\t\t\tvar basic:FlxBasic;\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar members:Array = (ObjectOrGroup as FlxGroup).members;\n\t\t\t\twhile(i < length)\n\t\t\t\t{\n\t\t\t\t\tif(overlapsAt(X,Y,members[i++],InScreenSpace,Camera))\n\t\t\t\t\t\tresults = true;\n\t\t\t\t}\n\t\t\t\treturn results;\n\t\t\t}\n\t\t\t\n\t\t\tif(ObjectOrGroup is FlxTilemap)\n\t\t\t{\n\t\t\t\t//Since tilemap's have to be the caller, not the target, to do proper tile-based collisions,\n\t\t\t\t// we redirect the call to the tilemap overlap here.\n\t\t\t\t//However, since this is overlapsAt(), we also have to invent the appropriate position for the tilemap.\n\t\t\t\t//So we calculate the offset between the player and the requested position, and subtract that from the tilemap.\n\t\t\t\tvar tilemap:FlxTilemap = ObjectOrGroup as FlxTilemap;\n\t\t\t\treturn tilemap.overlapsAt(tilemap.x - (X - x),tilemap.y - (Y - y),this,InScreenSpace,Camera);\n\t\t\t}\n\t\t\t\n\t\t\tvar object:FlxObject = ObjectOrGroup as FlxObject;\n\t\t\tif(!InScreenSpace)\n\t\t\t{\n\t\t\t\treturn\t(object.x + object.width > X) && (object.x < X + width) &&\n\t\t\t\t\t\t(object.y + object.height > Y) && (object.y < Y + height);\n\t\t\t}\n\t\t\t\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\tvar objectScreenPos:FlxPoint = object.getScreenXY(null,Camera);\n\t\t\t_point.x = X - int(Camera.scroll.x*scrollFactor.x); //copied from getScreenXY()\n\t\t\t_point.y = Y - int(Camera.scroll.y*scrollFactor.y);\n\t\t\t_point.x += (_point.x > 0)?0.0000001:-0.0000001;\n\t\t\t_point.y += (_point.y > 0)?0.0000001:-0.0000001;\n\t\t\treturn\t(objectScreenPos.x + object.width > _point.x) && (objectScreenPos.x < _point.x + width) &&\n\t\t\t\t(objectScreenPos.y + object.height > _point.y) && (objectScreenPos.y < _point.y + height);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Checks to see if a point in 2D world space overlaps this <code>FlxObject</code> object.\n\t\t * \n\t\t * @param\tPoint\t\t\tThe point in world space you want to check.\n\t\t * @param\tInScreenSpace\tWhether to take scroll factors into account when checking for overlap.\n\t\t * @param\tCamera\t\t\tSpecify which game camera you want.  If null getScreenXY() will just grab the first global camera.\n\t\t * \n\t\t * @return\tWhether or not the point overlaps this object.\n\t\t */\n\t\tpublic function overlapsPoint(Point:FlxPoint,InScreenSpace:Boolean=false,Camera:FlxCamera=null):Boolean\n\t\t{\n\t\t\tif(!InScreenSpace)\n\t\t\t\treturn (Point.x > x) && (Point.x < x + width) && (Point.y > y) && (Point.y < y + height);\n\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\tvar X:Number = Point.x - Camera.scroll.x;\n\t\t\tvar Y:Number = Point.y - Camera.scroll.y;\n\t\t\tgetScreenXY(_point,Camera);\n\t\t\treturn (X > _point.x) && (X < _point.x+width) && (Y > _point.y) && (Y < _point.y+height);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Check and see if this object is currently on screen.\n\t\t * \n\t\t * @param\tCamera\t\tSpecify which game camera you want.  If null getScreenXY() will just grab the first global camera.\n\t\t * \n\t\t * @return\tWhether the object is on screen or not.\n\t\t */\n\t\tpublic function onScreen(Camera:FlxCamera=null):Boolean\n\t\t{\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\tgetScreenXY(_point,Camera);\n\t\t\treturn (_point.x + width > 0) && (_point.x < Camera.width) && (_point.y + height > 0) && (_point.y < Camera.height);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to figure out the on-screen position of the object.\n\t\t * \n\t\t * @param\tCamera\t\tSpecify which game camera you want.  If null getScreenXY() will just grab the first global camera.\n\t\t * @param\tPoint\t\tTakes a <code>FlxPoint</code> object and assigns the post-scrolled X and Y values of this object to it.\n\t\t * \n\t\t * @return\tThe <code>Point</code> you passed in, or a new <code>Point</code> if you didn't pass one, containing the screen X and Y position of this object.\n\t\t */\n\t\tpublic function getScreenXY(Point:FlxPoint=null,Camera:FlxCamera=null):FlxPoint\n\t\t{\n\t\t\tif(Point == null)\n\t\t\t\tPoint = new FlxPoint();\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\tPoint.x = x - int(Camera.scroll.x*scrollFactor.x);\n\t\t\tPoint.y = y - int(Camera.scroll.y*scrollFactor.y);\n\t\t\tPoint.x += (Point.x > 0)?0.0000001:-0.0000001;\n\t\t\tPoint.y += (Point.y > 0)?0.0000001:-0.0000001;\n\t\t\treturn Point;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Tells this object to flicker, retro-style.\n\t\t * Pass a negative value to flicker forever.\n\t\t * \n\t\t * @param\tDuration\tHow many seconds to flicker for.\n\t\t */\n\t\tpublic function flicker(Duration:Number=1):void\n\t\t{\n\t\t\t_flickerTimer = Duration;\n\t\t\tif(_flickerTimer == 0)\n\t\t\t\t_flicker = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Check to see if the object is still flickering.\n\t\t * \n\t\t * @return\tWhether the object is flickering or not.\n\t\t */\n\t\tpublic function get flickering():Boolean\n\t\t{\n\t\t\treturn _flickerTimer != 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Whether the object collides or not.  For more control over what directions\n\t\t * the object will collide from, use collision constants (like LEFT, FLOOR, etc)\n\t\t * to set the value of allowCollisions directly.\n\t\t */\n\t\tpublic function get solid():Boolean\n\t\t{\n\t\t\treturn (allowCollisions & ANY) > NONE;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set solid(Solid:Boolean):void\n\t\t{\n\t\t\tif(Solid)\n\t\t\t\tallowCollisions = ANY;\n\t\t\telse\n\t\t\t\tallowCollisions = NONE;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Retrieve the midpoint of this object in world coordinates.\n\t\t * \n\t\t * @Point\tAllows you to pass in an existing <code>FlxPoint</code> object if you're so inclined.  Otherwise a new one is created.\n\t\t * \n\t\t * @return\tA <code>FlxPoint</code> object containing the midpoint of this object in world coordinates.\n\t\t */\n\t\tpublic function getMidpoint(Point:FlxPoint=null):FlxPoint\n\t\t{\n\t\t\tif(Point == null)\n\t\t\t\tPoint = new FlxPoint();\n\t\t\tPoint.x = x + width*0.5;\n\t\t\tPoint.y = y + height*0.5;\n\t\t\treturn Point;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Handy function for reviving game objects.\n\t\t * Resets their existence flags and position.\n\t\t * \n\t\t * @param\tX\tThe new X position of this object.\n\t\t * @param\tY\tThe new Y position of this object.\n\t\t */\n\t\tpublic function reset(X:Number,Y:Number):void\n\t\t{\n\t\t\trevive();\n\t\t\ttouching = NONE;\n\t\t\twasTouching = NONE;\n\t\t\tx = X;\n\t\t\ty = Y;\n\t\t\tlast.x = x;\n\t\t\tlast.y = y;\n\t\t\tvelocity.x = 0;\n\t\t\tvelocity.y = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Handy function for checking if this object is touching a particular surface.\n\t\t * For slightly better performance you can just &amp; the value directly into <code>touching</code>.\n\t\t * However, this method is good for readability and accessibility.\n\t\t * \n\t\t * @param\tDirection\tAny of the collision flags (e.g. LEFT, FLOOR, etc).\n\t\t * \n\t\t * @return\tWhether the object is touching an object in (any of) the specified direction(s) this frame.\n\t\t */\n\t\tpublic function isTouching(Direction:uint):Boolean\n\t\t{\n\t\t\treturn (touching & Direction) > NONE;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Handy function for checking if this object is just landed on a particular surface.\n\t\t * \n\t\t * @param\tDirection\tAny of the collision flags (e.g. LEFT, FLOOR, etc).\n\t\t * \n\t\t * @return\tWhether the object just landed on (any of) the specified surface(s) this frame.\n\t\t */\n\t\tpublic function justTouched(Direction:uint):Boolean\n\t\t{\n\t\t\treturn ((touching & Direction) > NONE) && ((wasTouching & Direction) <= NONE);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Reduces the \"health\" variable of this sprite by the amount specified in Damage.\n\t\t * Calls kill() if health drops to or below zero.\n\t\t * \n\t\t * @param\tDamage\t\tHow much health to take away (use a negative number to give a health bonus).\n\t\t */\n\t\tpublic function hurt(Damage:Number):void\n\t\t{\n\t\t\thealth = health - Damage;\n\t\t\tif(health <= 0)\n\t\t\t\tkill();\n\t\t}\n\t\t\n\t\t/**\n\t\t * The main collision resolution function in flixel.\n\t\t * \n\t\t * @param\tObject1 \tAny <code>FlxObject</code>.\n\t\t * @param\tObject2\t\tAny other <code>FlxObject</code>.\n\t\t * \n\t\t * @return\tWhether the objects in fact touched and were separated.\n\t\t */\n\t\tstatic public function separate(Object1:FlxObject, Object2:FlxObject):Boolean\n\t\t{\n\t\t\tvar separatedX:Boolean = separateX(Object1,Object2);\n\t\t\tvar separatedY:Boolean = separateY(Object1,Object2);\n\t\t\treturn separatedX || separatedY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The X-axis component of the object separation process.\n\t\t * \n\t\t * @param\tObject1 \tAny <code>FlxObject</code>.\n\t\t * @param\tObject2\t\tAny other <code>FlxObject</code>.\n\t\t * \n\t\t * @return\tWhether the objects in fact touched and were separated along the X axis.\n\t\t */\n\t\tstatic public function separateX(Object1:FlxObject, Object2:FlxObject):Boolean\n\t\t{\n\t\t\t//can't separate two immovable objects\n\t\t\tvar obj1immovable:Boolean = Object1.immovable;\n\t\t\tvar obj2immovable:Boolean = Object2.immovable;\n\t\t\tif(obj1immovable && obj2immovable)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\t//If one of the objects is a tilemap, just pass it off.\n\t\t\tif(Object1 is FlxTilemap)\n\t\t\t\treturn (Object1 as FlxTilemap).overlapsWithCallback(Object2,separateX);\n\t\t\tif(Object2 is FlxTilemap)\n\t\t\t\treturn (Object2 as FlxTilemap).overlapsWithCallback(Object1,separateX,true);\n\t\t\t\n\t\t\t//First, get the two object deltas\n\t\t\tvar overlap:Number = 0;\n\t\t\tvar obj1delta:Number = Object1.x - Object1.last.x;\n\t\t\tvar obj2delta:Number = Object2.x - Object2.last.x;\n\t\t\tif(obj1delta != obj2delta)\n\t\t\t{\n\t\t\t\t//Check if the X hulls actually overlap\n\t\t\t\tvar obj1deltaAbs:Number = (obj1delta > 0)?obj1delta:-obj1delta;\n\t\t\t\tvar obj2deltaAbs:Number = (obj2delta > 0)?obj2delta:-obj2delta;\n\t\t\t\tvar obj1rect:FlxRect = new FlxRect(Object1.x-((obj1delta > 0)?obj1delta:0),Object1.last.y,Object1.width+((obj1delta > 0)?obj1delta:-obj1delta),Object1.height);\n\t\t\t\tvar obj2rect:FlxRect = new FlxRect(Object2.x-((obj2delta > 0)?obj2delta:0),Object2.last.y,Object2.width+((obj2delta > 0)?obj2delta:-obj2delta),Object2.height);\n\t\t\t\tif((obj1rect.x + obj1rect.width > obj2rect.x) && (obj1rect.x < obj2rect.x + obj2rect.width) && (obj1rect.y + obj1rect.height > obj2rect.y) && (obj1rect.y < obj2rect.y + obj2rect.height))\n\t\t\t\t{\n\t\t\t\t\tvar maxOverlap:Number = obj1deltaAbs + obj2deltaAbs + OVERLAP_BIAS;\n\t\t\t\t\t\n\t\t\t\t\t//If they did overlap (and can), figure out by how much and flip the corresponding flags\n\t\t\t\t\tif(obj1delta > obj2delta)\n\t\t\t\t\t{\n\t\t\t\t\t\toverlap = Object1.x + Object1.width - Object2.x;\n\t\t\t\t\t\tif((overlap > maxOverlap) || !(Object1.allowCollisions & RIGHT) || !(Object2.allowCollisions & LEFT))\n\t\t\t\t\t\t\toverlap = 0;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tObject1.touching |= RIGHT;\n\t\t\t\t\t\t\tObject2.touching |= LEFT;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse if(obj1delta < obj2delta)\n\t\t\t\t\t{\n\t\t\t\t\t\toverlap = Object1.x - Object2.width - Object2.x;\n\t\t\t\t\t\tif((-overlap > maxOverlap) || !(Object1.allowCollisions & LEFT) || !(Object2.allowCollisions & RIGHT))\n\t\t\t\t\t\t\toverlap = 0;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tObject1.touching |= LEFT;\n\t\t\t\t\t\t\tObject2.touching |= RIGHT;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//Then adjust their positions and velocities accordingly (if there was any overlap)\n\t\t\tif(overlap != 0)\n\t\t\t{\n\t\t\t\tvar obj1v:Number = Object1.velocity.x;\n\t\t\t\tvar obj2v:Number = Object2.velocity.x;\n\t\t\t\t\n\t\t\t\tif(!obj1immovable && !obj2immovable)\n\t\t\t\t{\n\t\t\t\t\toverlap *= 0.5;\n\t\t\t\t\tObject1.x = Object1.x - overlap;\n\t\t\t\t\tObject2.x += overlap;\n\n\t\t\t\t\tvar obj1velocity:Number = Math.sqrt((obj2v * obj2v * Object2.mass)/Object1.mass) * ((obj2v > 0)?1:-1);\n\t\t\t\t\tvar obj2velocity:Number = Math.sqrt((obj1v * obj1v * Object1.mass)/Object2.mass) * ((obj1v > 0)?1:-1);\n\t\t\t\t\tvar average:Number = (obj1velocity + obj2velocity)*0.5;\n\t\t\t\t\tobj1velocity -= average;\n\t\t\t\t\tobj2velocity -= average;\n\t\t\t\t\tObject1.velocity.x = average + obj1velocity * Object1.elasticity;\n\t\t\t\t\tObject2.velocity.x = average + obj2velocity * Object2.elasticity;\n\t\t\t\t}\n\t\t\t\telse if(!obj1immovable)\n\t\t\t\t{\n\t\t\t\t\tObject1.x = Object1.x - overlap;\n\t\t\t\t\tObject1.velocity.x = obj2v - obj1v*Object1.elasticity;\n\t\t\t\t}\n\t\t\t\telse if(!obj2immovable)\n\t\t\t\t{\n\t\t\t\t\tObject2.x += overlap;\n\t\t\t\t\tObject2.velocity.x = obj1v - obj2v*Object2.elasticity;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The Y-axis component of the object separation process.\n\t\t * \n\t\t * @param\tObject1 \tAny <code>FlxObject</code>.\n\t\t * @param\tObject2\t\tAny other <code>FlxObject</code>.\n\t\t * \n\t\t * @return\tWhether the objects in fact touched and were separated along the Y axis.\n\t\t */\n\t\tstatic public function separateY(Object1:FlxObject, Object2:FlxObject):Boolean\n\t\t{\n\t\t\t//can't separate two immovable objects\n\t\t\tvar obj1immovable:Boolean = Object1.immovable;\n\t\t\tvar obj2immovable:Boolean = Object2.immovable;\n\t\t\tif(obj1immovable && obj2immovable)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\t//If one of the objects is a tilemap, just pass it off.\n\t\t\tif(Object1 is FlxTilemap)\n\t\t\t\treturn (Object1 as FlxTilemap).overlapsWithCallback(Object2,separateY);\n\t\t\tif(Object2 is FlxTilemap)\n\t\t\t\treturn (Object2 as FlxTilemap).overlapsWithCallback(Object1,separateY,true);\n\n\t\t\t//First, get the two object deltas\n\t\t\tvar overlap:Number = 0;\n\t\t\tvar obj1delta:Number = Object1.y - Object1.last.y;\n\t\t\tvar obj2delta:Number = Object2.y - Object2.last.y;\n\t\t\tif(obj1delta != obj2delta)\n\t\t\t{\n\t\t\t\t//Check if the Y hulls actually overlap\n\t\t\t\tvar obj1deltaAbs:Number = (obj1delta > 0)?obj1delta:-obj1delta;\n\t\t\t\tvar obj2deltaAbs:Number = (obj2delta > 0)?obj2delta:-obj2delta;\n\t\t\t\tvar obj1rect:FlxRect = new FlxRect(Object1.x,Object1.y-((obj1delta > 0)?obj1delta:0),Object1.width,Object1.height+obj1deltaAbs);\n\t\t\t\tvar obj2rect:FlxRect = new FlxRect(Object2.x,Object2.y-((obj2delta > 0)?obj2delta:0),Object2.width,Object2.height+obj2deltaAbs);\n\t\t\t\tif((obj1rect.x + obj1rect.width > obj2rect.x) && (obj1rect.x < obj2rect.x + obj2rect.width) && (obj1rect.y + obj1rect.height > obj2rect.y) && (obj1rect.y < obj2rect.y + obj2rect.height))\n\t\t\t\t{\n\t\t\t\t\tvar maxOverlap:Number = obj1deltaAbs + obj2deltaAbs + OVERLAP_BIAS;\n\t\t\t\t\t\n\t\t\t\t\t//If they did overlap (and can), figure out by how much and flip the corresponding flags\n\t\t\t\t\tif(obj1delta > obj2delta)\n\t\t\t\t\t{\n\t\t\t\t\t\toverlap = Object1.y + Object1.height - Object2.y;\n\t\t\t\t\t\tif((overlap > maxOverlap) || !(Object1.allowCollisions & DOWN) || !(Object2.allowCollisions & UP))\n\t\t\t\t\t\t\toverlap = 0;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tObject1.touching |= DOWN;\n\t\t\t\t\t\t\tObject2.touching |= UP;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse if(obj1delta < obj2delta)\n\t\t\t\t\t{\n\t\t\t\t\t\toverlap = Object1.y - Object2.height - Object2.y;\n\t\t\t\t\t\tif((-overlap > maxOverlap) || !(Object1.allowCollisions & UP) || !(Object2.allowCollisions & DOWN))\n\t\t\t\t\t\t\toverlap = 0;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tObject1.touching |= UP;\n\t\t\t\t\t\t\tObject2.touching |= DOWN;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//Then adjust their positions and velocities accordingly (if there was any overlap)\n\t\t\tif(overlap != 0)\n\t\t\t{\n\t\t\t\tvar obj1v:Number = Object1.velocity.y;\n\t\t\t\tvar obj2v:Number = Object2.velocity.y;\n\t\t\t\t\n\t\t\t\tif(!obj1immovable && !obj2immovable)\n\t\t\t\t{\n\t\t\t\t\toverlap *= 0.5;\n\t\t\t\t\tObject1.y = Object1.y - overlap;\n\t\t\t\t\tObject2.y += overlap;\n\n\t\t\t\t\tvar obj1velocity:Number = Math.sqrt((obj2v * obj2v * Object2.mass)/Object1.mass) * ((obj2v > 0)?1:-1);\n\t\t\t\t\tvar obj2velocity:Number = Math.sqrt((obj1v * obj1v * Object1.mass)/Object2.mass) * ((obj1v > 0)?1:-1);\n\t\t\t\t\tvar average:Number = (obj1velocity + obj2velocity)*0.5;\n\t\t\t\t\tobj1velocity -= average;\n\t\t\t\t\tobj2velocity -= average;\n\t\t\t\t\tObject1.velocity.y = average + obj1velocity * Object1.elasticity;\n\t\t\t\t\tObject2.velocity.y = average + obj2velocity * Object2.elasticity;\n\t\t\t\t}\n\t\t\t\telse if(!obj1immovable)\n\t\t\t\t{\n\t\t\t\t\tObject1.y = Object1.y - overlap;\n\t\t\t\t\tObject1.velocity.y = obj2v - obj1v*Object1.elasticity;\n\t\t\t\t\t//This is special case code that handles cases like horizontal moving platforms you can ride\n\t\t\t\t\tif(Object2.active && Object2.moves && (obj1delta > obj2delta))\n\t\t\t\t\t\tObject1.x += Object2.x - Object2.last.x;\n\t\t\t\t}\n\t\t\t\telse if(!obj2immovable)\n\t\t\t\t{\n\t\t\t\t\tObject2.y += overlap;\n\t\t\t\t\tObject2.velocity.y = obj1v - obj2v*Object2.elasticity;\n\t\t\t\t\t//This is special case code that handles cases like horizontal moving platforms you can ride\n\t\t\t\t\tif(Object1.active && Object1.moves && (obj1delta < obj2delta))\n\t\t\t\t\t\tObject2.x += Object1.x - Object1.last.x;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxParticle.as",
    "content": "package org.flixel\n{\n\t\n\t/**\n\t * This is a simple particle class that extends the default behavior\n\t * of <code>FlxSprite</code> to have slightly more specialized behavior\n\t * common to many game scenarios.  You can override and extend this class\n\t * just like you would <code>FlxSprite</code>. While <code>FlxEmitter</code>\n\t * used to work with just any old sprite, it now requires a\n\t * <code>FlxParticle</code> based class.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class FlxParticle extends FlxSprite\n\t{\n\t\t/**\n\t\t * How long this particle lives before it disappears.\n\t\t * NOTE: this is a maximum, not a minimum; the object\n\t\t * could get recycled before its lifespan is up.\n\t\t */\n\t\tpublic var lifespan:Number;\n\t\t\n\t\t/**\n\t\t * Determines how quickly the particles come to rest on the ground.\n\t\t * Only used if the particle has gravity-like acceleration applied.\n\t\t * @default 500\n\t\t */\n\t\tpublic var friction:Number;\n\t\t\n\t\t/**\n\t\t * Instantiate a new particle.  Like <code>FlxSprite</code>, all meaningful creation\n\t\t * happens during <code>loadGraphic()</code> or <code>makeGraphic()</code> or whatever.\n\t\t */\n\t\tpublic function FlxParticle()\n\t\t{\n\t\t\tsuper();\n\t\t\tlifespan = 0;\n\t\t\tfriction = 500;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The particle's main update logic.  Basically it checks to see if it should\n\t\t * be dead yet, and then has some special bounce behavior if there is some gravity on it.\n\t\t */\n\t\toverride public function update():void\n\t\t{\n\t\t\t//lifespan behavior\n\t\t\tif(lifespan <= 0)\n\t\t\t\treturn;\n\t\t\tlifespan -= FlxG.elapsed;\n\t\t\tif(lifespan <= 0)\n\t\t\t\tkill();\n\t\t\t\n\t\t\t//simpler bounce/spin behavior for now\n\t\t\tif(touching)\n\t\t\t{\n\t\t\t\tif(angularVelocity != 0)\n\t\t\t\t\tangularVelocity = -angularVelocity;\n\t\t\t}\n\t\t\tif(acceleration.y > 0) //special behavior for particles with gravity\n\t\t\t{\n\t\t\t\tif(touching & FLOOR)\n\t\t\t\t{\n\t\t\t\t\tdrag.x = friction;\n\t\t\t\t\t\n\t\t\t\t\tif(!(wasTouching & FLOOR))\n\t\t\t\t\t{\n\t\t\t\t\t\tif(velocity.y < -elasticity*10)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(angularVelocity != 0)\n\t\t\t\t\t\t\t\tangularVelocity *= -elasticity;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvelocity.y = 0;\n\t\t\t\t\t\t\tangularVelocity = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tdrag.x = 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Triggered whenever this object is launched by a <code>FlxEmitter</code>.\n\t\t * You can override this to add custom behavior like a sound or AI or something.\n\t\t */\n\t\tpublic function onEmit():void\n\t\t{\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxPath.as",
    "content": "package org.flixel\n{\n\timport flash.display.Graphics;\n\t\n\timport org.flixel.plugin.DebugPathDisplay;\n\t\n\t/**\n\t * This is a simple path data container.  Basically a list of points that\n\t * a <code>FlxObject</code> can follow.  Also has code for drawing debug visuals.\n\t * <code>FlxTilemap.findPath()</code> returns a path object, but you can\n\t * also just make your own, using the <code>add()</code> functions below\n\t * or by creating your own array of points.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxPath\n\t{\n\t\t/**\n\t\t * The list of <code>FlxPoint</code>s that make up the path data.\n\t\t */\n\t\tpublic var nodes:Array;\n\t\t/**\n\t\t * Specify a debug display color for the path.  Default is white.\n\t\t */\n\t\tpublic var debugColor:uint;\n\t\t/**\n\t\t * Specify a debug display scroll factor for the path.  Default is (1,1).\n\t\t * NOTE: does not affect world movement!  Object scroll factors take care of that.\n\t\t */\n\t\tpublic var debugScrollFactor:FlxPoint;\n\t\t/**\n\t\t * Setting this to true will prevent the object from appearing\n\t\t * when the visual debug mode in the debugger overlay is toggled on.\n\t\t * @default false\n\t\t */\n\t\tpublic var ignoreDrawDebug:Boolean;\n\n\t\t/**\n\t\t * Internal helper for keeping new variable instantiations under control.\n\t\t */\n\t\tprotected var _point:FlxPoint;\n\t\t\n\t\t/**\n\t\t * Instantiate a new path object.\n\t\t * \n\t\t * @param\tNodes\tOptional, can specify all the points for the path up front if you want.\n\t\t */\n\t\tpublic function FlxPath(Nodes:Array=null)\n\t\t{\n\t\t\tif(Nodes == null)\n\t\t\t\tnodes = new Array();\n\t\t\telse\n\t\t\t\tnodes = Nodes;\n\t\t\t_point = new FlxPoint();\n\t\t\tdebugScrollFactor = new FlxPoint(1.0,1.0);\n\t\t\tdebugColor = 0xffffff;\n\t\t\tignoreDrawDebug = false;\n\t\t\t\n\t\t\tvar debugPathDisplay:DebugPathDisplay = manager;\n\t\t\tif(debugPathDisplay != null)\n\t\t\t\tdebugPathDisplay.add(this);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\tvar debugPathDisplay:DebugPathDisplay = manager;\n\t\t\tif(debugPathDisplay != null)\n\t\t\t\tdebugPathDisplay.remove(this);\n\t\t\t\n\t\t\tdebugScrollFactor = null;\n\t\t\t_point = null;\n\t\t\tnodes = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Add a new node to the end of the path at the specified location.\n\t\t * \n\t\t * @param\tX\tX position of the new path point in world coordinates.\n\t\t * @param\tY\tY position of the new path point in world coordinates.\n\t\t */\n\t\tpublic function add(X:Number,Y:Number):void\n\t\t{\n\t\t\tnodes.push(new FlxPoint(X,Y));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Add a new node to the path at the specified location and index within the path.\n\t\t * \n\t\t * @param\tX\t\tX position of the new path point in world coordinates.\n\t\t * @param\tY\t\tY position of the new path point in world coordinates.\n\t\t * @param\tIndex\tWhere within the list of path nodes to insert this new point.\n\t\t */\n\t\tpublic function addAt(X:Number, Y:Number, Index:uint):void\n\t\t{\n\t\t\tif(Index > nodes.length)\n\t\t\t\tIndex = nodes.length;\n\t\t\tnodes.splice(Index,0,new FlxPoint(X,Y));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sometimes its easier or faster to just pass a point object instead of separate X and Y coordinates.\n\t\t * This also gives you the option of not creating a new node but actually adding that specific\n\t\t * <code>FlxPoint</code> object to the path.  This allows you to do neat things, like dynamic paths.\n\t\t * \n\t\t * @param\tNode\t\t\tThe point in world coordinates you want to add to the path.\n\t\t * @param\tAsReference\t\tWhether to add the point as a reference, or to create a new point with the specified values.\n\t\t */\n\t\tpublic function addPoint(Node:FlxPoint,AsReference:Boolean=false):void\n\t\t{\n\t\t\tif(AsReference)\n\t\t\t\tnodes.push(Node);\n\t\t\telse\n\t\t\t\tnodes.push(new FlxPoint(Node.x,Node.y));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sometimes its easier or faster to just pass a point object instead of separate X and Y coordinates.\n\t\t * This also gives you the option of not creating a new node but actually adding that specific\n\t\t * <code>FlxPoint</code> object to the path.  This allows you to do neat things, like dynamic paths.\n\t\t * \n\t\t * @param\tNode\t\t\tThe point in world coordinates you want to add to the path.\n\t\t * @param\tIndex\t\t\tWhere within the list of path nodes to insert this new point.\n\t\t * @param\tAsReference\t\tWhether to add the point as a reference, or to create a new point with the specified values.\n\t\t */\n\t\tpublic function addPointAt(Node:FlxPoint,Index:uint,AsReference:Boolean=false):void\n\t\t{\n\t\t\tif(Index > nodes.length)\n\t\t\t\tIndex = nodes.length;\n\t\t\tif(AsReference)\n\t\t\t\tnodes.splice(Index,0,Node);\n\t\t\telse\n\t\t\t\tnodes.splice(Index,0,new FlxPoint(Node.x,Node.y));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Remove a node from the path.\n\t\t * NOTE: only works with points added by reference or with references from <code>nodes</code> itself!\n\t\t * \n\t\t * @param\tNode\tThe point object you want to remove from the path.\n\t\t * \n\t\t * @return\tThe node that was excised.  Returns null if the node was not found.\n\t\t */\n\t\tpublic function remove(Node:FlxPoint):FlxPoint\n\t\t{\n\t\t\tvar index:int = nodes.indexOf(Node);\n\t\t\tif(index >= 0)\n\t\t\t\treturn nodes.splice(index,1)[0];\n\t\t\telse\n\t\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Remove a node from the path using the specified position in the list of path nodes.\n\t\t * \n\t\t * @param\tIndex\tWhere within the list of path nodes you want to remove a node.\n\t\t * \n\t\t * @return\tThe node that was excised.  Returns null if there were no nodes in the path.\n\t\t */\n\t\tpublic function removeAt(Index:uint):FlxPoint\n\t\t{\n\t\t\tif(nodes.length <= 0)\n\t\t\t\treturn null;\n\t\t\tif(Index >= nodes.length)\n\t\t\t\tIndex = nodes.length-1;\n\t\t\treturn nodes.splice(Index,1)[0];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Get the first node in the list.\n\t\t * \n\t\t * @return\tThe first node in the path.\n\t\t */\n\t\tpublic function head():FlxPoint\n\t\t{\n\t\t\tif(nodes.length > 0)\n\t\t\t\treturn nodes[0];\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Get the last node in the list.\n\t\t * \n\t\t * @return\tThe last node in the path.\n\t\t */\n\t\tpublic function tail():FlxPoint\n\t\t{\n\t\t\tif(nodes.length > 0)\n\t\t\t\treturn nodes[nodes.length-1];\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * While this doesn't override <code>FlxBasic.drawDebug()</code>, the behavior is very similar.\n\t\t * Based on this path data, it draws a simple lines-and-boxes representation of the path\n\t\t * if the visual debug mode was toggled in the debugger overlay.  You can use <code>debugColor</code>\n\t\t * and <code>debugScrollFactor</code> to control the path's appearance.\n\t\t * \n\t\t * @param\tCamera\t\tThe camera object the path will draw to.\n\t\t */\n\t\tpublic function drawDebug(Camera:FlxCamera=null):void\n\t\t{\n\t\t\tif(nodes.length <= 0)\n\t\t\t\treturn;\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\t\n\t\t\t//Set up our global flash graphics object to draw out the path\n\t\t\tvar gfx:Graphics = FlxG.flashGfx;\n\t\t\tgfx.clear();\n\t\t\t\n\t\t\t//Then fill up the object with node and path graphics\n\t\t\tvar node:FlxPoint;\n\t\t\tvar nextNode:FlxPoint;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = nodes.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\t//get a reference to the current node\n\t\t\t\tnode = nodes[i] as FlxPoint;\n\t\t\t\t\n\t\t\t\t//find the screen position of the node on this camera\n\t\t\t\t_point.x = node.x - int(Camera.scroll.x*debugScrollFactor.x); //copied from getScreenXY()\n\t\t\t\t_point.y = node.y - int(Camera.scroll.y*debugScrollFactor.y);\n\t\t\t\t_point.x = int(_point.x + ((_point.x > 0)?0.0000001:-0.0000001));\n\t\t\t\t_point.y = int(_point.y + ((_point.y > 0)?0.0000001:-0.0000001));\n\t\t\t\t\n\t\t\t\t//decide what color this node should be\n\t\t\t\tvar nodeSize:uint = 2;\n\t\t\t\tif((i == 0) || (i == l-1))\n\t\t\t\t\tnodeSize *= 2;\n\t\t\t\tvar nodeColor:uint = debugColor;\n\t\t\t\tif(l > 1)\n\t\t\t\t{\n\t\t\t\t\tif(i == 0)\n\t\t\t\t\t\tnodeColor = FlxG.GREEN;\n\t\t\t\t\telse if(i == l-1)\n\t\t\t\t\t\tnodeColor = FlxG.RED;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//draw a box for the node\n\t\t\t\tgfx.beginFill(nodeColor,0.5);\n\t\t\t\tgfx.lineStyle();\n\t\t\t\tgfx.drawRect(_point.x-nodeSize*0.5,_point.y-nodeSize*0.5,nodeSize,nodeSize);\n\t\t\t\tgfx.endFill();\n\n\t\t\t\t//then find the next node in the path\n\t\t\t\tvar linealpha:Number = 0.3;\n\t\t\t\tif(i < l-1)\n\t\t\t\t\tnextNode = nodes[i+1];\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tnextNode = nodes[0];\n\t\t\t\t\tlinealpha = 0.15;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//then draw a line to the next node\n\t\t\t\tgfx.moveTo(_point.x,_point.y);\n\t\t\t\tgfx.lineStyle(1,debugColor,linealpha);\n\t\t\t\t_point.x = nextNode.x - int(Camera.scroll.x*debugScrollFactor.x); //copied from getScreenXY()\n\t\t\t\t_point.y = nextNode.y - int(Camera.scroll.y*debugScrollFactor.y);\n\t\t\t\t_point.x = int(_point.x + ((_point.x > 0)?0.0000001:-0.0000001));\n\t\t\t\t_point.y = int(_point.y + ((_point.y > 0)?0.0000001:-0.0000001));\n\t\t\t\tgfx.lineTo(_point.x,_point.y);\n\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//then stamp the path down onto the game buffer\n\t\t\tCamera.buffer.draw(FlxG.flashGfxSprite);\n\t\t}\n\t\t\n\t\tstatic public function get manager():DebugPathDisplay\n\t\t{\n\t\t\treturn FlxG.getPlugin(DebugPathDisplay) as DebugPathDisplay;\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/FlxPoint.as",
    "content": "package org.flixel\n{\n\timport flash.geom.Point;\n\t\n\t/**\n\t * Stores a 2D floating point coordinate.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxPoint\n\t{\n\t\t/**\n\t\t * @default 0\n\t\t */\n\t\tpublic var x:Number;\n\t\t/**\n\t\t * @default 0\n\t\t */\n\t\tpublic var y:Number;\n\t\t\n\t\t/**\n\t\t * Instantiate a new point object.\n\t\t * \n\t\t * @param\tX\t\tThe X-coordinate of the point in space.\n\t\t * @param\tY\t\tThe Y-coordinate of the point in space.\n\t\t */\n\t\tpublic function FlxPoint(X:Number=0, Y:Number=0)\n\t\t{\n\t\t\tx = X;\n\t\t\ty = Y;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Instantiate a new point object.\n\t\t * \n\t\t * @param\tX\t\tThe X-coordinate of the point in space.\n\t\t * @param\tY\t\tThe Y-coordinate of the point in space.\n\t\t */\n\t\tpublic function make(X:Number=0, Y:Number=0):FlxPoint\n\t\t{\n\t\t\tx = X;\n\t\t\ty = Y;\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Helper function, just copies the values from the specified point.\n\t\t * \n\t\t * @param\tPoint\tAny <code>FlxPoint</code>.\n\t\t * \n\t\t * @return\tA reference to itself.\n\t\t */\n\t\tpublic function copyFrom(Point:FlxPoint):FlxPoint\n\t\t{\n\t\t\tx = Point.x;\n\t\t\ty = Point.y;\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Helper function, just copies the values from this point to the specified point.\n\t\t * \n\t\t * @param\tPoint\tAny <code>FlxPoint</code>.\n\t\t * \n\t\t * @return\tA reference to the altered point parameter.\n\t\t */\n\t\tpublic function copyTo(Point:FlxPoint):FlxPoint\n\t\t{\n\t\t\tPoint.x = x;\n\t\t\tPoint.y = y;\n\t\t\treturn Point;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Helper function, just copies the values from the specified Flash point.\n\t\t * \n\t\t * @param\tPoint\tAny <code>Point</code>.\n\t\t * \n\t\t * @return\tA reference to itself.\n\t\t */\n\t\tpublic function copyFromFlash(FlashPoint:Point):FlxPoint\n\t\t{\n\t\t\tx = FlashPoint.x;\n\t\t\ty = FlashPoint.y;\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Helper function, just copies the values from this point to the specified Flash point.\n\t\t * \n\t\t * @param\tPoint\tAny <code>Point</code>.\n\t\t * \n\t\t * @return\tA reference to the altered point parameter.\n\t\t */\n\t\tpublic function copyToFlash(FlashPoint:Point):Point\n\t\t{\n\t\t\tFlashPoint.x = x;\n\t\t\tFlashPoint.y = y;\n\t\t\treturn FlashPoint;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxRect.as",
    "content": "package org.flixel\n{\n\timport flash.geom.Rectangle;\n\n\t/**\n\t * Stores a rectangle.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxRect\n\t{\n\t\t/**\n\t\t * @default 0\n\t\t */\n\t\tpublic var x:Number;\n\t\t/**\n\t\t * @default 0\n\t\t */\n\t\tpublic var y:Number;\n\t\t/**\n\t\t * @default 0\n\t\t */\n\t\tpublic var width:Number;\n\t\t/**\n\t\t * @default 0\n\t\t */\n\t\tpublic var height:Number;\n\t\t\n\t\t/**\n\t\t * Instantiate a new rectangle.\n\t\t * \n\t\t * @param\tX\t\tThe X-coordinate of the point in space.\n\t\t * @param\tY\t\tThe Y-coordinate of the point in space.\n\t\t * @param\tWidth\tDesired width of the rectangle.\n\t\t * @param\tHeight\tDesired height of the rectangle.\n\t\t */\n\t\tpublic function FlxRect(X:Number=0, Y:Number=0, Width:Number=0, Height:Number=0)\n\t\t{\n\t\t\tx = X;\n\t\t\ty = Y;\n\t\t\twidth = Width;\n\t\t\theight = Height;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The X coordinate of the left side of the rectangle.  Read-only.\n\t\t */\n\t\tpublic function get left():Number\n\t\t{\n\t\t\treturn x;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The X coordinate of the right side of the rectangle.  Read-only.\n\t\t */\n\t\tpublic function get right():Number\n\t\t{\n\t\t\treturn x + width;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The Y coordinate of the top of the rectangle.  Read-only.\n\t\t */\n\t\tpublic function get top():Number\n\t\t{\n\t\t\treturn y;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The Y coordinate of the bottom of the rectangle.  Read-only.\n\t\t */\n\t\tpublic function get bottom():Number\n\t\t{\n\t\t\treturn y + height;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Instantiate a new rectangle.\n\t\t * \n\t\t * @param\tX\t\tThe X-coordinate of the point in space.\n\t\t * @param\tY\t\tThe Y-coordinate of the point in space.\n\t\t * @param\tWidth\tDesired width of the rectangle.\n\t\t * @param\tHeight\tDesired height of the rectangle.\n\t\t * \n\t\t * @return\tA reference to itself.\n\t\t */\n\t\tpublic function make(X:Number=0, Y:Number=0, Width:Number=0, Height:Number=0):FlxRect\n\t\t{\n\t\t\tx = X;\n\t\t\ty = Y;\n\t\t\twidth = Width;\n\t\t\theight = Height;\n\t\t\treturn this;\n\t\t}\n\n\t\t/**\n\t\t * Helper function, just copies the values from the specified rectangle.\n\t\t * \n\t\t * @param\tRect\tAny <code>FlxRect</code>.\n\t\t * \n\t\t * @return\tA reference to itself.\n\t\t */\n\t\tpublic function copyFrom(Rect:FlxRect):FlxRect\n\t\t{\n\t\t\tx = Rect.x;\n\t\t\ty = Rect.y;\n\t\t\twidth = Rect.width;\n\t\t\theight = Rect.height;\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Helper function, just copies the values from this rectangle to the specified rectangle.\n\t\t * \n\t\t * @param\tPoint\tAny <code>FlxRect</code>.\n\t\t * \n\t\t * @return\tA reference to the altered rectangle parameter.\n\t\t */\n\t\tpublic function copyTo(Rect:FlxRect):FlxRect\n\t\t{\n\t\t\tRect.x = x;\n\t\t\tRect.y = y;\n\t\t\tRect.width = width;\n\t\t\tRect.height = height;\n\t\t\treturn Rect;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Helper function, just copies the values from the specified Flash rectangle.\n\t\t * \n\t\t * @param\tFlashRect\tAny <code>Rectangle</code>.\n\t\t * \n\t\t * @return\tA reference to itself.\n\t\t */\n\t\tpublic function copyFromFlash(FlashRect:Rectangle):FlxRect\n\t\t{\n\t\t\tx = FlashRect.x;\n\t\t\ty = FlashRect.y;\n\t\t\twidth = FlashRect.width;\n\t\t\theight = FlashRect.height;\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Helper function, just copies the values from this rectangle to the specified Flash rectangle.\n\t\t * \n\t\t * @param\tPoint\tAny <code>Rectangle</code>.\n\t\t * \n\t\t * @return\tA reference to the altered rectangle parameter.\n\t\t */\n\t\tpublic function copyToFlash(FlashRect:Rectangle):Rectangle\n\t\t{\n\t\t\tFlashRect.x = x;\n\t\t\tFlashRect.y = y;\n\t\t\tFlashRect.width = width;\n\t\t\tFlashRect.height = height;\n\t\t\treturn FlashRect;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Checks to see if some <code>FlxRect</code> object overlaps this <code>FlxRect</code> object.\n\t\t * \n\t\t * @param\tRect\tThe rectangle being tested.\n\t\t * \n\t\t * @return\tWhether or not the two rectangles overlap.\n\t\t */\n\t\tpublic function overlaps(Rect:FlxRect):Boolean\n\t\t{\n\t\t\treturn (Rect.x + Rect.width > x) && (Rect.x < x+width) && (Rect.y + Rect.height > y) && (Rect.y < y+height);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxSave.as",
    "content": "package org.flixel\n{\n\timport flash.events.NetStatusEvent;\n\timport flash.net.SharedObject;\n\timport flash.net.SharedObjectFlushStatus;\n\t\n\t/**\n\t * A class to help automate and simplify save game functionality.\n\t * Basicaly a wrapper for the Flash SharedObject thing, but\n\t * handles some annoying storage request stuff too.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxSave extends Object\n\t{\n\t\tstatic protected var SUCCESS:uint = 0;\n\t\tstatic protected var PENDING:uint = 1;\n\t\tstatic protected var ERROR:uint = 2;\n\t\t/**\n\t\t * Allows you to directly access the data container in the local shared object.\n\t\t * @default null\n\t\t */\n\t\tpublic var data:Object;\n\t\t/**\n\t\t * The name of the local shared object.\n\t\t * @default null\n\t\t */\n\t\tpublic var name:String;\n\t\t/**\n\t\t * The local shared object itself.\n\t\t * @default null\n\t\t */\n\t\tprotected var _sharedObject:SharedObject;\n\t\t\n\t\t/**\n\t\t * Internal tracker for callback function in case save takes too long.\n\t\t */\n\t\tprotected var _onComplete:Function;\n\t\t/**\n\t\t * Internal tracker for save object close request.\n\t\t */\n\t\tprotected var _closeRequested:Boolean;\n\t\t\n\t\t/**\n\t\t * Blanks out the containers.\n\t\t */\n\t\tpublic function FlxSave()\n\t\t{\n\t\t\tdestroy();\n\t\t}\n\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\t_sharedObject = null;\n\t\t\tname = null;\n\t\t\tdata = null;\n\t\t\t_onComplete = null;\n\t\t\t_closeRequested = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Automatically creates or reconnects to locally saved data.\n\t\t * \n\t\t * @param\tName\tThe name of the object (should be the same each time to access old data).\n\t\t * \n\t\t * @return\tWhether or not you successfully connected to the save data.\n\t\t */\n\t\tpublic function bind(Name:String):Boolean\n\t\t{\n\t\t\tdestroy();\n\t\t\tname = Name;\n\t\t\ttry\n\t\t\t{\n\t\t\t\t_sharedObject = SharedObject.getLocal(name);\n\t\t\t}\n\t\t\tcatch(e:Error)\n\t\t\t{\n\t\t\t\tFlxG.log(\"ERROR: There was a problem binding to\\nthe shared object data from FlxSave.\");\n\t\t\t\tdestroy();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tdata = _sharedObject.data;\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * A way to safely call <code>flush()</code> and <code>destroy()</code> on your save file.\n\t\t * Will correctly handle storage size popups and all that good stuff.\n\t\t * If you don't want to save your changes first, just call <code>destroy()</code> instead.\n\t\t *\n\t\t * @param\tMinFileSize\t\tIf you need X amount of space for your save, specify it here.\n\t\t * @param\tOnComplete\t\tThis callback will be triggered when the data is written successfully.\n\t\t *\n\t\t * @return\tThe result of result of the <code>flush()</code> call (see below for more details).\n\t\t */\n\t\tpublic function close(MinFileSize:uint=0,OnComplete:Function=null):Boolean\n\t\t{\n\t\t\t_closeRequested = true;\n\t\t\treturn flush(MinFileSize,OnComplete);\n\t\t}\n\n\t\t/**\n\t\t * Writes the local shared object to disk immediately.  Leaves the object open in memory.\n\t\t *\n\t\t * @param\tMinFileSize\t\tIf you need X amount of space for your save, specify it here.\n\t\t * @param\tOnComplete\t\tThis callback will be triggered when the data is written successfully.\n\t\t *\n\t\t * @return\tWhether or not the data was written immediately.  False could be an error OR a storage request popup.\n\t\t */\n\t\tpublic function flush(MinFileSize:uint=0,OnComplete:Function=null):Boolean\n\t\t{\n\t\t\tif(!checkBinding())\n\t\t\t\treturn false;\n\t\t\t_onComplete = OnComplete;\n\t\t\tvar result:String = null;\n\t\t\ttry { result = _sharedObject.flush(MinFileSize); }\n\t\t\tcatch (e:Error) { return onDone(ERROR); }\n\t\t\tif(result == SharedObjectFlushStatus.PENDING)\n\t\t\t\t_sharedObject.addEventListener(NetStatusEvent.NET_STATUS,onFlushStatus);\n\t\t\treturn onDone((result == SharedObjectFlushStatus.FLUSHED)?SUCCESS:PENDING);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Erases everything stored in the local shared object.\n\t\t * Data is immediately erased and the object is saved that way,\n\t\t * so use with caution!\n\t\t * \n\t\t * @return\tReturns false if the save object is not bound yet.\n\t\t */\n\t\tpublic function erase():Boolean\n\t\t{\n\t\t\tif(!checkBinding())\n\t\t\t\treturn false;\n\t\t\t_sharedObject.clear();\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Event handler for special case storage requests.\n\t\t * \n\t\t * @param\tE\tFlash net status event.\n\t\t */\n\t\tprotected function onFlushStatus(E:NetStatusEvent):void\n\t\t{\n\t\t\t_sharedObject.removeEventListener(NetStatusEvent.NET_STATUS,onFlushStatus);\n\t\t\tonDone((E.info.code == \"SharedObject.Flush.Success\")?SUCCESS:ERROR);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Event handler for special case storage requests.\n\t\t * Handles logging of errors and calling of callback.\n\t\t * \n\t\t * @param\tResult\t\tOne of the result codes (PENDING, ERROR, or SUCCESS).\n\t\t * \n\t\t * @return\tWhether the operation was a success or not.\n\t\t */\n\t\tprotected function onDone(Result:uint):Boolean\n\t\t{\n\t\t\tswitch(Result)\n\t\t\t{\n\t\t\t\tcase PENDING:\n\t\t\t\t\tFlxG.log(\"FLIXEL: FlxSave is requesting extra storage space.\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase ERROR:\n\t\t\t\t\tFlxG.log(\"ERROR: There was a problem flushing\\nthe shared object data from FlxSave.\");\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(_onComplete != null)\n\t\t\t\t_onComplete(Result == SUCCESS);\n\t\t\tif(_closeRequested)\n\t\t\t\tdestroy();\t\t\t\n\t\t\treturn Result == SUCCESS;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Handy utility function for checking and warning if the shared object is bound yet or not.\n\t\t * \n\t\t * @return\tWhether the shared object was bound yet.\n\t\t */\n\t\tprotected function checkBinding():Boolean\n\t\t{\n\t\t\tif(_sharedObject == null)\n\t\t\t{\n\t\t\t\tFlxG.log(\"FLIXEL: You must call FlxSave.bind()\\nbefore you can read or write data.\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxSound.as",
    "content": "package org.flixel\n{\n\timport flash.events.Event;\n\timport flash.media.Sound;\n\timport flash.media.SoundChannel;\n\timport flash.media.SoundTransform;\n\timport flash.net.URLRequest;\n\t\n\t/**\n\t * This is the universal flixel sound object, used for streaming, music, and sound effects.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxSound extends FlxBasic\n\t{\n\t\t/**\n\t\t * The X position of this sound in world coordinates.\n\t\t * Only really matters if you are doing proximity/panning stuff.\n\t\t */\n\t\tpublic var x:Number;\n\t\t/**\n\t\t * The Y position of this sound in world coordinates.\n\t\t * Only really matters if you are doing proximity/panning stuff.\n\t\t */\n\t\tpublic var y:Number;\n\t\t/**\n\t\t * Whether or not this sound should be automatically destroyed when you switch states.\n\t\t */\n\t\tpublic var survive:Boolean;\n\t\t/**\n\t\t * The ID3 song name.  Defaults to null.  Currently only works for streamed sounds.\n\t\t */\n\t\tpublic var name:String;\n\t\t/**\n\t\t * The ID3 artist name.  Defaults to null.  Currently only works for streamed sounds.\n\t\t */\n\t\tpublic var artist:String;\n\t\t/**\n\t\t * Stores the average wave amplitude of both stereo channels\n\t\t */\n\t\tpublic var amplitude:Number;\n\t\t/**\n\t\t * Just the amplitude of the left stereo channel\n\t\t */\n\t\tpublic var amplitudeLeft:Number;\n\t\t/**\n\t\t * Just the amplitude of the left stereo channel\n\t\t */\n\t\tpublic var amplitudeRight:Number;\n\t\t/**\n\t\t * Whether to call destroy() when the sound has finished.\n\t\t */\n\t\tpublic var autoDestroy:Boolean;\n\n\t\t/**\n\t\t * Internal tracker for a Flash sound object.\n\t\t */\n\t\tprotected var _sound:Sound;\n\t\t/**\n\t\t * Internal tracker for a Flash sound channel object.\n\t\t */\n\t\tprotected var _channel:SoundChannel;\n\t\t/**\n\t\t * Internal tracker for a Flash sound transform object.\n\t\t */\n\t\tprotected var _transform:SoundTransform;\n\t\t/**\n\t\t * Internal tracker for the position in runtime of the music playback.\n\t\t */\n\t\tprotected var _position:Number;\n\t\t/**\n\t\t * Internal tracker for how loud the sound is.\n\t\t */\n\t\tprotected var _volume:Number;\n\t\t/**\n\t\t * Internal tracker for total volume adjustment.\n\t\t */\n\t\tprotected var _volumeAdjust:Number;\n\t\t/**\n\t\t * Internal tracker for whether the sound is looping or not.\n\t\t */\n\t\tprotected var _looped:Boolean;\n\t\t/**\n\t\t * Internal tracker for the sound's \"target\" (for proximity and panning).\n\t\t */\n\t\tprotected var _target:FlxObject;\n\t\t/**\n\t\t * Internal tracker for the maximum effective radius of this sound (for proximity and panning).\n\t\t */\n\t\tprotected var _radius:Number;\n\t\t/**\n\t\t * Internal tracker for whether to pan the sound left and right.  Default is false.\n\t\t */\n\t\tprotected var _pan:Boolean;\n\t\t/**\n\t\t * Internal timer used to keep track of requests to fade out the sound playback.\n\t\t */\n\t\tprotected var _fadeOutTimer:Number;\n\t\t/**\n\t\t * Internal helper for fading out sounds.\n\t\t */\n\t\tprotected var _fadeOutTotal:Number;\n\t\t/**\n\t\t * Internal flag for whether to pause or stop the sound when it's done fading out.\n\t\t */\n\t\tprotected var _pauseOnFadeOut:Boolean;\n\t\t/**\n\t\t * Internal timer for fading in the sound playback.\n\t\t */\n\t\tprotected var _fadeInTimer:Number;\n\t\t/**\n\t\t * Internal helper for fading in sounds.\n\t\t */\n\t\tprotected var _fadeInTotal:Number;\n\t\t\n\t\t/**\n\t\t * The FlxSound constructor gets all the variables initialized, but NOT ready to play a sound yet.\n\t\t */\n\t\tpublic function FlxSound()\n\t\t{\n\t\t\tsuper();\n\t\t\tcreateSound();\n\t\t}\n\t\t\n\t\t/**\n\t\t * An internal function for clearing all the variables used by sounds.\n\t\t */\n\t\tprotected function createSound():void\n\t\t{\n\t\t\tdestroy();\n\t\t\tx = 0;\n\t\t\ty = 0;\n\t\t\tif(_transform == null)\n\t\t\t\t_transform = new SoundTransform();\n\t\t\t_transform.pan = 0;\n\t\t\t_sound = null;\n\t\t\t_position = 0;\n\t\t\t_volume = 1.0;\n\t\t\t_volumeAdjust = 1.0;\n\t\t\t_looped = false;\n\t\t\t_target = null;\n\t\t\t_radius = 0;\n\t\t\t_pan = false;\n\t\t\t_fadeOutTimer = 0;\n\t\t\t_fadeOutTotal = 0;\n\t\t\t_pauseOnFadeOut = false;\n\t\t\t_fadeInTimer = 0;\n\t\t\t_fadeInTotal = 0;\n\t\t\texists = false;\n\t\t\tactive = false;\n\t\t\tvisible = false;\n\t\t\tname = null;\n\t\t\tartist = null;\n\t\t\tamplitude = 0;\n\t\t\tamplitudeLeft = 0;\n\t\t\tamplitudeRight = 0;\n\t\t\tautoDestroy = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tkill();\n\n\t\t\t_transform = null;\n\t\t\t_sound = null;\n\t\t\t_channel = null;\n\t\t\t_target = null;\n\t\t\tname = null;\n\t\t\tartist = null;\n\t\t\t\n\t\t\tsuper.destroy();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Handles fade out, fade in, panning, proximity, and amplitude operations each frame.\n\t\t */\n\t\toverride public function update():void\n\t\t{\n\t\t\tif(_position != 0)\n\t\t\t\treturn;\n\t\t\t\n\t\t\tvar radial:Number = 0.0;\n\t\t\tvar fade:Number = 1.0;\n\t\t\t\n\t\t\t//Distance-based volume control\n\t\t\tif(_target != null)\n\t\t\t{\n\t\t\t\tradial = FlxU.getDistance(new FlxPoint(_target.x,_target.y), new FlxPoint(x,y))/_radius;\n\t\t\t\tif(radial < 0) radial = 0;\n\t\t\t\tif(radial > 1) radial = 1;\n\t\t\t\t\n\t\t\t\tif(_pan)\n\t\t\t\t{\n\t\t\t\t\tvar d:Number = (x - _target.x) / _radius;\n\t\t\t\t\tif(d < -1) d = -1;\n\t\t\t\t\telse if(d > 1) d = 1;\n\t\t\t\t\t_transform.pan = d;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//Cross-fading volume control\n\t\t\tif(_fadeOutTimer > 0)\n\t\t\t{\n\t\t\t\t_fadeOutTimer -= FlxG.elapsed;\n\t\t\t\tif(_fadeOutTimer <= 0)\n\t\t\t\t{\n\t\t\t\t\tif(_pauseOnFadeOut)\n\t\t\t\t\t\tpause();\n\t\t\t\t\telse\n\t\t\t\t\t\tstop();\n\t\t\t\t}\n\t\t\t\tfade = _fadeOutTimer/_fadeOutTotal;\n\t\t\t\tif(fade < 0) fade = 0;\n\t\t\t}\n\t\t\telse if(_fadeInTimer > 0)\n\t\t\t{\n\t\t\t\t_fadeInTimer -= FlxG.elapsed;\n\t\t\t\tfade = _fadeInTimer/_fadeInTotal;\n\t\t\t\tif(fade < 0) fade = 0;\n\t\t\t\tfade = 1 - fade;\n\t\t\t}\n\t\t\t\n\t\t\t_volumeAdjust = (1 - radial) * fade;\n\t\t\tupdateTransform();\n\t\t\t\n\t\t\tif((_transform.volume > 0) && (_channel != null))\n\t\t\t{\n\t\t\t\tamplitudeLeft = _channel.leftPeak/_transform.volume;\n\t\t\t\tamplitudeRight = _channel.rightPeak/_transform.volume;\n\t\t\t\tamplitude = (amplitudeLeft+amplitudeRight)*0.5;\n\t\t\t}\n\t\t}\n\t\t\n\t\toverride public function kill():void\n\t\t{\n\t\t\tsuper.kill();\n\t\t\tif(_channel != null)\n\t\t\t\tstop();\n\t\t}\n\t\t\n\t\t/**\n\t\t * One of two main setup functions for sounds, this function loads a sound from an embedded MP3.\n\t\t * \n\t\t * @param\tEmbeddedSound\tAn embedded Class object representing an MP3 file.\n\t\t * @param\tLooped\t\t\tWhether or not this sound should loop endlessly.\n\t\t * @param\tAutoDestroy\t\tWhether or not this <code>FlxSound</code> instance should be destroyed when the sound finishes playing.  Default value is false, but FlxG.play() and FlxG.stream() will set it to true by default.\n\t\t * \n\t\t * @return\tThis <code>FlxSound</code> instance (nice for chaining stuff together, if you're into that).\n\t\t */\n\t\tpublic function loadEmbedded(EmbeddedSound:Class, Looped:Boolean=false, AutoDestroy:Boolean=false):FlxSound\n\t\t{\n\t\t\tstop();\n\t\t\tcreateSound();\n\t\t\t_sound = new EmbeddedSound();\n\t\t\t//NOTE: can't pull ID3 info from embedded sound currently\n\t\t\t_looped = Looped;\n\t\t\tupdateTransform();\n\t\t\texists = true;\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * One of two main setup functions for sounds, this function loads a sound from a URL.\n\t\t * \n\t\t * @param\tEmbeddedSound\tA string representing the URL of the MP3 file you want to play.\n\t\t * @param\tLooped\t\t\tWhether or not this sound should loop endlessly.\n\t\t * @param\tAutoDestroy\t\tWhether or not this <code>FlxSound</code> instance should be destroyed when the sound finishes playing.  Default value is false, but FlxG.play() and FlxG.stream() will set it to true by default.\n\t\t * \n\t\t * @return\tThis <code>FlxSound</code> instance (nice for chaining stuff together, if you're into that).\n\t\t */\n\t\tpublic function loadStream(SoundURL:String, Looped:Boolean=false, AutoDestroy:Boolean=false):FlxSound\n\t\t{\n\t\t\tstop();\n\t\t\tcreateSound();\n\t\t\t_sound = new Sound();\n\t\t\t_sound.addEventListener(Event.ID3, gotID3);\n\t\t\t_sound.load(new URLRequest(SoundURL));\n\t\t\t_looped = Looped;\n\t\t\tupdateTransform();\n\t\t\texists = true;\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function if you want this sound's volume to change\n\t\t * based on distance from a particular FlxCore object.\n\t\t * \n\t\t * @param\tX\t\tThe X position of the sound.\n\t\t * @param\tY\t\tThe Y position of the sound.\n\t\t * @param\tObject\tThe object you want to track.\n\t\t * @param\tRadius\tThe maximum distance this sound can travel.\n\t\t * @param\tPan\t\tWhether the sound should pan in addition to the volume changes (default: true).\n\t\t * \n\t\t * @return\tThis FlxSound instance (nice for chaining stuff together, if you're into that).\n\t\t */\n\t\tpublic function proximity(X:Number,Y:Number,Object:FlxObject,Radius:Number,Pan:Boolean=true):FlxSound\n\t\t{\n\t\t\tx = X;\n\t\t\ty = Y;\n\t\t\t_target = Object;\n\t\t\t_radius = Radius;\n\t\t\t_pan = Pan;\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to play the sound - also works on paused sounds.\n\t\t * \n\t\t * @param\tForceRestart\tWhether to start the sound over or not.  Default value is false, meaning if the sound is already playing or was paused when you call <code>play()</code>, it will continue playing from its current position, NOT start again from the beginning.\n\t\t */\n\t\tpublic function play(ForceRestart:Boolean=false):void\n\t\t{\n\t\t\tif(_position < 0)\n\t\t\t\treturn;\n\t\t\tif(ForceRestart)\n\t\t\t{\n\t\t\t\tvar oldAutoDestroy:Boolean = autoDestroy;\n\t\t\t\tautoDestroy = false;\n\t\t\t\tstop();\n\t\t\t\tautoDestroy = oldAutoDestroy;\n\t\t\t}\n\t\t\tif(_looped)\n\t\t\t{\n\t\t\t\tif(_position == 0)\n\t\t\t\t{\n\t\t\t\t\tif(_channel == null)\n\t\t\t\t\t\t_channel = _sound.play(0,9999,_transform);\n\t\t\t\t\tif(_channel == null)\n\t\t\t\t\t\texists = false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_channel = _sound.play(_position,0,_transform);\n\t\t\t\t\tif(_channel == null)\n\t\t\t\t\t\texists = false;\n\t\t\t\t\telse\n\t\t\t\t\t\t_channel.addEventListener(Event.SOUND_COMPLETE, looped);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(_position == 0)\n\t\t\t\t{\n\t\t\t\t\tif(_channel == null)\n\t\t\t\t\t{\n\t\t\t\t\t\t_channel = _sound.play(0,0,_transform);\n\t\t\t\t\t\tif(_channel == null)\n\t\t\t\t\t\t\texists = false;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t_channel.addEventListener(Event.SOUND_COMPLETE, stopped);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_channel = _sound.play(_position,0,_transform);\n\t\t\t\t\tif(_channel == null)\n\t\t\t\t\t\texists = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tactive = (_channel != null);\n\t\t\t_position = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Unpause a sound.  Only works on sounds that have been paused.\n\t\t */\n\t\tpublic function resume():void\n\t\t{\n\t\t\tif(_position <= 0)\n\t\t\t\treturn;\n\t\t\tif(_looped)\n\t\t\t{\n\t\t\t\t_channel = _sound.play(_position,0,_transform);\n\t\t\t\tif(_channel == null)\n\t\t\t\t\texists = false;\n\t\t\t\telse\n\t\t\t\t\t_channel.addEventListener(Event.SOUND_COMPLETE, looped);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_channel = _sound.play(_position,0,_transform);\n\t\t\t\tif(_channel == null)\n\t\t\t\t\texists = false;\n\t\t\t}\n\t\t\tactive = (_channel != null);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to pause this sound.\n\t\t */\n\t\tpublic function pause():void\n\t\t{\n\t\t\tif(_channel == null)\n\t\t\t{\n\t\t\t\t_position = -1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t_position = _channel.position;\n\t\t\t_channel.stop();\n\t\t\tif(_looped)\n\t\t\t{\n\t\t\t\twhile(_position >= _sound.length)\n\t\t\t\t\t_position -= _sound.length;\n\t\t\t}\n\t\t\tif(_position <= 0)\n\t\t\t\t_position = 1;\n\t\t\t_channel = null;\n\t\t\tactive = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to stop this sound.\n\t\t */\n\t\tpublic function stop():void\n\t\t{\n\t\t\t_position = 0;\n\t\t\tif(_channel != null)\n\t\t\t{\n\t\t\t\t_channel.stop();\n\t\t\t\tstopped();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to make this sound fade out over a certain time interval.\n\t\t * \n\t\t * @param\tSeconds\t\t\tThe amount of time the fade out operation should take.\n\t\t * @param\tPauseInstead\tTells the sound to pause on fadeout, instead of stopping.\n\t\t */\n\t\tpublic function fadeOut(Seconds:Number,PauseInstead:Boolean=false):void\n\t\t{\n\t\t\t_pauseOnFadeOut = PauseInstead;\n\t\t\t_fadeInTimer = 0;\n\t\t\t_fadeOutTimer = Seconds;\n\t\t\t_fadeOutTotal = _fadeOutTimer;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to make a sound fade in over a certain\n\t\t * time interval (calls <code>play()</code> automatically).\n\t\t * \n\t\t * @param\tSeconds\t\tThe amount of time the fade-in operation should take.\n\t\t */\n\t\tpublic function fadeIn(Seconds:Number):void\n\t\t{\n\t\t\t_fadeOutTimer = 0;\n\t\t\t_fadeInTimer = Seconds;\n\t\t\t_fadeInTotal = _fadeInTimer;\n\t\t\tplay();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set <code>volume</code> to a value between 0 and 1 to change how this sound is.\n\t\t */\n\t\tpublic function get volume():Number\n\t\t{\n\t\t\treturn _volume;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set volume(Volume:Number):void\n\t\t{\n\t\t\t_volume = Volume;\n\t\t\tif(_volume < 0)\n\t\t\t\t_volume = 0;\n\t\t\telse if(_volume > 1)\n\t\t\t\t_volume = 1;\n\t\t\tupdateTransform();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns the currently selected \"real\" volume of the sound (takes fades and proximity into account).\n\t\t * \n\t\t * @return\tThe adjusted volume of the sound.\n\t\t */\n\t\tpublic function getActualVolume():Number\n\t\t{\n\t\t\treturn _volume*_volumeAdjust;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call after adjusting the volume to update the sound channel's settings.\n\t\t */\n\t\tinternal function updateTransform():void\n\t\t{\n\t\t\t_transform.volume = (FlxG.mute?0:1)*FlxG.volume*_volume*_volumeAdjust;\n\t\t\tif(_channel != null)\n\t\t\t\t_channel.soundTransform = _transform;\n\t\t}\n\t\t\n\t\t/**\n\t\t * An internal helper function used to help Flash resume playing a looped sound.\n\t\t * \n\t\t * @param\tevent\t\tAn <code>Event</code> object.\n\t\t */\n\t\tprotected function looped(event:Event=null):void\n\t\t{\n\t\t    if (_channel == null)\n\t\t    \treturn;\n\t        _channel.removeEventListener(Event.SOUND_COMPLETE,looped);\n\t        _channel = null;\n\t\t\tplay();\n\t\t}\n\n\t\t/**\n\t\t * An internal helper function used to help Flash clean up and re-use finished sounds.\n\t\t * \n\t\t * @param\tevent\t\tAn <code>Event</code> object.\n\t\t */\n\t\tprotected function stopped(event:Event=null):void\n\t\t{\n\t\t\tif(!_looped)\n\t        \t_channel.removeEventListener(Event.SOUND_COMPLETE,stopped);\n\t        else\n\t        \t_channel.removeEventListener(Event.SOUND_COMPLETE,looped);\n\t        _channel = null;\n\t\t\tactive = false;\n\t\t\tif(autoDestroy)\n\t\t\t\tdestroy();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal event handler for ID3 info (i.e. fetching the song name).\n\t\t * \n\t\t * @param\tevent\tAn <code>Event</code> object.\n\t\t */\n\t\tprotected function gotID3(event:Event=null):void\n\t\t{\n\t\t\tFlxG.log(\"got ID3 info!\");\n\t\t\tif(_sound.id3.songName.length > 0)\n\t\t\t\tname = _sound.id3.songName;\n\t\t\tif(_sound.id3.artist.length > 0)\n\t\t\t\tartist = _sound.id3.artist;\n\t\t\t_sound.removeEventListener(Event.ID3, gotID3);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxSprite.as",
    "content": "package org.flixel\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Graphics;\n\timport flash.geom.ColorTransform;\n\timport flash.geom.Matrix;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.system.FlxAnim;\n\t\n\t/**\n\t * The main \"game object\" class, the sprite is a <code>FlxObject</code>\n\t * with a bunch of graphics options and abilities, like animation and stamping.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxSprite extends FlxObject\n\t{\n\t\t[Embed(source=\"data/default.png\")] protected var ImgDefault:Class;\n\t\t\n\t\t/**\n\t\t * WARNING: The origin of the sprite will default to its center.\n\t\t * If you change this, the visuals and the collisions will likely be\n\t\t * pretty out-of-sync if you do any rotation.\n\t\t */\n\t\tpublic var origin:FlxPoint;\n\t\t/**\n\t\t* If you changed the size of your sprite object after loading or making the graphic,\n\t\t* you might need to offset the graphic away from the bound box to center it the way you want.\n\t\t*/\n\t\tpublic var offset:FlxPoint;\n\t\t\n\t\t/**\n\t\t * Change the size of your sprite's graphic.\n\t\t * NOTE: Scale doesn't currently affect collisions automatically,\n\t\t * you will need to adjust the width, height and offset manually.\n\t\t * WARNING: scaling sprites decreases rendering performance for this sprite by a factor of 10x!\n\t\t */\n\t\tpublic var scale:FlxPoint;\n\t\t/**\n\t\t * Blending modes, just like Photoshop or whatever.\n\t\t * E.g. \"multiply\", \"screen\", etc.\n\t\t * @default null\n\t\t */\n\t\tpublic var blend:String;\n\t\t/**\n\t\t * Controls whether the object is smoothed when rotated, affects performance.\n\t\t * @default false\n\t\t */\n\t\tpublic var antialiasing:Boolean;\n\t\t/**\n\t\t * Whether the current animation has finished its first (or only) loop.\n\t\t */\n\t\tpublic var finished:Boolean;\n\t\t/**\n\t\t * The width of the actual graphic or image being displayed (not necessarily the game object/bounding box).\n\t\t * NOTE: Edit at your own risk!!  This is intended to be read-only.\n\t\t */\n\t\tpublic var frameWidth:uint;\n\t\t/**\n\t\t * The height of the actual graphic or image being displayed (not necessarily the game object/bounding box).\n\t\t * NOTE: Edit at your own risk!!  This is intended to be read-only.\n\t\t */\n\t\tpublic var frameHeight:uint;\n\t\t/**\n\t\t * The total number of frames in this image.  WARNING: assumes each row in the sprite sheet is full!\n\t\t */\n\t\tpublic var frames:uint;\n\t\t/**\n\t\t * The actual Flash <code>BitmapData</code> object representing the current display state of the sprite.\n\t\t */\n\t\tpublic var framePixels:BitmapData;\n\t\t/**\n\t\t * Set this flag to true to force the sprite to update during the draw() call.\n\t\t * NOTE: Rarely if ever necessary, most sprite operations will flip this flag automatically.\n\t\t */\n\t\tpublic var dirty:Boolean;\n\t\t\n\t\t/**\n\t\t * Internal, stores all the animations that were added to this sprite.\n\t\t */\n\t\tprotected var _animations:Array;\n\t\t/**\n\t\t * Internal, keeps track of whether the sprite was loaded with support for automatic reverse/mirroring.\n\t\t */\n\t\tprotected var _flipped:uint;\n\t\t/**\n\t\t * Internal, keeps track of the current animation being played.\n\t\t */\n\t\tprotected var _curAnim:FlxAnim;\n\t\t/**\n\t\t * Internal, keeps track of the current frame of animation.\n\t\t * This is NOT an index into the tile sheet, but the frame number in the animation object.\n\t\t */\n\t\tprotected var _curFrame:uint;\n\t\t/**\n\t\t * Internal, keeps track of the current index into the tile sheet based on animation or rotation.\n\t\t */\n\t\tprotected var _curIndex:uint;\n\t\t/**\n\t\t * Internal, used to time each frame of animation.\n\t\t */\n\t\tprotected var _frameTimer:Number;\n\t\t/**\n\t\t * Internal tracker for the animation callback.  Default is null.\n\t\t * If assigned, will be called each time the current frame changes.\n\t\t * A function that has 3 parameters: a string name, a uint frame number, and a uint frame index.\n\t\t */\n\t\tprotected var _callback:Function;\n\t\t/**\n\t\t * Internal tracker for what direction the sprite is currently facing, used with Flash getter/setter.\n\t\t */\n\t\tprotected var _facing:uint;\n\t\t/**\n\t\t * Internal tracker for opacity, used with Flash getter/setter.\n\t\t */\n\t\tprotected var _alpha:Number;\n\t\t/**\n\t\t * Internal tracker for color tint, used with Flash getter/setter.\n\t\t */\n\t\tprotected var _color:uint;\n\t\t/**\n\t\t * Internal tracker for how many frames of \"baked\" rotation there are (if any).\n\t\t */\n\t\tprotected var _bakedRotation:Number;\n\t\t/**\n\t\t * Internal, stores the entire source graphic (not the current displayed animation frame), used with Flash getter/setter.\n\t\t */\n\t\tprotected var _pixels:BitmapData;\n\t\t\n\t\t/**\n\t\t * Internal, reused frequently during drawing and animating.\n\t\t */\n\t\tprotected var _flashPoint:Point;\n\t\t/**\n\t\t * Internal, reused frequently during drawing and animating.\n\t\t */\n\t\tprotected var _flashRect:Rectangle;\n\t\t/**\n\t\t * Internal, reused frequently during drawing and animating.\n\t\t */\n\t\tprotected var _flashRect2:Rectangle;\n\t\t/**\n\t\t * Internal, reused frequently during drawing and animating. Always contains (0,0).\n\t\t */\n\t\tprotected var _flashPointZero:Point;\n\t\t/**\n\t\t * Internal, helps with animation, caching and drawing.\n\t\t */\n\t\tprotected var _colorTransform:ColorTransform;\n\t\t/**\n\t\t * Internal, helps with animation, caching and drawing.\n\t\t */\n\t\tprotected var _matrix:Matrix;\n\t\t\n\t\t/**\n\t\t * Creates a white 8x8 square <code>FlxSprite</code> at the specified position.\n\t\t * Optionally can load a simple, one-frame graphic instead.\n\t\t * \n\t\t * @param\tX\t\t\t\tThe initial X position of the sprite.\n\t\t * @param\tY\t\t\t\tThe initial Y position of the sprite.\n\t\t * @param\tSimpleGraphic\tThe graphic you want to display (OPTIONAL - for simple stuff only, do NOT use for animated images!).\n\t\t */\n\t\tpublic function FlxSprite(X:Number=0,Y:Number=0,SimpleGraphic:Class=null)\n\t\t{\n\t\t\tsuper(X,Y);\n\n\t\t\t_flashPoint = new Point();\n\t\t\t_flashRect = new Rectangle();\n\t\t\t_flashRect2 = new Rectangle();\n\t\t\t_flashPointZero = new Point();\n\t\t\toffset = new FlxPoint();\n\t\t\torigin = new FlxPoint();\n\t\t\t\n\t\t\tscale = new FlxPoint(1.0,1.0);\n\t\t\t_alpha = 1;\n\t\t\t_color = 0x00ffffff;\n\t\t\tblend = null;\n\t\t\tantialiasing = false;\n\t\t\tcameras = null;\n\t\t\t\n\t\t\tfinished = false;\n\t\t\t_facing = RIGHT;\n\t\t\t_animations = new Array();\n\t\t\t_flipped = 0;\n\t\t\t_curAnim = null;\n\t\t\t_curFrame = 0;\n\t\t\t_curIndex = 0;\n\t\t\t_frameTimer = 0;\n\n\t\t\t_matrix = new Matrix();\n\t\t\t_callback = null;\n\t\t\t\n\t\t\tif(SimpleGraphic == null)\n\t\t\t\tSimpleGraphic = ImgDefault;\n\t\t\tloadGraphic(SimpleGraphic);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tif(_animations != null)\n\t\t\t{\n\t\t\t\tvar a:FlxAnim;\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar l:uint = _animations.length;\n\t\t\t\twhile(i < l)\n\t\t\t\t{\n\t\t\t\t\ta = _animations[i++];\n\t\t\t\t\tif(a != null)\n\t\t\t\t\t\ta.destroy();\n\t\t\t\t}\n\t\t\t\t_animations = null;\n\t\t\t}\n\t\t\t\n\t\t\t_flashPoint = null;\n\t\t\t_flashRect = null;\n\t\t\t_flashRect2 = null;\n\t\t\t_flashPointZero = null;\n\t\t\toffset = null;\n\t\t\torigin = null;\n\t\t\tscale = null;\n\t\t\t_curAnim = null;\n\t\t\t_matrix = null;\n\t\t\t_callback = null;\n\t\t\tframePixels = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Load an image from an embedded graphic file.\n\t\t * \n\t\t * @param\tGraphic\t\tThe image you want to use.\n\t\t * @param\tAnimated\tWhether the Graphic parameter is a single sprite or a row of sprites.\n\t\t * @param\tReverse\t\tWhether you need this class to generate horizontally flipped versions of the animation frames.\n\t\t * @param\tWidth\t\tOptional, specify the width of your sprite (helps FlxSprite figure out what to do with non-square sprites or sprite sheets).\n\t\t * @param\tHeight\t\tOptional, specify the height of your sprite (helps FlxSprite figure out what to do with non-square sprites or sprite sheets).\n\t\t * @param\tUnique\t\tOptional, whether the graphic should be a unique instance in the graphics cache.  Default is false.\n\t\t * \n\t\t * @return\tThis FlxSprite instance (nice for chaining stuff together, if you're into that).\n\t\t */\n\t\tpublic function loadGraphic(Graphic:Class,Animated:Boolean=false,Reverse:Boolean=false,Width:uint=0,Height:uint=0,Unique:Boolean=false):FlxSprite\n\t\t{\n\t\t\t_bakedRotation = 0;\n\t\t\t_pixels = FlxG.addBitmap(Graphic,Reverse,Unique);\n\t\t\tif(Reverse)\n\t\t\t\t_flipped = _pixels.width>>1;\n\t\t\telse\n\t\t\t\t_flipped = 0;\n\t\t\tif(Width == 0)\n\t\t\t{\n\t\t\t\tif(Animated)\n\t\t\t\t\tWidth = _pixels.height;\n\t\t\t\telse if(_flipped > 0)\n\t\t\t\t\tWidth = _pixels.width*0.5;\n\t\t\t\telse\n\t\t\t\t\tWidth = _pixels.width;\n\t\t\t}\n\t\t\twidth = frameWidth = Width;\n\t\t\tif(Height == 0)\n\t\t\t{\n\t\t\t\tif(Animated)\n\t\t\t\t\tHeight = width;\n\t\t\t\telse\n\t\t\t\t\tHeight = _pixels.height;\n\t\t\t}\n\t\t\theight = frameHeight = Height;\n\t\t\tresetHelpers();\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Create a pre-rotated sprite sheet from a simple sprite.\n\t\t * This can make a huge difference in graphical performance!\n\t\t * \n\t\t * @param\tGraphic\t\t\tThe image you want to rotate and stamp.\n\t\t * @param\tRotations\t\tThe number of rotation frames the final sprite should have.  For small sprites this can be quite a large number (360 even) without any problems.\n\t\t * @param\tFrame\t\t\tIf the Graphic has a single row of square animation frames on it, you can specify which of the frames you want to use here.  Default is -1, or \"use whole graphic.\"\n\t\t * @param\tAntiAliasing\tWhether to use high quality rotations when creating the graphic.  Default is false.\n\t\t * @param\tAutoBuffer\t\tWhether to automatically increase the image size to accomodate rotated corners.  Default is false.  Will create frames that are 150% larger on each axis than the original frame or graphic.\n\t\t * \n\t\t * @return\tThis FlxSprite instance (nice for chaining stuff together, if you're into that).\n\t\t */\n\t\tpublic function loadRotatedGraphic(Graphic:Class, Rotations:uint=16, Frame:int=-1, AntiAliasing:Boolean=false, AutoBuffer:Boolean=false):FlxSprite\n\t\t{\n\t\t\t//Create the brush and canvas\n\t\t\tvar rows:uint = Math.sqrt(Rotations);\n\t\t\tvar brush:BitmapData = FlxG.addBitmap(Graphic);\n\t\t\tif(Frame >= 0)\n\t\t\t{\n\t\t\t\t//Using just a segment of the graphic - find the right bit here\n\t\t\t\tvar full:BitmapData = brush;\n\t\t\t\tbrush = new BitmapData(full.height,full.height);\n\t\t\t\tvar rx:uint = Frame*brush.width;\n\t\t\t\tvar ry:uint = 0;\n\t\t\t\tvar fw:uint = full.width;\n\t\t\t\tif(rx >= fw)\n\t\t\t\t{\n\t\t\t\t\try = uint(rx/fw)*brush.height;\n\t\t\t\t\trx %= fw;\n\t\t\t\t}\n\t\t\t\t_flashRect.x = rx;\n\t\t\t\t_flashRect.y = ry;\n\t\t\t\t_flashRect.width = brush.width;\n\t\t\t\t_flashRect.height = brush.height;\n\t\t\t\tbrush.copyPixels(full,_flashRect,_flashPointZero);\n\t\t\t}\n\t\t\t\n\t\t\tvar max:uint = brush.width;\n\t\t\tif(brush.height > max)\n\t\t\t\tmax = brush.height;\n\t\t\tif(AutoBuffer)\n\t\t\t\tmax *= 1.5;\n\t\t\tvar columns:uint = FlxU.ceil(Rotations/rows);\n\t\t\twidth = max*columns;\n\t\t\theight = max*rows;\n\t\t\tvar key:String = String(Graphic) + \":\" + Frame + \":\" + width + \"x\" + height;\n\t\t\tvar skipGen:Boolean = FlxG.checkBitmapCache(key);\n\t\t\t_pixels = FlxG.createBitmap(width, height, 0, true, key);\n\t\t\twidth = frameWidth = _pixels.width;\n\t\t\theight = frameHeight = _pixels.height;\n\t\t\t_bakedRotation = 360/Rotations;\n\t\t\t\n\t\t\t//Generate a new sheet if necessary, then fix up the width and height\n\t\t\tif(!skipGen)\n\t\t\t{\n\t\t\t\tvar row:uint = 0;\n\t\t\t\tvar column:uint;\n\t\t\t\tvar bakedAngle:Number = 0;\n\t\t\t\tvar halfBrushWidth:uint = brush.width*0.5;\n\t\t\t\tvar halfBrushHeight:uint = brush.height*0.5;\n\t\t\t\tvar midpointX:uint = max*0.5;\n\t\t\t\tvar midpointY:uint = max*0.5;\n\t\t\t\twhile(row < rows)\n\t\t\t\t{\n\t\t\t\t\tcolumn = 0;\n\t\t\t\t\twhile(column < columns)\n\t\t\t\t\t{\n\t\t\t\t\t\t_matrix.identity();\n\t\t\t\t\t\t_matrix.translate(-halfBrushWidth,-halfBrushHeight);\n\t\t\t\t\t\t_matrix.rotate(bakedAngle*0.017453293);\n\t\t\t\t\t\t_matrix.translate(max*column+midpointX, midpointY);\n\t\t\t\t\t\tbakedAngle += _bakedRotation;\n\t\t\t\t\t\t_pixels.draw(brush,_matrix,null,null,null,AntiAliasing);\n\t\t\t\t\t\tcolumn++;\n\t\t\t\t\t}\n\t\t\t\t\tmidpointY += max;\n\t\t\t\t\trow++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tframeWidth = frameHeight = width = height = max;\n\t\t\tresetHelpers();\n\t\t\tif(AutoBuffer)\n\t\t\t{\n\t\t\t\twidth = brush.width;\n\t\t\t\theight = brush.height;\n\t\t\t\tcenterOffsets();\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * This function creates a flat colored square image dynamically.\n\t\t * \n\t\t * @param\tWidth\t\tThe width of the sprite you want to generate.\n\t\t * @param\tHeight\t\tThe height of the sprite you want to generate.\n\t\t * @param\tColor\t\tSpecifies the color of the generated block.\n\t\t * @param\tUnique\t\tWhether the graphic should be a unique instance in the graphics cache.  Default is false.\n\t\t * @param\tKey\t\t\tOptional parameter - specify a string key to identify this graphic in the cache.  Trumps Unique flag.\n\t\t * \n\t\t * @return\tThis FlxSprite instance (nice for chaining stuff together, if you're into that).\n\t\t */\n\t\tpublic function makeGraphic(Width:uint,Height:uint,Color:uint=0xffffffff,Unique:Boolean=false,Key:String=null):FlxSprite\n\t\t{\n\t\t\t_bakedRotation = 0;\n\t\t\t_pixels = FlxG.createBitmap(Width,Height,Color,Unique,Key);\n\t\t\twidth = frameWidth = _pixels.width;\n\t\t\theight = frameHeight = _pixels.height;\n\t\t\tresetHelpers();\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Resets some important variables for sprite optimization and rendering.\n\t\t */\n\t\tprotected function resetHelpers():void\n\t\t{\n\t\t\t_flashRect.x = 0;\n\t\t\t_flashRect.y = 0;\n\t\t\t_flashRect.width = frameWidth;\n\t\t\t_flashRect.height = frameHeight;\n\t\t\t_flashRect2.x = 0;\n\t\t\t_flashRect2.y = 0;\n\t\t\t_flashRect2.width = _pixels.width;\n\t\t\t_flashRect2.height = _pixels.height;\n\t\t\tif((framePixels == null) || (framePixels.width != width) || (framePixels.height != height))\n\t\t\t\tframePixels = new BitmapData(width,height);\n\t\t\torigin.make(frameWidth*0.5,frameHeight*0.5);\n\t\t\tframePixels.copyPixels(_pixels,_flashRect,_flashPointZero);\n\t\t\tframes = (_flashRect2.width / _flashRect.width) * (_flashRect2.height / _flashRect.height);\n\t\t\tif(_colorTransform != null) framePixels.colorTransform(_flashRect,_colorTransform);\n\t\t\t_curIndex = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Automatically called after update() by the game loop,\n\t\t * this function just calls updateAnimation().\n\t\t */\n\t\toverride public function postUpdate():void\n\t\t{\n\t\t\tsuper.postUpdate();\n\t\t\tupdateAnimation();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by game loop, updates then blits or renders current frame of animation to the screen\n\t\t */\n\t\toverride public function draw():void\n\t\t{\n\t\t\tif(_flickerTimer != 0)\n\t\t\t{\n\t\t\t\t_flicker = !_flicker;\n\t\t\t\tif(_flicker)\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif(dirty)\t//rarely \n\t\t\t\tcalcFrame();\n\t\t\t\n\t\t\tif(cameras == null)\n\t\t\t\tcameras = FlxG.cameras;\n\t\t\tvar camera:FlxCamera;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = cameras.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tcamera = cameras[i++];\n\t\t\t\tif(!onScreen(camera))\n\t\t\t\t\tcontinue;\n\t\t\t\t_point.x = x - int(camera.scroll.x*scrollFactor.x) - offset.x;\n\t\t\t\t_point.y = y - int(camera.scroll.y*scrollFactor.y) - offset.y;\n\t\t\t\t_point.x += (_point.x > 0)?0.0000001:-0.0000001;\n\t\t\t\t_point.y += (_point.y > 0)?0.0000001:-0.0000001;\n\t\t\t\tif(((angle == 0) || (_bakedRotation > 0)) && (scale.x == 1) && (scale.y == 1) && (blend == null))\n\t\t\t\t{\t//Simple render\n\t\t\t\t\t_flashPoint.x = _point.x;\n\t\t\t\t\t_flashPoint.y = _point.y;\n\t\t\t\t\tcamera.buffer.copyPixels(framePixels,_flashRect,_flashPoint,null,null,true);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\t//Advanced render\n\t\t\t\t\t_matrix.identity();\n\t\t\t\t\t_matrix.translate(-origin.x,-origin.y);\n\t\t\t\t\t_matrix.scale(scale.x,scale.y);\n\t\t\t\t\tif((angle != 0) && (_bakedRotation <= 0))\n\t\t\t\t\t\t_matrix.rotate(angle * 0.017453293);\n\t\t\t\t\t_matrix.translate(_point.x+origin.x,_point.y+origin.y);\n\t\t\t\t\tcamera.buffer.draw(framePixels,_matrix,null,blend,null,antialiasing);\n\t\t\t\t}\n\t\t\t\t_VISIBLECOUNT++;\n\t\t\t\tif(FlxG.visualDebug && !ignoreDrawDebug)\n\t\t\t\t\tdrawDebug(camera);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * This function draws or stamps one <code>FlxSprite</code> onto another.\n\t\t * This function is NOT intended to replace <code>draw()</code>!\n\t\t * \n\t\t * @param\tBrush\t\tThe image you want to use as a brush or stamp or pen or whatever.\n\t\t * @param\tX\t\t\tThe X coordinate of the brush's top left corner on this sprite.\n\t\t * @param\tY\t\t\tThey Y coordinate of the brush's top left corner on this sprite.\n\t\t */\n\t\tpublic function stamp(Brush:FlxSprite,X:int=0,Y:int=0):void\n\t\t{\n\t\t\tBrush.drawFrame();\n\t\t\tvar bitmapData:BitmapData = Brush.framePixels;\n\t\t\t\n\t\t\t//Simple draw\n\t\t\tif(((Brush.angle == 0) || (Brush._bakedRotation > 0)) && (Brush.scale.x == 1) && (Brush.scale.y == 1) && (Brush.blend == null))\n\t\t\t{\n\t\t\t\t_flashPoint.x = X;\n\t\t\t\t_flashPoint.y = Y;\n\t\t\t\t_flashRect2.width = bitmapData.width;\n\t\t\t\t_flashRect2.height = bitmapData.height;\n\t\t\t\t_pixels.copyPixels(bitmapData,_flashRect2,_flashPoint,null,null,true);\n\t\t\t\t_flashRect2.width = _pixels.width;\n\t\t\t\t_flashRect2.height = _pixels.height;\n\t\t\t\tcalcFrame();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//Advanced draw\n\t\t\t_matrix.identity();\n\t\t\t_matrix.translate(-Brush.origin.x,-Brush.origin.y);\n\t\t\t_matrix.scale(Brush.scale.x,Brush.scale.y);\n\t\t\tif(Brush.angle != 0)\n\t\t\t\t_matrix.rotate(Brush.angle * 0.017453293);\n\t\t\t_matrix.translate(X+Brush.origin.x,Y+Brush.origin.y);\n\t\t\t_pixels.draw(bitmapData,_matrix,null,Brush.blend,null,Brush.antialiasing);\n\t\t\tcalcFrame();\n\t\t}\n\t\t\n\t\t/**\n\t\t * This function draws a line on this sprite from position X1,Y1\n\t\t * to position X2,Y2 with the specified color.\n\t\t * \n\t\t * @param\tStartX\t\tX coordinate of the line's start point.\n\t\t * @param\tStartY\t\tY coordinate of the line's start point.\n\t\t * @param\tEndX\t\tX coordinate of the line's end point.\n\t\t * @param\tEndY\t\tY coordinate of the line's end point.\n\t\t * @param\tColor\t\tThe line's color.\n\t\t * @param\tThickness\tHow thick the line is in pixels (default value is 1).\n\t\t */\n\t\tpublic function drawLine(StartX:Number,StartY:Number,EndX:Number,EndY:Number,Color:uint,Thickness:uint=1):void\n\t\t{\n\t\t\t//Draw line\n\t\t\tvar gfx:Graphics = FlxG.flashGfx;\n\t\t\tgfx.clear();\n\t\t\tgfx.moveTo(StartX,StartY);\n\t\t\tvar alphaComponent:Number = Number((Color >> 24) & 0xFF) / 255;\n\t\t\tif(alphaComponent <= 0)\n\t\t\t\talphaComponent = 1;\n\t\t\tgfx.lineStyle(Thickness,Color,alphaComponent);\n\t\t\tgfx.lineTo(EndX,EndY);\n\t\t\t\n\t\t\t//Cache line to bitmap\n\t\t\t_pixels.draw(FlxG.flashGfxSprite);\n\t\t\tdirty = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fills this sprite's graphic with a specific color.\n\t\t * \n\t\t * @param\tColor\t\tThe color with which to fill the graphic, format 0xAARRGGBB.\n\t\t */\n\t\tpublic function fill(Color:uint):void\n\t\t{\n\t\t\t_pixels.fillRect(_flashRect2,Color);\n\t\t\tif(_pixels != framePixels)\n\t\t\t\tdirty = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function for updating the sprite's animation.\n\t\t * Useful for cases when you need to update this but are buried down in too many supers.\n\t\t * This function is called automatically by <code>FlxSprite.postUpdate()</code>.\n\t\t */\n\t\tprotected function updateAnimation():void\n\t\t{\n\t\t\tif(_bakedRotation > 0)\n\t\t\t{\n\t\t\t\tvar oldIndex:uint = _curIndex;\n\t\t\t\tvar angleHelper:int = angle%360;\n\t\t\t\tif(angleHelper < 0)\n\t\t\t\t\tangleHelper += 360;\n\t\t\t\t_curIndex = angleHelper/_bakedRotation + 0.5;\n\t\t\t\tif(oldIndex != _curIndex)\n\t\t\t\t\tdirty = true;\n\t\t\t}\n\t\t\telse if((_curAnim != null) && (_curAnim.delay > 0) && (_curAnim.looped || !finished))\n\t\t\t{\n\t\t\t\t_frameTimer += FlxG.elapsed;\n\t\t\t\twhile(_frameTimer > _curAnim.delay)\n\t\t\t\t{\n\t\t\t\t\t_frameTimer = _frameTimer - _curAnim.delay;\n\t\t\t\t\tif(_curFrame == _curAnim.frames.length-1)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(_curAnim.looped)\n\t\t\t\t\t\t\t_curFrame = 0;\n\t\t\t\t\t\tfinished = true;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\t_curFrame++;\n\t\t\t\t\t_curIndex = _curAnim.frames[_curFrame];\n\t\t\t\t\tdirty = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(dirty)\n\t\t\t\tcalcFrame();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Request (or force) that the sprite update the frame before rendering.\n\t\t * Useful if you are doing procedural generation or other weirdness!\n\t\t * \n\t\t * @param\tForce\tForce the frame to redraw, even if its not flagged as necessary.\n\t\t */\n\t\tpublic function drawFrame(Force:Boolean=false):void\n\t\t{\n\t\t\tif(Force || dirty)\n\t\t\t\tcalcFrame();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adds a new animation to the sprite.\n\t\t * \n\t\t * @param\tName\t\tWhat this animation should be called (e.g. \"run\").\n\t\t * @param\tFrames\t\tAn array of numbers indicating what frames to play in what order (e.g. 1, 2, 3).\n\t\t * @param\tFrameRate\tThe speed in frames per second that the animation should play at (e.g. 40 fps).\n\t\t * @param\tLooped\t\tWhether or not the animation is looped or just plays once.\n\t\t */\n\t\tpublic function addAnimation(Name:String, Frames:Array, FrameRate:Number=0, Looped:Boolean=true):void\n\t\t{\n\t\t\t_animations.push(new FlxAnim(Name,Frames,FrameRate,Looped));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Pass in a function to be called whenever this sprite's animation changes.\n\t\t * \n\t\t * @param\tAnimationCallback\t\tA function that has 3 parameters: a string name, a uint frame number, and a uint frame index.\n\t\t */\n\t\tpublic function addAnimationCallback(AnimationCallback:Function):void\n\t\t{\n\t\t\t_callback = AnimationCallback;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Plays an existing animation (e.g. \"run\").\n\t\t * If you call an animation that is already playing it will be ignored.\n\t\t * \n\t\t * @param\tAnimName\tThe string name of the animation you want to play.\n\t\t * @param\tForce\t\tWhether to force the animation to restart.\n\t\t */\n\t\tpublic function play(AnimName:String,Force:Boolean=false):void\n\t\t{\n\t\t\tif(!Force && (_curAnim != null) && (AnimName == _curAnim.name) && (!_curAnim.looped || !finished)) return;\n\t\t\t_curFrame = 0;\n\t\t\t_curIndex = 0;\n\t\t\t_frameTimer = 0;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = _animations.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tif(_animations[i].name == AnimName)\n\t\t\t\t{\n\t\t\t\t\t_curAnim = _animations[i];\n\t\t\t\t\tif(_curAnim.delay <= 0)\n\t\t\t\t\t\tfinished = true;\n\t\t\t\t\telse\n\t\t\t\t\t\tfinished = false;\n\t\t\t\t\t_curIndex = _curAnim.frames[_curFrame];\n\t\t\t\t\tdirty = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tFlxG.log(\"WARNING: No animation called \\\"\"+AnimName+\"\\\"\");\n\t\t}\n\t\t\n\t\t/**\n\t\t * Tell the sprite to change to a random frame of animation\n\t\t * Useful for instantiating particles or other weird things.\n\t\t */\n\t\tpublic function randomFrame():void\n\t\t{\n\t\t\t_curAnim = null;\n\t\t\t_curIndex = int(FlxG.random()*(_pixels.width/frameWidth));\n\t\t\tdirty = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Helper function that just sets origin to (0,0)\n\t\t */\n\t\tpublic function setOriginToCorner():void\n\t\t{\n\t\t\torigin.x = origin.y = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Helper function that adjusts the offset automatically to center the bounding box within the graphic.\n\t\t * \n\t\t * @param\tAdjustPosition\t\tAdjusts the actual X and Y position just once to match the offset change. Default is false.\n\t\t */\n\t\tpublic function centerOffsets(AdjustPosition:Boolean=false):void\n\t\t{\n\t\t\toffset.x = (frameWidth-width)*0.5;\n\t\t\toffset.y = (frameHeight-height)*0.5;\n\t\t\tif(AdjustPosition)\n\t\t\t{\n\t\t\t\tx += offset.x;\n\t\t\t\ty += offset.y;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic function replaceColor(Color:uint,NewColor:uint,FetchPositions:Boolean=false):Array\n\t\t{\n\t\t\tvar positions:Array = null;\n\t\t\tif(FetchPositions)\n\t\t\t\tpositions = new Array();\n\t\t\t\n\t\t\tvar row:uint = 0;\n\t\t\tvar column:uint;\n\t\t\tvar rows:uint = _pixels.height;\n\t\t\tvar columns:uint = _pixels.width;\n\t\t\twhile(row < rows)\n\t\t\t{\n\t\t\t\tcolumn = 0;\n\t\t\t\twhile(column < columns)\n\t\t\t\t{\n\t\t\t\t\tif(_pixels.getPixel32(column,row) == Color)\n\t\t\t\t\t{\n\t\t\t\t\t\t_pixels.setPixel32(column,row,NewColor);\n\t\t\t\t\t\tif(FetchPositions)\n\t\t\t\t\t\t\tpositions.push(new FlxPoint(column,row));\n\t\t\t\t\t\tdirty = true;\n\t\t\t\t\t}\n\t\t\t\t\tcolumn++;\n\t\t\t\t}\n\t\t\t\trow++;\n\t\t\t}\n\t\t\t\n\t\t\treturn positions;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set <code>pixels</code> to any <code>BitmapData</code> object.\n\t\t * Automatically adjust graphic size and render helpers.\n\t\t */\n\t\tpublic function get pixels():BitmapData\n\t\t{\n\t\t\treturn _pixels;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set pixels(Pixels:BitmapData):void\n\t\t{\n\t\t\t_pixels = Pixels;\n\t\t\twidth = frameWidth = _pixels.width;\n\t\t\theight = frameHeight = _pixels.height;\n\t\t\tresetHelpers();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set <code>facing</code> using <code>FlxSprite.LEFT</code>,<code>RIGHT</code>,\n\t\t * <code>UP</code>, and <code>DOWN</code> to take advantage of\n\t\t * flipped sprites and/or just track player orientation more easily.\n\t\t */\n\t\tpublic function get facing():uint\n\t\t{\n\t\t\treturn _facing;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set facing(Direction:uint):void\n\t\t{\n\t\t\tif(_facing != Direction)\n\t\t\t\tdirty = true;\n\t\t\t_facing = Direction;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set <code>alpha</code> to a number between 0 and 1 to change the opacity of the sprite.\n\t\t */\n\t\tpublic function get alpha():Number\n\t\t{\n\t\t\treturn _alpha;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set alpha(Alpha:Number):void\n\t\t{\n\t\t\tif(Alpha > 1)\n\t\t\t\tAlpha = 1;\n\t\t\tif(Alpha < 0)\n\t\t\t\tAlpha = 0;\n\t\t\tif(Alpha == _alpha)\n\t\t\t\treturn;\n\t\t\t_alpha = Alpha;\n\t\t\tif((_alpha != 1) || (_color != 0x00ffffff))\n\t\t\t\t_colorTransform = new ColorTransform((_color>>16)*0.00392,(_color>>8&0xff)*0.00392,(_color&0xff)*0.00392,_alpha);\n\t\t\telse\n\t\t\t\t_colorTransform = null;\n\t\t\tdirty = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set <code>color</code> to a number in this format: 0xRRGGBB.\n\t\t * <code>color</code> IGNORES ALPHA.  To change the opacity use <code>alpha</code>.\n\t\t * Tints the whole sprite to be this color (similar to OpenGL vertex colors).\n\t\t */\n\t\tpublic function get color():uint\n\t\t{\n\t\t\treturn _color;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set color(Color:uint):void\n\t\t{\n\t\t\tColor &= 0x00ffffff;\n\t\t\tif(_color == Color)\n\t\t\t\treturn;\n\t\t\t_color = Color;\n\t\t\tif((_alpha != 1) || (_color != 0x00ffffff))\n\t\t\t\t_colorTransform = new ColorTransform((_color>>16)*0.00392,(_color>>8&0xff)*0.00392,(_color&0xff)*0.00392,_alpha);\n\t\t\telse\n\t\t\t\t_colorTransform = null;\n\t\t\tdirty = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Tell the sprite to change to a specific frame of animation.\n\t\t * \n\t\t * @param\tFrame\tThe frame you want to display.\n\t\t */\n\t\tpublic function get frame():uint\n\t\t{\n\t\t\treturn _curIndex;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set frame(Frame:uint):void\n\t\t{\n\t\t\t_curAnim = null;\n\t\t\t_curIndex = Frame;\n\t\t\tdirty = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Check and see if this object is currently on screen.\n\t\t * Differs from <code>FlxObject</code>'s implementation\n\t\t * in that it takes the actual graphic into account,\n\t\t * not just the hitbox or bounding box or whatever.\n\t\t * \n\t\t * @param\tCamera\t\tSpecify which game camera you want.  If null getScreenXY() will just grab the first global camera.\n\t\t * \n\t\t * @return\tWhether the object is on screen or not.\n\t\t */\n\t\toverride public function onScreen(Camera:FlxCamera=null):Boolean\n\t\t{\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\tgetScreenXY(_point,Camera);\n\t\t\t_point.x = _point.x - offset.x;\n\t\t\t_point.y = _point.y - offset.y;\n\n\t\t\tif(((angle == 0) || (_bakedRotation > 0)) && (scale.x == 1) && (scale.y == 1))\n\t\t\t\treturn ((_point.x + frameWidth > 0) && (_point.x < Camera.width) && (_point.y + frameHeight > 0) && (_point.y < Camera.height));\n\t\t\t\n\t\t\tvar halfWidth:Number = frameWidth/2;\n\t\t\tvar halfHeight:Number = frameHeight/2;\n\t\t\tvar absScaleX:Number = (scale.x>0)?scale.x:-scale.x;\n\t\t\tvar absScaleY:Number = (scale.y>0)?scale.y:-scale.y;\n\t\t\tvar radius:Number = Math.sqrt(halfWidth*halfWidth+halfHeight*halfHeight)*((absScaleX >= absScaleY)?absScaleX:absScaleY);\n\t\t\t_point.x += halfWidth;\n\t\t\t_point.y += halfHeight;\n\t\t\treturn ((_point.x + radius > 0) && (_point.x - radius < Camera.width) && (_point.y + radius > 0) && (_point.y - radius < Camera.height));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Checks to see if a point in 2D world space overlaps this <code>FlxSprite</code> object's current displayed pixels.\n\t\t * This check is ALWAYS made in screen space, and always takes scroll factors into account.\n\t\t * \n\t\t * @param\tPoint\t\tThe point in world space you want to check.\n\t\t * @param\tMask\t\tUsed in the pixel hit test to determine what counts as solid.\n\t\t * @param\tCamera\t\tSpecify which game camera you want.  If null getScreenXY() will just grab the first global camera.\n\t\t * \n\t\t * @return\tWhether or not the point overlaps this object.\n\t\t */\n\t\tpublic function pixelsOverlapPoint(Point:FlxPoint,Mask:uint=0xFF,Camera:FlxCamera=null):Boolean\n\t\t{\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\tgetScreenXY(_point,Camera);\n\t\t\t_point.x = _point.x - offset.x;\n\t\t\t_point.y = _point.y - offset.y;\n\t\t\t_flashPoint.x = (Point.x - Camera.scroll.x) - _point.x;\n\t\t\t_flashPoint.y = (Point.y - Camera.scroll.y) - _point.y;\n\t\t\treturn framePixels.hitTest(_flashPointZero,Mask,_flashPoint);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function to update the current animation frame.\n\t\t */\n\t\tprotected function calcFrame():void\n\t\t{\n\t\t\tvar indexX:uint = _curIndex*frameWidth;\n\t\t\tvar indexY:uint = 0;\n\n\t\t\t//Handle sprite sheets\n\t\t\tvar widthHelper:uint = _flipped?_flipped:_pixels.width;\n\t\t\tif(indexX >= widthHelper)\n\t\t\t{\n\t\t\t\tindexY = uint(indexX/widthHelper)*frameHeight;\n\t\t\t\tindexX %= widthHelper;\n\t\t\t}\n\t\t\t\n\t\t\t//handle reversed sprites\n\t\t\tif(_flipped && (_facing == LEFT))\n\t\t\t\tindexX = (_flipped<<1)-indexX-frameWidth;\n\t\t\t\n\t\t\t//Update display bitmap\n\t\t\t_flashRect.x = indexX;\n\t\t\t_flashRect.y = indexY;\n\t\t\tframePixels.copyPixels(_pixels,_flashRect,_flashPointZero);\n\t\t\t_flashRect.x = _flashRect.y = 0;\n\t\t\tif(_colorTransform != null)\n\t\t\t\tframePixels.colorTransform(_flashRect,_colorTransform);\n\t\t\tif(_callback != null)\n\t\t\t\t_callback(((_curAnim != null)?(_curAnim.name):null),_curFrame,_curIndex);\n\t\t\tdirty = false;\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/FlxState.as",
    "content": "package org.flixel\n{\n\timport org.flixel.system.FlxQuadTree;\n\t\n\t/**\n\t * This is the basic game \"state\" object - e.g. in a simple game\n\t * you might have a menu state and a play state.\n\t * It is for all intents and purpose a fancy FlxGroup.\n\t * And really, it's not even that fancy.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxState extends FlxGroup\n\t{\n\t\t/**\n\t\t * This function is called after the game engine successfully switches states.\n\t\t * Override this function, NOT the constructor, to initialize or set up your game state.\n\t\t * We do NOT recommend overriding the constructor, unless you want some crazy unpredictable things to happen!\n\t\t */\n\t\tpublic function create():void\n\t\t{\n\t\t\t\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxText.as",
    "content": "package org.flixel\n{\n\timport flash.display.BitmapData;\n\timport flash.text.TextField;\n\timport flash.text.TextFormat;\n\t\n\t/**\n\t * Extends <code>FlxSprite</code> to support rendering text.\n\t * Can tint, fade, rotate and scale just like a sprite.\n\t * Doesn't really animate though, as far as I know.\n\t * Also does nice pixel-perfect centering on pixel fonts\n\t * as long as they are only one liners.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxText extends FlxSprite\n\t{\n\t\t/**\n\t\t * Internal reference to a Flash <code>TextField</code> object.\n\t\t */\n\t\tprotected var _textField:TextField;\n\t\t/**\n\t\t * Whether the actual text field needs to be regenerated and stamped again.\n\t\t * This is NOT the same thing as <code>FlxSprite.dirty</code>.\n\t\t */\n\t\tprotected var _regen:Boolean;\n\t\t/**\n\t\t * Internal tracker for the text shadow color, default is clear/transparent.\n\t\t */\n\t\tprotected var _shadow:uint;\n\t\t\n\t\t/**\n\t\t * Creates a new <code>FlxText</code> object at the specified position.\n\t\t * \n\t\t * @param\tX\t\t\t\tThe X position of the text.\n\t\t * @param\tY\t\t\t\tThe Y position of the text.\n\t\t * @param\tWidth\t\t\tThe width of the text object (height is determined automatically).\n\t\t * @param\tText\t\t\tThe actual text you would like to display initially.\n\t\t * @param\tEmbeddedFont\tWhether this text field uses embedded fonts or nto\n\t\t */\n\t\tpublic function FlxText(X:Number, Y:Number, Width:uint, Text:String=null, EmbeddedFont:Boolean=true)\n\t\t{\n\t\t\tsuper(X,Y);\n\t\t\tmakeGraphic(Width,1,0);\n\t\t\t\n\t\t\tif(Text == null)\n\t\t\t\tText = \"\";\n\t\t\t_textField = new TextField();\n\t\t\t_textField.width = Width;\n\t\t\t_textField.embedFonts = EmbeddedFont;\n\t\t\t_textField.selectable = false;\n\t\t\t_textField.sharpness = 100;\n\t\t\t_textField.multiline = true;\n\t\t\t_textField.wordWrap = true;\n\t\t\t_textField.text = Text;\n\t\t\tvar format:TextFormat = new TextFormat(\"system\",8,0xffffff);\n\t\t\t_textField.defaultTextFormat = format;\n\t\t\t_textField.setTextFormat(format);\n\t\t\tif(Text.length <= 0)\n\t\t\t\t_textField.height = 1;\n\t\t\telse\n\t\t\t\t_textField.height = 10;\n\t\t\t\n\t\t\t_regen = true;\n\t\t\t_shadow = 0;\n\t\t\tallowCollisions = NONE;\n\t\t\tcalcFrame();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\t_textField = null;\n\t\t\tsuper.destroy();\n\t\t}\n\t\t\n\t\t/**\n\t\t * You can use this if you have a lot of text parameters\n\t\t * to set instead of the individual properties.\n\t\t * \n\t\t * @param\tFont\t\tThe name of the font face for the text display.\n\t\t * @param\tSize\t\tThe size of the font (in pixels essentially).\n\t\t * @param\tColor\t\tThe color of the text in traditional flash 0xRRGGBB format.\n\t\t * @param\tAlignment\tA string representing the desired alignment (\"left,\"right\" or \"center\").\n\t\t * @param\tShadowColor\tA uint representing the desired text shadow color in flash 0xRRGGBB format.\n\t\t * \n\t\t * @return\tThis FlxText instance (nice for chaining stuff together, if you're into that).\n\t\t */\n\t\tpublic function setFormat(Font:String=null,Size:Number=8,Color:uint=0xffffff,Alignment:String=null,ShadowColor:uint=0):FlxText\n\t\t{\n\t\t\tif(Font == null)\n\t\t\t\tFont = \"\";\n\t\t\tvar format:TextFormat = dtfCopy();\n\t\t\tformat.font = Font;\n\t\t\tformat.size = Size;\n\t\t\tformat.color = Color;\n\t\t\tformat.align = Alignment;\n\t\t\t_textField.defaultTextFormat = format;\n\t\t\t_textField.setTextFormat(format);\n\t\t\t_shadow = ShadowColor;\n\t\t\t_regen = true;\n\t\t\tcalcFrame();\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The text being displayed.\n\t\t */\n\t\tpublic function get text():String\n\t\t{\n\t\t\treturn _textField.text;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set text(Text:String):void\n\t\t{\n\t\t\tvar ot:String = _textField.text;\n\t\t\t_textField.text = Text;\n\t\t\tif(_textField.text != ot)\n\t\t\t{\n\t\t\t\t_regen = true;\n\t\t\t\tcalcFrame();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * The size of the text being displayed.\n\t\t */\n\t\t public function get size():Number\n\t\t{\n\t\t\treturn _textField.defaultTextFormat.size as Number;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set size(Size:Number):void\n\t\t{\n\t\t\tvar format:TextFormat = dtfCopy();\n\t\t\tformat.size = Size;\n\t\t\t_textField.defaultTextFormat = format;\n\t\t\t_textField.setTextFormat(format);\n\t\t\t_regen = true;\n\t\t\tcalcFrame();\n\t\t}\n\t\t\n\t\t/**\n\t\t * The color of the text being displayed.\n\t\t */\n\t\toverride public function get color():uint\n\t\t{\n\t\t\treturn _textField.defaultTextFormat.color as uint;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\toverride public function set color(Color:uint):void\n\t\t{\n\t\t\tvar format:TextFormat = dtfCopy();\n\t\t\tformat.color = Color;\n\t\t\t_textField.defaultTextFormat = format;\n\t\t\t_textField.setTextFormat(format);\n\t\t\t_regen = true;\n\t\t\tcalcFrame();\n\t\t}\n\t\t\n\t\t/**\n\t\t * The font used for this text.\n\t\t */\n\t\tpublic function get font():String\n\t\t{\n\t\t\treturn _textField.defaultTextFormat.font;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set font(Font:String):void\n\t\t{\n\t\t\tvar format:TextFormat = dtfCopy();\n\t\t\tformat.font = Font;\n\t\t\t_textField.defaultTextFormat = format;\n\t\t\t_textField.setTextFormat(format);\n\t\t\t_regen = true;\n\t\t\tcalcFrame();\n\t\t}\n\t\t\n\t\t/**\n\t\t * The alignment of the font (\"left\", \"right\", or \"center\").\n\t\t */\n\t\tpublic function get alignment():String\n\t\t{\n\t\t\treturn _textField.defaultTextFormat.align;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set alignment(Alignment:String):void\n\t\t{\n\t\t\tvar format:TextFormat = dtfCopy();\n\t\t\tformat.align = Alignment;\n\t\t\t_textField.defaultTextFormat = format;\n\t\t\t_textField.setTextFormat(format);\n\t\t\tcalcFrame();\n\t\t}\n\t\t\n\t\t/**\n\t\t * The color of the text shadow in 0xAARRGGBB hex format.\n\t\t */\n\t\tpublic function get shadow():uint\n\t\t{\n\t\t\treturn _shadow;\n\t\t}\n\t\t\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tpublic function set shadow(Color:uint):void\n\t\t{\n\t\t\t_shadow = Color;\n\t\t\tcalcFrame();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function to update the current animation frame.\n\t\t */\n\t\toverride protected function calcFrame():void\n\t\t{\n\t\t\tif(_regen)\n\t\t\t{\n\t\t\t\t//Need to generate a new buffer to store the text graphic\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar nl:uint = _textField.numLines;\n\t\t\t\theight = 0;\n\t\t\t\twhile(i < nl)\n\t\t\t\t\theight += _textField.getLineMetrics(i++).height;\n\t\t\t\theight += 4; //account for 2px gutter on top and bottom\n\t\t\t\t_pixels = new BitmapData(width,height,true,0);\n\t\t\t\tframeHeight = height;\n\t\t\t\t_textField.height = height*1.2;\n\t\t\t\t_flashRect.x = 0;\n\t\t\t\t_flashRect.y = 0;\n\t\t\t\t_flashRect.width = width;\n\t\t\t\t_flashRect.height = height;\n\t\t\t\t_regen = false;\n\t\t\t}\n\t\t\telse\t//Else just clear the old buffer before redrawing the text\n\t\t\t\t_pixels.fillRect(_flashRect,0);\n\t\t\t\n\t\t\tif((_textField != null) && (_textField.text != null) && (_textField.text.length > 0))\n\t\t\t{\n\t\t\t\t//Now that we've cleared a buffer, we need to actually render the text to it\n\t\t\t\tvar format:TextFormat = _textField.defaultTextFormat;\n\t\t\t\tvar formatAdjusted:TextFormat = format;\n\t\t\t\t_matrix.identity();\n\t\t\t\t//If it's a single, centered line of text, we center it ourselves so it doesn't blur to hell\n\t\t\t\tif((format.align == \"center\") && (_textField.numLines == 1))\n\t\t\t\t{\n\t\t\t\t\tformatAdjusted = new TextFormat(format.font,format.size,format.color,null,null,null,null,null,\"left\");\n\t\t\t\t\t_textField.setTextFormat(formatAdjusted);\t\t\t\t\n\t\t\t\t\t_matrix.translate(Math.floor((width - _textField.getLineMetrics(0).width)/2),0);\n\t\t\t\t}\n\t\t\t\t//Render a single pixel shadow beneath the text\n\t\t\t\tif(_shadow > 0)\n\t\t\t\t{\n\t\t\t\t\t_textField.setTextFormat(new TextFormat(formatAdjusted.font,formatAdjusted.size,_shadow,null,null,null,null,null,formatAdjusted.align));\t\t\t\t\n\t\t\t\t\t_matrix.translate(1,1);\n\t\t\t\t\t_pixels.draw(_textField,_matrix,_colorTransform);\n\t\t\t\t\t_matrix.translate(-1,-1);\n\t\t\t\t\t_textField.setTextFormat(new TextFormat(formatAdjusted.font,formatAdjusted.size,formatAdjusted.color,null,null,null,null,null,formatAdjusted.align));\n\t\t\t\t}\n\t\t\t\t//Actually draw the text onto the buffer\n\t\t\t\t_pixels.draw(_textField,_matrix,_colorTransform);\n\t\t\t\t_textField.setTextFormat(new TextFormat(format.font,format.size,format.color,null,null,null,null,null,format.align));\n\t\t\t}\n\t\t\t\n\t\t\t//Finally, update the visible pixels\n\t\t\tif((framePixels == null) || (framePixels.width != _pixels.width) || (framePixels.height != _pixels.height))\n\t\t\t\tframePixels = new BitmapData(_pixels.width,_pixels.height,true,0);\n\t\t\tframePixels.copyPixels(_pixels,_flashRect,_flashPointZero);\n\t\t}\n\t\t\n\t\t/**\n\t\t * A helper function for updating the <code>TextField</code> that we use for rendering.\n\t\t * \n\t\t * @return\tA writable copy of <code>TextField.defaultTextFormat</code>.\n\t\t */\n\t\tprotected function dtfCopy():TextFormat\n\t\t{\n\t\t\tvar defaultTextFormat:TextFormat = _textField.defaultTextFormat;\n\t\t\treturn new TextFormat(defaultTextFormat.font,defaultTextFormat.size,defaultTextFormat.color,defaultTextFormat.bold,defaultTextFormat.italic,defaultTextFormat.underline,defaultTextFormat.url,defaultTextFormat.target,defaultTextFormat.align);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxTileblock.as",
    "content": "package org.flixel\n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Rectangle;\n\t\n\t/**\n\t * This is a basic \"environment object\" class, used to create simple walls and floors.\n\t * It can be filled with a random selection of tiles to quickly add detail.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class FlxTileblock extends FlxSprite\n\t{\t\t\n\t\t/**\n\t\t * Creates a new <code>FlxBlock</code> object with the specified position and size.\n\t\t * \n\t\t * @param\tX\t\t\tThe X position of the block.\n\t\t * @param\tY\t\t\tThe Y position of the block.\n\t\t * @param\tWidth\t\tThe width of the block.\n\t\t * @param\tHeight\t\tThe height of the block.\n\t\t */\n\t\tpublic function FlxTileblock(X:int,Y:int,Width:uint,Height:uint)\n\t\t{\n\t\t\tsuper(X,Y);\n\t\t\tmakeGraphic(Width,Height,0,true);\n\t\t\tactive = false;\n\t\t\timmovable = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fills the block with a randomly arranged selection of graphics from the image provided.\n\t\t * \n\t\t * @param\tTileGraphic \tThe graphic class that contains the tiles that should fill this block.\n\t\t * @param\tTileWidth\t\tThe width of a single tile in the graphic.\n\t\t * @param\tTileHeight\t\tThe height of a single tile in the graphic.\n\t\t * @param\tEmpties\t\t\tThe number of \"empty\" tiles to add to the auto-fill algorithm (e.g. 8 tiles + 4 empties = 1/3 of block will be open holes).\n\t\t */\n\t\tpublic function loadTiles(TileGraphic:Class,TileWidth:uint=0,TileHeight:uint=0,Empties:uint=0):FlxTileblock\n\t\t{\n\t\t\tif(TileGraphic == null)\n\t\t\t\treturn this;\n\t\t\t\n\t\t\t//First create a tile brush\n\t\t\tvar sprite:FlxSprite = new FlxSprite().loadGraphic(TileGraphic,true,false,TileWidth,TileHeight);\n\t\t\tvar spriteWidth:uint = sprite.width;\n\t\t\tvar spriteHeight:uint = sprite.height;\n\t\t\tvar total:uint = sprite.frames + Empties;\n\t\t\t\n\t\t\t//Then prep the \"canvas\" as it were (just doublechecking that the size is on tile boundaries)\n\t\t\tvar regen:Boolean = false;\n\t\t\tif(width % sprite.width != 0)\n\t\t\t{\n\t\t\t\twidth = uint(width/spriteWidth+1)*spriteWidth;\n\t\t\t\tregen = true;\n\t\t\t}\n\t\t\tif(height % sprite.height != 0)\n\t\t\t{\n\t\t\t\theight = uint(height/spriteHeight+1)*spriteHeight;\n\t\t\t\tregen = true;\n\t\t\t}\n\t\t\tif(regen)\n\t\t\t\tmakeGraphic(width,height,0,true);\n\t\t\telse\n\t\t\t\tthis.fill(0);\n\t\t\t\n\t\t\t//Stamp random tiles onto the canvas\n\t\t\tvar row:uint = 0;\n\t\t\tvar column:uint;\n\t\t\tvar destinationX:uint;\n\t\t\tvar destinationY:uint = 0;\n\t\t\tvar widthInTiles:uint = width/spriteWidth;\n\t\t\tvar heightInTiles:uint = height/spriteHeight;\n\t\t\twhile(row < heightInTiles)\n\t\t\t{\n\t\t\t\tdestinationX = 0;\n\t\t\t\tcolumn = 0;\n\t\t\t\twhile(column < widthInTiles)\n\t\t\t\t{\n\t\t\t\t\tif(FlxG.random()*total > Empties)\n\t\t\t\t\t{\n\t\t\t\t\t\tsprite.randomFrame();\n\t\t\t\t\t\tsprite.drawFrame();\n\t\t\t\t\t\tstamp(sprite,destinationX,destinationY);\n\t\t\t\t\t}\n\t\t\t\t\tdestinationX += spriteWidth;\n\t\t\t\t\tcolumn++;\n\t\t\t\t}\n\t\t\t\tdestinationY += spriteHeight;\n\t\t\t\trow++;\n\t\t\t}\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxTilemap.as",
    "content": "package org.flixel\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Graphics;\n\timport flash.geom.Matrix;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.system.FlxTile;\n\timport org.flixel.system.FlxTilemapBuffer;\n\n\t/**\n\t * This is a traditional tilemap display and collision class.\n\t * It takes a string of comma-separated numbers and then associates\n\t * those values with tiles from the sheet you pass in.\n\t * It also includes some handy static parsers that can convert\n\t * arrays or images into strings that can be loaded.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxTilemap extends FlxObject\n\t{\n\t\t[Embed(source=\"data/autotiles.png\")] static public var ImgAuto:Class;\n\t\t[Embed(source=\"data/autotiles_alt.png\")] static public var ImgAutoAlt:Class;\n\t\t\n\t\t/**\n\t\t * No auto-tiling.\n\t\t */\n\t\tstatic public const OFF:uint = 0;\n\t\t/**\n\t\t * Good for levels with thin walls that don'tile need interior corner art.\n\t\t */\n\t\tstatic public const AUTO:uint = 1;\n\t\t/**\n\t\t * Better for levels with thick walls that look better with interior corner art.\n\t\t */\n\t\tstatic public const ALT:uint = 2;\n\n\t\t/**\n\t\t * Set this flag to use one of the 16-tile binary auto-tile algorithms (OFF, AUTO, or ALT).\n\t\t */\n\t\tpublic var auto:uint;\n\t\t\n\t\t/**\n\t\t * Read-only variable, do NOT recommend changing after the map is loaded!\n\t\t */\n\t\tpublic var widthInTiles:uint;\n\t\t/**\n\t\t * Read-only variable, do NOT recommend changing after the map is loaded!\n\t\t */\n\t\tpublic var heightInTiles:uint;\n\t\t/**\n\t\t * Read-only variable, do NOT recommend changing after the map is loaded!\n\t\t */\n\t\tpublic var totalTiles:uint;\n\t\t\n\t\t/**\n\t\t * Rendering helper, minimize new object instantiation on repetitive methods.\n\t\t */\n\t\tprotected var _flashPoint:Point;\n\t\t/**\n\t\t * Rendering helper, minimize new object instantiation on repetitive methods.\n\t\t */\n\t\tprotected var _flashRect:Rectangle;\n\t\t\n\t\t/**\n\t\t * Internal reference to the bitmap data object that stores the original tile graphics.\n\t\t */\n\t\tprotected var _tiles:BitmapData;\n\t\t/**\n\t\t * Internal list of buffers, one for each camera, used for drawing the tilemaps.\n\t\t */\n\t\tprotected var _buffers:Array;\n\t\t/**\n\t\t * Internal representation of the actual tile data, as a large 1D array of integers.\n\t\t */\n\t\tprotected var _data:Array;\n\t\t/**\n\t\t * Internal representation of rectangles, one for each tile in the entire tilemap, used to speed up drawing.\n\t\t */\n\t\tprotected var _rects:Array;\n\t\t/**\n\t\t * Internal, the width of a single tile.\n\t\t */\n\t\tprotected var _tileWidth:uint;\n\t\t/**\n\t\t * Internal, the height of a single tile.\n\t\t */\n\t\tprotected var _tileHeight:uint;\n\t\t/**\n\t\t * Internal collection of tile objects, one for each type of tile in the map (NOTE one for every single tile in the whole map).\n\t\t */\n\t\tprotected var _tileObjects:Array;\n\t\t\n\t\t/**\n\t\t * Internal, used for rendering the debug bounding box display.\n\t\t */\n\t\tprotected var _debugTileNotSolid:BitmapData;\n\t\t/**\n\t\t * Internal, used for rendering the debug bounding box display.\n\t\t */\n\t\tprotected var _debugTilePartial:BitmapData;\n\t\t/**\n\t\t * Internal, used for rendering the debug bounding box display.\n\t\t */\n\t\tprotected var _debugTileSolid:BitmapData;\n\t\t/**\n\t\t * Internal, used for rendering the debug bounding box display.\n\t\t */\n\t\tprotected var _debugRect:Rectangle;\n\t\t/**\n\t\t * Internal flag for checking to see if we need to refresh\n\t\t * the tilemap display to show or hide the bounding boxes.\n\t\t */\n\t\tprotected var _lastVisualDebug:Boolean;\n\t\t/**\n\t\t * Internal, used to sort of insert blank tiles in front of the tiles in the provided graphic.\n\t\t */\n\t\tprotected var _startingIndex:uint;\n\t\t\n\t\t/**\n\t\t * The tilemap constructor just initializes some basic variables.\n\t\t */\n\t\tpublic function FlxTilemap()\n\t\t{\n\t\t\tsuper();\n\t\t\tauto = OFF;\n\t\t\twidthInTiles = 0;\n\t\t\theightInTiles = 0;\n\t\t\ttotalTiles = 0;\n\t\t\t_buffers = new Array();\n\t\t\t_flashPoint = new Point();\n\t\t\t_flashRect = null;\n\t\t\t_data = null;\n\t\t\t_tileWidth = 0;\n\t\t\t_tileHeight = 0;\n\t\t\t_rects = null;\n\t\t\t_tiles = null;\n\t\t\t_tileObjects = null;\n\t\t\timmovable = true;\n\t\t\tcameras = null;\n\t\t\t_debugTileNotSolid = null;\n\t\t\t_debugTilePartial = null;\n\t\t\t_debugTileSolid = null;\n\t\t\t_debugRect = null;\n\t\t\t_lastVisualDebug = FlxG.visualDebug;\n\t\t\t_startingIndex = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\t_flashPoint = null;\n\t\t\t_flashRect = null;\n\t\t\t_tiles = null;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = _tileObjects.length;\n\t\t\twhile(i < l)\n\t\t\t\t(_tileObjects[i++] as FlxTile).destroy();\n\t\t\t_tileObjects = null;\n\t\t\ti = 0;\n\t\t\tl = _buffers.length;\n\t\t\twhile(i < l)\n\t\t\t\t(_buffers[i++] as FlxTilemapBuffer).destroy();\n\t\t\t_buffers = null;\n\t\t\t_data = null;\n\t\t\t_rects = null;\n\t\t\t_debugTileNotSolid = null;\n\t\t\t_debugTilePartial = null;\n\t\t\t_debugTileSolid = null;\n\t\t\t_debugRect = null;\n\n\t\t\tsuper.destroy();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Load the tilemap with string data and a tile graphic.\n\t\t * \n\t\t * @param\tMapData\t\t\tA string of comma and line-return delineated indices indicating what order the tiles should go in.\n\t\t * @param\tTileGraphic\t\tAll the tiles you want to use, arranged in a strip corresponding to the numbers in MapData.\n\t\t * @param\tTileWidth\t\tThe width of your tiles (e.g. 8) - defaults to height of the tile graphic if unspecified.\n\t\t * @param\tTileHeight\t\tThe height of your tiles (e.g. 8) - defaults to width if unspecified.\n\t\t * @param\tAutoTile\t\tWhether to load the map using an automatic tile placement algorithm.  Setting this to either AUTO or ALT will override any values you put for StartingIndex, DrawIndex, or CollideIndex.\n\t\t * @param\tStartingIndex\tUsed to sort of insert empty tiles in front of the provided graphic.  Default is 0, usually safest ot leave it at that.  Ignored if AutoTile is set.\n\t\t * @param\tDrawIndex\t\tInitializes all tile objects equal to and after this index as visible. Default value is 1.  Ignored if AutoTile is set.\n\t\t * @param\tCollideIndex\tInitializes all tile objects equal to and after this index as allowCollisions = ANY.  Default value is 1.  Ignored if AutoTile is set.  Can override and customize per-tile-type collision behavior using <code>setTileProperties()</code>.\t\n\t\t * \n\t\t * @return\tA pointer this instance of FlxTilemap, for chaining as usual :)\n\t\t */\n\t\tpublic function loadMap(MapData:String, TileGraphic:Class, TileWidth:uint=0, TileHeight:uint=0, AutoTile:uint=OFF, StartingIndex:uint=0, DrawIndex:uint=1, CollideIndex:uint=1):FlxTilemap\n\t\t{\n\t\t\tauto = AutoTile;\n\t\t\t_startingIndex = StartingIndex;\n\n\t\t\t//Figure out the map dimensions based on the data string\n\t\t\tvar columns:Array;\n\t\t\tvar rows:Array = MapData.split(\"\\n\");\n\t\t\theightInTiles = rows.length;\n\t\t\t_data = new Array();\n\t\t\tvar row:uint = 0;\n\t\t\tvar column:uint;\n\t\t\twhile(row < heightInTiles)\n\t\t\t{\n\t\t\t\tcolumns = rows[row++].split(\",\");\n\t\t\t\tif(columns.length <= 1)\n\t\t\t\t{\n\t\t\t\t\theightInTiles = heightInTiles - 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif(widthInTiles == 0)\n\t\t\t\t\twidthInTiles = columns.length;\n\t\t\t\tcolumn = 0;\n\t\t\t\twhile(column < widthInTiles)\n\t\t\t\t\t_data.push(uint(columns[column++]));\n\t\t\t}\n\t\t\t\n\t\t\t//Pre-process the map data if it's auto-tiled\n\t\t\tvar i:uint;\n\t\t\ttotalTiles = widthInTiles*heightInTiles;\n\t\t\tif(auto > OFF)\n\t\t\t{\n\t\t\t\t_startingIndex = 1;\n\t\t\t\tDrawIndex = 1;\n\t\t\t\tCollideIndex = 1;\n\t\t\t\ti = 0;\n\t\t\t\twhile(i < totalTiles)\n\t\t\t\t\tautoTile(i++);\n\t\t\t}\n\t\t\t\n\t\t\t//Figure out the size of the tiles\n\t\t\t_tiles = FlxG.addBitmap(TileGraphic);\n\t\t\t_tileWidth = TileWidth;\n\t\t\tif(_tileWidth == 0)\n\t\t\t\t_tileWidth = _tiles.height;\n\t\t\t_tileHeight = TileHeight;\n\t\t\tif(_tileHeight == 0)\n\t\t\t\t_tileHeight = _tileWidth;\n\t\t\t\n\t\t\t//create some tile objects that we'll use for overlap checks (one for each tile)\n\t\t\ti = 0;\n\t\t\tvar l:uint = (_tiles.width/_tileWidth) * (_tiles.height/_tileHeight);\n\t\t\tif(auto > OFF)\n\t\t\t\tl++;\n\t\t\t_tileObjects = new Array(l);\n\t\t\tvar ac:uint;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\t_tileObjects[i] = new FlxTile(this,i,_tileWidth,_tileHeight,(i >= DrawIndex),(i >= CollideIndex)?allowCollisions:NONE);\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//create debug tiles for rendering bounding boxes on demand\n\t\t\t_debugTileNotSolid = makeDebugTile(FlxG.BLUE);\n\t\t\t_debugTilePartial = makeDebugTile(FlxG.PINK);\n\t\t\t_debugTileSolid = makeDebugTile(FlxG.GREEN);\n\t\t\t_debugRect = new Rectangle(0,0,_tileWidth,_tileHeight);\n\t\t\t\n\t\t\t//Then go through and create the actual map\n\t\t\twidth = widthInTiles*_tileWidth;\n\t\t\theight = heightInTiles*_tileHeight;\n\t\t\t_rects = new Array(totalTiles);\n\t\t\ti = 0;\n\t\t\twhile(i < totalTiles)\n\t\t\t\tupdateTile(i++);\n\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function to clean up the map loading code.\n\t\t * Just generates a wireframe box the size of a tile with the specified color.\n\t\t */\n\t\tprotected function makeDebugTile(Color:uint):BitmapData\n\t\t{\n\t\t\tvar debugTile:BitmapData\n\t\t\tdebugTile = new BitmapData(_tileWidth,_tileHeight,true,0);\n\n\t\t\tvar gfx:Graphics = FlxG.flashGfx;\n\t\t\tgfx.clear();\n\t\t\tgfx.moveTo(0,0);\n\t\t\tgfx.lineStyle(1,Color,0.5);\n\t\t\tgfx.lineTo(_tileWidth-1,0);\n\t\t\tgfx.lineTo(_tileWidth-1,_tileHeight-1);\n\t\t\tgfx.lineTo(0,_tileHeight-1);\n\t\t\tgfx.lineTo(0,0);\n\t\t\t\n\t\t\tdebugTile.draw(FlxG.flashGfxSprite);\n\t\t\treturn debugTile;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Main logic loop for tilemap is pretty simple,\n\t\t * just checks to see if visual debug got turned on.\n\t\t * If it did, the tilemap is flagged as dirty so it\n\t\t * will be redrawn with debug info on the next draw call.\n\t\t */\n\t\toverride public function update():void\n\t\t{\n\t\t\tif(_lastVisualDebug != FlxG.visualDebug)\n\t\t\t{\n\t\t\t\t_lastVisualDebug = FlxG.visualDebug;\n\t\t\t\tsetDirty();\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Internal function that actually renders the tilemap to the tilemap buffer.  Called by draw().\n\t\t * \n\t\t * @param\tBuffer\t\tThe <code>FlxTilemapBuffer</code> you are rendering to.\n\t\t * @param\tCamera\t\tThe related <code>FlxCamera</code>, mainly for scroll values.\n\t\t */\n\t\tprotected function drawTilemap(Buffer:FlxTilemapBuffer,Camera:FlxCamera):void\n\t\t{\n\t\t\tBuffer.fill();\n\t\t\t\n\t\t\t//Copy tile images into the tile buffer\n\t\t\t_point.x = int(Camera.scroll.x*scrollFactor.x) - x; //modified from getScreenXY()\n\t\t\t_point.y = int(Camera.scroll.y*scrollFactor.y) - y;\n\t\t\tvar screenXInTiles:int = (_point.x + ((_point.x > 0)?0.0000001:-0.0000001))/_tileWidth;\n\t\t\tvar screenYInTiles:int = (_point.y + ((_point.y > 0)?0.0000001:-0.0000001))/_tileHeight;\n\t\t\tvar screenRows:uint = Buffer.rows;\n\t\t\tvar screenColumns:uint = Buffer.columns;\n\t\t\t\n\t\t\t//Bound the upper left corner\n\t\t\tif(screenXInTiles < 0)\n\t\t\t\tscreenXInTiles = 0;\n\t\t\tif(screenXInTiles > widthInTiles-screenColumns)\n\t\t\t\tscreenXInTiles = widthInTiles-screenColumns;\n\t\t\tif(screenYInTiles < 0)\n\t\t\t\tscreenYInTiles = 0;\n\t\t\tif(screenYInTiles > heightInTiles-screenRows)\n\t\t\t\tscreenYInTiles = heightInTiles-screenRows;\n\t\t\t\n\t\t\tvar rowIndex:int = screenYInTiles*widthInTiles+screenXInTiles;\n\t\t\t_flashPoint.y = 0;\n\t\t\tvar row:uint = 0;\n\t\t\tvar column:uint;\n\t\t\tvar columnIndex:uint;\n\t\t\tvar tile:FlxTile;\n\t\t\tvar debugTile:BitmapData;\n\t\t\twhile(row < screenRows)\n\t\t\t{\n\t\t\t\tcolumnIndex = rowIndex;\n\t\t\t\tcolumn = 0;\n\t\t\t\t_flashPoint.x = 0;\n\t\t\t\twhile(column < screenColumns)\n\t\t\t\t{\n\t\t\t\t\t_flashRect = _rects[columnIndex] as Rectangle;\n\t\t\t\t\tif(_flashRect != null)\n\t\t\t\t\t{\n\t\t\t\t\t\tBuffer.pixels.copyPixels(_tiles,_flashRect,_flashPoint,null,null,true);\n\t\t\t\t\t\tif(FlxG.visualDebug && !ignoreDrawDebug)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttile = _tileObjects[_data[columnIndex]];\n\t\t\t\t\t\t\tif(tile != null)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif(tile.allowCollisions <= NONE)\n\t\t\t\t\t\t\t\t\tdebugTile = _debugTileNotSolid; //blue\n\t\t\t\t\t\t\t\telse if(tile.allowCollisions != ANY)\n\t\t\t\t\t\t\t\t\tdebugTile = _debugTilePartial; //pink\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tdebugTile = _debugTileSolid; //green\n\t\t\t\t\t\t\t\tBuffer.pixels.copyPixels(debugTile,_debugRect,_flashPoint,null,null,true);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t_flashPoint.x += _tileWidth;\n\t\t\t\t\tcolumn++;\n\t\t\t\t\tcolumnIndex++;\n\t\t\t\t}\n\t\t\t\trowIndex += widthInTiles;\n\t\t\t\t_flashPoint.y += _tileHeight;\n\t\t\t\trow++;\n\t\t\t}\n\t\t\tBuffer.x = screenXInTiles*_tileWidth;\n\t\t\tBuffer.y = screenYInTiles*_tileHeight;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Draws the tilemap buffers to the cameras and handles flickering.\n\t\t */\n\t\toverride public function draw():void\n\t\t{\n\t\t\tif(_flickerTimer != 0)\n\t\t\t{\n\t\t\t\t_flicker = !_flicker;\n\t\t\t\tif(_flicker)\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif(cameras == null)\n\t\t\t\tcameras = FlxG.cameras;\n\t\t\tvar camera:FlxCamera;\n\t\t\tvar buffer:FlxTilemapBuffer;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = cameras.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tcamera = cameras[i];\n\t\t\t\tif(_buffers[i] == null)\n\t\t\t\t\t_buffers[i] = new FlxTilemapBuffer(_tileWidth,_tileHeight,widthInTiles,heightInTiles,camera);\n\t\t\t\tbuffer = _buffers[i++] as FlxTilemapBuffer;\n\t\t\t\tif(!buffer.dirty)\n\t\t\t\t{\n\t\t\t\t\t_point.x = x - int(camera.scroll.x*scrollFactor.x) + buffer.x; //copied from getScreenXY()\n\t\t\t\t\t_point.y = y - int(camera.scroll.y*scrollFactor.y) + buffer.y;\n\t\t\t\t\tbuffer.dirty = (_point.x > 0) || (_point.y > 0) || (_point.x + buffer.width < camera.width) || (_point.y + buffer.height < camera.height);\n\t\t\t\t}\n\t\t\t\tif(buffer.dirty)\n\t\t\t\t{\n\t\t\t\t\tdrawTilemap(buffer,camera);\n\t\t\t\t\tbuffer.dirty = false;\n\t\t\t\t}\n\t\t\t\t_flashPoint.x = x - int(camera.scroll.x*scrollFactor.x) + buffer.x; //copied from getScreenXY()\n\t\t\t\t_flashPoint.y = y - int(camera.scroll.y*scrollFactor.y) + buffer.y;\n\t\t\t\t_flashPoint.x += (_flashPoint.x > 0)?0.0000001:-0.0000001;\n\t\t\t\t_flashPoint.y += (_flashPoint.y > 0)?0.0000001:-0.0000001;\n\t\t\t\tbuffer.draw(camera,_flashPoint);\n\t\t\t\t_VISIBLECOUNT++;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fetches the tilemap data array.\n\t\t * \n\t\t * @param\tSimple\t\tIf true, returns the data as copy, as a series of 1s and 0s (useful for auto-tiling stuff). Default value is false, meaning it will return the actual data array (NOT a copy).\n\t\t * \n\t\t * @return\tAn array the size of the tilemap full of integers indicating tile placement.\n\t\t */\n\t\tpublic function getData(Simple:Boolean=false):Array\n\t\t{\n\t\t\tif(!Simple)\n\t\t\t\treturn _data;\n\t\t\t\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = _data.length;\n\t\t\tvar data:Array = new Array(l);\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tdata[i] = ((_tileObjects[_data[i]] as FlxTile).allowCollisions > 0)?1:0;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\treturn data;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the dirty flag on all the tilemap buffers.\n\t\t * Basically forces a reset of the drawn tilemaps, even if it wasn'tile necessary.\n\t\t * \n\t\t * @param\tDirty\t\tWhether to flag the tilemap buffers as dirty or not.\n\t\t */\n\t\tpublic function setDirty(Dirty:Boolean=true):void\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = _buffers.length;\n\t\t\twhile(i < l)\n\t\t\t\t(_buffers[i++] as FlxTilemapBuffer).dirty = Dirty;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Find a path through the tilemap.  Any tile with any collision flags set is treated as impassable.\n\t\t * If no path is discovered then a null reference is returned.\n\t\t * \n\t\t * @param\tStart\t\tThe start point in world coordinates.\n\t\t * @param\tEnd\t\t\tThe end point in world coordinates.\n\t\t * @param\tSimplify\tWhether to run a basic simplification algorithm over the path data, removing extra points that are on the same line.  Default value is true.\n\t\t * @param\tRaySimplify\tWhether to run an extra raycasting simplification algorithm over the remaining path data.  This can result in some close corners being cut, and should be used with care if at all (yet).  Default value is false.\n\t\t * \n\t\t * @return\tA <code>FlxPath</code> from the start to the end.  If no path could be found, then a null reference is returned.\n\t\t */\n\t\tpublic function findPath(Start:FlxPoint,End:FlxPoint,Simplify:Boolean=true,RaySimplify:Boolean=false):FlxPath\n\t\t{\n\t\t\t//figure out what tile we are starting and ending on.\n\t\t\tvar startIndex:uint = int((Start.y-y)/_tileHeight) * widthInTiles + int((Start.x-x)/_tileWidth);\n\t\t\tvar endIndex:uint = int((End.y-y)/_tileHeight) * widthInTiles + int((End.x-x)/_tileWidth);\n\n\t\t\t//check that the start and end are clear.\n\t\t\tif( ((_tileObjects[_data[startIndex]] as FlxTile).allowCollisions > 0) ||\n\t\t\t\t((_tileObjects[_data[endIndex]] as FlxTile).allowCollisions > 0) )\n\t\t\t\treturn null;\n\t\t\t\n\t\t\t//figure out how far each of the tiles is from the starting tile\n\t\t\tvar distances:Array = computePathDistance(startIndex,endIndex);\n\t\t\tif(distances == null)\n\t\t\t\treturn null;\n\n\t\t\t//then count backward to find the shortest path.\n\t\t\tvar points:Array = new Array();\n\t\t\twalkPath(distances,endIndex,points);\n\t\t\t\n\t\t\t//reset the start and end points to be exact\n\t\t\tvar node:FlxPoint;\n\t\t\tnode = points[points.length-1] as FlxPoint;\n\t\t\tnode.x = Start.x;\n\t\t\tnode.y = Start.y;\n\t\t\tnode = points[0] as FlxPoint;\n\t\t\tnode.x = End.x;\n\t\t\tnode.y = End.y;\n\n\t\t\t//some simple path cleanup options\n\t\t\tif(Simplify)\n\t\t\t\tsimplifyPath(points);\n\t\t\tif(RaySimplify)\n\t\t\t\traySimplifyPath(points);\n\t\t\t\n\t\t\t//finally load the remaining points into a new path object and return it\n\t\t\tvar path:FlxPath = new FlxPath();\n\t\t\tvar i:int = points.length - 1;\n\t\t\twhile(i >= 0)\n\t\t\t{\n\t\t\t\tnode = points[i--] as FlxPoint;\n\t\t\t\tif(node != null)\n\t\t\t\t\tpath.addPoint(node,true);\n\t\t\t}\n\t\t\treturn path;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Pathfinding helper function, strips out extra points on the same line.\n\t\t *\n\t\t * @param\tPoints\t\tAn array of <code>FlxPoint</code> nodes.\n\t\t */\n\t\tprotected function simplifyPath(Points:Array):void\n\t\t{\n\t\t\tvar deltaPrevious:Number;\n\t\t\tvar deltaNext:Number;\n\t\t\tvar last:FlxPoint = Points[0];\n\t\t\tvar node:FlxPoint;\n\t\t\tvar i:uint = 1;\n\t\t\tvar l:uint = Points.length-1;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tnode = Points[i];\n\t\t\t\tdeltaPrevious = (node.x - last.x)/(node.y - last.y);\n\t\t\t\tdeltaNext = (node.x - Points[i+1].x)/(node.y - Points[i+1].y);\n\t\t\t\tif((last.x == Points[i+1].x) || (last.y == Points[i+1].y) || (deltaPrevious == deltaNext))\n\t\t\t\t\tPoints[i] = null;\n\t\t\t\telse\n\t\t\t\t\tlast = node;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Pathfinding helper function, strips out even more points by raycasting from one point to the next and dropping unnecessary points.\n\t\t * \n\t\t * @param\tPoints\t\tAn array of <code>FlxPoint</code> nodes.\n\t\t */\n\t\tprotected function raySimplifyPath(Points:Array):void\n\t\t{\n\t\t\tvar source:FlxPoint = Points[0];\n\t\t\tvar lastIndex:int = -1;\n\t\t\tvar node:FlxPoint;\n\t\t\tvar i:uint = 1;\n\t\t\tvar l:uint = Points.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tnode = Points[i++];\n\t\t\t\tif(node == null)\n\t\t\t\t\tcontinue;\n\t\t\t\tif(ray(source,node,_point))\t\n\t\t\t\t{\n\t\t\t\t\tif(lastIndex >= 0)\n\t\t\t\t\t\tPoints[lastIndex] = null;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tsource = Points[lastIndex];\n\t\t\t\tlastIndex = i-1;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Pathfinding helper function, floods a grid with distance information until it finds the end point.\n\t\t * NOTE: Currently this process does NOT use any kind of fancy heuristic!  It's pretty brute.\n\t\t * \n\t\t * @param\tStartIndex\tThe starting tile's map index.\n\t\t * @param\tEndIndex\tThe ending tile's map index.\n\t\t * \n\t\t * @return\tA Flash <code>Array</code> of <code>FlxPoint</code> nodes.  If the end tile could not be found, then a null <code>Array</code> is returned instead.\n\t\t */\n\t\tprotected function computePathDistance(StartIndex:uint, EndIndex:uint):Array\n\t\t{\n\t\t\t//Create a distance-based representation of the tilemap.\n\t\t\t//All walls are flagged as -2, all open areas as -1.\n\t\t\tvar mapSize:uint = widthInTiles*heightInTiles;\n\t\t\tvar distances:Array = new Array(mapSize);\n\t\t\tvar i:int = 0;\n\t\t\twhile(i < mapSize)\n\t\t\t{\n\t\t\t\tif((_tileObjects[_data[i]] as FlxTile).allowCollisions)\n\t\t\t\t\tdistances[i] = -2;\n\t\t\t\telse\n\t\t\t\t\tdistances[i] = -1;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tdistances[StartIndex] = 0;\n\t\t\tvar distance:uint = 1;\n\t\t\tvar neighbors:Array = [StartIndex];\n\t\t\tvar current:Array;\n\t\t\tvar currentIndex:uint;\n\t\t\tvar left:Boolean;\n\t\t\tvar right:Boolean;\n\t\t\tvar up:Boolean;\n\t\t\tvar down:Boolean;\n\t\t\tvar currentLength:uint;\n\t\t\tvar foundEnd:Boolean = false;\n\t\t\twhile(neighbors.length > 0)\n\t\t\t{\n\t\t\t\tcurrent = neighbors;\n\t\t\t\tneighbors = new Array();\n\t\t\t\t\n\t\t\t\ti = 0;\n\t\t\t\tcurrentLength = current.length;\n\t\t\t\twhile(i < currentLength)\n\t\t\t\t{\n\t\t\t\t\tcurrentIndex = current[i++];\n\t\t\t\t\tif(currentIndex == EndIndex)\n\t\t\t\t\t{\n\t\t\t\t\t\tfoundEnd = true;\n\t\t\t\t\t\tneighbors.length = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t//basic map bounds\n\t\t\t\t\tleft = currentIndex%widthInTiles > 0;\n\t\t\t\t\tright = currentIndex%widthInTiles < widthInTiles-1;\n\t\t\t\t\tup = currentIndex/widthInTiles > 0;\n\t\t\t\t\tdown = currentIndex/widthInTiles < heightInTiles-1;\n\t\t\t\t\t\n\t\t\t\t\tvar index:uint;\n\t\t\t\t\tif(up)\n\t\t\t\t\t{\n\t\t\t\t\t\tindex = currentIndex - widthInTiles;\n\t\t\t\t\t\tif(distances[index] == -1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdistances[index] = distance;\n\t\t\t\t\t\t\tneighbors.push(index);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(right)\n\t\t\t\t\t{\n\t\t\t\t\t\tindex = currentIndex + 1;\n\t\t\t\t\t\tif(distances[index] == -1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdistances[index] = distance;\n\t\t\t\t\t\t\tneighbors.push(index);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(down)\n\t\t\t\t\t{\n\t\t\t\t\t\tindex = currentIndex + widthInTiles;\n\t\t\t\t\t\tif(distances[index] == -1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdistances[index] = distance;\n\t\t\t\t\t\t\tneighbors.push(index);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(left)\n\t\t\t\t\t{\n\t\t\t\t\t\tindex = currentIndex - 1;\n\t\t\t\t\t\tif(distances[index] == -1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdistances[index] = distance;\n\t\t\t\t\t\t\tneighbors.push(index);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(up && right)\n\t\t\t\t\t{\n\t\t\t\t\t\tindex = currentIndex - widthInTiles + 1;\n\t\t\t\t\t\tif((distances[index] == -1) && (distances[currentIndex-widthInTiles] >= -1) && (distances[currentIndex+1] >= -1))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdistances[index] = distance;\n\t\t\t\t\t\t\tneighbors.push(index);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(right && down)\n\t\t\t\t\t{\n\t\t\t\t\t\tindex = currentIndex + widthInTiles + 1;\n\t\t\t\t\t\tif((distances[index] == -1) && (distances[currentIndex+widthInTiles] >= -1) && (distances[currentIndex+1] >= -1))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdistances[index] = distance;\n\t\t\t\t\t\t\tneighbors.push(index);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(left && down)\n\t\t\t\t\t{\n\t\t\t\t\t\tindex = currentIndex + widthInTiles - 1;\n\t\t\t\t\t\tif((distances[index] == -1) && (distances[currentIndex+widthInTiles] >= -1) && (distances[currentIndex-1] >= -1))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdistances[index] = distance;\n\t\t\t\t\t\t\tneighbors.push(index);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(up && left)\n\t\t\t\t\t{\n\t\t\t\t\t\tindex = currentIndex - widthInTiles - 1;\n\t\t\t\t\t\tif((distances[index] == -1) && (distances[currentIndex-widthInTiles] >= -1) && (distances[currentIndex-1] >= -1))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdistances[index] = distance;\n\t\t\t\t\t\t\tneighbors.push(index);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdistance++;\n\t\t\t}\n\t\t\tif(!foundEnd)\n\t\t\t\tdistances = null;\n\t\t\treturn distances;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Pathfinding helper function, recursively walks the grid and finds a shortest path back to the start.\n\t\t * \n\t\t * @param\tData\tA Flash <code>Array</code> of distance information.\n\t\t * @param\tStart\tThe tile we're on in our walk backward.\n\t\t * @param\tPoints\tA Flash <code>Array</code> of <code>FlxPoint</code> nodes composing the path from the start to the end, compiled in reverse order.\n\t\t */\n\t\tprotected function walkPath(Data:Array,Start:uint,Points:Array):void\n\t\t{\n\t\t\tPoints.push(new FlxPoint(x + uint(Start%widthInTiles)*_tileWidth + _tileWidth*0.5, y + uint(Start/widthInTiles)*_tileHeight + _tileHeight*0.5));\n\t\t\tif(Data[Start] == 0)\n\t\t\t\treturn;\n\t\t\t\n\t\t\t//basic map bounds\n\t\t\tvar left:Boolean = Start%widthInTiles > 0;\n\t\t\tvar right:Boolean = Start%widthInTiles < widthInTiles-1;\n\t\t\tvar up:Boolean = Start/widthInTiles > 0;\n\t\t\tvar down:Boolean = Start/widthInTiles < heightInTiles-1;\n\t\t\t\n\t\t\tvar current:uint = Data[Start];\n\t\t\tvar i:uint;\n\t\t\tif(up)\n\t\t\t{\n\t\t\t\ti = Start - widthInTiles;\n\t\t\t\tif((Data[i] >= 0) && (Data[i] < current))\n\t\t\t\t{\n\t\t\t\t\twalkPath(Data,i,Points);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(right)\n\t\t\t{\n\t\t\t\ti = Start + 1;\n\t\t\t\tif((Data[i] >= 0) && (Data[i] < current))\n\t\t\t\t{\n\t\t\t\t\twalkPath(Data,i,Points);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(down)\n\t\t\t{\n\t\t\t\ti = Start + widthInTiles;\n\t\t\t\tif((Data[i] >= 0) && (Data[i] < current))\n\t\t\t\t{\n\t\t\t\t\twalkPath(Data,i,Points);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(left)\n\t\t\t{\n\t\t\t\ti = Start - 1;\n\t\t\t\tif((Data[i] >= 0) && (Data[i] < current))\n\t\t\t\t{\n\t\t\t\t\twalkPath(Data,i,Points);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(up && right)\n\t\t\t{\n\t\t\t\ti = Start - widthInTiles + 1;\n\t\t\t\tif((Data[i] >= 0) && (Data[i] < current))\n\t\t\t\t{\n\t\t\t\t\twalkPath(Data,i,Points);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(right && down)\n\t\t\t{\n\t\t\t\ti = Start + widthInTiles + 1;\n\t\t\t\tif((Data[i] >= 0) && (Data[i] < current))\n\t\t\t\t{\n\t\t\t\t\twalkPath(Data,i,Points);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(left && down)\n\t\t\t{\n\t\t\t\ti = Start + widthInTiles - 1;\n\t\t\t\tif((Data[i] >= 0) && (Data[i] < current))\n\t\t\t\t{\n\t\t\t\t\twalkPath(Data,i,Points);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(up && left)\n\t\t\t{\n\t\t\t\ti = Start - widthInTiles - 1;\n\t\t\t\tif((Data[i] >= 0) && (Data[i] < current))\n\t\t\t\t{\n\t\t\t\t\twalkPath(Data,i,Points);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Checks to see if some <code>FlxObject</code> overlaps this <code>FlxObject</code> object in world space.\n\t\t * If the group has a LOT of things in it, it might be faster to use <code>FlxG.overlaps()</code>.\n\t\t * WARNING: Currently tilemaps do NOT support screen space overlap checks!\n\t\t * \n\t\t * @param\tObject\t\t\tThe object being tested.\n\t\t * @param\tInScreenSpace\tWhether to take scroll factors into account when checking for overlap.\n\t\t * @param\tCamera\t\t\tSpecify which game camera you want.  If null getScreenXY() will just grab the first global camera.\n\t\t * \n\t\t * @return\tWhether or not the two objects overlap.\n\t\t */\n\t\toverride public function overlaps(ObjectOrGroup:FlxBasic,InScreenSpace:Boolean=false,Camera:FlxCamera=null):Boolean\n\t\t{\n\t\t\tif(ObjectOrGroup is FlxGroup)\n\t\t\t{\n\t\t\t\tvar results:Boolean = false;\n\t\t\t\tvar basic:FlxBasic;\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar members:Array = (ObjectOrGroup as FlxGroup).members;\n\t\t\t\twhile(i < length)\n\t\t\t\t{\n\t\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\t\tif(basic is FlxObject)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(overlapsWithCallback(basic as FlxObject))\n\t\t\t\t\t\t\tresults = true;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif(overlaps(basic,InScreenSpace,Camera))\n\t\t\t\t\t\t\tresults = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn results;\n\t\t\t}\n\t\t\telse if(ObjectOrGroup is FlxObject)\n\t\t\t\treturn overlapsWithCallback(ObjectOrGroup as FlxObject);\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Checks to see if this <code>FlxObject</code> were located at the given position, would it overlap the <code>FlxObject</code> or <code>FlxGroup</code>?\n\t\t * This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size into account.\n\t\t * WARNING: Currently tilemaps do NOT support screen space overlap checks!\n\t\t * \n\t\t * @param\tX\t\t\t\tThe X position you want to check.  Pretends this object (the caller, not the parameter) is located here.\n\t\t * @param\tY\t\t\t\tThe Y position you want to check.  Pretends this object (the caller, not the parameter) is located here.\n\t\t * @param\tObjectOrGroup\tThe object or group being tested.\n\t\t * @param\tInScreenSpace\tWhether to take scroll factors into account when checking for overlap.  Default is false, or \"only compare in world space.\"\n\t\t * @param\tCamera\t\t\tSpecify which game camera you want.  If null getScreenXY() will just grab the first global camera.\n\t\t * \n\t\t * @return\tWhether or not the two objects overlap.\n\t\t */\n\t\toverride public function overlapsAt(X:Number,Y:Number,ObjectOrGroup:FlxBasic,InScreenSpace:Boolean=false,Camera:FlxCamera=null):Boolean\n\t\t{\n\t\t\tif(ObjectOrGroup is FlxGroup)\n\t\t\t{\n\t\t\t\tvar results:Boolean = false;\n\t\t\t\tvar basic:FlxBasic;\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar members:Array = (ObjectOrGroup as FlxGroup).members;\n\t\t\t\twhile(i < length)\n\t\t\t\t{\n\t\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\t\tif(basic is FlxObject)\n\t\t\t\t\t{\n\t\t\t\t\t\t_point.x = X;\n\t\t\t\t\t\t_point.y = Y;\n\t\t\t\t\t\tif(overlapsWithCallback(basic as FlxObject,null,false,_point))\n\t\t\t\t\t\t\tresults = true;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif(overlapsAt(X,Y,basic,InScreenSpace,Camera))\n\t\t\t\t\t\t\tresults = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn results;\n\t\t\t}\n\t\t\telse if(ObjectOrGroup is FlxObject)\n\t\t\t{\n\t\t\t\t_point.x = X;\n\t\t\t\t_point.y = Y;\n\t\t\t\treturn overlapsWithCallback(ObjectOrGroup as FlxObject,null,false,_point);\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Checks if the Object overlaps any tiles with any collision flags set,\n\t\t * and calls the specified callback function (if there is one).\n\t\t * Also calls the tile's registered callback if the filter matches.\n\t\t * \n\t\t * @param\tObject\t\t\t\tThe <code>FlxObject</code> you are checking for overlaps against.\n\t\t * @param\tCallback\t\t\tAn optional function that takes the form \"myCallback(Object1:FlxObject,Object2:FlxObject)\", where Object1 is a FlxTile object, and Object2 is the object passed in in the first parameter of this method.\n\t\t * @param\tFlipCallbackParams\tUsed to preserve A-B list ordering from FlxObject.separate() - returns the FlxTile object as the second parameter instead.\n\t\t * @param\tPosition\t\t\tOptional, specify a custom position for the tilemap (useful for overlapsAt()-type funcitonality).\n\t\t * \n\t\t * @return\tWhether there were overlaps, or if a callback was specified, whatever the return value of the callback was.\n\t\t */\n\t\tpublic function overlapsWithCallback(Object:FlxObject,Callback:Function=null,FlipCallbackParams:Boolean=false,Position:FlxPoint=null):Boolean\n\t\t{\n\t\t\tvar results:Boolean = false;\n\t\t\t\n\t\t\tvar X:Number = x;\n\t\t\tvar Y:Number = y;\n\t\t\tif(Position != null)\n\t\t\t{\n\t\t\t\tX = Position.x;\n\t\t\t\tY = Position.y;\n\t\t\t}\n\t\t\t\n\t\t\t//Figure out what tiles we need to check against\n\t\t\tvar selectionX:int = FlxU.floor((Object.x - X)/_tileWidth);\n\t\t\tvar selectionY:int = FlxU.floor((Object.y - Y)/_tileHeight);\n\t\t\tvar selectionWidth:uint = selectionX + (FlxU.ceil(Object.width/_tileWidth)) + 1;\n\t\t\tvar selectionHeight:uint = selectionY + FlxU.ceil(Object.height/_tileHeight) + 1;\n\t\t\t\n\t\t\t//Then bound these coordinates by the map edges\n\t\t\tif(selectionX < 0)\n\t\t\t\tselectionX = 0;\n\t\t\tif(selectionY < 0)\n\t\t\t\tselectionY = 0;\n\t\t\tif(selectionWidth > widthInTiles)\n\t\t\t\tselectionWidth = widthInTiles;\n\t\t\tif(selectionHeight > heightInTiles)\n\t\t\t\tselectionHeight = heightInTiles;\n\t\t\t\n\t\t\t//Then loop through this selection of tiles and call FlxObject.separate() accordingly\n\t\t\tvar rowStart:uint = selectionY*widthInTiles;\n\t\t\tvar row:uint = selectionY;\n\t\t\tvar column:uint;\n\t\t\tvar tile:FlxTile;\n\t\t\tvar overlapFound:Boolean;\n\t\t\tvar deltaX:Number = X - last.x;\n\t\t\tvar deltaY:Number = Y - last.y;\n\t\t\twhile(row < selectionHeight)\n\t\t\t{\n\t\t\t\tcolumn = selectionX;\n\t\t\t\twhile(column < selectionWidth)\n\t\t\t\t{\n\t\t\t\t\toverlapFound = false;\n\t\t\t\t\ttile = _tileObjects[_data[rowStart+column]] as FlxTile;\n\t\t\t\t\tif(tile.allowCollisions)\n\t\t\t\t\t{\n\t\t\t\t\t\ttile.x = X+column*_tileWidth;\n\t\t\t\t\t\ttile.y = Y+row*_tileHeight;\n\t\t\t\t\t\ttile.last.x = tile.x - deltaX;\n\t\t\t\t\t\ttile.last.y = tile.y - deltaY;\n\t\t\t\t\t\tif(Callback != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(FlipCallbackParams)\n\t\t\t\t\t\t\t\toverlapFound = Callback(Object,tile);\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\toverlapFound = Callback(tile,Object);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\toverlapFound = (Object.x + Object.width > tile.x) && (Object.x < tile.x + tile.width) && (Object.y + Object.height > tile.y) && (Object.y < tile.y + tile.height);\n\t\t\t\t\t\tif(overlapFound)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif((tile.callback != null) && ((tile.filter == null) || (Object is tile.filter)))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttile.mapIndex = rowStart+column;\n\t\t\t\t\t\t\t\ttile.callback(tile,Object);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tresults = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse if((tile.callback != null) && ((tile.filter == null) || (Object is tile.filter)))\n\t\t\t\t\t{\n\t\t\t\t\t\ttile.mapIndex = rowStart+column;\n\t\t\t\t\t\ttile.callback(tile,Object);\n\t\t\t\t\t}\n\t\t\t\t\tcolumn++;\n\t\t\t\t}\n\t\t\t\trowStart += widthInTiles;\n\t\t\t\trow++;\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Checks to see if a point in 2D world space overlaps this <code>FlxObject</code> object.\n\t\t * \n\t\t * @param\tPoint\t\t\tThe point in world space you want to check.\n\t\t * @param\tInScreenSpace\tWhether to take scroll factors into account when checking for overlap.\n\t\t * @param\tCamera\t\t\tSpecify which game camera you want.  If null getScreenXY() will just grab the first global camera.\n\t\t * \n\t\t * @return\tWhether or not the point overlaps this object.\n\t\t */\n\t\toverride public function overlapsPoint(Point:FlxPoint,InScreenSpace:Boolean=false,Camera:FlxCamera=null):Boolean\n\t\t{\n\t\t\tif(!InScreenSpace)\n\t\t\t\treturn (_tileObjects[_data[uint(uint((Point.y-y)/_tileHeight)*widthInTiles + (Point.x-x)/_tileWidth)]] as FlxTile).allowCollisions > 0;\n\t\t\t\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\tPoint.x = Point.x - Camera.scroll.x;\n\t\t\tPoint.y = Point.y - Camera.scroll.y;\n\t\t\tgetScreenXY(_point,Camera);\n\t\t\treturn (_tileObjects[_data[uint(uint((Point.y-_point.y)/_tileHeight)*widthInTiles + (Point.x-_point.x)/_tileWidth)]] as FlxTile).allowCollisions > 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Check the value of a particular tile.\n\t\t * \n\t\t * @param\tX\t\tThe X coordinate of the tile (in tiles, not pixels).\n\t\t * @param\tY\t\tThe Y coordinate of the tile (in tiles, not pixels).\n\t\t * \n\t\t * @return\tA uint containing the value of the tile at this spot in the array.\n\t\t */\n\t\tpublic function getTile(X:uint,Y:uint):uint\n\t\t{\n\t\t\treturn _data[Y * widthInTiles + X] as uint;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Get the value of a tile in the tilemap by index.\n\t\t * \n\t\t * @param\tIndex\tThe slot in the data array (Y * widthInTiles + X) where this tile is stored.\n\t\t * \n\t\t * @return\tA uint containing the value of the tile at this spot in the array.\n\t\t */\n\t\tpublic function getTileByIndex(Index:uint):uint\n\t\t{\n\t\t\treturn _data[Index] as uint;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns a new Flash <code>Array</code> full of every map index of the requested tile type.\n\t\t *\n\t\t * @param\tIndex\tThe requested tile type.\n\t\t * \n\t\t * @return\tAn <code>Array</code> with a list of all map indices of that tile type.\n\t\t */\n\t\tpublic function getTileInstances(Index:uint):Array\n\t\t{\n\t\t\tvar array:Array = null;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = widthInTiles * heightInTiles;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tif(_data[i] == Index)\n\t\t\t\t{\n\t\t\t\t\tif(array == null)\n\t\t\t\t\t\tarray = new Array();\n\t\t\t\t\tarray.push(i);\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\treturn array;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns a new Flash <code>Array</code> full of every coordinate of the requested tile type.\n\t\t * \n\t\t * @param\tIndex\t\tThe requested tile type.\n\t\t * @param\tMidpoint\tWhether to return the coordinates of the tile midpoint, or upper left corner. Default is true, return midpoint.\n\t\t * \n\t\t * @return\tAn <code>Array</code> with a list of all the coordinates of that tile type.\n\t\t */\n\t\tpublic function getTileCoords(Index:uint,Midpoint:Boolean=true):Array\n\t\t{\n\t\t\tvar array:Array = null;\n\t\t\t\n\t\t\tvar point:FlxPoint;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = widthInTiles * heightInTiles;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tif(_data[i] == Index)\n\t\t\t\t{\n\t\t\t\t\tpoint = new FlxPoint(x + uint(i%widthInTiles)*_tileWidth,y + uint(i/widthInTiles)*_tileHeight);\n\t\t\t\t\tif(Midpoint)\n\t\t\t\t\t{\n\t\t\t\t\t\tpoint.x += _tileWidth*0.5;\n\t\t\t\t\t\tpoint.y += _tileHeight*0.5;\n\t\t\t\t\t}\n\t\t\t\t\tif(array == null)\n\t\t\t\t\t\tarray = new Array();\n\t\t\t\t\tarray.push(point);\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\treturn array;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Change the data and graphic of a tile in the tilemap.\n\t\t * \n\t\t * @param\tX\t\t\t\tThe X coordinate of the tile (in tiles, not pixels).\n\t\t * @param\tY\t\t\t\tThe Y coordinate of the tile (in tiles, not pixels).\n\t\t * @param\tTile\t\t\tThe new integer data you wish to inject.\n\t\t * @param\tUpdateGraphics\tWhether the graphical representation of this tile should change.\n\t\t * \n\t\t * @return\tWhether or not the tile was actually changed.\n\t\t */ \n\t\tpublic function setTile(X:uint,Y:uint,Tile:uint,UpdateGraphics:Boolean=true):Boolean\n\t\t{\n\t\t\tif((X >= widthInTiles) || (Y >= heightInTiles))\n\t\t\t\treturn false;\n\t\t\treturn setTileByIndex(Y * widthInTiles + X,Tile,UpdateGraphics);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Change the data and graphic of a tile in the tilemap.\n\t\t * \n\t\t * @param\tIndex\t\t\tThe slot in the data array (Y * widthInTiles + X) where this tile is stored.\n\t\t * @param\tTile\t\t\tThe new integer data you wish to inject.\n\t\t * @param\tUpdateGraphics\tWhether the graphical representation of this tile should change.\n\t\t * \n\t\t * @return\tWhether or not the tile was actually changed.\n\t\t */\n\t\tpublic function setTileByIndex(Index:uint,Tile:uint,UpdateGraphics:Boolean=true):Boolean\n\t\t{\n\t\t\tif(Index >= _data.length)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\tvar ok:Boolean = true;\n\t\t\t_data[Index] = Tile;\n\t\t\t\n\t\t\tif(!UpdateGraphics)\n\t\t\t\treturn ok;\n\t\t\t\n\t\t\tsetDirty();\n\t\t\t\n\t\t\tif(auto == OFF)\n\t\t\t{\n\t\t\t\tupdateTile(Index);\n\t\t\t\treturn ok;\n\t\t\t}\n\t\t\t\n\t\t\t//If this map is autotiled and it changes, locally update the arrangement\n\t\t\tvar i:uint;\n\t\t\tvar row:int = int(Index/widthInTiles) - 1;\n\t\t\tvar rowLength:int = row + 3;\n\t\t\tvar column:int = Index%widthInTiles - 1;\n\t\t\tvar columnHeight:int = column + 3;\n\t\t\twhile(row < rowLength)\n\t\t\t{\n\t\t\t\tcolumn = columnHeight - 3;\n\t\t\t\twhile(column < columnHeight)\n\t\t\t\t{\n\t\t\t\t\tif((row >= 0) && (row < heightInTiles) && (column >= 0) && (column < widthInTiles))\n\t\t\t\t\t{\n\t\t\t\t\t\ti = row*widthInTiles+column;\n\t\t\t\t\t\tautoTile(i);\n\t\t\t\t\t\tupdateTile(i);\n\t\t\t\t\t}\n\t\t\t\t\tcolumn++;\n\t\t\t\t}\n\t\t\t\trow++;\n\t\t\t}\n\t\t\t\n\t\t\treturn ok;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adjust collision settings and/or bind a callback function to a range of tiles.\n\t\t * This callback function, if present, is triggered by calls to overlap() or overlapsWithCallback().\n\t\t * \n\t\t * @param\tTile\t\t\tThe tile or tiles you want to adjust.\n\t\t * @param\tAllowCollisions\tModify the tile or tiles to only allow collisions from certain directions, use FlxObject constants NONE, ANY, LEFT, RIGHT, etc.  Default is \"ANY\".\n\t\t * @param\tCallback\t\tThe function to trigger, e.g. <code>lavaCallback(Tile:FlxTile, Object:FlxObject)</code>.\n\t\t * @param\tCallbackFilter\tIf you only want the callback to go off for certain classes or objects based on a certain class, set that class here.\n\t\t * @param\tRange\t\t\tIf you want this callback to work for a bunch of different tiles, input the range here.  Default value is 1.\n\t\t */\n\t\tpublic function setTileProperties(Tile:uint,AllowCollisions:uint=0x1111,Callback:Function=null,CallbackFilter:Class=null,Range:uint=1):void\n\t\t{\n\t\t\tif(Range <= 0)\n\t\t\t\tRange = 1;\n\t\t\tvar tile:FlxTile;\n\t\t\tvar i:uint = Tile;\n\t\t\tvar l:uint = Tile+Range;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\ttile = _tileObjects[i++] as FlxTile;\n\t\t\t\ttile.allowCollisions = AllowCollisions;\n\t\t\t\ttile.callback = Callback;\n\t\t\t\ttile.filter = CallbackFilter;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to lock the automatic camera to the map's edges.\n\t\t * \n\t\t * @param\tCamera\t\t\tSpecify which game camera you want.  If null getScreenXY() will just grab the first global camera.\n\t\t * @param\tBorder\t\t\tAdjusts the camera follow boundary by whatever number of tiles you specify here.  Handy for blocking off deadends that are offscreen, etc.  Use a negative number to add padding instead of hiding the edges.\n\t\t * @param\tUpdateWorld\t\tWhether to update the collision system's world size, default value is true.\n\t\t */\n\t\tpublic function follow(Camera:FlxCamera=null,Border:int=0,UpdateWorld:Boolean=true):void\n\t\t{\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\tCamera.setBounds(x+Border*_tileWidth,y+Border*_tileHeight,width-Border*_tileWidth*2,height-Border*_tileHeight*2,UpdateWorld);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Get the world coordinates and size of the entire tilemap as a <code>FlxRect</code>.\n\t\t * \n\t\t * @param\tBounds\t\tOptional, pass in a pre-existing <code>FlxRect</code> to prevent instantiation of a new object.\n\t\t * \n\t\t * @return\tA <code>FlxRect</code> containing the world coordinates and size of the entire tilemap.\n\t\t */\n\t\tpublic function getBounds(Bounds:FlxRect=null):FlxRect\n\t\t{\n\t\t\tif(Bounds == null)\n\t\t\t\tBounds = new FlxRect();\n\t\t\treturn Bounds.make(x,y,width,height);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Shoots a ray from the start point to the end point.\n\t\t * If/when it passes through a tile, it stores that point and returns false.\n\t\t * \n\t\t * @param\tStart\t\tThe world coordinates of the start of the ray.\n\t\t * @param\tEnd\t\t\tThe world coordinates of the end of the ray.\n\t\t * @param\tResult\t\tA <code>Point</code> object containing the first wall impact.\n\t\t * @param\tResolution\tDefaults to 1, meaning check every tile or so.  Higher means more checks!\n\t\t * @return\tReturns true if the ray made it from Start to End without hitting anything.  Returns false and fills Result if a tile was hit.\n\t\t */\n\t\tpublic function ray(Start:FlxPoint, End:FlxPoint, Result:FlxPoint=null, Resolution:Number=1):Boolean\n\t\t{\n\t\t\tvar step:Number = _tileWidth;\n\t\t\tif(_tileHeight < _tileWidth)\n\t\t\t\tstep = _tileHeight;\n\t\t\tstep /= Resolution;\n\t\t\tvar deltaX:Number = End.x - Start.x;\n\t\t\tvar deltaY:Number = End.y - Start.y;\n\t\t\tvar distance:Number = Math.sqrt(deltaX*deltaX + deltaY*deltaY);\n\t\t\tvar steps:uint = Math.ceil(distance/step);\n\t\t\tvar stepX:Number = deltaX/steps;\n\t\t\tvar stepY:Number = deltaY/steps;\n\t\t\tvar curX:Number = Start.x - stepX - x;\n\t\t\tvar curY:Number = Start.y - stepY - y;\n\t\t\tvar tileX:uint;\n\t\t\tvar tileY:uint;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < steps)\n\t\t\t{\n\t\t\t\tcurX += stepX;\n\t\t\t\tcurY += stepY;\n\t\t\t\t\n\t\t\t\tif((curX < 0) || (curX > width) || (curY < 0) || (curY > height))\n\t\t\t\t{\n\t\t\t\t\ti++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ttileX = curX/_tileWidth;\n\t\t\t\ttileY = curY/_tileHeight;\n\t\t\t\tif((_tileObjects[_data[tileY*widthInTiles+tileX]] as FlxTile).allowCollisions)\n\t\t\t\t{\n\t\t\t\t\t//Some basic helper stuff\n\t\t\t\t\ttileX *= _tileWidth;\n\t\t\t\t\ttileY *= _tileHeight;\n\t\t\t\t\tvar rx:Number = 0;\n\t\t\t\t\tvar ry:Number = 0;\n\t\t\t\t\tvar q:Number;\n\t\t\t\t\tvar lx:Number = curX-stepX;\n\t\t\t\t\tvar ly:Number = curY-stepY;\n\t\t\t\t\t\n\t\t\t\t\t//Figure out if it crosses the X boundary\n\t\t\t\t\tq = tileX;\n\t\t\t\t\tif(deltaX < 0)\n\t\t\t\t\t\tq += _tileWidth;\n\t\t\t\t\trx = q;\n\t\t\t\t\try = ly + stepY*((q-lx)/stepX);\n\t\t\t\t\tif((ry > tileY) && (ry < tileY + _tileHeight))\n\t\t\t\t\t{\n\t\t\t\t\t\tif(Result == null)\n\t\t\t\t\t\t\tResult = new FlxPoint();\n\t\t\t\t\t\tResult.x = rx;\n\t\t\t\t\t\tResult.y = ry;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t//Else, figure out if it crosses the Y boundary\n\t\t\t\t\tq = tileY;\n\t\t\t\t\tif(deltaY < 0)\n\t\t\t\t\t\tq += _tileHeight;\n\t\t\t\t\trx = lx + stepX*((q-ly)/stepY);\n\t\t\t\t\try = q;\n\t\t\t\t\tif((rx > tileX) && (rx < tileX + _tileWidth))\n\t\t\t\t\t{\n\t\t\t\t\t\tif(Result == null)\n\t\t\t\t\t\t\tResult = new FlxPoint();\n\t\t\t\t\t\tResult.x = rx;\n\t\t\t\t\t\tResult.y = ry;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Converts a one-dimensional array of tile data to a comma-separated string.\n\t\t * \n\t\t * @param\tData\t\tAn array full of integer tile references.\n\t\t * @param\tWidth\t\tThe number of tiles in each row.\n\t\t * @param\tInvert\t\tRecommended only for 1-bit arrays - changes 0s to 1s and vice versa.\n\t\t * \n\t\t * @return\tA comma-separated string containing the level data in a <code>FlxTilemap</code>-friendly format.\n\t\t */\n\t\tstatic public function arrayToCSV(Data:Array,Width:int,Invert:Boolean=false):String\n\t\t{\n\t\t\tvar row:uint = 0;\n\t\t\tvar column:uint;\n\t\t\tvar csv:String;\n\t\t\tvar Height:int = Data.length / Width;\n\t\t\tvar index:int;\n\t\t\twhile(row < Height)\n\t\t\t{\n\t\t\t\tcolumn = 0;\n\t\t\t\twhile(column < Width)\n\t\t\t\t{\n\t\t\t\t\tindex = Data[row*Width+column];\n\t\t\t\t\tif(Invert)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(index == 0)\n\t\t\t\t\t\t\tindex = 1;\n\t\t\t\t\t\telse if(index == 1)\n\t\t\t\t\t\t\tindex = 0;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif(column == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(row == 0)\n\t\t\t\t\t\t\tcsv += index;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tcsv += \"\\n\"+index;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tcsv += \", \"+index;\n\t\t\t\t\tcolumn++;\n\t\t\t\t}\n\t\t\t\trow++;\n\t\t\t}\n\t\t\treturn csv;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Converts a <code>BitmapData</code> object to a comma-separated string.\n\t\t * Black pixels are flagged as 'solid' by default,\n\t\t * non-black pixels are set as non-colliding.\n\t\t * Black pixels must be PURE BLACK.\n\t\t * \n\t\t * @param\tbitmapData\tA Flash <code>BitmapData</code> object, preferably black and white.\n\t\t * @param\tInvert\t\tLoad white pixels as solid instead.\n\t\t * @param\tScale\t\tDefault is 1.  Scale of 2 means each pixel forms a 2x2 block of tiles, and so on.\n\t\t * @param\tColorMap\tAn array of color values (uint 0xAARRGGBB) in the order they're intended to be assigned as indices\n\t\t * \n\t\t * @return\tA comma-separated string containing the level data in a <code>FlxTilemap</code>-friendly format.\n\t\t */\n\t\tstatic public function bitmapToCSV(bitmapData:BitmapData,Invert:Boolean=false,Scale:uint=1,ColorMap:Array=null):String\n\t\t{\n\t\t\t//Import and scale image if necessary\n\t\t\tif(Scale > 1)\n\t\t\t{\n\t\t\t\tvar bd:BitmapData = bitmapData;\n\t\t\t\tbitmapData = new BitmapData(bitmapData.width*Scale,bitmapData.height*Scale);\n\t\t\t\tvar mtx:Matrix = new Matrix();\n\t\t\t\tmtx.scale(Scale,Scale);\n\t\t\t\tbitmapData.draw(bd,mtx);\n\t\t\t}\n\t\t\t\n\t\t\t//Walk image and export pixel values\n\t\t\tvar row:uint = 0;\n\t\t\tvar column:uint;\n\t\t\tvar pixel:uint;\n\t\t\tvar csv:String = \"\";\n\t\t\tvar bitmapWidth:uint = bitmapData.width;\n\t\t\tvar bitmapHeight:uint = bitmapData.height;\n\t\t\twhile(row < bitmapHeight)\n\t\t\t{\n\t\t\t\tcolumn = 0;\n\t\t\t\twhile(column < bitmapWidth)\n\t\t\t\t{\n\t\t\t\t\t//Decide if this pixel/tile is solid (1) or not (0)\n\t\t\t\t\tpixel = bitmapData.getPixel(column,row);\n\t\t\t\t\tif(ColorMap != null)\n\t\t\t\t\t\tpixel = ColorMap.indexOf(pixel);\n\t\t\t\t\telse if((Invert && (pixel > 0)) || (!Invert && (pixel == 0)))\n\t\t\t\t\t\tpixel = 1;\n\t\t\t\t\telse\n\t\t\t\t\t\tpixel = 0;\n\t\t\t\t\t\n\t\t\t\t\t//Write the result to the string\n\t\t\t\t\tif(column == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(row == 0)\n\t\t\t\t\t\t\tcsv += pixel;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tcsv += \"\\n\"+pixel;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tcsv += \", \"+pixel;\n\t\t\t\t\tcolumn++;\n\t\t\t\t}\n\t\t\t\trow++;\n\t\t\t}\n\t\t\treturn csv;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Converts a resource image file to a comma-separated string.\n\t\t * Black pixels are flagged as 'solid' by default,\n\t\t * non-black pixels are set as non-colliding.\n\t\t * Black pixels must be PURE BLACK.\n\t\t * \n\t\t * @param\tImageFile\tAn embedded graphic, preferably black and white.\n\t\t * @param\tInvert\t\tLoad white pixels as solid instead.\n\t\t * @param\tScale\t\tDefault is 1.  Scale of 2 means each pixel forms a 2x2 block of tiles, and so on.\n\t\t * \n\t\t * @return\tA comma-separated string containing the level data in a <code>FlxTilemap</code>-friendly format.\n\t\t */\n\t\tstatic public function imageToCSV(ImageFile:Class,Invert:Boolean=false,Scale:uint=1):String\n\t\t{\n\t\t\treturn bitmapToCSV((new ImageFile).bitmapData,Invert,Scale);\n\t\t}\n\t\t\n\t\t/**\n\t\t * An internal function used by the binary auto-tilers.\n\t\t * \n\t\t * @param\tIndex\t\tThe index of the tile you want to analyze.\n\t\t */\n\t\tprotected function autoTile(Index:uint):void\n\t\t{\n\t\t\tif(_data[Index] == 0)\n\t\t\t\treturn;\n\t\t\t\n\t\t\t_data[Index] = 0;\n\t\t\tif((Index-widthInTiles < 0) || (_data[Index-widthInTiles] > 0)) \t\t//UP\n\t\t\t\t_data[Index] += 1;\n\t\t\tif((Index%widthInTiles >= widthInTiles-1) || (_data[Index+1] > 0)) \t\t//RIGHT\n\t\t\t\t_data[Index] += 2;\n\t\t\tif((Index+widthInTiles >= totalTiles) || (_data[Index+widthInTiles] > 0)) //DOWN\n\t\t\t\t_data[Index] += 4;\n\t\t\tif((Index%widthInTiles <= 0) || (_data[Index-1] > 0)) \t\t\t\t\t//LEFT\n\t\t\t\t_data[Index] += 8;\n\t\t\tif((auto == ALT) && (_data[Index] == 15))\t//The alternate algo checks for interior corners\n\t\t\t{\n\t\t\t\tif((Index%widthInTiles > 0) && (Index+widthInTiles < totalTiles) && (_data[Index+widthInTiles-1] <= 0))\n\t\t\t\t\t_data[Index] = 1;\t\t//BOTTOM LEFT OPEN\n\t\t\t\tif((Index%widthInTiles > 0) && (Index-widthInTiles >= 0) && (_data[Index-widthInTiles-1] <= 0))\n\t\t\t\t\t_data[Index] = 2;\t\t//TOP LEFT OPEN\n\t\t\t\tif((Index%widthInTiles < widthInTiles-1) && (Index-widthInTiles >= 0) && (_data[Index-widthInTiles+1] <= 0))\n\t\t\t\t\t_data[Index] = 4;\t\t//TOP RIGHT OPEN\n\t\t\t\tif((Index%widthInTiles < widthInTiles-1) && (Index+widthInTiles < totalTiles) && (_data[Index+widthInTiles+1] <= 0))\n\t\t\t\t\t_data[Index] = 8; \t\t//BOTTOM RIGHT OPEN\n\t\t\t}\n\t\t\t_data[Index] += 1;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function used in setTileByIndex() and the constructor to update the map.\n\t\t * \n\t\t * @param\tIndex\t\tThe index of the tile you want to update.\n\t\t */\n\t\tprotected function updateTile(Index:uint):void\n\t\t{\n\t\t\tvar tile:FlxTile = _tileObjects[_data[Index]] as FlxTile;\n\t\t\tif((tile == null) || !tile.visible)\n\t\t\t{\n\t\t\t\t_rects[Index] = null;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar rx:uint = (_data[Index]-_startingIndex)*_tileWidth;\n\t\t\tvar ry:uint = 0;\n\t\t\tif(rx >= _tiles.width)\n\t\t\t{\n\t\t\t\try = uint(rx/_tiles.width)*_tileHeight;\n\t\t\t\trx %= _tiles.width;\n\t\t\t}\n\t\t\t_rects[Index] = (new Rectangle(rx,ry,_tileWidth,_tileHeight));\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/FlxTimer.as",
    "content": "package org.flixel\n{\n\timport org.flixel.plugin.TimerManager;\n\t\n\t/**\n\t * A simple timer class, leveraging the new plugins system.\n\t * Can be used with callbacks or by polling the <code>finished</code> flag.\n\t * Not intended to be added to a game state or group; the timer manager\n\t * is responsible for actually calling update(), not the user.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class FlxTimer\n\t{\n\t\t/**\n\t\t * How much time the timer was set for.\n\t\t */\n\t\tpublic var time:Number;\n\t\t/**\n\t\t * How many loops the timer was set for.\n\t\t */\n\t\tpublic var loops:uint;\n\t\t/**\n\t\t * Pauses or checks the pause state of the timer.\n\t\t */\n\t\tpublic var paused:Boolean;\n\t\t/**\n\t\t * Check to see if the timer is finished.\n\t\t */\n\t\tpublic var finished:Boolean;\n\t\t\n\t\t/**\n\t\t * Internal tracker for the time's-up callback function.\n\t\t * Callback should be formed \"onTimer(Timer:FlxTimer);\"\n\t\t */\n\t\tprotected var _callback:Function;\n\t\t/**\n\t\t * Internal tracker for the actual timer counting up.\n\t\t */\n\t\tprotected var _timeCounter:Number;\n\t\t/**\n\t\t * Internal tracker for the loops counting up.\n\t\t */\n\t\tprotected var _loopsCounter:uint;\n\t\t\n\t\t/**\n\t\t * Instantiate the timer.  Does not set or start the timer.\n\t\t */\n\t\tpublic function FlxTimer()\n\t\t{\n\t\t\ttime = 0;\n\t\t\tloops = 0;\n\t\t\t_callback = null;\n\t\t\t_timeCounter = 0;\n\t\t\t_loopsCounter = 0;\n\n\t\t\tpaused = false;\n\t\t\tfinished = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\tstop();\n\t\t\t_callback = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by the timer manager plugin to update the timer.\n\t\t * If time runs out, the loop counter is advanced, the timer reset, and the callback called if it exists.\n\t\t * If the timer runs out of loops, then the timer calls <code>stop()</code>.\n\t\t * However, callbacks are called AFTER <code>stop()</code> is called.\n\t\t */\n\t\tpublic function update():void\n\t\t{\n\t\t\t_timeCounter += FlxG.elapsed;\n\t\t\twhile((_timeCounter >= time) && !paused && !finished)\n\t\t\t{\n\t\t\t\t_timeCounter -= time;\n\t\t\t\t\n\t\t\t\t_loopsCounter++;\n\t\t\t\tif((loops > 0) && (_loopsCounter >= loops))\n\t\t\t\t\tstop();\n\t\t\t\t\n\t\t\t\tif(_callback != null)\n\t\t\t\t\t_callback(this);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Starts or resumes the timer.  If this timer was paused,\n\t\t * then all the parameters are ignored, and the timer is resumed.\n\t\t * Adds the timer to the timer manager.\n\t\t * \n\t\t * @param\tTime\t\tHow many seconds it takes for the timer to go off.\n\t\t * @param\tLoops\t\tHow many times the timer should go off.  Default is 1, or \"just count down once.\"\n\t\t * @param\tCallback\tOptional, triggered whenever the time runs out, once for each loop.  Callback should be formed \"onTimer(Timer:FlxTimer);\"\n\t\t * \n\t\t * @return\tA reference to itself (handy for chaining or whatever).\n\t\t */\n\t\tpublic function start(Time:Number=1,Loops:uint=1,Callback:Function=null):FlxTimer\n\t\t{\n\t\t\tvar timerManager:TimerManager = manager;\n\t\t\tif(timerManager != null)\n\t\t\t\ttimerManager.add(this);\n\t\t\t\n\t\t\tif(paused)\n\t\t\t{\n\t\t\t\tpaused = false;\n\t\t\t\treturn this;\n\t\t\t}\n\t\t\t\n\t\t\tpaused = false;\n\t\t\tfinished = false;\n\t\t\ttime = Time;\n\t\t\tloops = Loops;\n\t\t\t_callback = Callback;\n\t\t\t_timeCounter = 0;\n\t\t\t_loopsCounter = 0;\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops the timer and removes it from the timer manager.\n\t\t */\n\t\tpublic function stop():void\n\t\t{\n\t\t\tfinished = true;\n\t\t\tvar timerManager:TimerManager = manager;\n\t\t\tif(timerManager != null)\n\t\t\t\ttimerManager.remove(this);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Read-only: check how much time is left on the timer.\n\t\t */\n\t\tpublic function get timeLeft():Number\n\t\t{\n\t\t\treturn time-_timeCounter;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Read-only: check how many loops are left on the timer.\n\t\t */\n\t\tpublic function get loopsLeft():int\n\t\t{\n\t\t\treturn loops-_loopsCounter;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Read-only: how far along the timer is, on a scale of 0.0 to 1.0.\n\t\t */\n\t\tpublic function get progress():Number\n\t\t{\n\t\t\tif(time > 0)\n\t\t\t\treturn _timeCounter/time;\n\t\t\telse\n\t\t\t\treturn 0;\n\t\t}\n\t\t\n\t\tstatic public function get manager():TimerManager\n\t\t{\n\t\t\treturn FlxG.getPlugin(TimerManager) as TimerManager;\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/FlxU.as",
    "content": "package org.flixel\n{\n\timport flash.net.URLRequest;\n\timport flash.net.navigateToURL;\n\timport flash.utils.getDefinitionByName;\n\timport flash.utils.getQualifiedClassName;\n\timport flash.utils.getTimer;\n\t\n\tpublic class FlxU\n\t{\n\t\t/**\n\t\t * Opens a web page in a new tab or window.\n\t\t * MUST be called from the UI thread or else badness.\n\t\t * \n\t\t * @param\tURL\t\tThe address of the web page.\n\t\t */\n\t\tstatic public function openURL(URL:String):void\n\t\t{\n\t\t\tnavigateToURL(new URLRequest(URL), \"_blank\");\n\t\t}\n\t\t\n\t\t/**\n\t\t * Calculate the absolute value of a number.\n\t\t * \n\t\t * @param\tValue\tAny number.\n\t\t * \n\t\t * @return\tThe absolute value of that number.\n\t\t */\n\t\tstatic public function abs(Value:Number):Number\n\t\t{\n\t\t\treturn (Value>0)?Value:-Value;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2.\n\t\t * \n\t\t * @param\tValue\tAny number.\n\t\t * \n\t\t * @return\tThe rounded value of that number.\n\t\t */\n\t\tstatic public function floor(Value:Number):Number\n\t\t{\n\t\t\tvar number:Number = int(Value);\n\t\t\treturn (Value>0)?(number):((number!=Value)?(number-1):(number));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Round up to the next whole number.  E.g. ceil(1.3) == 2, and ceil(-2.3) == -3.\n\t\t * \n\t\t * @param\tValue\tAny number.\n\t\t * \n\t\t * @return\tThe rounded value of that number.\n\t\t */\n\t\tstatic public function ceil(Value:Number):Number\n\t\t{\n\t\t\tvar number:Number = int(Value);\n\t\t\treturn (Value>0)?((number!=Value)?(number+1):(number)):(number);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Round to the closest whole number. E.g. round(1.7) == 2, and round(-2.3) == -2.\n\t\t * \n\t\t * @param\tValue\tAny number.\n\t\t * \n\t\t * @return\tThe rounded value of that number.\n\t\t */\n\t\tstatic public function round(Value:Number):Number\n\t\t{\n\t\t\tvar number:Number = int(Value+0.5);\n\t\t\treturn (Value>0)?(number):((number!=Value)?(number-1):(number));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Figure out which number is smaller.\n\t\t * \n\t\t * @param\tNumber1\t\tAny number.\n\t\t * @param\tNumber2\t\tAny number.\n\t\t * \n\t\t * @return\tThe smaller of the two numbers.\n\t\t */\n\t\tstatic public function min(Number1:Number,Number2:Number):Number\n\t\t{\n\t\t\treturn (Number1 <= Number2)?Number1:Number2;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Figure out which number is larger.\n\t\t * \n\t\t * @param\tNumber1\t\tAny number.\n\t\t * @param\tNumber2\t\tAny number.\n\t\t * \n\t\t * @return\tThe larger of the two numbers.\n\t\t */\n\t\tstatic public function max(Number1:Number,Number2:Number):Number\n\t\t{\n\t\t\treturn (Number1 >= Number2)?Number1:Number2;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Bound a number by a minimum and maximum.\n\t\t * Ensures that this number is no smaller than the minimum,\n\t\t * and no larger than the maximum.\n\t\t * \n\t\t * @param\tValue\tAny number.\n\t\t * @param\tMin\t\tAny number.\n\t\t * @param\tMax\t\tAny number.\n\t\t * \n\t\t * @return\tThe bounded value of the number.\n\t\t */\n\t\tstatic public function bound(Value:Number,Min:Number,Max:Number):Number\n\t\t{\n\t\t\tvar lowerBound:Number = (Value<Min)?Min:Value;\n\t\t\treturn (lowerBound>Max)?Max:lowerBound;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Generates a random number based on the seed provided.\n\t\t * \n\t\t * @param\tSeed\tA number between 0 and 1, used to generate a predictable random number (very optional).\n\t\t * \n\t\t * @return\tA <code>Number</code> between 0 and 1.\n\t\t */\n\t\tstatic public function srand(Seed:Number):Number\n\t\t{\n\t\t\treturn ((69621 * int(Seed * 0x7FFFFFFF)) % 0x7FFFFFFF) / 0x7FFFFFFF;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Shuffles the entries in an array into a new random order.\n\t\t * <code>FlxG.shuffle()</code> is deterministic and safe for use with replays/recordings.\n\t\t * HOWEVER, <code>FlxU.shuffle()</code> is NOT deterministic and unsafe for use with replays/recordings.\n\t\t * \n\t\t * @param\tA\t\t\t\tA Flash <code>Array</code> object containing...stuff.\n\t\t * @param\tHowManyTimes\tHow many swaps to perform during the shuffle operation.  Good rule of thumb is 2-4 times as many objects are in the list.\n\t\t * \n\t\t * @return\tThe same Flash <code>Array</code> object that you passed in in the first place.\n\t\t */\n\t\tstatic public function shuffle(Objects:Array,HowManyTimes:uint):Array\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\tvar index1:uint;\n\t\t\tvar index2:uint;\n\t\t\tvar object:Object;\n\t\t\twhile(i < HowManyTimes)\n\t\t\t{\n\t\t\t\tindex1 = Math.random()*Objects.length;\n\t\t\t\tindex2 = Math.random()*Objects.length;\n\t\t\t\tobject = Objects[index2];\n\t\t\t\tObjects[index2] = Objects[index1];\n\t\t\t\tObjects[index1] = object;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\treturn Objects;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fetch a random entry from the given array.\n\t\t * Will return null if random selection is missing, or array has no entries.\n\t\t * <code>FlxG.getRandom()</code> is deterministic and safe for use with replays/recordings.\n\t\t * HOWEVER, <code>FlxU.getRandom()</code> is NOT deterministic and unsafe for use with replays/recordings.\n\t\t * \n\t\t * @param\tObjects\t\tA Flash array of objects.\n\t\t * @param\tStartIndex\tOptional offset off the front of the array. Default value is 0, or the beginning of the array.\n\t\t * @param\tLength\t\tOptional restriction on the number of values you want to randomly select from.\n\t\t * \n\t\t * @return\tThe random object that was selected.\n\t\t */\n\t\tstatic public function getRandom(Objects:Array,StartIndex:uint=0,Length:uint=0):Object\n\t\t{\n\t\t\tif(Objects != null)\n\t\t\t{\n\t\t\t\tvar l:uint = Length;\n\t\t\t\tif((l == 0) || (l > Objects.length - StartIndex))\n\t\t\t\t\tl = Objects.length - StartIndex;\n\t\t\t\tif(l > 0)\n\t\t\t\t\treturn Objects[StartIndex + uint(Math.random()*l)];\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Just grabs the current \"ticks\" or time in milliseconds that has passed since Flash Player started up.\n\t\t * Useful for finding out how long it takes to execute specific blocks of code.\n\t\t * \n\t\t * @return\tA <code>uint</code> to be passed to <code>FlxU.endProfile()</code>.\n\t\t */\n\t\tstatic public function getTicks():uint\n\t\t{\n\t\t\treturn getTimer();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Takes two \"ticks\" timestamps and formats them into the number of seconds that passed as a String.\n\t\t * Useful for logging, debugging, the watch window, or whatever else.\n\t\t * \n\t\t * @param\tStartTicks\tThe first timestamp from the system.\n\t\t * @param\tEndTicks\tThe second timestamp from the system.\n\t\t * \n\t\t * @return\tA <code>String</code> containing the formatted time elapsed information.\n\t\t */\n\t\tstatic public function formatTicks(StartTicks:uint,EndTicks:uint):String\n\t\t{\n\t\t\treturn ((EndTicks-StartTicks)/1000)+\"s\"\n\t\t}\n\t\t\n\t\t/**\n\t\t * Generate a Flash <code>uint</code> color from RGBA components.\n\t\t * \n\t\t * @param   Red     The red component, between 0 and 255.\n\t\t * @param   Green   The green component, between 0 and 255.\n\t\t * @param   Blue    The blue component, between 0 and 255.\n\t\t * @param   Alpha   How opaque the color should be, either between 0 and 1 or 0 and 255.\n\t\t * \n\t\t * @return  The color as a <code>uint</code>.\n\t\t */\n\t\tstatic public function makeColor(Red:uint, Green:uint, Blue:uint, Alpha:Number=1.0):uint\n\t\t{\n\t\t\treturn (((Alpha>1)?Alpha:(Alpha * 255)) & 0xFF) << 24 | (Red & 0xFF) << 16 | (Green & 0xFF) << 8 | (Blue & 0xFF);\n\t\t}\n\n\t\t/**\n\t\t * Generate a Flash <code>uint</code> color from HSB components.\n\t\t * \n\t\t * @param\tHue\t\t\tA number between 0 and 360, indicating position on a color strip or wheel.\n\t\t * @param\tSaturation\tA number between 0 and 1, indicating how colorful or gray the color should be.  0 is gray, 1 is vibrant.\n\t\t * @param\tBrightness\tA number between 0 and 1, indicating how bright the color should be.  0 is black, 1 is full bright.\n\t\t * @param   Alpha   \tHow opaque the color should be, either between 0 and 1 or 0 and 255.\n\t\t * \n\t\t * @return\tThe color as a <code>uint</code>.\n\t\t */\n\t\tstatic public function makeColorFromHSB(Hue:Number,Saturation:Number,Brightness:Number,Alpha:Number=1.0):uint\n\t\t{\n\t\t\tvar red:Number;\n\t\t\tvar green:Number;\n\t\t\tvar blue:Number;\n\t\t\tif(Saturation == 0.0)\n\t\t\t{\n\t\t\t\tred   = Brightness;\n\t\t\t\tgreen = Brightness;        \n\t\t\t\tblue  = Brightness;\n\t\t\t}       \n\t\t\telse\n\t\t\t{\n\t\t\t\tif(Hue == 360)\n\t\t\t\t\tHue = 0;\n\t\t\t\tvar slice:int = Hue/60;\n\t\t\t\tvar hf:Number = Hue/60 - slice;\n\t\t\t\tvar aa:Number = Brightness*(1 - Saturation);\n\t\t\t\tvar bb:Number = Brightness*(1 - Saturation*hf);\n\t\t\t\tvar cc:Number = Brightness*(1 - Saturation*(1.0 - hf));\n\t\t\t\tswitch (slice)\n\t\t\t\t{\n\t\t\t\t\tcase 0: red = Brightness; green = cc;   blue = aa;  break;\n\t\t\t\t\tcase 1: red = bb;  green = Brightness;  blue = aa;  break;\n\t\t\t\t\tcase 2: red = aa;  green = Brightness;  blue = cc;  break;\n\t\t\t\t\tcase 3: red = aa;  green = bb;   blue = Brightness; break;\n\t\t\t\t\tcase 4: red = cc;  green = aa;   blue = Brightness; break;\n\t\t\t\t\tcase 5: red = Brightness; green = aa;   blue = bb;  break;\n\t\t\t\t\tdefault: red = 0;  green = 0;    blue = 0;   break;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn (((Alpha>1)?Alpha:(Alpha * 255)) & 0xFF) << 24 | uint(red*255) << 16 | uint(green*255) << 8 | uint(blue*255);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Loads an array with the RGBA values of a Flash <code>uint</code> color.\n\t\t * RGB values are stored 0-255.  Alpha is stored as a floating point number between 0 and 1.\n\t\t * \n\t\t * @param\tColor\tThe color you want to break into components.\n\t\t * @param\tResults\tAn optional parameter, allows you to use an array that already exists in memory to store the result.\n\t\t * \n\t\t * @return\tAn <code>Array</code> object containing the Red, Green, Blue and Alpha values of the given color.\n\t\t */\n\t\tstatic public function getRGBA(Color:uint,Results:Array=null):Array\n\t\t{\n\t\t\tif(Results == null)\n\t\t\t\tResults = new Array();\n\t\t\tResults[0] = (Color >> 16) & 0xFF;\n\t\t\tResults[1] = (Color >> 8) & 0xFF;\n\t\t\tResults[2] = Color & 0xFF;\n\t\t\tResults[3] = Number((Color >> 24) & 0xFF) / 255;\n\t\t\treturn Results;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Loads an array with the HSB values of a Flash <code>uint</code> color.\n\t\t * Hue is a value between 0 and 360.  Saturation, Brightness and Alpha\n\t\t * are as floating point numbers between 0 and 1.\n\t\t * \n\t\t * @param\tColor\tThe color you want to break into components.\n\t\t * @param\tResults\tAn optional parameter, allows you to use an array that already exists in memory to store the result.\n\t\t * \n\t\t * @return\tAn <code>Array</code> object containing the Red, Green, Blue and Alpha values of the given color.\n\t\t */\n\t\tstatic public function getHSB(Color:uint,Results:Array=null):Array\n\t\t{\n\t\t\tif(Results == null)\n\t\t\t\tResults = new Array();\n\t\t\t\n\t\t\tvar red:Number = Number((Color >> 16) & 0xFF) / 255;\n\t\t\tvar green:Number = Number((Color >> 8) & 0xFF) / 255;\n\t\t\tvar blue:Number = Number((Color) & 0xFF) / 255;\n\t\t\t\n\t\t\tvar m:Number = (red>green)?red:green;\n\t\t\tvar dmax:Number = (m>blue)?m:blue;\n\t\t\tm = (red>green)?green:red;\n\t\t\tvar dmin:Number = (m>blue)?blue:m;\n\t\t\tvar range:Number = dmax - dmin;\n\t\t\t\n\t\t\tResults[2] = dmax;\n\t\t\tResults[1] = 0;\n\t\t\tResults[0] = 0;\n\t\t\t\n\t\t\tif(dmax != 0)\n\t\t\t\tResults[1] = range / dmax;\n\t\t\tif(Results[1] != 0) \n\t\t\t{\n\t\t\t\tif (red == dmax)\n\t\t\t\t\tResults[0] = (green - blue) / range;\n\t\t\t\telse if (green == dmax)\n\t\t\t\t\tResults[0] = 2 + (blue - red) / range;\n\t\t\t\telse if (blue == dmax)\n\t\t\t\t\tResults[0] = 4 + (red - green) / range;\n\t\t\t\tResults[0] *= 60;\n\t\t\t\tif(Results[0] < 0)\n\t\t\t\t\tResults[0] += 360;\n\t\t\t}\n\t\t\t\n\t\t\tResults[3] = Number((Color >> 24) & 0xFF) / 255;\n\t\t\treturn Results;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Format seconds as minutes with a colon, an optionally with milliseconds too.\n\t\t * \n\t\t * @param\tSeconds\t\tThe number of seconds (for example, time remaining, time spent, etc).\n\t\t * @param\tShowMS\t\tWhether to show milliseconds after a \".\" as well.  Default value is false.\n\t\t * \n\t\t * @return\tA nicely formatted <code>String</code>, like \"1:03\".\n\t\t */\n\t\tstatic public function formatTime(Seconds:Number,ShowMS:Boolean=false):String\n\t\t{\n\t\t\tvar timeString:String = int(Seconds/60) + \":\";\n\t\t\tvar timeStringHelper:int = int(Seconds)%60;\n\t\t\tif(timeStringHelper < 10)\n\t\t\t\ttimeString += \"0\";\n\t\t\ttimeString += timeStringHelper;\n\t\t\tif(ShowMS)\n\t\t\t{\n\t\t\t\ttimeString += \".\";\n\t\t\t\ttimeStringHelper = (Seconds-int(Seconds))*100;\n\t\t\t\tif(timeStringHelper < 10)\n\t\t\t\t\ttimeString += \"0\";\n\t\t\t\ttimeString += timeStringHelper;\n\t\t\t}\n\t\t\treturn timeString;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Generate a comma-separated string from an array.\n\t\t * Especially useful for tracing or other debug output.\n\t\t * \n\t\t * @param\tAnyArray\tAny <code>Array</code> object.\n\t\t * \n\t\t * @return\tA comma-separated <code>String</code> containing the <code>.toString()</code> output of each element in the array.\n\t\t */\n\t\tstatic public function formatArray(AnyArray:Array):String\n\t\t{\n\t\t\tif((AnyArray == null) || (AnyArray.length <= 0))\n\t\t\t\treturn \"\";\n\t\t\tvar string:String = AnyArray[0].toString();\n\t\t\tvar i:uint = 1;\n\t\t\tvar l:uint = AnyArray.length;\n\t\t\twhile(i < l)\n\t\t\t\tstring += \", \" + AnyArray[i++].toString();\n\t\t\treturn string;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Automatically commas and decimals in the right places for displaying money amounts.\n\t\t * Does not include a dollar sign or anything, so doesn't really do much\n\t\t * if you call say <code>var results:String = FlxU.formatMoney(10,false);</code>\n\t\t * However, very handy for displaying large sums or decimal money values.\n\t\t * \n\t\t * @param\tAmount\t\t\tHow much moneys (in dollars, or the equivalent \"main\" currency - i.e. not cents).\n\t\t * @param\tShowDecimal\t\tWhether to show the decimals/cents component. Default value is true.\n\t\t * @param\tEnglishStyle\tMajor quantities (thousands, millions, etc) separated by commas, and decimal by a period.  Default value is true.\n\t\t * \n\t\t * @return\tA nicely formatted <code>String</code>.  Does not include a dollar sign or anything!\n\t\t */\n\t\tstatic public function formatMoney(Amount:Number,ShowDecimal:Boolean=true,EnglishStyle:Boolean=true):String\n\t\t{\n\t\t\tvar helper:int;\n\t\t\tvar amount:int = Amount;\n\t\t\tvar string:String = \"\";\n\t\t\tvar comma:String = \"\";\n\t\t\tvar zeroes:String = \"\";\n\t\t\twhile(amount > 0)\n\t\t\t{\n\t\t\t\tif((string.length > 0) && comma.length <= 0)\n\t\t\t\t{\n\t\t\t\t\tif(EnglishStyle)\n\t\t\t\t\t\tcomma = \",\";\n\t\t\t\t\telse\n\t\t\t\t\t\tcomma = \".\";\n\t\t\t\t}\n\t\t\t\tzeroes = \"\";\n\t\t\t\thelper = amount - int(amount/1000)*1000;\n\t\t\t\tamount /= 1000;\n\t\t\t\tif(amount > 0)\n\t\t\t\t{\n\t\t\t\t\tif(helper < 100)\n\t\t\t\t\t\tzeroes += \"0\";\n\t\t\t\t\tif(helper < 10)\n\t\t\t\t\t\tzeroes += \"0\";\n\t\t\t\t}\n\t\t\t\tstring = zeroes + helper + comma + string;\n\t\t\t}\n\t\t\tif(ShowDecimal)\n\t\t\t{\n\t\t\t\tamount = int(Amount*100)-(int(Amount)*100);\n\t\t\t\tstring += (EnglishStyle?\".\":\",\") + amount;\n\t\t\t\tif(amount < 10)\n\t\t\t\t\tstring += \"0\";\n\t\t\t}\n\t\t\treturn string;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Get the <code>String</code> name of any <code>Object</code>.\n\t\t * \n\t\t * @param\tObj\t\tThe <code>Object</code> object in question.\n\t\t * @param\tSimple\tReturns only the class name, not the package or packages.\n\t\t * \n\t\t * @return\tThe name of the <code>Class</code> as a <code>String</code> object.\n\t\t */\n\t\tstatic public function getClassName(Obj:Object,Simple:Boolean=false):String\n\t\t{\n\t\t\tvar string:String = getQualifiedClassName(Obj);\n\t\t\tstring = string.replace(\"::\",\".\");\n\t\t\tif(Simple)\n\t\t\t\tstring = string.substr(string.lastIndexOf(\".\")+1);\n\t\t\treturn string;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Check to see if two objects have the same class name.\n\t\t * \n\t\t * @param\tObject1\t\tThe first object you want to check.\n\t\t * @param\tObject2\t\tThe second object you want to check.\n\t\t * \n\t\t * @return\tWhether they have the same class name or not.\n\t\t */\n\t\tstatic public function compareClassNames(Object1:Object,Object2:Object):Boolean\n\t\t{\n\t\t\treturn getQualifiedClassName(Object1) == getQualifiedClassName(Object2);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Look up a <code>Class</code> object by its string name.\n\t\t * \n\t\t * @param\tName\tThe <code>String</code> name of the <code>Class</code> you are interested in.\n\t\t * \n\t\t * @return\tA <code>Class</code> object.\n\t\t */\n\t\tstatic public function getClass(Name:String):Class\n\t\t{\n\t\t\treturn getDefinitionByName(Name) as Class;\n\t\t}\n\t\t\n\t\t/**\n\t\t * A tween-like function that takes a starting velocity\n\t\t * and some other factors and returns an altered velocity.\n\t\t * \n\t\t * @param\tVelocity\t\tAny component of velocity (e.g. 20).\n\t\t * @param\tAcceleration\tRate at which the velocity is changing.\n\t\t * @param\tDrag\t\t\tReally kind of a deceleration, this is how much the velocity changes if Acceleration is not set.\n\t\t * @param\tMax\t\t\t\tAn absolute value cap for the velocity.\n\t\t * \n\t\t * @return\tThe altered Velocity value.\n\t\t */\n\t\tstatic public function computeVelocity(Velocity:Number, Acceleration:Number=0, Drag:Number=0, Max:Number=10000):Number\n\t\t{\n\t\t\tif(Acceleration != 0)\n\t\t\t\tVelocity += Acceleration*FlxG.elapsed;\n\t\t\telse if(Drag != 0)\n\t\t\t{\n\t\t\t\tvar drag:Number = Drag*FlxG.elapsed;\n\t\t\t\tif(Velocity - drag > 0)\n\t\t\t\t\tVelocity = Velocity - drag;\n\t\t\t\telse if(Velocity + drag < 0)\n\t\t\t\t\tVelocity += drag;\n\t\t\t\telse\n\t\t\t\t\tVelocity = 0;\n\t\t\t}\n\t\t\tif((Velocity != 0) && (Max != 10000))\n\t\t\t{\n\t\t\t\tif(Velocity > Max)\n\t\t\t\t\tVelocity = Max;\n\t\t\t\telse if(Velocity < -Max)\n\t\t\t\t\tVelocity = -Max;\n\t\t\t}\n\t\t\treturn Velocity;\n\t\t}\n\t\t\n\t\t//*** NOTE: THESE LAST THREE FUNCTIONS REQUIRE FLXPOINT ***//\n\t\t\n\t\t/**\n\t\t * Rotates a point in 2D space around another point by the given angle.\n\t\t * \n\t\t * @param\tX\t\tThe X coordinate of the point you want to rotate.\n\t\t * @param\tY\t\tThe Y coordinate of the point you want to rotate.\n\t\t * @param\tPivotX\tThe X coordinate of the point you want to rotate around.\n\t\t * @param\tPivotY\tThe Y coordinate of the point you want to rotate around.\n\t\t * @param\tAngle\tRotate the point by this many degrees.\n\t\t * @param\tPoint\tOptional <code>FlxPoint</code> to store the results in.\n\t\t * \n\t\t * @return\tA <code>FlxPoint</code> containing the coordinates of the rotated point.\n\t\t */\n\t\tstatic public function rotatePoint(X:Number, Y:Number, PivotX:Number, PivotY:Number, Angle:Number,Point:FlxPoint=null):FlxPoint\n\t\t{\n\t\t\tvar sin:Number = 0;\n\t\t\tvar cos:Number = 0;\n\t\t\tvar radians:Number = Angle * -0.017453293;\n\t\t\twhile (radians < -3.14159265)\n\t\t\t\tradians += 6.28318531;\n\t\t\twhile (radians >  3.14159265)\n\t\t\t\tradians = radians - 6.28318531;\n\t\t\t\n\t\t\tif (radians < 0)\n\t\t\t{\n\t\t\t\tsin = 1.27323954 * radians + .405284735 * radians * radians;\n\t\t\t\tif (sin < 0)\n\t\t\t\t\tsin = .225 * (sin *-sin - sin) + sin;\n\t\t\t\telse\n\t\t\t\t\tsin = .225 * (sin * sin - sin) + sin;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsin = 1.27323954 * radians - 0.405284735 * radians * radians;\n\t\t\t\tif (sin < 0)\n\t\t\t\t\tsin = .225 * (sin *-sin - sin) + sin;\n\t\t\t\telse\n\t\t\t\t\tsin = .225 * (sin * sin - sin) + sin;\n\t\t\t}\n\t\t\t\n\t\t\tradians += 1.57079632;\n\t\t\tif (radians >  3.14159265)\n\t\t\t\tradians = radians - 6.28318531;\n\t\t\tif (radians < 0)\n\t\t\t{\n\t\t\t\tcos = 1.27323954 * radians + 0.405284735 * radians * radians;\n\t\t\t\tif (cos < 0)\n\t\t\t\t\tcos = .225 * (cos *-cos - cos) + cos;\n\t\t\t\telse\n\t\t\t\t\tcos = .225 * (cos * cos - cos) + cos;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcos = 1.27323954 * radians - 0.405284735 * radians * radians;\n\t\t\t\tif (cos < 0)\n\t\t\t\t\tcos = .225 * (cos *-cos - cos) + cos;\n\t\t\t\telse\n\t\t\t\t\tcos = .225 * (cos * cos - cos) + cos;\n\t\t\t}\n\t\t\t\n\t\t\tvar dx:Number = X-PivotX;\n\t\t\tvar dy:Number = PivotY+Y; //Y axis is inverted in flash, normally this would be a subtract operation\n\t\t\tif(Point == null)\n\t\t\t\tPoint = new FlxPoint();\n\t\t\tPoint.x = PivotX + cos*dx - sin*dy;\n\t\t\tPoint.y = PivotY - sin*dx - cos*dy;\n\t\t\treturn Point;\n\t\t};\n\t\t\n\t\t/**\n\t\t * Calculates the angle between two points.  0 degrees points straight up.\n\t\t * \n\t\t * @param\tPoint1\t\tThe X coordinate of the point.\n\t\t * @param\tPoint2\t\tThe Y coordinate of the point.\n\t\t * \n\t\t * @return\tThe angle in degrees, between -180 and 180.\n\t\t */\n\t\tstatic public function getAngle(Point1:FlxPoint, Point2:FlxPoint):Number\n\t\t{\n\t\t\tvar x:Number = Point2.x - Point1.x;\n\t\t\tvar y:Number = Point2.y - Point1.y;\n\t\t\tif((x == 0) && (y == 0))\n\t\t\t\treturn 0;\n\t\t\tvar c1:Number = 3.14159265 * 0.25;\n\t\t\tvar c2:Number = 3 * c1;\n\t\t\tvar ay:Number = (y < 0)?-y:y;\n\t\t\tvar angle:Number = 0;\n\t\t\tif (x >= 0)\n\t\t\t\tangle = c1 - c1 * ((x - ay) / (x + ay));\n\t\t\telse\n\t\t\t\tangle = c2 - c1 * ((x + ay) / (ay - x));\n\t\t\tangle = ((y < 0)?-angle:angle)*57.2957796;\n\t\t\tif(angle > 90)\n\t\t\t\tangle = angle - 270;\n\t\t\telse\n\t\t\t\tangle += 90;\n\t\t\treturn angle;\n\t\t};\n\t\t\n\t\t/**\n\t\t * Calculate the distance between two points.\n\t\t * \n\t\t * @param Point1\tA <code>FlxPoint</code> object referring to the first location.\n\t\t * @param Point2\tA <code>FlxPoint</code> object referring to the second location.\n\t\t * \n\t\t * @return\tThe distance between the two points as a floating point <code>Number</code> object.\n\t\t */\n\t\tstatic public function getDistance(Point1:FlxPoint,Point2:FlxPoint):Number\n\t\t{\n\t\t\tvar dx:Number = Point1.x - Point2.x;\n\t\t\tvar dy:Number = Point1.y - Point2.y;\n\t\t\treturn Math.sqrt(dx * dx + dy * dy);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/plugin/DebugPathDisplay.as",
    "content": "package org.flixel.plugin\n{\n\timport org.flixel.*;\n\t\n\t/**\n\t * A simple manager for tracking and drawing FlxPath debug data to the screen.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class DebugPathDisplay extends FlxBasic\n\t{\n\t\tprotected var _paths:Array;\n\t\t\n\t\t/**\n\t\t * Instantiates a new debug path display manager.\n\t\t */\n\t\tpublic function DebugPathDisplay()\n\t\t{\n\t\t\t_paths = new Array();\n\t\t\tactive = false; //don't call update on this plugin\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tsuper.destroy();\n\t\t\tclear();\n\t\t\t_paths = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by <code>FlxG.drawPlugins()</code> after the game state has been drawn.\n\t\t * Cycles through cameras and calls <code>drawDebug()</code> on each one.\n\t\t */\n\t\toverride public function draw():void\n\t\t{\n\t\t\tif(!FlxG.visualDebug || ignoreDrawDebug)\n\t\t\t\treturn;\t\n\t\t\t\n\t\t\tif(cameras == null)\n\t\t\t\tcameras = FlxG.cameras;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = cameras.length;\n\t\t\twhile(i < l)\n\t\t\t\tdrawDebug(cameras[i++]);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Similar to <code>FlxObject</code>'s <code>drawDebug()</code> functionality,\n\t\t * this function calls <code>drawDebug()</code> on each <code>FlxPath</code> for the specified camera.\n\t\t * Very helpful for debugging!\n\t\t * \n\t\t * @param\tCamera\tWhich <code>FlxCamera</code> object to draw the debug data to.\n\t\t */\n\t\toverride public function drawDebug(Camera:FlxCamera=null):void\n\t\t{\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\t\n\t\t\tvar i:int = _paths.length-1;\n\t\t\tvar path:FlxPath;\n\t\t\twhile(i >= 0)\n\t\t\t{\n\t\t\t\tpath = _paths[i--] as FlxPath;\n\t\t\t\tif((path != null) && !path.ignoreDrawDebug)\n\t\t\t\t\tpath.drawDebug(Camera);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Add a path to the path debug display manager.\n\t\t * Usually called automatically by <code>FlxPath</code>'s constructor.\n\t\t * \n\t\t * @param\tPath\tThe <code>FlxPath</code> you want to add to the manager.\n\t\t */\n\t\tpublic function add(Path:FlxPath):void\n\t\t{\n\t\t\t_paths.push(Path);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Remove a path from the path debug display manager.\n\t\t * Usually called automatically by <code>FlxPath</code>'s <code>destroy()</code> function.\n\t\t * \n\t\t * @param\tPath\tThe <code>FlxPath</code> you want to remove from the manager.\n\t\t */\n\t\tpublic function remove(Path:FlxPath):void\n\t\t{\n\t\t\tvar index:int = _paths.indexOf(Path);\n\t\t\tif(index >= 0)\n\t\t\t\t_paths.splice(index,1);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes all the paths from the path debug display manager.\n\t\t */\n\t\tpublic function clear():void\n\t\t{\n\t\t\tvar i:int = _paths.length-1;\n\t\t\tvar path:FlxPath;\n\t\t\twhile(i >= 0)\n\t\t\t{\n\t\t\t\tpath = _paths[i--] as FlxPath;\n\t\t\t\tif(path != null)\n\t\t\t\t\tpath.destroy();\n\t\t\t}\n\t\t\t_paths.length = 0;\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/plugin/TimerManager.as",
    "content": "package org.flixel.plugin\n{\n\timport org.flixel.*;\n\t\n\t/**\n\t * A simple manager for tracking and updating game timer objects.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class TimerManager extends FlxBasic\n\t{\n\t\tprotected var _timers:Array;\n\t\t\n\t\t/**\n\t\t * Instantiates a new timer manager.\n\t\t */\n\t\tpublic function TimerManager()\n\t\t{\n\t\t\t_timers = new Array();\n\t\t\tvisible = false; //don't call draw on this plugin\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tclear();\n\t\t\t_timers = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by <code>FlxG.updatePlugins()</code> before the game state has been updated.\n\t\t * Cycles through timers and calls <code>update()</code> on each one.\n\t\t */\n\t\toverride public function update():void\n\t\t{\n\t\t\tvar i:int = _timers.length-1;\n\t\t\tvar timer:FlxTimer;\n\t\t\twhile(i >= 0)\n\t\t\t{\n\t\t\t\ttimer = _timers[i--] as FlxTimer;\n\t\t\t\tif((timer != null) && !timer.paused && !timer.finished && (timer.time > 0))\n\t\t\t\t\ttimer.update();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Add a new timer to the timer manager.\n\t\t * Usually called automatically by <code>FlxTimer</code>'s constructor.\n\t\t * \n\t\t * @param\tTimer\tThe <code>FlxTimer</code> you want to add to the manager.\n\t\t */\n\t\tpublic function add(Timer:FlxTimer):void\n\t\t{\n\t\t\t_timers.push(Timer);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Remove a timer from the timer manager.\n\t\t * Usually called automatically by <code>FlxTimer</code>'s <code>stop()</code> function.\n\t\t * \n\t\t * @param\tTimer\tThe <code>FlxTimer</code> you want to remove from the manager.\n\t\t */\n\t\tpublic function remove(Timer:FlxTimer):void\n\t\t{\n\t\t\tvar index:int = _timers.indexOf(Timer);\n\t\t\tif(index >= 0)\n\t\t\t\t_timers.splice(index,1);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes all the timers from the timer manager.\n\t\t */\n\t\tpublic function clear():void\n\t\t{\n\t\t\tvar i:int = _timers.length-1;\n\t\t\tvar timer:FlxTimer;\n\t\t\twhile(i >= 0)\n\t\t\t{\n\t\t\t\ttimer = _timers[i--] as FlxTimer;\n\t\t\t\tif(timer != null)\n\t\t\t\t\ttimer.destroy();\n\t\t\t}\n\t\t\t_timers.length = 0;\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/system/FlxAnim.as",
    "content": "package org.flixel.system\n{\n\t/**\n\t * Just a helper structure for the FlxSprite animation system.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxAnim\n\t{\n\t\t/**\n\t\t * String name of the animation (e.g. \"walk\")\n\t\t */\n\t\tpublic var name:String;\n\t\t/**\n\t\t * Seconds between frames (basically the framerate)\n\t\t */\n\t\tpublic var delay:Number;\n\t\t/**\n\t\t * A list of frames stored as <code>uint</code> objects\n\t\t */\n\t\tpublic var frames:Array;\n\t\t/**\n\t\t * Whether or not the animation is looped\n\t\t */\n\t\tpublic var looped:Boolean;\n\t\t\n\t\t/**\n\t\t * Constructor\n\t\t * \n\t\t * @param\tName\t\tWhat this animation should be called (e.g. \"run\")\n\t\t * @param\tFrames\t\tAn array of numbers indicating what frames to play in what order (e.g. 1, 2, 3)\n\t\t * @param\tFrameRate\tThe speed in frames per second that the animation should play at (e.g. 40)\n\t\t * @param\tLooped\t\tWhether or not the animation is looped or just plays once\n\t\t */\n\t\tpublic function FlxAnim(Name:String, Frames:Array, FrameRate:Number=0, Looped:Boolean=true)\n\t\t{\n\t\t\tname = Name;\n\t\t\tdelay = 0;\n\t\t\tif(FrameRate > 0)\n\t\t\t\tdelay = 1.0/FrameRate;\n\t\t\tframes = Frames;\n\t\t\tlooped = Looped;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\tframes = null;\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/system/FlxDebugger.as",
    "content": "package org.flixel.system\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Sprite;\n\timport flash.events.MouseEvent;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport flash.text.TextField;\n\timport flash.text.TextFormat;\n\t\n\timport org.flixel.FlxG;\n\timport org.flixel.system.debug.Log;\n\timport org.flixel.system.debug.Perf;\n\timport org.flixel.system.debug.VCR;\n\timport org.flixel.system.debug.Vis;\n\timport org.flixel.system.debug.Watch;\n\t\n\t/**\n\t * Container for the new debugger overlay.\n\t * Most of the functionality is in the debug folder widgets,\n\t * but this class instantiates the widgets and handles their basic formatting and arrangement.\n\t */\n\tpublic class FlxDebugger extends Sprite\n\t{\n\t\t/**\n\t\t * Container for the performance monitor widget.\n\t\t */\n\t\tpublic var perf:Perf;\n\t\t/**\n\t\t * Container for the trace output widget.\n\t\t */\n\t\tpublic var log:Log;\n\t\t/**\n\t\t * Container for the watch window widget.\n\t\t */\n\t\tpublic var watch:Watch;\n\t\t/**\n\t\t * Container for the record, stop and play buttons.\n\t\t */\n\t\tpublic var vcr:VCR;\n\t\t/**\n\t\t * Container for the visual debug mode toggle.\n\t\t */\n\t\tpublic var vis:Vis;\n\t\t/**\n\t\t * Whether the mouse is currently over one of the debugger windows or not.\n\t\t */\n\t\tpublic var hasMouse:Boolean;\n\t\t\n\t\t/**\n\t\t * Internal, tracks what debugger window layout user has currently selected.\n\t\t */\n\t\tprotected var _layout:uint;\n\t\t/**\n\t\t * Internal, stores width and height of the Flash Player window.\n\t\t */\n\t\tprotected var _screen:Point;\n\t\t/**\n\t\t * Internal, used to space out windows from the edges.\n\t\t */\n\t\tprotected var _gutter:uint;\n\t\t\n\t\t/**\n\t\t * Instantiates the debugger overlay.\n\t\t * \n\t\t * @param Width\t\tThe width of the screen.\n\t\t * @param Height\tThe height of the screen.\n\t\t */\n\t\tpublic function FlxDebugger(Width:Number,Height:Number)\n\t\t{\n\t\t\tsuper();\n\t\t\tvisible = false;\n\t\t\thasMouse = false;\n\t\t\t_screen = new Point(Width,Height);\n\n\t\t\taddChild(new Bitmap(new BitmapData(Width,15,true,0x7f000000)));\n\t\t\t\n\t\t\tvar txt:TextField = new TextField();\n\t\t\ttxt.x = 2;\n\t\t\ttxt.width = 160;\n\t\t\ttxt.height = 16;\n\t\t\ttxt.selectable = false;\n\t\t\ttxt.multiline = false;\n\t\t\ttxt.defaultTextFormat = new TextFormat(\"Courier\",12,0xffffff);\n\t\t\tvar str:String = FlxG.getLibraryName();\n\t\t\tif(FlxG.debug)\n\t\t\t\tstr += \" [debug]\";\n\t\t\telse\n\t\t\t\tstr += \" [release]\";\n\t\t\ttxt.text = str;\n\t\t\taddChild(txt);\n\t\t\t\n\t\t\t_gutter = 8;\n\t\t\tvar screenBounds:Rectangle = new Rectangle(_gutter,15+_gutter/2,_screen.x-_gutter*2,_screen.y-_gutter*1.5-15);\n\t\t\t\n\t\t\tlog = new Log(\"log\",0,0,true,screenBounds);\n\t\t\taddChild(log);\n\t\t\t\n\t\t\twatch = new Watch(\"watch\",0,0,true,screenBounds);\n\t\t\taddChild(watch);\n\t\t\t\n\t\t\tperf = new Perf(\"stats\",0,0,false,screenBounds);\n\t\t\taddChild(perf);\n\t\t\t\n\t\t\tvcr = new VCR();\n\t\t\tvcr.x = (Width - vcr.width/2)/2;\n\t\t\tvcr.y = 2;\n\t\t\taddChild(vcr);\n\t\t\t\n\t\t\tvis = new Vis();\n\t\t\tvis.x = Width-vis.width - 4;\n\t\t\tvis.y = 2;\n\t\t\taddChild(vis);\n\t\t\t\n\t\t\tsetLayout(FlxG.DEBUGGER_STANDARD);\n\t\t\t\n\t\t\t//Should help with fake mouse focus type behavior\n\t\t\taddEventListener(MouseEvent.MOUSE_OVER,handleMouseOver);\n\t\t\taddEventListener(MouseEvent.MOUSE_OUT,handleMouseOut);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\t_screen = null;\n\t\t\tremoveChild(log);\n\t\t\tlog.destroy();\n\t\t\tlog = null;\n\t\t\tremoveChild(watch);\n\t\t\twatch.destroy();\n\t\t\twatch = null;\n\t\t\tremoveChild(perf);\n\t\t\tperf.destroy();\n\t\t\tperf = null;\n\t\t\tremoveChild(vcr);\n\t\t\tvcr.destroy();\n\t\t\tvcr = null;\n\t\t\tremoveChild(vis);\n\t\t\tvis.destroy();\n\t\t\tvis = null;\n\t\t\t\n\t\t\tremoveEventListener(MouseEvent.MOUSE_OVER,handleMouseOver);\n\t\t\tremoveEventListener(MouseEvent.MOUSE_OUT,handleMouseOut);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Mouse handler that helps with fake \"mouse focus\" type behavior.\n\t\t * \n\t\t * @param\tE\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseOver(E:MouseEvent=null):void\n\t\t{\n\t\t\thasMouse = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Mouse handler that helps with fake \"mouse focus\" type behavior.\n\t\t * \n\t\t * @param\tE\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseOut(E:MouseEvent=null):void\n\t\t{\n\t\t\thasMouse = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Rearrange the debugger windows using one of the constants specified in FlxG.\n\t\t * \n\t\t * @param\tLayout\t\tThe layout style for the debugger windows, e.g. <code>FlxG.DEBUGGER_MICRO</code>.\n\t\t */\n\t\tpublic function setLayout(Layout:uint):void\n\t\t{\n\t\t\t_layout = Layout;\n\t\t\tresetLayout();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Forces the debugger windows to reset to the last specified layout.\n\t\t * The default layout is <code>FlxG.DEBUGGER_STANDARD</code>.\n\t\t */\n\t\tpublic function resetLayout():void\n\t\t{\n\t\t\tswitch(_layout)\n\t\t\t{\n\t\t\t\tcase FlxG.DEBUGGER_MICRO:\n\t\t\t\t\tlog.resize(_screen.x/4,68);\n\t\t\t\t\tlog.reposition(0,_screen.y);\n\t\t\t\t\twatch.resize(_screen.x/4,68);\n\t\t\t\t\twatch.reposition(_screen.x,_screen.y);\n\t\t\t\t\tperf.reposition(_screen.x,0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase FlxG.DEBUGGER_BIG:\n\t\t\t\t\tlog.resize((_screen.x-_gutter*3)/2,_screen.y/2);\n\t\t\t\t\tlog.reposition(0,_screen.y);\n\t\t\t\t\twatch.resize((_screen.x-_gutter*3)/2,_screen.y/2);\n\t\t\t\t\twatch.reposition(_screen.x,_screen.y);\n\t\t\t\t\tperf.reposition(_screen.x,0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase FlxG.DEBUGGER_TOP:\n\t\t\t\t\tlog.resize((_screen.x-_gutter*3)/2,_screen.y/4);\n\t\t\t\t\tlog.reposition(0,0);\n\t\t\t\t\twatch.resize((_screen.x-_gutter*3)/2,_screen.y/4);\n\t\t\t\t\twatch.reposition(_screen.x,0);\n\t\t\t\t\tperf.reposition(_screen.x,_screen.y);\n\t\t\t\t\tbreak;\n\t\t\t\tcase FlxG.DEBUGGER_LEFT:\n\t\t\t\t\tlog.resize(_screen.x/3,(_screen.y-15-_gutter*2.5)/2);\n\t\t\t\t\tlog.reposition(0,0);\n\t\t\t\t\twatch.resize(_screen.x/3,(_screen.y-15-_gutter*2.5)/2);\n\t\t\t\t\twatch.reposition(0,_screen.y);\n\t\t\t\t\tperf.reposition(_screen.x,0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase FlxG.DEBUGGER_RIGHT:\n\t\t\t\t\tlog.resize(_screen.x/3,(_screen.y-15-_gutter*2.5)/2);\n\t\t\t\t\tlog.reposition(_screen.x,0);\n\t\t\t\t\twatch.resize(_screen.x/3,(_screen.y-15-_gutter*2.5)/2);\n\t\t\t\t\twatch.reposition(_screen.x,_screen.y);\n\t\t\t\t\tperf.reposition(0,0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase FlxG.DEBUGGER_STANDARD:\n\t\t\t\tdefault:\n\t\t\t\t\tlog.resize((_screen.x-_gutter*3)/2,_screen.y/4);\n\t\t\t\t\tlog.reposition(0,_screen.y);\n\t\t\t\t\twatch.resize((_screen.x-_gutter*3)/2,_screen.y/4);\n\t\t\t\t\twatch.reposition(_screen.x,_screen.y);\n\t\t\t\t\tperf.reposition(_screen.x,0);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/system/FlxList.as",
    "content": "package org.flixel.system\n{\n\timport org.flixel.FlxObject;\n\t\n\t/**\n\t * A miniature linked list class.\n\t * Useful for optimizing time-critical or highly repetitive tasks!\n\t * See <code>FlxQuadTree</code> for how to use it, IF YOU DARE.\n\t */\n\tpublic class FlxList\n\t{\n\t\t/**\n\t\t * Stores a reference to a <code>FlxObject</code>.\n\t\t */\n\t\tpublic var object:FlxObject;\n\t\t/**\n\t\t * Stores a reference to the next link in the list.\n\t\t */\n\t\tpublic var next:FlxList;\n\t\t\n\t\t/**\n\t\t * Creates a new link, and sets <code>object</code> and <code>next</code> to <code>null</code>.\n\t\t */\n\t\tpublic function FlxList()\n\t\t{\n\t\t\tobject = null;\n\t\t\tnext = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\tobject = null;\n\t\t\tif(next != null)\n\t\t\t\tnext.destroy();\n\t\t\tnext = null;\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/system/FlxPreloader.as",
    "content": "package org.flixel.system\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.DisplayObject;\n\timport flash.display.MovieClip;\n\timport flash.display.Sprite;\n\timport flash.display.StageAlign;\n\timport flash.display.StageScaleMode;\n\timport flash.events.Event;\n\timport flash.events.MouseEvent;\n\timport flash.net.URLRequest;\n\timport flash.net.navigateToURL;\n\timport flash.text.TextField;\n\timport flash.text.TextFormat;\n\timport flash.utils.getDefinitionByName;\n\timport flash.utils.getTimer;\n\t\n\timport org.flixel.FlxG;\n\n\t/**\n\t * This class handles the 8-bit style preloader.\n\t */\n\tpublic class FlxPreloader extends MovieClip\n\t{\n\t\t[Embed(source=\"../data/logo.png\")] protected var ImgLogo:Class;\n\t\t[Embed(source=\"../data/logo_corners.png\")] protected var ImgLogoCorners:Class;\n\t\t[Embed(source=\"../data/logo_light.png\")] protected var ImgLogoLight:Class;\n\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tprotected var _init:Boolean;\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tprotected var _buffer:Sprite;\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tprotected var _bmpBar:Bitmap;\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tprotected var _text:TextField;\n\t\t/**\n\t\t * Useful for storing \"real\" stage width if you're scaling your preloader graphics.\n\t\t */\n\t\tprotected var _width:uint;\n\t\t/**\n\t\t * Useful for storing \"real\" stage height if you're scaling your preloader graphics.\n\t\t */\n\t\tprotected var _height:uint;\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tprotected var _logo:Bitmap;\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tprotected var _logoGlow:Bitmap;\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tprotected var _min:uint;\n\n\t\t/**\n\t\t * This should always be the name of your main project/document class (e.g. GravityHook).\n\t\t */\n\t\tpublic var className:String;\n\t\t/**\n\t\t * Set this to your game's URL to use built-in site-locking.\n\t\t */\n\t\tpublic var myURL:String;\n\t\t/**\n\t\t * Change this if you want the flixel logo to show for more or less time.  Default value is 0 seconds.\n\t\t */\n\t\tpublic var minDisplayTime:Number;\n\t\t\n\t\t/**\n\t\t * Constructor\n\t\t */\n\t\tpublic function FlxPreloader()\n\t\t{\n\t\t\tminDisplayTime = 0;\n\t\t\t\n\t\t\tstop();\n            stage.scaleMode = StageScaleMode.NO_SCALE;\n\t\t\tstage.align = StageAlign.TOP_LEFT;\n\t\t\t\n\t\t\t//Check if we are on debug or release mode and set _DEBUG accordingly\n            try\n            {\n                throw new Error(\"Setting global debug flag...\");\n            }\n            catch(E:Error)\n            {\n                var re:RegExp = /\\[.*:[0-9]+\\]/;\n                FlxG.debug = re.test(E.getStackTrace());\n            }\n\t\t\t\n\t\t\tvar tmp:Bitmap;\n\t\t\tif(!FlxG.debug && (myURL != null) && (root.loaderInfo.url.indexOf(myURL) < 0))\n\t\t\t{\n\t\t\t\ttmp = new Bitmap(new BitmapData(stage.stageWidth,stage.stageHeight,true,0xFFFFFFFF));\n\t\t\t\taddChild(tmp);\n\t\t\t\t\n\t\t\t\tvar format:TextFormat = new TextFormat();\n\t\t\t\tformat.color = 0x000000;\n\t\t\t\tformat.size = 16;\n\t\t\t\tformat.align = \"center\";\n\t\t\t\tformat.bold = true;\n\t\t\t\tformat.font = \"system\";\n\t\t\t\t\n\t\t\t\tvar textField:TextField = new TextField();\n\t\t\t\ttextField.width = tmp.width-16;\n\t\t\t\ttextField.height = tmp.height-16;\n\t\t\t\ttextField.y = 8;\n\t\t\t\ttextField.multiline = true;\n\t\t\t\ttextField.wordWrap = true;\n\t\t\t\ttextField.embedFonts = true;\n\t\t\t\ttextField.defaultTextFormat = format;\n\t\t\t\ttextField.text = \"Hi there!  It looks like somebody copied this game without my permission.  Just click anywhere, or copy-paste this URL into your browser.\\n\\n\"+myURL+\"\\n\\nto play the game at my site.  Thanks, and have fun!\";\n\t\t\t\taddChild(textField);\n\t\t\t\t\n\t\t\t\ttextField.addEventListener(MouseEvent.CLICK,goToMyURL);\n\t\t\t\ttmp.addEventListener(MouseEvent.CLICK,goToMyURL);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis._init = false;\n\t\t\taddEventListener(Event.ENTER_FRAME, onEnterFrame);\n\t\t}\n\t\t\n\t\tprivate function goToMyURL(event:MouseEvent=null):void\n\t\t{\n\t\t\tvar prefix:String = myURL.match(/^https?:/) ? \"\" : \"http://\";\n\t\t\tnavigateToURL(new URLRequest(prefix+myURL));\n\t\t}\n\t\t\n\t\tprivate function onEnterFrame(event:Event):void\n        {\n\t\t\tif(!this._init)\n\t\t\t{\n\t\t\t\tif((stage.stageWidth <= 0) || (stage.stageHeight <= 0))\n\t\t\t\t\treturn;\n\t\t\t\tcreate();\n\t\t\t\tthis._init = true;\n\t\t\t}\n            graphics.clear();\n\t\t\tvar time:uint = getTimer();\n            if((framesLoaded >= totalFrames) && (time > _min))\n            {\n                removeEventListener(Event.ENTER_FRAME, onEnterFrame);\n                nextFrame();\n                var mainClass:Class = Class(getDefinitionByName(className));\n\t            if(mainClass)\n\t            {\n\t                var app:Object = new mainClass();\n\t                addChild(app as DisplayObject);\n\t            }\n                destroy();\n            }\n            else\n\t\t\t{\n\t\t\t\tvar percent:Number = root.loaderInfo.bytesLoaded/root.loaderInfo.bytesTotal;\n\t\t\t\tif((_min > 0) && (percent > time/_min))\n\t\t\t\t\tpercent = time/_min;\n            \tupdate(percent);\n\t\t\t}\n        }\n\t\t\n\t\t/**\n\t\t * Override this to create your own preloader objects.\n\t\t * Highly recommended you also override update()!\n\t\t */\n\t\tprotected function create():void\n\t\t{\n\t\t\t_min = 0;\n\t\t\tif(!FlxG.debug)\n\t\t\t\t_min = minDisplayTime*1000;\n\t\t\t_buffer = new Sprite();\n\t\t\t_buffer.scaleX = 2;\n\t\t\t_buffer.scaleY = 2;\n\t\t\taddChild(_buffer);\n\t\t\t_width = stage.stageWidth/_buffer.scaleX;\n\t\t\t_height = stage.stageHeight/_buffer.scaleY;\n\t\t\t_buffer.addChild(new Bitmap(new BitmapData(_width,_height,false,0x00345e)));\n\t\t\tvar bitmap:Bitmap = new ImgLogoLight();\n\t\t\tbitmap.smoothing = true;\n\t\t\tbitmap.width = bitmap.height = _height;\n\t\t\tbitmap.x = (_width-bitmap.width)/2;\n\t\t\t_buffer.addChild(bitmap);\n\t\t\t_bmpBar = new Bitmap(new BitmapData(1,7,false,0x5f6aff));\n\t\t\t_bmpBar.x = 4;\n\t\t\t_bmpBar.y = _height-11;\n\t\t\t_buffer.addChild(_bmpBar);\n\t\t\t_text = new TextField();\n\t\t\t_text.defaultTextFormat = new TextFormat(\"system\",8,0x5f6aff);\n\t\t\t_text.embedFonts = true;\n\t\t\t_text.selectable = false;\n\t\t\t_text.multiline = false;\n\t\t\t_text.x = 2;\n\t\t\t_text.y = _bmpBar.y - 11;\n\t\t\t_text.width = 80;\n\t\t\t_buffer.addChild(_text);\n\t\t\t_logo = new ImgLogo();\n\t\t\t_logo.scaleX = _logo.scaleY = _height/8;\n\t\t\t_logo.x = (_width-_logo.width)/2;\n\t\t\t_logo.y = (_height-_logo.height)/2;\n\t\t\t_buffer.addChild(_logo);\n\t\t\t_logoGlow = new ImgLogo();\n\t\t\t_logoGlow.smoothing = true;\n\t\t\t_logoGlow.blendMode = \"screen\";\n\t\t\t_logoGlow.scaleX = _logoGlow.scaleY = _height/8;\n\t\t\t_logoGlow.x = (_width-_logoGlow.width)/2;\n\t\t\t_logoGlow.y = (_height-_logoGlow.height)/2;\n\t\t\t_buffer.addChild(_logoGlow);\n\t\t\tbitmap = new ImgLogoCorners();\n\t\t\tbitmap.smoothing = true;\n\t\t\tbitmap.width = _width;\n\t\t\tbitmap.height = _height;\n\t\t\t_buffer.addChild(bitmap);\n\t\t\tbitmap = new Bitmap(new BitmapData(_width,_height,false,0xffffff));\n\t\t\tvar i:uint = 0;\n\t\t\tvar j:uint = 0;\n\t\t\twhile(i < _height)\n\t\t\t{\n\t\t\t\tj = 0;\n\t\t\t\twhile(j < _width)\n\t\t\t\t\tbitmap.bitmapData.setPixel(j++,i,0);\n\t\t\t\ti+=2;\n\t\t\t}\n\t\t\tbitmap.blendMode = \"overlay\";\n\t\t\tbitmap.alpha = 0.25;\n\t\t\t_buffer.addChild(bitmap);\n\t\t}\n\t\t\n\t\tprotected function destroy():void\n\t\t{\n\t\t\tremoveChild(_buffer);\n\t\t\t_buffer = null;\n\t\t\t_bmpBar = null;\n\t\t\t_text = null;\n\t\t\t_logo = null;\n\t\t\t_logoGlow = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Override this function to manually update the preloader.\n\t\t * \n\t\t * @param\tPercent\t\tHow much of the program has loaded.\n\t\t */\n\t\tprotected function update(Percent:Number):void\n\t\t{\n\t\t\t_bmpBar.scaleX = Percent*(_width-8);\n\t\t\t_text.text = \"FLX v\"+FlxG.LIBRARY_MAJOR_VERSION+\".\"+FlxG.LIBRARY_MINOR_VERSION+\" \"+Math.floor(Percent*100)+\"%\";\n\t\t\t_text.setTextFormat(_text.defaultTextFormat);\n\t\t\tif(Percent < 0.1)\n\t\t\t{\n\t\t\t\t_logoGlow.alpha = 0;\n\t\t\t\t_logo.alpha = 0;\n\t\t\t}\n\t\t\telse if(Percent < 0.15)\n\t\t\t{\n\t\t\t\t_logoGlow.alpha = Math.random();\n\t\t\t\t_logo.alpha = 0;\n\t\t\t}\n\t\t\telse if(Percent < 0.2)\n\t\t\t{\n\t\t\t\t_logoGlow.alpha = 0;\n\t\t\t\t_logo.alpha = 0;\n\t\t\t}\n\t\t\telse if(Percent < 0.25)\n\t\t\t{\n\t\t\t\t_logoGlow.alpha = 0;\n\t\t\t\t_logo.alpha = Math.random();\n\t\t\t}\n\t\t\telse if(Percent < 0.7)\n\t\t\t{\n\t\t\t\t_logoGlow.alpha = (Percent-0.45)/0.45;\n\t\t\t\t_logo.alpha = 1;\n\t\t\t}\n\t\t\telse if((Percent > 0.8) && (Percent < 0.9))\n\t\t\t{\n\t\t\t\t_logoGlow.alpha = 1-(Percent-0.8)/0.1;\n\t\t\t\t_logo.alpha = 0;\n\t\t\t}\n\t\t\telse if(Percent > 0.9)\n\t\t\t{\n\t\t\t\t_buffer.alpha = 1-(Percent-0.9)/0.1;\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/system/FlxQuadTree.as",
    "content": "package org.flixel.system\n{\n\timport org.flixel.FlxBasic;\n\timport org.flixel.FlxGroup;\n\timport org.flixel.FlxObject;\n\timport org.flixel.FlxRect;\n\n\t/**\n\t * A fairly generic quad tree structure for rapid overlap checks.\n\t * FlxQuadTree is also configured for single or dual list operation.\n\t * You can add items either to its A list or its B list.\n\t * When you do an overlap check, you can compare the A list to itself,\n\t * or the A list against the B list.  Handy for different things!\n\t */\n\tpublic class FlxQuadTree extends FlxRect\n\t{\n\t\t/**\n\t\t * Flag for specifying that you want to add an object to the A list.\n\t\t */\n\t\tstatic public const A_LIST:uint = 0;\n\t\t/**\n\t\t * Flag for specifying that you want to add an object to the B list.\n\t\t */\n\t\tstatic public const B_LIST:uint = 1;\n\t\t\n\t\t/**\n\t\t * Controls the granularity of the quad tree.  Default is 6 (decent performance on large and small worlds).\n\t\t */\n\t\tstatic public var divisions:uint;\n\t\t\n\t\t/**\n\t\t * Whether this branch of the tree can be subdivided or not.\n\t\t */\n\t\tprotected var _canSubdivide:Boolean;\n\t\t\n\t\t/**\n\t\t * Refers to the internal A and B linked lists,\n\t\t * which are used to store objects in the leaves.\n\t\t */\n\t\tprotected var _headA:FlxList;\n\t\t/**\n\t\t * Refers to the internal A and B linked lists,\n\t\t * which are used to store objects in the leaves.\n\t\t */\n\t\tprotected var _tailA:FlxList;\n\t\t/**\n\t\t * Refers to the internal A and B linked lists,\n\t\t * which are used to store objects in the leaves.\n\t\t */\n\t\tprotected var _headB:FlxList;\n\t\t/**\n\t\t * Refers to the internal A and B linked lists,\n\t\t * which are used to store objects in the leaves.\n\t\t */\n\t\tprotected var _tailB:FlxList;\n\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tstatic protected var _min:uint;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _northWestTree:FlxQuadTree;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _northEastTree:FlxQuadTree;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _southEastTree:FlxQuadTree;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _southWestTree:FlxQuadTree;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _leftEdge:Number;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _rightEdge:Number;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _topEdge:Number;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _bottomEdge:Number;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _halfWidth:Number;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _halfHeight:Number;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _midpointX:Number;\n\t\t/**\n\t\t * Internal, governs and assists with the formation of the tree.\n\t\t */\n\t\tprotected var _midpointY:Number;\n\t\t\n\t\t/**\n\t\t * Internal, used to reduce recursive method parameters during object placement and tree formation.\n\t\t */\n\t\tstatic protected var _object:FlxObject;\n\t\t/**\n\t\t * Internal, used to reduce recursive method parameters during object placement and tree formation.\n\t\t */\n\t\tstatic protected var _objectLeftEdge:Number;\n\t\t/**\n\t\t * Internal, used to reduce recursive method parameters during object placement and tree formation.\n\t\t */\n\t\tstatic protected var _objectTopEdge:Number;\n\t\t/**\n\t\t * Internal, used to reduce recursive method parameters during object placement and tree formation.\n\t\t */\n\t\tstatic protected var _objectRightEdge:Number;\n\t\t/**\n\t\t * Internal, used to reduce recursive method parameters during object placement and tree formation.\n\t\t */\n\t\tstatic protected var _objectBottomEdge:Number;\n\t\t\n\t\t/**\n\t\t * Internal, used during tree processing and overlap checks.\n\t\t */\n\t\tstatic protected var _list:uint;\n\t\t/**\n\t\t * Internal, used during tree processing and overlap checks.\n\t\t */\n\t\tstatic protected var _useBothLists:Boolean;\n\t\t/**\n\t\t * Internal, used during tree processing and overlap checks.\n\t\t */\n\t\tstatic protected var _processingCallback:Function;\n\t\t/**\n\t\t * Internal, used during tree processing and overlap checks.\n\t\t */\n\t\tstatic protected var _notifyCallback:Function;\n\t\t/**\n\t\t * Internal, used during tree processing and overlap checks.\n\t\t */\n\t\tstatic protected var _iterator:FlxList;\n\t\t\n\t\t/**\n\t\t * Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.\n\t\t */\n\t\tstatic protected var _objectHullX:Number;\n\t\t/**\n\t\t * Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.\n\t\t */\n\t\tstatic protected var _objectHullY:Number;\n\t\t/**\n\t\t * Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.\n\t\t */\n\t\tstatic protected var _objectHullWidth:Number;\n\t\t/**\n\t\t * Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.\n\t\t */\n\t\tstatic protected var _objectHullHeight:Number;\n\t\t\n\t\t/**\n\t\t * Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.\n\t\t */\n\t\tstatic protected var _checkObjectHullX:Number;\n\t\t/**\n\t\t * Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.\n\t\t */\n\t\tstatic protected var _checkObjectHullY:Number;\n\t\t/**\n\t\t * Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.\n\t\t */\n\t\tstatic protected var _checkObjectHullWidth:Number;\n\t\t/**\n\t\t * Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.\n\t\t */\n\t\tstatic protected var _checkObjectHullHeight:Number;\n\t\t\n\t\t/**\n\t\t * Instantiate a new Quad Tree node.\n\t\t * \n\t\t * @param\tX\t\t\tThe X-coordinate of the point in space.\n\t\t * @param\tY\t\t\tThe Y-coordinate of the point in space.\n\t\t * @param\tWidth\t\tDesired width of this node.\n\t\t * @param\tHeight\t\tDesired height of this node.\n\t\t * @param\tParent\t\tThe parent branch or node.  Pass null to create a root.\n\t\t */\n\t\tpublic function FlxQuadTree(X:Number, Y:Number, Width:Number, Height:Number, Parent:FlxQuadTree=null)\n\t\t{\n\t\t\tsuper(X,Y,Width,Height);\n\t\t\t_headA = _tailA = new FlxList();\n\t\t\t_headB = _tailB = new FlxList();\n\t\t\t\n\t\t\t//Copy the parent's children (if there are any)\n\t\t\tif(Parent != null)\n\t\t\t{\n\t\t\t\tvar iterator:FlxList;\n\t\t\t\tvar ot:FlxList;\n\t\t\t\tif(Parent._headA.object != null)\n\t\t\t\t{\n\t\t\t\t\titerator = Parent._headA;\n\t\t\t\t\twhile(iterator != null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(_tailA.object != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tot = _tailA;\n\t\t\t\t\t\t\t_tailA = new FlxList();\n\t\t\t\t\t\t\tot.next = _tailA;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t_tailA.object = iterator.object;\n\t\t\t\t\t\titerator = iterator.next;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(Parent._headB.object != null)\n\t\t\t\t{\n\t\t\t\t\titerator = Parent._headB;\n\t\t\t\t\twhile(iterator != null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(_tailB.object != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tot = _tailB;\n\t\t\t\t\t\t\t_tailB = new FlxList();\n\t\t\t\t\t\t\tot.next = _tailB;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t_tailB.object = iterator.object;\n\t\t\t\t\t\titerator = iterator.next;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t\t_min = (width + height)/(2*divisions);\n\t\t\t_canSubdivide = (width > _min) || (height > _min);\n\t\t\t\n\t\t\t//Set up comparison/sort helpers\n\t\t\t_northWestTree = null;\n\t\t\t_northEastTree = null;\n\t\t\t_southEastTree = null;\n\t\t\t_southWestTree = null;\n\t\t\t_leftEdge = x;\n\t\t\t_rightEdge = x+width;\n\t\t\t_halfWidth = width/2;\n\t\t\t_midpointX = _leftEdge+_halfWidth;\n\t\t\t_topEdge = y;\n\t\t\t_bottomEdge = y+height;\n\t\t\t_halfHeight = height/2;\n\t\t\t_midpointY = _topEdge+_halfHeight;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\t_headA.destroy();\n\t\t\t_headA = null;\n\t\t\t_tailA.destroy();\n\t\t\t_tailA = null;\n\t\t\t_headB.destroy();\n\t\t\t_headB = null;\n\t\t\t_tailB.destroy();\n\t\t\t_tailB = null;\n\n\t\t\tif(_northWestTree != null)\n\t\t\t\t_northWestTree.destroy();\n\t\t\t_northWestTree = null;\n\t\t\tif(_northEastTree != null)\n\t\t\t\t_northEastTree.destroy();\n\t\t\t_northEastTree = null;\n\t\t\tif(_southEastTree != null)\n\t\t\t\t_southEastTree.destroy();\n\t\t\t_southEastTree = null;\n\t\t\tif(_southWestTree != null)\n\t\t\t\t_southWestTree.destroy();\n\t\t\t_southWestTree = null;\n\n\t\t\t_object = null;\n\t\t\t_processingCallback = null;\n\t\t\t_notifyCallback = null;\n\t\t}\n\n\t\t/**\n\t\t * Load objects and/or groups into the quad tree, and register notify and processing callbacks.\n\t\t * \n\t\t * @param ObjectOrGroup1\tAny object that is or extends FlxObject or FlxGroup.\n\t\t * @param ObjectOrGroup2\tAny object that is or extends FlxObject or FlxGroup.  If null, the first parameter will be checked against itself.\n\t\t * @param NotifyCallback\tA function with the form <code>myFunction(Object1:FlxObject,Object2:FlxObject):void</code> that is called whenever two objects are found to overlap in world space, and either no ProcessCallback is specified, or the ProcessCallback returns true. \n\t\t * @param ProcessCallback\tA function with the form <code>myFunction(Object1:FlxObject,Object2:FlxObject):Boolean</code> that is called whenever two objects are found to overlap in world space.  The NotifyCallback is only called if this function returns true.  See FlxObject.separate(). \n\t\t */\n\t\tpublic function load(ObjectOrGroup1:FlxBasic, ObjectOrGroup2:FlxBasic=null, NotifyCallback:Function=null, ProcessCallback:Function=null):void\n\t\t{\n\t\t\tadd(ObjectOrGroup1, A_LIST);\n\t\t\tif(ObjectOrGroup2 != null)\n\t\t\t{\n\t\t\t\tadd(ObjectOrGroup2, B_LIST);\n\t\t\t\t_useBothLists = true;\n\t\t\t}\n\t\t\telse\n\t\t\t\t_useBothLists = false;\n\t\t\t_notifyCallback = NotifyCallback;\n\t\t\t_processingCallback = ProcessCallback;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Call this function to add an object to the root of the tree.\n\t\t * This function will recursively add all group members, but\n\t\t * not the groups themselves.\n\t\t * \n\t\t * @param\tObjectOrGroup\tFlxObjects are just added, FlxGroups are recursed and their applicable members added accordingly.\n\t\t * @param\tList\t\t\tA <code>uint</code> flag indicating the list to which you want to add the objects.  Options are <code>A_LIST</code> and <code>B_LIST</code>.\n\t\t */\n\t\tpublic function add(ObjectOrGroup:FlxBasic, List:uint):void\n\t\t{\n\t\t\t_list = List;\n\t\t\tif(ObjectOrGroup is FlxGroup)\n\t\t\t{\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar basic:FlxBasic;\n\t\t\t\tvar members:Array = (ObjectOrGroup as FlxGroup).members;\n\t\t\t\tvar l:uint = (ObjectOrGroup as FlxGroup).length;\n\t\t\t\twhile(i < l)\n\t\t\t\t{\n\t\t\t\t\tbasic = members[i++] as FlxBasic;\n\t\t\t\t\tif((basic != null) && basic.exists)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(basic is FlxGroup)\n\t\t\t\t\t\t\tadd(basic,List);\n\t\t\t\t\t\telse if(basic is FlxObject)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_object = basic as FlxObject;\n\t\t\t\t\t\t\tif(_object.exists && _object.allowCollisions)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t_objectLeftEdge = _object.x;\n\t\t\t\t\t\t\t\t_objectTopEdge = _object.y;\n\t\t\t\t\t\t\t\t_objectRightEdge = _object.x + _object.width;\n\t\t\t\t\t\t\t\t_objectBottomEdge = _object.y + _object.height;\n\t\t\t\t\t\t\t\taddObject();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_object = ObjectOrGroup as FlxObject;\n\t\t\t\tif(_object.exists && _object.allowCollisions)\n\t\t\t\t{\n\t\t\t\t\t_objectLeftEdge = _object.x;\n\t\t\t\t\t_objectTopEdge = _object.y;\n\t\t\t\t\t_objectRightEdge = _object.x + _object.width;\n\t\t\t\t\t_objectBottomEdge = _object.y + _object.height;\n\t\t\t\t\taddObject();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function for recursively navigating and creating the tree\n\t\t * while adding objects to the appropriate nodes.\n\t\t */\n\t\tprotected function addObject():void\n\t\t{\n\t\t\t//If this quad (not its children) lies entirely inside this object, add it here\n\t\t\tif(!_canSubdivide || ((_leftEdge >= _objectLeftEdge) && (_rightEdge <= _objectRightEdge) && (_topEdge >= _objectTopEdge) && (_bottomEdge <= _objectBottomEdge)))\n\t\t\t{\n\t\t\t\taddToList();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//See if the selected object fits completely inside any of the quadrants\n\t\t\tif((_objectLeftEdge > _leftEdge) && (_objectRightEdge < _midpointX))\n\t\t\t{\n\t\t\t\tif((_objectTopEdge > _topEdge) && (_objectBottomEdge < _midpointY))\n\t\t\t\t{\n\t\t\t\t\tif(_northWestTree == null)\n\t\t\t\t\t\t_northWestTree = new FlxQuadTree(_leftEdge,_topEdge,_halfWidth,_halfHeight,this);\n\t\t\t\t\t_northWestTree.addObject();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif((_objectTopEdge > _midpointY) && (_objectBottomEdge < _bottomEdge))\n\t\t\t\t{\n\t\t\t\t\tif(_southWestTree == null)\n\t\t\t\t\t\t_southWestTree = new FlxQuadTree(_leftEdge,_midpointY,_halfWidth,_halfHeight,this);\n\t\t\t\t\t_southWestTree.addObject();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif((_objectLeftEdge > _midpointX) && (_objectRightEdge < _rightEdge))\n\t\t\t{\n\t\t\t\tif((_objectTopEdge > _topEdge) && (_objectBottomEdge < _midpointY))\n\t\t\t\t{\n\t\t\t\t\tif(_northEastTree == null)\n\t\t\t\t\t\t_northEastTree = new FlxQuadTree(_midpointX,_topEdge,_halfWidth,_halfHeight,this);\n\t\t\t\t\t_northEastTree.addObject();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif((_objectTopEdge > _midpointY) && (_objectBottomEdge < _bottomEdge))\n\t\t\t\t{\n\t\t\t\t\tif(_southEastTree == null)\n\t\t\t\t\t\t_southEastTree = new FlxQuadTree(_midpointX,_midpointY,_halfWidth,_halfHeight,this);\n\t\t\t\t\t_southEastTree.addObject();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//If it wasn't completely contained we have to check out the partial overlaps\n\t\t\tif((_objectRightEdge > _leftEdge) && (_objectLeftEdge < _midpointX) && (_objectBottomEdge > _topEdge) && (_objectTopEdge < _midpointY))\n\t\t\t{\n\t\t\t\tif(_northWestTree == null)\n\t\t\t\t\t_northWestTree = new FlxQuadTree(_leftEdge,_topEdge,_halfWidth,_halfHeight,this);\n\t\t\t\t_northWestTree.addObject();\n\t\t\t}\n\t\t\tif((_objectRightEdge > _midpointX) && (_objectLeftEdge < _rightEdge) && (_objectBottomEdge > _topEdge) && (_objectTopEdge < _midpointY))\n\t\t\t{\n\t\t\t\tif(_northEastTree == null)\n\t\t\t\t\t_northEastTree = new FlxQuadTree(_midpointX,_topEdge,_halfWidth,_halfHeight,this);\n\t\t\t\t_northEastTree.addObject();\n\t\t\t}\n\t\t\tif((_objectRightEdge > _midpointX) && (_objectLeftEdge < _rightEdge) && (_objectBottomEdge > _midpointY) && (_objectTopEdge < _bottomEdge))\n\t\t\t{\n\t\t\t\tif(_southEastTree == null)\n\t\t\t\t\t_southEastTree = new FlxQuadTree(_midpointX,_midpointY,_halfWidth,_halfHeight,this);\n\t\t\t\t_southEastTree.addObject();\n\t\t\t}\n\t\t\tif((_objectRightEdge > _leftEdge) && (_objectLeftEdge < _midpointX) && (_objectBottomEdge > _midpointY) && (_objectTopEdge < _bottomEdge))\n\t\t\t{\n\t\t\t\tif(_southWestTree == null)\n\t\t\t\t\t_southWestTree = new FlxQuadTree(_leftEdge,_midpointY,_halfWidth,_halfHeight,this);\n\t\t\t\t_southWestTree.addObject();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function for recursively adding objects to leaf lists.\n\t\t */\n\t\tprotected function addToList():void\n\t\t{\n\t\t\tvar ot:FlxList;\n\t\t\tif(_list == A_LIST)\n\t\t\t{\n\t\t\t\tif(_tailA.object != null)\n\t\t\t\t{\n\t\t\t\t\tot = _tailA;\n\t\t\t\t\t_tailA = new FlxList();\n\t\t\t\t\tot.next = _tailA;\n\t\t\t\t}\n\t\t\t\t_tailA.object = _object;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(_tailB.object != null)\n\t\t\t\t{\n\t\t\t\t\tot = _tailB;\n\t\t\t\t\t_tailB = new FlxList();\n\t\t\t\t\tot.next = _tailB;\n\t\t\t\t}\n\t\t\t\t_tailB.object = _object;\n\t\t\t}\n\t\t\tif(!_canSubdivide)\n\t\t\t\treturn;\n\t\t\tif(_northWestTree != null)\n\t\t\t\t_northWestTree.addToList();\n\t\t\tif(_northEastTree != null)\n\t\t\t\t_northEastTree.addToList();\n\t\t\tif(_southEastTree != null)\n\t\t\t\t_southEastTree.addToList();\n\t\t\tif(_southWestTree != null)\n\t\t\t\t_southWestTree.addToList();\n\t\t}\n\t\t\n\t\t/**\n\t\t * <code>FlxQuadTree</code>'s other main function.  Call this after adding objects\n\t\t * using <code>FlxQuadTree.load()</code> to compare the objects that you loaded.\n\t\t *\n\t\t * @return\tWhether or not any overlaps were found.\n\t\t */\n\t\tpublic function execute():Boolean\n\t\t{\n\t\t\tvar overlapProcessed:Boolean = false;\n\t\t\tvar iterator:FlxList;\n\t\t\t\n\t\t\tif(_headA.object != null)\n\t\t\t{\n\t\t\t\titerator = _headA;\n\t\t\t\twhile(iterator != null)\n\t\t\t\t{\n\t\t\t\t\t_object = iterator.object;\n\t\t\t\t\tif(_useBothLists)\n\t\t\t\t\t\t_iterator = _headB;\n\t\t\t\t\telse\n\t\t\t\t\t\t_iterator = iterator.next;\n\t\t\t\t\tif(\t_object.exists && (_object.allowCollisions > 0) &&\n\t\t\t\t\t\t(_iterator != null) && (_iterator.object != null) &&\n\t\t\t\t\t\t_iterator.object.exists &&overlapNode())\n\t\t\t\t\t{\n\t\t\t\t\t\toverlapProcessed = true;\n\t\t\t\t\t}\n\t\t\t\t\titerator = iterator.next;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//Advance through the tree by calling overlap on each child\n\t\t\tif((_northWestTree != null) && _northWestTree.execute())\n\t\t\t\toverlapProcessed = true;\n\t\t\tif((_northEastTree != null) && _northEastTree.execute())\n\t\t\t\toverlapProcessed = true;\n\t\t\tif((_southEastTree != null) && _southEastTree.execute())\n\t\t\t\toverlapProcessed = true;\n\t\t\tif((_southWestTree != null) && _southWestTree.execute())\n\t\t\t\toverlapProcessed = true;\n\t\t\t\n\t\t\treturn overlapProcessed;\n\t\t}\n\t\t\n\t\t/**\n\t\t * An internal function for comparing an object against the contents of a node.\n\t\t * \n\t\t * @return\tWhether or not any overlaps were found.\n\t\t */\n\t\tprotected function overlapNode():Boolean\n\t\t{\n\t\t\t//Walk the list and check for overlaps\n\t\t\tvar overlapProcessed:Boolean = false;\n\t\t\tvar checkObject:FlxObject;\n\t\t\twhile(_iterator != null)\n\t\t\t{\n\t\t\t\tif(!_object.exists || (_object.allowCollisions <= 0))\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tcheckObject = _iterator.object;\n\t\t\t\tif((_object === checkObject) || !checkObject.exists || (checkObject.allowCollisions <= 0))\n\t\t\t\t{\n\t\t\t\t\t_iterator = _iterator.next;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//calculate bulk hull for _object\n\t\t\t\t_objectHullX = (_object.x < _object.last.x)?_object.x:_object.last.x;\n\t\t\t\t_objectHullY = (_object.y < _object.last.y)?_object.y:_object.last.y;\n\t\t\t\t_objectHullWidth = _object.x - _object.last.x;\n\t\t\t\t_objectHullWidth = _object.width + ((_objectHullWidth>0)?_objectHullWidth:-_objectHullWidth);\n\t\t\t\t_objectHullHeight = _object.y - _object.last.y;\n\t\t\t\t_objectHullHeight = _object.height + ((_objectHullHeight>0)?_objectHullHeight:-_objectHullHeight);\n\t\t\t\t\n\t\t\t\t//calculate bulk hull for checkObject\n\t\t\t\t_checkObjectHullX = (checkObject.x < checkObject.last.x)?checkObject.x:checkObject.last.x;\n\t\t\t\t_checkObjectHullY = (checkObject.y < checkObject.last.y)?checkObject.y:checkObject.last.y;\n\t\t\t\t_checkObjectHullWidth = checkObject.x - checkObject.last.x;\n\t\t\t\t_checkObjectHullWidth = checkObject.width + ((_checkObjectHullWidth>0)?_checkObjectHullWidth:-_checkObjectHullWidth);\n\t\t\t\t_checkObjectHullHeight = checkObject.y - checkObject.last.y;\n\t\t\t\t_checkObjectHullHeight = checkObject.height + ((_checkObjectHullHeight>0)?_checkObjectHullHeight:-_checkObjectHullHeight);\n\t\t\t\t\n\t\t\t\t//check for intersection of the two hulls\n\t\t\t\tif(\t(_objectHullX + _objectHullWidth > _checkObjectHullX) &&\n\t\t\t\t\t(_objectHullX < _checkObjectHullX + _checkObjectHullWidth) &&\n\t\t\t\t\t(_objectHullY + _objectHullHeight > _checkObjectHullY) &&\n\t\t\t\t\t(_objectHullY < _checkObjectHullY + _checkObjectHullHeight) )\n\t\t\t\t{\n\t\t\t\t\t//Execute callback functions if they exist\n\t\t\t\t\tif((_processingCallback == null) || _processingCallback(_object,checkObject))\n\t\t\t\t\t\toverlapProcessed = true;\n\t\t\t\t\tif(overlapProcessed && (_notifyCallback != null))\n\t\t\t\t\t\t_notifyCallback(_object,checkObject);\n\t\t\t\t}\n\t\t\t\t_iterator = _iterator.next;\n\t\t\t}\n\t\t\t\n\t\t\treturn overlapProcessed;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/system/FlxReplay.as",
    "content": "package org.flixel.system\n{\n\timport org.flixel.FlxG;\n\timport org.flixel.system.replay.FrameRecord;\n\timport org.flixel.system.replay.MouseRecord;\n\n\t/**\n\t * The replay object both records and replays game recordings,\n\t * as well as handle saving and loading replays to and from files.\n\t * Gameplay recordings are essentially a list of keyboard and mouse inputs,\n\t * but since Flixel is fairly deterministic, we can use these to play back\n\t * recordings of gameplay with a decent amount of fidelity.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxReplay\n\t{\n\t\t/**\n\t\t * The random number generator seed value for this recording.\n\t\t */\n\t\tpublic var seed:Number;\n\t\t/**\n\t\t * The current frame for this recording.\n\t\t */\n\t\tpublic var frame:int;\n\t\t/**\n\t\t * The number of frames in this recording.\n\t\t */\n\t\tpublic var frameCount:int;\n\t\t/**\n\t\t * Whether the replay has finished playing or not.\n\t\t */\n\t\tpublic var finished:Boolean;\n\t\t\n\t\t/**\n\t\t * Internal container for all the frames in this replay.\n\t\t */\n\t\tprotected var _frames:Array;\n\t\t/**\n\t\t * Internal tracker for max number of frames we can fit before growing the <code>_frames</code> again.\n\t\t */\n\t\tprotected var _capacity:int;\n\t\t/**\n\t\t * Internal helper variable for keeping track of where we are in <code>_frames</code> during recording or replay.\n\t\t */\n\t\tprotected var _marker:int;\n\t\t\n\t\t/**\n\t\t * Instantiate a new replay object.  Doesn't actually do much until you call create() or load().\n\t\t */\n\t\tpublic function FlxReplay()\n\t\t{\n\t\t\tseed = 0;\n\t\t\tframe = 0;\n\t\t\tframeCount = 0;\n\t\t\tfinished = false;\n\t\t\t_frames = null;\n\t\t\t_capacity = 0;\n\t\t\t_marker = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\tif(_frames == null)\n\t\t\t\treturn;\n\t\t\tvar i:int = frameCount-1;\n\t\t\twhile(i >= 0)\n\t\t\t\t(_frames[i--] as FrameRecord).destroy();\n\t\t\t_frames = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Create a new gameplay recording.  Requires the current random number generator seed.\n\t\t * \n\t\t * @param\tSeed\tThe current seed from the random number generator.\n\t\t */\n\t\tpublic function create(Seed:Number):void\n\t\t{\n\t\t\tdestroy();\n\t\t\tinit();\n\t\t\tseed = Seed;\n\t\t\trewind();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Load replay data from a <code>String</code> object.\n\t\t * Strings can come from embedded assets or external\n\t\t * files loaded through the debugger overlay. \n\t\t * \n\t\t * @param\tFileContents\tA <code>String</code> object containing a gameplay recording.\n\t\t */\n\t\tpublic function load(FileContents:String):void\n\t\t{\n\t\t\tinit();\n\t\t\t\n\t\t\tvar lines:Array = FileContents.split(\"\\n\");\n\t\t\t\n\t\t\tseed = Number(lines[0]);\n\t\t\t\n\t\t\tvar line:String;\n\t\t\tvar i:uint = 1;\n\t\t\tvar l:uint = lines.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tline = lines[i++] as String;\n\t\t\t\tif(line.length > 3)\n\t\t\t\t{\n\t\t\t\t\t_frames[frameCount++] = new FrameRecord().load(line);\n\t\t\t\t\tif(frameCount >= _capacity)\n\t\t\t\t\t{\n\t\t\t\t\t\t_capacity *= 2;\n\t\t\t\t\t\t_frames.length = _capacity;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\trewind();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Common initialization terms used by both <code>create()</code> and <code>load()</code> to set up the replay object.\n\t\t */\n\t\tprotected function init():void\n\t\t{\n\t\t\t_capacity = 100;\n\t\t\t_frames = new Array(_capacity);\n\t\t\tframeCount = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Save the current recording data off to a <code>String</code> object.\n\t\t * Basically goes through and calls <code>FrameRecord.save()</code> on each frame in the replay.\n\t\t * \n\t\t * return\tThe gameplay recording in simple ASCII format.\n\t\t */\n\t\tpublic function save():String\n\t\t{\n\t\t\tif(frameCount <= 0)\n\t\t\t\treturn null;\n\t\t\tvar output:String = seed+\"\\n\";\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < frameCount)\n\t\t\t\toutput += _frames[i++].save() + \"\\n\";\n\t\t\treturn output;\n\t\t}\n\n\t\t/**\n\t\t * Get the current input data from the input managers and store it in a new frame record.\n\t\t */\n\t\tpublic function recordFrame():void\n\t\t{\n\t\t\tvar keysRecord:Array = FlxG.keys.record();\n\t\t\tvar mouseRecord:MouseRecord = FlxG.mouse.record();\n\t\t\tif((keysRecord == null) && (mouseRecord == null))\n\t\t\t{\n\t\t\t\tframe++;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t_frames[frameCount++] = new FrameRecord().create(frame++,keysRecord,mouseRecord);\n\t\t\tif(frameCount >= _capacity)\n\t\t\t{\n\t\t\t\t_capacity *= 2;\n\t\t\t\t_frames.length = _capacity;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Get the current frame record data and load it into the input managers.\n\t\t */\n\t\tpublic function playNextFrame():void\n\t\t{\n\t\t\tFlxG.resetInput();\n\t\t\t\n\t\t\tif(_marker >= frameCount)\n\t\t\t{\n\t\t\t\tfinished = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif((_frames[_marker] as FrameRecord).frame != frame++)\n\t\t\t\treturn;\n\t\t\t\n\t\t\tvar fr:FrameRecord = _frames[_marker++];\n\t\t\tif(fr.keys != null)\n\t\t\t\tFlxG.keys.playback(fr.keys);\n\t\t\tif(fr.mouse != null)\n\t\t\t\tFlxG.mouse.playback(fr.mouse);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Reset the replay back to the first frame.\n\t\t */\n\t\tpublic function rewind():void\n\t\t{\n\t\t\t_marker = 0;\n\t\t\tframe = 0;\n\t\t\tfinished = false;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/system/FlxTile.as",
    "content": "package org.flixel.system\n{\n\timport org.flixel.FlxObject;\n\timport org.flixel.FlxTilemap;\n\t\n\t/**\n\t * A simple helper object for <code>FlxTilemap</code> that helps expand collision opportunities and control.\n\t * You can use <code>FlxTilemap.setTileProperties()</code> to alter the collision properties and\n\t * callback functions and filters for this object to do things like one-way tiles or whatever.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxTile extends FlxObject\n\t{\n\t\t/**\n\t\t * This function is called whenever an object hits a tile of this type.\n\t\t * This function should take the form <code>myFunction(Tile:FlxTile,Object:FlxObject):void</code>.\n\t\t * Defaults to null, set through <code>FlxTilemap.setTileProperties()</code>.\n\t\t */\n\t\tpublic var callback:Function;\n\t\t/**\n\t\t * Each tile can store its own filter class for their callback functions.\n\t\t * That is, the callback will only be triggered if an object with a class\n\t\t * type matching the filter touched it.\n\t\t * Defaults to null, set through <code>FlxTilemap.setTileProperties()</code>.\n\t\t */\n\t\tpublic var filter:Class;\n\t\t/**\n\t\t * A reference to the tilemap this tile object belongs to.\n\t\t */\n\t\tpublic var tilemap:FlxTilemap;\n\t\t/**\n\t\t * The index of this tile type in the core map data.\n\t\t * For example, if your map only has 16 kinds of tiles in it,\n\t\t * this number is usually between 0 and 15.\n\t\t */\n\t\tpublic var index:uint;\n\t\t/**\n\t\t * The current map index of this tile object at this moment.\n\t\t * You can think of tile objects as moving around the tilemap helping with collisions.\n\t\t * This value is only reliable and useful if used from the callback function.\n\t\t */\n\t\tpublic var mapIndex:uint;\n\t\t\n\t\t/**\n\t\t * Instantiate this new tile object.  This is usually called from <code>FlxTilemap.loadMap()</code>.\n\t\t * \n\t\t * @param Tilemap\t\t\tA reference to the tilemap object creating the tile.\n\t\t * @param Index\t\t\t\tThe actual core map data index for this tile type.\n\t\t * @param Width\t\t\t\tThe width of the tile.\n\t\t * @param Height\t\t\tThe height of the tile.\n\t\t * @param Visible\t\t\tWhether the tile is visible or not.\n\t\t * @param AllowCollisions\tThe collision flags for the object.  By default this value is ANY or NONE depending on the parameters sent to loadMap().\n\t\t */\n\t\tpublic function FlxTile(Tilemap:FlxTilemap, Index:uint, Width:Number, Height:Number, Visible:Boolean, AllowCollisions:uint)\n\t\t{\n\t\t\tsuper(0, 0, Width, Height);\n\t\t\timmovable = true;\n\t\t\tmoves = false;\n\t\t\tcallback = null;\n\t\t\tfilter = null;\n\t\t\t\n\t\t\ttilemap = Tilemap;\n\t\t\tindex = Index;\n\t\t\tvisible = Visible;\n\t\t\tallowCollisions = AllowCollisions;\n\t\t\t\n\t\t\tmapIndex = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tsuper.destroy();\n\t\t\tcallback = null;\n\t\t\ttilemap = null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/system/FlxTilemapBuffer.as",
    "content": "package org.flixel.system\n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.FlxCamera;\n\timport org.flixel.FlxG;\n\timport org.flixel.FlxU;\n\n\t/**\n\t * A helper object to keep tilemap drawing performance decent across the new multi-camera system.\n\t * Pretty much don't even have to think about this class unless you are doing some crazy hacking.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpublic class FlxTilemapBuffer\n\t{\n\t\t/**\n\t\t * The current X position of the buffer.\n\t\t */\n\t\tpublic var x:Number;\n\t\t/**\n\t\t * The current Y position of the buffer.\n\t\t */\n\t\tpublic var y:Number;\n\t\t/**\n\t\t * The width of the buffer (usually just a few tiles wider than the camera).\n\t\t */\n\t\tpublic var width:Number;\n\t\t/**\n\t\t * The height of the buffer (usually just a few tiles taller than the camera).\n\t\t */\n\t\tpublic var height:Number;\n\t\t/**\n\t\t * Whether the buffer needs to be redrawn.\n\t\t */\n\t\tpublic var dirty:Boolean;\n\t\t/**\n\t\t * How many rows of tiles fit in this buffer.\n\t\t */\n\t\tpublic var rows:uint;\n\t\t/**\n\t\t * How many columns of tiles fit in this buffer.\n\t\t */\n\t\tpublic var columns:uint;\n\n\t\tprotected var _pixels:BitmapData;\t\n\t\tprotected var _flashRect:Rectangle;\n\n\t\t/**\n\t\t * Instantiates a new camera-specific buffer for storing the visual tilemap data.\n\t\t *  \n\t\t * @param TileWidth\t\tThe width of the tiles in this tilemap.\n\t\t * @param TileHeight\tThe height of the tiles in this tilemap.\n\t\t * @param WidthInTiles\tHow many tiles wide the tilemap is.\n\t\t * @param HeightInTiles\tHow many tiles tall the tilemap is.\n\t\t * @param Camera\t\tWhich camera this buffer relates to.\n\t\t */\n\t\tpublic function FlxTilemapBuffer(TileWidth:Number,TileHeight:Number,WidthInTiles:uint,HeightInTiles:uint,Camera:FlxCamera=null)\n\t\t{\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\n\t\t\tcolumns = FlxU.ceil(Camera.width/TileWidth)+1;\n\t\t\tif(columns > WidthInTiles)\n\t\t\t\tcolumns = WidthInTiles;\n\t\t\trows = FlxU.ceil(Camera.height/TileHeight)+1;\n\t\t\tif(rows > HeightInTiles)\n\t\t\t\trows = HeightInTiles;\n\t\t\t\n\t\t\t_pixels = new BitmapData(columns*TileWidth,rows*TileHeight,true,0);\n\t\t\twidth = _pixels.width;\n\t\t\theight = _pixels.height;\t\t\t\n\t\t\t_flashRect = new Rectangle(0,0,width,height);\n\t\t\tdirty = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\t_pixels = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fill the buffer with the specified color.\n\t\t * Default value is transparent.\n\t\t * \n\t\t * @param\tColor\tWhat color to fill with, in 0xAARRGGBB hex format.\n\t\t */\n\t\tpublic function fill(Color:uint=0):void\n\t\t{\n\t\t\t_pixels.fillRect(_flashRect,Color);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Read-only, nab the actual buffer <code>BitmapData</code> object.\n\t\t * \n\t\t * @return\tThe buffer bitmap data.\n\t\t */\n\t\tpublic function get pixels():BitmapData\n\t\t{\n\t\t\treturn _pixels;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Just stamps this buffer onto the specified camera at the specified location.\n\t\t * \n\t\t * @param\tCamera\t\tWhich camera to draw the buffer onto.\n\t\t * @param\tFlashPoint\tWhere to draw the buffer at in camera coordinates.\n\t\t */\n\t\tpublic function draw(Camera:FlxCamera,FlashPoint:Point):void\n\t\t{\n\t\t\tCamera.buffer.copyPixels(_pixels,_flashRect,FlashPoint,null,null,true);\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/system/FlxWindow.as",
    "content": "package org.flixel.system\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Sprite;\n\timport flash.events.Event;\n\timport flash.events.MouseEvent;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport flash.text.TextField;\n\timport flash.text.TextFormat;\n\t\n\timport org.flixel.FlxU;\n\t\n\t/**\n\t * A generic, Flash-based window class, created for use in <code>FlxDebugger</code>.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class FlxWindow extends Sprite\n\t{\n\t\t[Embed(source=\"../data/handle.png\")] protected var ImgHandle:Class;\n\n\t\t/**\n\t\t * Minimum allowed X and Y dimensions for this window.\n\t\t */\n\t\tpublic var minSize:Point;\n\t\t/**\n\t\t * Maximum allowed X and Y dimensions for this window.\n\t\t */\n\t\tpublic var maxSize:Point;\n\t\t\n\t\t/**\n\t\t * Width of the window.  Using Sprite.width is super unreliable for some reason!\n\t\t */\n\t\tprotected var _width:uint;\n\t\t/**\n\t\t * Height of the window.  Using Sprite.height is super unreliable for some reason!\n\t\t */\n\t\tprotected var _height:uint;\n\t\t/**\n\t\t * Controls where the window is allowed to be positioned.\n\t\t */\n\t\tprotected var _bounds:Rectangle;\n\t\t\n\t\t/**\n\t\t * Window display element.\n\t\t */\n\t\tprotected var _background:Bitmap;\n\t\t/**\n\t\t * Window display element.\n\t\t */\n\t\tprotected var _header:Bitmap;\n\t\t/**\n\t\t * Window display element.\n\t\t */\n\t\tprotected var _shadow:Bitmap;\n\t\t/**\n\t\t * Window display element.\n\t\t */\n\t\tprotected var _title:TextField;\n\t\t/**\n\t\t * Window display element.\n\t\t */\n\t\tprotected var _handle:Bitmap;\n\t\t\n\t\t/**\n\t\t * Helper for interaction.\n\t\t */\n\t\tprotected var _overHeader:Boolean;\n\t\t/**\n\t\t * Helper for interaction.\n\t\t */\n\t\tprotected var _overHandle:Boolean;\n\t\t/**\n\t\t * Helper for interaction.\n\t\t */\n\t\tprotected var _drag:Point;\n\t\t/**\n\t\t * Helper for interaction.\n\t\t */\n\t\tprotected var _dragging:Boolean;\n\t\t/**\n\t\t * Helper for interaction.\n\t\t */\n\t\tprotected var _resizing:Boolean;\n\t\t/**\n\t\t * Helper for interaction.\n\t\t */\n\t\tprotected var _resizable:Boolean;\n\t\t\n\t\t/**\n\t\t * Creates a new window object.  This Flash-based class is mainly (only?) used by <code>FlxDebugger</code>.\n\t\t * \n\t\t * @param Title\t\t\tThe name of the window, displayed in the header bar.\n\t\t * @param Width\t\t\tThe initial width of the window.\n\t\t * @param Height\t\tThe initial height of the window.\n\t\t * @param Resizable\t\tWhether you can change the size of the window with a drag handle.\n\t\t * @param Bounds\t\tA rectangle indicating the valid screen area for the window.\n\t\t * @param BGColor\t\tWhat color the window background should be, default is gray and transparent.\n\t\t * @param TopColor\t\tWhat color the window header bar should be, default is black and transparent.\n\t\t */\n\t\tpublic function FlxWindow(Title:String,Width:Number,Height:Number,Resizable:Boolean=true,Bounds:Rectangle=null,BGColor:uint=0x7f7f7f7f, TopColor:uint=0x7f000000)\n\t\t{\n\t\t\tsuper();\n\t\t\t_width = Width;\n\t\t\t_height = Height;\n\t\t\t_bounds = Bounds;\n\t\t\tminSize = new Point(50,30);\n\t\t\tif(_bounds != null)\n\t\t\t\tmaxSize = new Point(_bounds.width,_bounds.height);\n\t\t\telse\n\t\t\t\tmaxSize = new Point(Number.MAX_VALUE,Number.MAX_VALUE);\n\t\t\t_drag = new Point();\n\t\t\t_resizable = Resizable;\n\t\t\t\n\t\t\t_shadow = new Bitmap(new BitmapData(1,2,true,0xff000000));\n\t\t\taddChild(_shadow);\n\t\t\t_background = new Bitmap(new BitmapData(1,1,true,BGColor));\n\t\t\t_background.y = 15;\n\t\t\taddChild(_background);\n\t\t\t_header = new Bitmap(new BitmapData(1,15,true,TopColor));\n\t\t\taddChild(_header);\n\t\t\t\n\t\t\t_title = new TextField();\n\t\t\t_title.x = 2;\n\t\t\t_title.height = 16;\n\t\t\t_title.selectable = false;\n\t\t\t_title.multiline = false;\n\t\t\t_title.defaultTextFormat = new TextFormat(\"Courier\",12,0xffffff);\n\t\t\t_title.text = Title;\n\t\t\taddChild(_title);\n\t\t\t\n\t\t\tif(_resizable)\n\t\t\t{\n\t\t\t\t_handle = new ImgHandle();\n\t\t\t\taddChild(_handle);\n\t\t\t}\n\t\t\t\n\t\t\tif((_width != 0) || (_height != 0))\n\t\t\t\tupdateSize();\n\t\t\tbound();\n\t\t\t\n\t\t\taddEventListener(Event.ENTER_FRAME,init);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\tminSize = null;\n\t\t\tmaxSize = null;\n\t\t\t_bounds = null;\n\t\t\tremoveChild(_shadow);\n\t\t\t_shadow = null;\n\t\t\tremoveChild(_background);\n\t\t\t_background = null;\n\t\t\tremoveChild(_header);\n\t\t\t_header = null;\n\t\t\tremoveChild(_title);\n\t\t\t_title = null;\n\t\t\tif(_handle != null)\n\t\t\t\tremoveChild(_handle);\n\t\t\t_handle = null;\n\t\t\t_drag = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Resize the window.  Subject to pre-specified minimums, maximums, and bounding rectangles.\n\t\t *  \n\t\t * @param Width\t\tHow wide to make the window.\n\t\t * @param Height\tHow tall to make the window.\n\t\t */\n\t\tpublic function resize(Width:Number,Height:Number):void\n\t\t{\n\t\t\t_width = Width;\n\t\t\t_height = Height;\n\t\t\tupdateSize();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Change the position of the window.  Subject to pre-specified bounding rectangles.\n\t\t * \n\t\t * @param X\t\tDesired X position of top left corner of the window.\n\t\t * @param Y\t\tDesired Y position of top left corner of the window.\n\t\t */\n\t\tpublic function reposition(X:Number,Y:Number):void\n\t\t{\n\t\t\tx = X;\n\t\t\ty = Y;\n\t\t\tbound();\n\t\t}\n\t\t\n\t\t//***EVENT HANDLERS***//\n\t\t\n\t\t/**\n\t\t * Used to set up basic mouse listeners.\n\t\t * \n\t\t * @param E\t\tFlash event.\n\t\t */\n\t\tprotected function init(E:Event=null):void\n\t\t{\n\t\t\tif(root == null)\n\t\t\t\treturn;\n\t\t\tremoveEventListener(Event.ENTER_FRAME,init);\n\t\t\t\n\t\t\tstage.addEventListener(MouseEvent.MOUSE_MOVE,handleMouseMove);\n\t\t\tstage.addEventListener(MouseEvent.MOUSE_DOWN,handleMouseDown);\n\t\t\tstage.addEventListener(MouseEvent.MOUSE_UP,handleMouseUp);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Mouse movement handler.  Figures out if mouse is over handle or header bar or what.\n\t\t * \n\t\t * @param E\t\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseMove(E:MouseEvent=null):void\n\t\t{\n\t\t\tif(_dragging) //user is moving the window around\n\t\t\t{\n\t\t\t\t_overHeader = true;\n\t\t\t\treposition(parent.mouseX - _drag.x, parent.mouseY - _drag.y);\n\t\t\t}\n\t\t\telse if(_resizing)\n\t\t\t{\n\t\t\t\t_overHandle = true;\n\t\t\t\tresize(mouseX - _drag.x, mouseY - _drag.y);\n\t\t\t}\n\t\t\telse if((mouseX >= 0) && (mouseX <= _width) && (mouseY >= 0) && (mouseY <= _height))\n\t\t\t{\t//not dragging, mouse is over the window\n\t\t\t\t_overHeader = (mouseX <= _header.width) && (mouseY <= _header.height);\n\t\t\t\tif(_resizable)\n\t\t\t\t\t_overHandle = (mouseX >= _width - _handle.width) && (mouseY >= _height - _handle.height);\n\t\t\t}\n\t\t\telse\n\t\t\t{\t//not dragging, mouse is NOT over window\n\t\t\t\t_overHandle = _overHeader = false;\n\t\t\t}\n\t\t\t\n\t\t\tupdateGUI();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Figure out if window is being repositioned (clicked on header) or resized (clicked on handle).\n\t\t * \n\t\t * @param E\t\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseDown(E:MouseEvent=null):void\n\t\t{\n\t\t\tif(_overHeader)\n\t\t\t{\n\t\t\t\t_dragging = true;\n\t\t\t\t_drag.x = mouseX;\n\t\t\t\t_drag.y = mouseY;\n\t\t\t}\n\t\t\telse if(_overHandle)\n\t\t\t{\n\t\t\t\t_resizing = true;\n\t\t\t\t_drag.x = _width-mouseX;\n\t\t\t\t_drag.y = _height-mouseY;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * User let go of header bar or handler (or nothing), so turn off drag and resize behaviors.\n\t\t * \n\t\t * @param E\t\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseUp(E:MouseEvent=null):void\n\t\t{\n\t\t\t_dragging = false;\n\t\t\t_resizing = false;\n\t\t}\n\t\t\n\t\t//***MISC GUI MGMT STUFF***//\n\t\t\n\t\t/**\n\t\t * Keep the window within the pre-specified bounding rectangle. \n\t\t */\n\t\tprotected function bound():void\n\t\t{\n\t\t\tif(_bounds != null)\n\t\t\t{\n\t\t\t\tx = FlxU.bound(x,_bounds.left,_bounds.right-_width);\n\t\t\t\ty = FlxU.bound(y,_bounds.top,_bounds.bottom-_height);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Update the Flash shapes to match the new size, and reposition the header, shadow, and handle accordingly.\n\t\t */\n\t\tprotected function updateSize():void\n\t\t{\n\t\t\t_width = FlxU.bound(_width,minSize.x,maxSize.x);\n\t\t\t_height = FlxU.bound(_height,minSize.y,maxSize.y);\n\t\t\t\n\t\t\t_header.scaleX = _width;\n\t\t\t_background.scaleX = _width;\n\t\t\t_background.scaleY = _height-15;\n\t\t\t_shadow.scaleX = _width;\n\t\t\t_shadow.y = _height;\n\t\t\t_title.width = _width-4;\n\t\t\tif(_resizable)\n\t\t\t{\n\t\t\t\t_handle.x = _width-_handle.width;\n\t\t\t\t_handle.y = _height-_handle.height;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Figure out if the header or handle are highlighted.\n\t\t */\n\t\tprotected function updateGUI():void\n\t\t{\n\t\t\tif(_overHeader || _overHandle)\n\t\t\t{\n\t\t\t\tif(_title.alpha != 1.0)\n\t\t\t\t\t_title.alpha = 1.0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(_title.alpha != 0.65)\n\t\t\t\t\t_title.alpha = 0.65;\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/system/debug/Log.as",
    "content": "package org.flixel.system.debug\n{\n\timport flash.geom.Rectangle;\n\timport flash.text.TextField;\n\timport flash.text.TextFormat;\n\timport org.flixel.system.FlxWindow;\n\n\t/**\n\t * A simple trace output window for use in the debugger overlay.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class Log extends FlxWindow\n\t{\n\t\tstatic protected const MAX_LOG_LINES:uint = 200;\n\n\t\tprotected var _text:TextField;\n\t\tprotected var _lines:Array;\n\t\t\n\t\t/**\n\t\t * Creates a new window object.  This Flash-based class is mainly (only?) used by <code>FlxDebugger</code>.\n\t\t * \n\t\t * @param Title\t\t\tThe name of the window, displayed in the header bar.\n\t\t * @param Width\t\t\tThe initial width of the window.\n\t\t * @param Height\t\tThe initial height of the window.\n\t\t * @param Resizable\t\tWhether you can change the size of the window with a drag handle.\n\t\t * @param Bounds\t\tA rectangle indicating the valid screen area for the window.\n\t\t * @param BGColor\t\tWhat color the window background should be, default is gray and transparent.\n\t\t * @param TopColor\t\tWhat color the window header bar should be, default is black and transparent.\n\t\t */\t\n\t\tpublic function Log(Title:String, Width:Number, Height:Number, Resizable:Boolean=true, Bounds:Rectangle=null, BGColor:uint=0x7f7f7f7f, TopColor:uint=0x7f000000)\n\t\t{\n\t\t\tsuper(Title, Width, Height, Resizable, Bounds, BGColor, TopColor);\n\t\t\t\n\t\t\t_text = new TextField();\n\t\t\t_text.x = 2;\n\t\t\t_text.y = 15;\n\t\t\t_text.multiline = true;\n\t\t\t_text.wordWrap = true;\n\t\t\t_text.selectable = true;\n\t\t\t_text.defaultTextFormat = new TextFormat(\"Courier\",12,0xffffff);\n\t\t\taddChild(_text);\n\t\t\t\n\t\t\t_lines = new Array();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tremoveChild(_text);\n\t\t\t_text = null;\n\t\t\t_lines = null;\n\t\t\tsuper.destroy();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adds a new line to the log window.\n\t\t * \n\t\t * @param Text\t\tThe line you want to add to the log window.\n\t\t */\n\t\tpublic function add(Text:String):void\n\t\t{\n\t\t\tif(_lines.length <= 0)\n\t\t\t\t_text.text = \"\";\n\t\t\t_lines.push(Text);\n\t\t\tif(_lines.length > MAX_LOG_LINES)\n\t\t\t{\n\t\t\t\t_lines.shift();\n\t\t\t\tvar newText:String = \"\";\n\t\t\t\tfor(var i:uint = 0; i < _lines.length; i++)\n\t\t\t\t\tnewText += _lines[i]+\"\\n\";\n\t\t\t\t_text.text = newText;\n\t\t\t}\n\t\t\telse\n\t\t\t\t_text.appendText(Text+\"\\n\");\n\t\t\t_text.scrollV = _text.height;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adjusts the width and height of the text field accordingly.\n\t\t */\n\t\toverride protected function updateSize():void\n\t\t{\n\t\t\tsuper.updateSize();\n\t\t\t\n\t\t\t_text.width = _width-10;\n\t\t\t_text.height = _height-15;\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/system/debug/Perf.as",
    "content": "package org.flixel.system.debug\n{\n\timport flash.geom.Rectangle;\n\timport flash.system.System;\n\timport flash.text.TextField;\n\timport flash.text.TextFormat;\n\timport flash.utils.getTimer;\n\t\n\timport org.flixel.FlxG;\n\timport org.flixel.system.FlxWindow;\n\t\n\t/**\n\t * A simple performance monitor widget, for use in the debugger overlay.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class Perf extends FlxWindow\n\t{\n\t\tprotected var _text:TextField;\n\t\t\n\t\tprotected var _lastTime:int;\n\t\tprotected var _updateTimer:int;\n\t\t\n\t\tprotected var _flixelUpdate:Array;\n\t\tprotected var _flixelUpdateMarker:uint;\n\t\tprotected var _flixelDraw:Array;\n\t\tprotected var _flixelDrawMarker:uint;\n\t\tprotected var _flash:Array;\n\t\tprotected var _flashMarker:uint;\n\t\tprotected var _activeObject:Array;\n\t\tprotected var _objectMarker:uint;\n\t\tprotected var _visibleObject:Array;\n\t\tprotected var _visibleObjectMarker:uint;\n\t\t\n\t\t/**\n\t\t * Creates flashPlayerFramerate new window object.  This Flash-based class is mainly (only?) used by <code>FlxDebugger</code>.\n\t\t * \n\t\t * @param Title\t\t\tThe name of the window, displayed in the header bar.\n\t\t * @param Width\t\t\tThe initial width of the window.\n\t\t * @param Height\t\tThe initial height of the window.\n\t\t * @param Resizable\t\tWhether you can change the size of the window with flashPlayerFramerate drag handle.\n\t\t * @param Bounds\t\tA rectangle indicating the valid screen area for the window.\n\t\t * @param BGColor\t\tWhat color the window background should be, default is gray and transparent.\n\t\t * @param TopColor\t\tWhat color the window header bar should be, default is black and transparent.\n\t\t */\n\t\tpublic function Perf(Title:String, Width:Number, Height:Number, Resizable:Boolean=true, Bounds:Rectangle=null, BGColor:uint=0x7f7f7f7f, TopColor:uint=0x7f000000)\n\t\t{\n\t\t\tsuper(Title, Width, Height, Resizable, Bounds, BGColor, TopColor);\n\t\t\tresize(90,66);\n\t\t\t\n\t\t\t_lastTime = 0;\n\t\t\t_updateTimer = 0;\n\t\t\t\n\t\t\t_text = new TextField();\n\t\t\t_text.width = _width;\n\t\t\t_text.x = 2;\n\t\t\t_text.y = 15;\n\t\t\t_text.multiline = true;\n\t\t\t_text.wordWrap = true;\n\t\t\t_text.selectable = true;\n\t\t\t_text.defaultTextFormat = new TextFormat(\"Courier\",12,0xffffff);\n\t\t\taddChild(_text);\n\t\t\t\n\t\t\t_flixelUpdate = new Array(32);\n\t\t\t_flixelUpdateMarker = 0;\n\t\t\t_flixelDraw = new Array(32);\n\t\t\t_flixelDrawMarker = 0;\n\t\t\t_flash = new Array(32);\n\t\t\t_flashMarker = 0;\n\t\t\t_activeObject = new Array(32);\n\t\t\t_objectMarker = 0;\n\t\t\t_visibleObject = new Array(32);\n\t\t\t_visibleObjectMarker = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tremoveChild(_text);\n\t\t\t_text = null;\n\t\t\t_flixelUpdate = null;\n\t\t\t_flixelDraw = null;\n\t\t\t_flash = null;\n\t\t\t_activeObject = null;\n\t\t\t_visibleObject = null;\n\t\t\tsuper.destroy();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called each frame, but really only updates once every second or so, to save on performance.\n\t\t * Takes all the data in the accumulators and parses it into useful performance data.\n\t\t */\n\t\tpublic function update():void\n\t\t{\n\t\t\tvar time:int = getTimer();\n\t\t\tvar elapsed:int = time - _lastTime;\n\t\t\tvar updateEvery:uint = 500;\n\t\t\tif(elapsed > updateEvery)\n\t\t\t\telapsed = updateEvery;\n\t\t\t_lastTime = time;\n\t\t\t\n\t\t\t_updateTimer += elapsed;\n\t\t\tif(_updateTimer > updateEvery)\n\t\t\t{\n\t\t\t\tvar i:uint;\n\t\t\t\tvar output:String = \"\";\n\n\t\t\t\tvar flashPlayerFramerate:Number = 0;\n\t\t\t\ti = 0;\n\t\t\t\twhile (i < _flashMarker)\n\t\t\t\t\tflashPlayerFramerate += _flash[i++];\n\t\t\t\tflashPlayerFramerate /= _flashMarker;\n\t\t\t\toutput += uint(1/(flashPlayerFramerate/1000)) + \"/\" + FlxG.flashFramerate + \"fps\\n\";\n\t\t\t\t\n\t\t\t\toutput += Number( ( System.totalMemory * 0.000000954 ).toFixed(2) ) + \"MB\\n\";\n\n\t\t\t\tvar updateTime:uint = 0;\n\t\t\t\ti = 0;\n\t\t\t\twhile(i < _flixelUpdateMarker)\n\t\t\t\t\tupdateTime += _flixelUpdate[i++];\n\t\t\t\t\n\t\t\t\tvar activeCount:uint = 0;\n\t\t\t\tvar te:uint = 0;\n\t\t\t\ti = 0;\n\t\t\t\twhile(i < _objectMarker)\n\t\t\t\t{\n\t\t\t\t\tactiveCount += _activeObject[i];\n\t\t\t\t\tvisibleCount += _visibleObject[i++];\n\t\t\t\t}\n\t\t\t\tactiveCount /= _objectMarker;\n\t\t\t\t\n\t\t\t\toutput += \"U:\" + activeCount + \" \" + uint(updateTime/_flixelDrawMarker) + \"ms\\n\";\n\t\t\t\t\n\t\t\t\tvar drawTime:uint = 0;\n\t\t\t\ti = 0;\n\t\t\t\twhile(i < _flixelDrawMarker)\n\t\t\t\t\tdrawTime += _flixelDraw[i++];\n\t\t\t\t\n\t\t\t\tvar visibleCount:uint = 0;\n\t\t\t\ti = 0;\n\t\t\t\twhile(i < _visibleObjectMarker)\n\t\t\t\t\tvisibleCount += _visibleObject[i++];\n\t\t\t\tvisibleCount /= _visibleObjectMarker;\n\n\t\t\t\toutput += \"D:\" + visibleCount + \" \" + uint(drawTime/_flixelDrawMarker) + \"ms\";\n\n\t\t\t\t_text.text = output;\n\n\t\t\t\t_flixelUpdateMarker = 0;\n\t\t\t\t_flixelDrawMarker = 0;\n\t\t\t\t_flashMarker = 0;\n\t\t\t\t_objectMarker = 0;\n\t\t\t\t_visibleObjectMarker = 0;\n\t\t\t\t_updateTimer -= updateEvery;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Keep track of how long updates take.\n\t\t * \n\t\t * @param Time\tHow long this update took.\n\t\t */\n\t\tpublic function flixelUpdate(Time:int):void\n\t\t{\n\t\t\t_flixelUpdate[_flixelUpdateMarker++] = Time;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Keep track of how long renders take.\n\t\t * \n\t\t * @param\tTime\tHow long this render took.\n\t\t */\n\t\tpublic function flixelDraw(Time:int):void\n\t\t{\n\t\t\t_flixelDraw[_flixelDrawMarker++] = Time;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Keep track of how long the Flash player and browser take.\n\t\t * \n\t\t * @param Time\tHow long Flash/browser took.\n\t\t */\n\t\tpublic function flash(Time:int):void\n\t\t{\n\t\t\t_flash[_flashMarker++] = Time;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Keep track of how many objects were updated.\n\t\t * \n\t\t * @param Count\tHow many objects were updated.\n\t\t */\n\t\tpublic function activeObjects(Count:int):void\n\t\t{\n\t\t\t_activeObject[_objectMarker++] = Count;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Keep track of how many objects were updated.\n\t\t *  \n\t\t * @param Count\tHow many objects were updated.\n\t\t */\n\t\tpublic function visibleObjects(Count:int):void\n\t\t{\n\t\t\t_visibleObject[_visibleObjectMarker++] = Count;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/system/debug/VCR.as",
    "content": "package org.flixel.system.debug\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Sprite;\n\timport flash.events.Event;\n\timport flash.events.IOErrorEvent;\n\timport flash.events.MouseEvent;\n\timport flash.net.FileFilter;\n\timport flash.net.FileReference;\n\timport flash.text.TextField;\n\timport flash.text.TextFormat;\n\timport flash.utils.ByteArray;\n\t\n\timport org.flixel.FlxG;\n\timport org.flixel.FlxU;\n\timport org.flixel.system.FlxReplay;\n\timport org.flixel.system.replay.FrameRecord;\n\timport org.flixel.system.replay.MouseRecord;\n\t\n\t/**\n\t * This class contains the record, stop, play, and step 1 frame buttons seen on the top edge of the debugger overlay.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class VCR extends Sprite\n\t{\n\t\t[Embed(source=\"../../data/vcr/open.png\")] protected var ImgOpen:Class;\n\t\t[Embed(source=\"../../data/vcr/record_off.png\")] protected var ImgRecordOff:Class;\n\t\t[Embed(source=\"../../data/vcr/record_on.png\")] protected var ImgRecordOn:Class;\n\t\t[Embed(source=\"../../data/vcr/stop.png\")] protected var ImgStop:Class;\n\t\t[Embed(source=\"../../data/vcr/flixel.png\")] protected var ImgFlixel:Class;\n\t\t[Embed(source=\"../../data/vcr/restart.png\")] protected var ImgRestart:Class;\n\t\t[Embed(source=\"../../data/vcr/pause.png\")] protected var ImgPause:Class;\n\t\t[Embed(source=\"../../data/vcr/play.png\")] protected var ImgPlay:Class;\n\t\t[Embed(source=\"../../data/vcr/step.png\")] protected var ImgStep:Class;\n\t\t\n\t\tstatic protected const FILE_TYPES:Array = [new FileFilter(\"Flixel Game Recording\", \"*.fgr\")];\n\t\tstatic protected const DEFAULT_FILE_NAME:String = \"replay.fgr\";\n\t\t\n\t\t/**\n\t\t * Whether the debugger has been paused. \n\t\t */\n\t\tpublic var paused:Boolean;\n\t\t/**\n\t\t * Whether a \"1 frame step forward\" was requested.\n\t\t */\n\t\tpublic var stepRequested:Boolean;\n\t\t\n\t\tprotected var _open:Bitmap;\n\t\tprotected var _recordOff:Bitmap;\n\t\tprotected var _recordOn:Bitmap;\n\t\tprotected var _stop:Bitmap;\n\t\tprotected var _flixel:Bitmap;\n\t\tprotected var _restart:Bitmap;\n\t\tprotected var _pause:Bitmap;\n\t\tprotected var _play:Bitmap;\n\t\tprotected var _step:Bitmap;\n\t\t\n\t\tprotected var _overOpen:Boolean;\n\t\tprotected var _overRecord:Boolean;\n\t\tprotected var _overRestart:Boolean;\n\t\tprotected var _overPause:Boolean;\n\t\tprotected var _overStep:Boolean;\n\t\t\n\t\tprotected var _pressingOpen:Boolean;\n\t\tprotected var _pressingRecord:Boolean;\n\t\tprotected var _pressingRestart:Boolean;\n\t\tprotected var _pressingPause:Boolean;\n\t\tprotected var _pressingStep:Boolean;\n\t\t\n\t\tprotected var _file:FileReference;\n\t\t\n\t\tprotected var _runtimeDisplay:TextField;\n\t\tprotected var _runtime:uint;\n\t\t\n\t\t/**\n\t\t * Creates the \"VCR\" control panel for debugger pausing, stepping, and recording.\n\t\t */\n\t\tpublic function VCR()\n\t\t{\n\t\t\tsuper();\n\t\t\t\n\t\t\tvar spacing:uint = 7;\n\t\t\t\n\t\t\t_open = new ImgOpen();\n\t\t\taddChild(_open);\n\t\t\t\n\t\t\t_recordOff = new ImgRecordOff();\n\t\t\t_recordOff.x = _open.x + _open.width + spacing;\n\t\t\taddChild(_recordOff);\n\t\t\t\n\t\t\t_recordOn = new ImgRecordOn();\n\t\t\t_recordOn.x = _recordOff.x;\n\t\t\t_recordOn.visible = false;\n\t\t\taddChild(_recordOn);\n\t\t\t\n\t\t\t_stop = new ImgStop();\n\t\t\t_stop.x = _recordOff.x;\n\t\t\t_stop.visible = false;\n\t\t\taddChild(_stop);\n\t\t\t\n\t\t\t_flixel = new ImgFlixel();\n\t\t\t_flixel.x = _recordOff.x + _recordOff.width + spacing;\n\t\t\taddChild(_flixel);\n\t\t\t\n\t\t\t_restart = new ImgRestart();\n\t\t\t_restart.x = _flixel.x + _flixel.width + spacing;\n\t\t\taddChild(_restart);\n\t\t\t\n\t\t\t_pause = new ImgPause();\n\t\t\t_pause.x = _restart.x + _restart.width + spacing;\n\t\t\taddChild(_pause);\n\t\t\t\n\t\t\t_play = new ImgPlay();\n\t\t\t_play.x = _pause.x;\n\t\t\t_play.visible = false;\n\t\t\taddChild(_play);\n\t\t\t\n\t\t\t_step = new ImgStep();\n\t\t\t_step.x = _pause.x + _pause.width + spacing;\n\t\t\taddChild(_step);\n\t\t\t\n\t\t\t_runtimeDisplay = new TextField();\n\t\t\t_runtimeDisplay.width = width;\n\t\t\t_runtimeDisplay.x = width;\n\t\t\t_runtimeDisplay.y = -2;\n\t\t\t_runtimeDisplay.multiline = false;\n\t\t\t_runtimeDisplay.wordWrap = false;\n\t\t\t_runtimeDisplay.selectable = false;\n\t\t\t_runtimeDisplay.defaultTextFormat = new TextFormat(\"Courier\",12,0xffffff,null,null,null,null,null,\"center\");\n\t\t\t_runtimeDisplay.visible = false;\n\t\t\taddChild(_runtimeDisplay);\n\t\t\t_runtime = 0;\n\t\t\t\n\t\t\tstepRequested = false;\n\t\t\t_file = null;\n\n\t\t\tunpress();\n\t\t\tcheckOver();\n\t\t\tupdateGUI();\n\t\t\t\n\t\t\taddEventListener(Event.ENTER_FRAME,init);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\t_file = null;\n\t\t\t\n\t\t\tremoveChild(_open);\n\t\t\t_open = null;\n\t\t\tremoveChild(_recordOff);\n\t\t\t_recordOff = null;\n\t\t\tremoveChild(_recordOn);\n\t\t\t_recordOn = null;\n\t\t\tremoveChild(_stop);\n\t\t\t_stop = null;\n\t\t\tremoveChild(_flixel);\n\t\t\t_flixel = null;\n\t\t\tremoveChild(_restart);\n\t\t\t_restart = null;\n\t\t\tremoveChild(_pause);\n\t\t\t_pause = null;\n\t\t\tremoveChild(_play);\n\t\t\t_play = null;\n\t\t\tremoveChild(_step);\n\t\t\t_step = null;\n\t\t\t\n\t\t\tparent.removeEventListener(MouseEvent.MOUSE_MOVE,handleMouseMove);\n\t\t\tparent.removeEventListener(MouseEvent.MOUSE_DOWN,handleMouseDown);\n\t\t\tparent.removeEventListener(MouseEvent.MOUSE_UP,handleMouseUp);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Usually called by FlxGame when a requested recording has begun.\n\t\t * Just updates the VCR GUI so the buttons are in the right state.\n\t\t */\n\t\tpublic function recording():void\n\t\t{\n\t\t\t_stop.visible = false;\n\t\t\t_recordOff.visible = false;\n\t\t\t_recordOn.visible = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Usually called by FlxGame when a replay has been stopped.\n\t\t * Just updates the VCR GUI so the buttons are in the right state.\n\t\t */\n\t\tpublic function stopped():void\n\t\t{\n\t\t\t_stop.visible = false;\n\t\t\t_recordOn.visible = false;\n\t\t\t_recordOff.visible = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Usually called by FlxGame when a requested replay has begun.\n\t\t * Just updates the VCR GUI so the buttons are in the right state.\n\t\t */\n\t\tpublic function playing():void\n\t\t{\n\t\t\t_recordOff.visible = false;\n\t\t\t_recordOn.visible = false;\n\t\t\t_stop.visible = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Just updates the VCR GUI so the runtime displays roughly the right thing.\n\t\t */\n\t\tpublic function updateRuntime(Time:uint):void\n\t\t{\n\t\t\t_runtime += Time;\n\t\t\t_runtimeDisplay.text = FlxU.formatTime(_runtime/1000,true);\n\t\t\tif(!_runtimeDisplay.visible)\n\t\t\t\t_runtimeDisplay.visible = true;\n\t\t}\n\t\t\n\t\t//*** ACTUAL BUTTON BEHAVIORS ***//\n\t\t\n\t\t/**\n\t\t * Called when the \"open file\" button is pressed.\n\t\t * Opens the file dialog and registers event handlers for the file dialog.\n\t\t */\n\t\tpublic function onOpen():void\n\t\t{\n\t\t\t_file = new FileReference();\n\t\t\t_file.addEventListener(Event.SELECT, onOpenSelect);\n\t\t\t_file.addEventListener(Event.CANCEL, onOpenCancel);\n\t\t\t_file.browse(FILE_TYPES);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when a file is picked from the file dialog.\n\t\t * Attempts to load the file and registers file loading event handlers.\n\t\t * \n\t\t * @param\tE\tFlash event.\n\t\t */\n\t\tprotected function onOpenSelect(E:Event=null):void\n\t\t{\n\t\t\t_file.removeEventListener(Event.SELECT, onOpenSelect);\n\t\t\t_file.removeEventListener(Event.CANCEL, onOpenCancel);\n\t\t\t\n\t\t\t_file.addEventListener(Event.COMPLETE, onOpenComplete);\n\t\t\t_file.addEventListener(IOErrorEvent.IO_ERROR, onOpenError);\n\t\t\t_file.load();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when a file is opened successfully.\n\t\t * If there's stuff inside, then the contents are loaded into a new replay.\n\t\t *\n\t\t * @param\tE\tFlash Event.\n\t\t */\n\t\tprotected function onOpenComplete(E:Event=null):void\n\t\t{\n\t\t\t_file.removeEventListener(Event.COMPLETE, onOpenComplete);\n\t\t\t_file.removeEventListener(IOErrorEvent.IO_ERROR, onOpenError);\n\t\t\t\n\t\t\t//Turn the file into a giant string\n\t\t\tvar fileContents:String = null;\n\t\t\tvar data:ByteArray = _file.data;\n\t\t\tif(data != null)\n\t\t\t\tfileContents = data.readUTFBytes(data.bytesAvailable);\n\t\t\t_file = null;\n\t\t\tif((fileContents == null) || (fileContents.length <= 0))\n\t\t\t{\n\t\t\t\tFlxG.log(\"ERROR: Empty flixel gameplay record.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tFlxG.loadReplay(fileContents);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called if the open file dialog is canceled.\n\t\t * \n\t\t * @param\tE\tFlash Event.\n\t\t */\n\t\tprotected function onOpenCancel(E:Event=null):void\n\t\t{\n\t\t\t_file.removeEventListener(Event.SELECT, onOpenSelect);\n\t\t\t_file.removeEventListener(Event.CANCEL, onOpenCancel);\n\t\t\t_file = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called if there is a file open error.\n\t\t * \n\t\t * @param\tE\tFlash Event.\n\t\t */\n\t\tprotected function onOpenError(E:Event=null):void\n\t\t{\n\t\t\t_file.removeEventListener(Event.COMPLETE, onOpenComplete);\n\t\t\t_file.removeEventListener(IOErrorEvent.IO_ERROR, onOpenError);\n\t\t\t_file = null;\n\t\t\tFlxG.log(\"ERROR: Unable to open flixel gameplay record.\");\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when the user presses the white record button.\n\t\t * If Alt is pressed, the current state is reset, and a new recording is requested.\n\t\t * If Alt is NOT pressed, the game is reset, and a new recording is requested.\n\t\t * \n\t\t * @param\tStandardMode\tWhether to reset the whole game, or just this <code>FlxState</code>.  StandardMode == false is useful for recording demos or attract modes.\n\t\t */\n\t\tpublic function onRecord(StandardMode:Boolean=false):void\n\t\t{\n\t\t\tif(_play.visible)\n\t\t\t\tonPlay();\n\t\t\tFlxG.recordReplay(StandardMode);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when the user presses the red record button.\n\t\t * Stops the current recording, opens the save file dialog, and registers event handlers.\n\t\t */\n\t\tpublic function stopRecording():void\n\t\t{\n\t\t\tvar data:String = FlxG.stopRecording();\n\t\t\tif((data != null) && (data.length > 0))\n\t\t\t{\n\t\t\t\t_file = new FileReference();\n\t\t\t\t_file.addEventListener(Event.COMPLETE, onSaveComplete);\n\t\t\t\t_file.addEventListener(Event.CANCEL,onSaveCancel);\n\t\t\t\t_file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError);\n\t\t\t\t_file.save(data, DEFAULT_FILE_NAME);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when the file is saved successfully.\n\t\t * \n\t\t * @param\tE\tFlash Event.\n\t\t */\n\t\tprotected function onSaveComplete(E:Event=null):void\n\t\t{\n\t\t\t_file.removeEventListener(Event.COMPLETE, onSaveComplete);\n\t\t\t_file.removeEventListener(Event.CANCEL,onSaveCancel);\n\t\t\t_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);\n\t\t\t_file = null;\n\t\t\tFlxG.log(\"FLIXEL: successfully saved flixel gameplay record.\");\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when the save file dialog is cancelled.\n\t\t * \n\t\t * @param\tE\tFlash Event.\n\t\t */\n\t\tprotected function onSaveCancel(E:Event=null):void\n\t\t{\n\t\t\t_file.removeEventListener(Event.COMPLETE, onSaveComplete);\n\t\t\t_file.removeEventListener(Event.CANCEL,onSaveCancel);\n\t\t\t_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);\n\t\t\t_file = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called if there is an error while saving the gameplay recording.\n\t\t * \n\t\t * @param\tE\tFlash Event.\n\t\t */\n\t\tprotected function onSaveError(E:Event=null):void\n\t\t{\n\t\t\t_file.removeEventListener(Event.COMPLETE, onSaveComplete);\n\t\t\t_file.removeEventListener(Event.CANCEL,onSaveCancel);\n\t\t\t_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);\n\t\t\t_file = null;\n\t\t\tFlxG.log(\"ERROR: problem saving flixel gameplay record.\");\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when the user presses the stop button.\n\t\t * Stops the current replay.\n\t\t */\n\t\tpublic function onStop():void\n\t\t{\n\t\t\tFlxG.stopReplay();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when the user presses the Rewind-looking button.\n\t\t * If Alt is pressed, the entire game is reset.\n\t\t * If Alt is NOT pressed, only the current state is reset.\n\t\t * The GUI is updated accordingly.\n\t\t * \n\t\t * @param\tStandardMode\tWhether to reset the current game (== true), or just the current state.  Just resetting the current state can be very handy for debugging.\n\t\t */\n\t\tpublic function onRestart(StandardMode:Boolean=false):void\n\t\t{\n\t\t\tif(FlxG.reloadReplay(StandardMode))\n\t\t\t{\n\t\t\t\t_recordOff.visible = false;\n\t\t\t\t_recordOn.visible = false;\n\t\t\t\t_stop.visible = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when the user presses the Pause button.\n\t\t * This is different from user-defined pause behavior, or focus lost behavior.\n\t\t * Does NOT pause music playback!!\n\t\t */\n\t\tpublic function onPause():void\n\t\t{\n\t\t\tpaused = true;\n\t\t\t_pause.visible = false;\n\t\t\t_play.visible = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when the user presses the Play button.\n\t\t * This is different from user-defined unpause behavior, or focus gained behavior.\n\t\t */\n\t\tpublic function onPlay():void\n\t\t{\n\t\t\tpaused = false;\n\t\t\t_play.visible = false;\n\t\t\t_pause.visible = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called when the user presses the fast-forward-looking button.\n\t\t * Requests a 1-frame step forward in the game loop.\n\t\t */\n\t\tpublic function onStep():void\n\t\t{\n\t\t\tif(!paused)\n\t\t\t\tonPause();\n\t\t\tstepRequested = true;\n\t\t}\n\t\t\n\t\t//***EVENT HANDLERS***//\n\t\t\n\t\t/**\n\t\t * Just sets up basic mouse listeners, a la FlxWindow.\n\t\t * \n\t\t * @param\tE\tFlash event.\n\t\t */\n\t\tprotected function init(E:Event=null):void\n\t\t{\n\t\t\tif(root == null)\n\t\t\t\treturn;\n\t\t\tremoveEventListener(Event.ENTER_FRAME,init);\n\n\t\t\tparent.addEventListener(MouseEvent.MOUSE_MOVE,handleMouseMove);\n\t\t\tparent.addEventListener(MouseEvent.MOUSE_DOWN,handleMouseDown);\n\t\t\tparent.addEventListener(MouseEvent.MOUSE_UP,handleMouseUp);\n\t\t}\n\t\t\n\t\t/**\n\t\t * If the mouse moves, check to see if any buttons should be highlighted.\n\t\t * \n\t\t * @param\tE\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseMove(E:MouseEvent=null):void\n\t\t{\n\t\t\tif(!checkOver())\n\t\t\t\tunpress();\n\t\t\tupdateGUI();\n\t\t}\n\t\t\n\t\t/**\n\t\t * If the mouse is pressed down, check to see if the user started pressing down a specific button.\n\t\t * \n\t\t * @param\tE\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseDown(E:MouseEvent=null):void\n\t\t{\n\t\t\tunpress();\n\t\t\tif(_overOpen)\n\t\t\t\t_pressingOpen = true;\n\t\t\tif(_overRecord)\n\t\t\t\t_pressingRecord = true;\n\t\t\tif(_overRestart)\n\t\t\t\t_pressingRestart = true;\n\t\t\tif(_overPause)\n\t\t\t\t_pressingPause = true;\n\t\t\tif(_overStep)\n\t\t\t\t_pressingStep = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * If the mouse is released, check to see if it was released over a button that was pressed.\n\t\t * If it was, take the appropriate action based on button state and visibility.\n\t\t * \n\t\t * @param\tE\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseUp(E:MouseEvent=null):void\n\t\t{\n\t\t\tif(_overOpen && _pressingOpen)\n\t\t\t\tonOpen();\n\t\t\telse if(_overRecord && _pressingRecord)\n\t\t\t{\n\t\t\t\tif(_stop.visible)\n\t\t\t\t\tonStop();\n\t\t\t\telse if(_recordOn.visible)\n\t\t\t\t\tstopRecording();\n\t\t\t\telse\n\t\t\t\t\tonRecord(!E.altKey);\n\t\t\t}\n\t\t\telse if(_overRestart && _pressingRestart)\n\t\t\t\tonRestart(!E.altKey);\n\t\t\telse if(_overPause && _pressingPause)\n\t\t\t{\n\t\t\t\tif(_play.visible)\n\t\t\t\t\tonPlay();\n\t\t\t\telse\n\t\t\t\t\tonPause();\n\t\t\t}\n\t\t\telse if(_overStep && _pressingStep)\n\t\t\t\tonStep();\n\t\t\t\n\t\t\tunpress();\n\t\t\tcheckOver();\n\t\t\tupdateGUI();\n\t\t}\n\t\t\n\t\t//***MISC GUI MGMT STUFF***//\n\t\t\n\t\t/**\n\t\t * This function checks to see what button the mouse is currently over.\n\t\t * Has some special behavior based on whether a recording is happening or not.\n\t\t * \n\t\t * @return\tWhether the mouse was over any buttons or not.\n\t\t */\n\t\tprotected function checkOver():Boolean\n\t\t{\n\t\t\t_overOpen = _overRecord = _overRestart = _overPause = _overStep = false;\n\t\t\tif((mouseX < 0) || (mouseX > width) || (mouseY < 0) || (mouseY > 15))\n\t\t\t\treturn false;\n\t\t\tif((mouseX >= _recordOff.x) && (mouseX <= _recordOff.x + _recordOff.width))\n\t\t\t\t_overRecord = true;\n\t\t\tif(!_recordOn.visible && !_overRecord)\n\t\t\t{\n\t\t\t\tif((mouseX >= _open.x) && (mouseX <= _open.x + _open.width))\n\t\t\t\t\t_overOpen = true;\n\t\t\t\telse if((mouseX >= _restart.x) && (mouseX <= _restart.x + _restart.width))\n\t\t\t\t\t_overRestart = true;\n\t\t\t\telse if((mouseX >= _pause.x) && (mouseX <= _pause.x + _pause.width))\n\t\t\t\t\t_overPause = true;\n\t\t\t\telse if((mouseX >= _step.x) && (mouseX <= _step.x + _step.width))\n\t\t\t\t\t_overStep = true;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets all the pressed state variables for the buttons to false.\n\t\t */\n\t\tprotected function unpress():void\n\t\t{\n\t\t\t_pressingOpen = false;\n\t\t\t_pressingRecord = false;\n\t\t\t_pressingRestart = false;\n\t\t\t_pressingPause = false;\n\t\t\t_pressingStep = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Figures out what buttons to highlight based on the _overWhatever and _pressingWhatever variables.\n\t\t */\n\t\tprotected function updateGUI():void\n\t\t{\n\t\t\tif(_recordOn.visible)\n\t\t\t{\n\t\t\t\t_open.alpha = _restart.alpha = _pause.alpha = _step.alpha = 0.35;\n\t\t\t\t_recordOn.alpha = 1.0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif(_overOpen && (_open.alpha != 1.0))\n\t\t\t\t_open.alpha = 1.0;\n\t\t\telse if(!_overOpen && (_open.alpha != 0.8))\n\t\t\t\t_open.alpha = 0.8;\n\t\t\t\n\t\t\tif(_overRecord && (_recordOff.alpha != 1.0))\n\t\t\t\t_recordOff.alpha = _recordOn.alpha = _stop.alpha = 1.0;\n\t\t\telse if(!_overRecord && (_recordOff.alpha != 0.8))\n\t\t\t\t_recordOff.alpha = _recordOn.alpha = _stop.alpha = 0.8;\n\t\t\t\n\t\t\tif(_overRestart && (_restart.alpha != 1.0))\n\t\t\t\t_restart.alpha = 1.0;\n\t\t\telse if(!_overRestart && (_restart.alpha != 0.8))\n\t\t\t\t_restart.alpha = 0.8;\n\t\t\t\n\t\t\tif(_overPause && (_pause.alpha != 1.0))\n\t\t\t\t_pause.alpha = _play.alpha = 1.0;\n\t\t\telse if(!_overPause && (_pause.alpha != 0.8))\n\t\t\t\t_pause.alpha = _play.alpha = 0.8;\n\t\t\t\n\t\t\tif(_overStep && (_step.alpha != 1.0))\n\t\t\t\t_step.alpha = 1.0;\n\t\t\telse if(!_overStep && (_step.alpha != 0.8))\n\t\t\t\t_step.alpha = 0.8;\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/system/debug/Vis.as",
    "content": "package org.flixel.system.debug\n{\n\timport flash.display.Bitmap;\n\timport flash.display.Sprite;\n\timport flash.events.Event;\n\timport flash.events.MouseEvent;\n\t\n\timport org.flixel.FlxG;\n\t\n\t/**\n\t * This control panel has all the visual debugger toggles in it, in the debugger overlay.\n\t * Currently there is only one toggle that flips on all the visual debug settings.\n\t * This panel is heavily based on the VCR panel.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class Vis extends Sprite\n\t{\n\t\t[Embed(source=\"../../data/vis/bounds.png\")] protected var ImgBounds:Class;\n\n\t\tprotected var _bounds:Bitmap;\n\t\tprotected var _overBounds:Boolean;\n\t\tprotected var _pressingBounds:Boolean;\n\t\t\n\t\t/**\n\t\t * Instantiate the visual debugger panel.\n\t\t */\n\t\tpublic function Vis()\n\t\t{\n\t\t\tsuper();\n\t\t\t\n\t\t\tvar spacing:uint = 7;\n\t\t\t\n\t\t\t_bounds = new ImgBounds();\n\t\t\taddChild(_bounds);\n\t\t\t\n\t\t\tunpress();\n\t\t\tcheckOver();\n\t\t\tupdateGUI();\n\t\t\t\n\t\t\taddEventListener(Event.ENTER_FRAME,init);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\tremoveChild(_bounds);\n\t\t\t_bounds = null;\n\t\t\t\n\t\t\tparent.removeEventListener(MouseEvent.MOUSE_MOVE,handleMouseMove);\n\t\t\tparent.removeEventListener(MouseEvent.MOUSE_DOWN,handleMouseDown);\n\t\t\tparent.removeEventListener(MouseEvent.MOUSE_UP,handleMouseUp);\n\t\t}\n\t\t\n\t\t//***ACTUAL BUTTON BEHAVIORS***//\n\t\t\n\t\t/**\n\t\t * Called when the bounding box toggle is pressed.\n\t\t */\n\t\tpublic function onBounds():void\n\t\t{\n\t\t\tFlxG.visualDebug = !FlxG.visualDebug;\n\t\t}\n\t\t\n\t\t//***EVENT HANDLERS***//\n\t\t\n\t\t/**\n\t\t * Just sets up basic mouse listeners, a la FlxWindow.\n\t\t * \n\t\t * @param\tE\tFlash event.\n\t\t */\n\t\tprotected function init(E:Event=null):void\n\t\t{\n\t\t\tif(root == null)\n\t\t\t\treturn;\n\t\t\tremoveEventListener(Event.ENTER_FRAME,init);\n\t\t\t\n\t\t\tparent.addEventListener(MouseEvent.MOUSE_MOVE,handleMouseMove);\n\t\t\tparent.addEventListener(MouseEvent.MOUSE_DOWN,handleMouseDown);\n\t\t\tparent.addEventListener(MouseEvent.MOUSE_UP,handleMouseUp);\n\t\t}\n\t\t\n\t\t/**\n\t\t * If the mouse moves, check to see if any buttons should be highlighted.\n\t\t * \n\t\t * @param\tE\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseMove(E:MouseEvent=null):void\n\t\t{\n\t\t\tif(!checkOver())\n\t\t\t\tunpress();\n\t\t\tupdateGUI();\n\t\t}\n\t\t\n\t\t/**\n\t\t * If the mouse is pressed down, check to see if the user started pressing down a specific button.\n\t\t * \n\t\t * @param\tE\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseDown(E:MouseEvent=null):void\n\t\t{\n\t\t\tunpress();\n\t\t\tif(_overBounds)\n\t\t\t\t_pressingBounds = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * If the mouse is released, check to see if it was released over a button that was pressed.\n\t\t * If it was, take the appropriate action based on button state and visibility.\n\t\t * \n\t\t * @param\tE\tFlash mouse event.\n\t\t */\n\t\tprotected function handleMouseUp(E:MouseEvent=null):void\n\t\t{\n\t\t\tif(_overBounds && _pressingBounds)\n\t\t\t\tonBounds();\n\t\t\tunpress();\n\t\t\tcheckOver();\n\t\t\tupdateGUI();\n\t\t}\n\t\t\n\t\t//***MISC GUI MGMT STUFF***//\n\t\t\n\t\t/**\n\t\t * This function checks to see what button the mouse is currently over.\n\t\t * Has some special behavior based on whether a recording is happening or not.\n\t\t * \n\t\t * @return\tWhether the mouse was over any buttons or not.\n\t\t */\n\t\tprotected function checkOver():Boolean\n\t\t{\n\t\t\t_overBounds = false;\n\t\t\tif((mouseX < 0) || (mouseX > width) || (mouseY < 0) || (mouseY > height))\n\t\t\t\treturn false;\n\t\t\tif((mouseX > _bounds.x) || (mouseX < _bounds.x + _bounds.width))\n\t\t\t\t_overBounds = true;\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets all the pressed state variables for the buttons to false.\n\t\t */\n\t\tprotected function unpress():void\n\t\t{\n\t\t\t_pressingBounds = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Figures out what buttons to highlight based on the _overWhatever and _pressingWhatever variables.\n\t\t */\n\t\tprotected function updateGUI():void\n\t\t{\n\t\t\tif(FlxG.visualDebug)\n\t\t\t{\n\t\t\t\tif(_overBounds && (_bounds.alpha != 1.0))\n\t\t\t\t\t_bounds.alpha = 1.0;\n\t\t\t\telse if(!_overBounds && (_bounds.alpha != 0.9))\n\t\t\t\t\t_bounds.alpha = 0.9;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(_overBounds && (_bounds.alpha != 0.6))\n\t\t\t\t\t_bounds.alpha = 0.6;\n\t\t\t\telse if(!_overBounds && (_bounds.alpha != 0.5))\n\t\t\t\t\t_bounds.alpha = 0.5;\n\t\t\t}\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/system/debug/Watch.as",
    "content": "package org.flixel.system.debug\n{\n\timport flash.display.Sprite;\n\timport flash.geom.Rectangle;\n\timport flash.text.TextField;\n\timport flash.text.TextFormat;\n\t\n\timport org.flixel.FlxU;\n\timport org.flixel.system.FlxWindow;\n\t\n\t/**\n\t * A Visual Studio-style \"watch\" window, for use in the debugger overlay.\n\t * Track the values of any public variable in real-time, and/or edit their values on the fly.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class Watch extends FlxWindow\n\t{\n\t\tstatic protected const MAX_LOG_LINES:uint = 1024;\n\t\tstatic protected const LINE_HEIGHT:uint = 15;\n\t\t\n\t\t/**\n\t\t * Whether a watch entry is currently being edited or not. \n\t\t */\t\t\n\t\tpublic var editing:Boolean;\n\t\t\n\t\tprotected var _names:Sprite;\n\t\tprotected var _values:Sprite;\n\t\tprotected var _watching:Array;\n\t\t\n\t\t/**\n\t\t * Creates a new window object.  This Flash-based class is mainly (only?) used by <code>FlxDebugger</code>.\n\t\t * \n\t\t * @param Title\t\t\tThe name of the window, displayed in the header bar.\n\t\t * @param Width\t\t\tThe initial width of the window.\n\t\t * @param Height\t\tThe initial height of the window.\n\t\t * @param Resizable\t\tWhether you can change the size of the window with a drag handle.\n\t\t * @param Bounds\t\tA rectangle indicating the valid screen area for the window.\n\t\t * @param BGColor\t\tWhat color the window background should be, default is gray and transparent.\n\t\t * @param TopColor\t\tWhat color the window header bar should be, default is black and transparent.\n\t\t */\n\t\tpublic function Watch(Title:String, Width:Number, Height:Number, Resizable:Boolean=true, Bounds:Rectangle=null, BGColor:uint=0x7f7f7f7f, TopColor:uint=0x7f000000)\n\t\t{\n\t\t\tsuper(Title, Width, Height, Resizable, Bounds, BGColor, TopColor);\n\t\t\t\n\t\t\t_names = new Sprite();\n\t\t\t_names.x = 2;\n\t\t\t_names.y = 15;\n\t\t\taddChild(_names);\n\n\t\t\t_values = new Sprite();\n\t\t\t_values.x = 2;\n\t\t\t_values.y = 15;\n\t\t\taddChild(_values);\n\t\t\t\n\t\t\t_watching = new Array();\n\t\t\t\n\t\t\tediting = false;\n\t\t\t\n\t\t\tremoveAll();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tremoveChild(_names);\n\t\t\t_names = null;\n\t\t\tremoveChild(_values);\n\t\t\t_values = null;\n\t\t\tvar i:int = 0;\n\t\t\tvar l:uint = _watching.length;\n\t\t\twhile(i < l)\n\t\t\t\t(_watching[i++] as WatchEntry).destroy();\n\t\t\t_watching = null;\n\t\t\tsuper.destroy();\n\t\t}\n\n\t\t/**\n\t\t * Add a new variable to the watch window.\n\t\t * Has some simple code in place to prevent\n\t\t * accidentally watching the same variable twice.\n\t\t * \n\t\t * @param AnyObject\t\tThe <code>Object</code> containing the variable you want to track, e.g. this or Player.velocity.\n\t\t * @param VariableName\tThe <code>String</code> name of the variable you want to track, e.g. \"width\" or \"x\".\n\t\t * @param DisplayName\tOptional <code>String</code> that can be displayed in the watch window instead of the basic class-name information.\n\t\t */\n\t\tpublic function add(AnyObject:Object,VariableName:String,DisplayName:String=null):void\n\t\t{\n\t\t\t//Don't add repeats\n\t\t\tvar watchEntry:WatchEntry;\n\t\t\tvar i:int = 0;\n\t\t\tvar l:uint = _watching.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\twatchEntry = _watching[i++] as WatchEntry;\n\t\t\t\tif((watchEntry.object == AnyObject) && (watchEntry.field == VariableName))\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//Good, no repeats, add away!\n\t\t\twatchEntry = new WatchEntry(_watching.length*LINE_HEIGHT,_width/2,_width/2-10,AnyObject,VariableName,DisplayName);\n\t\t\t_names.addChild(watchEntry.nameDisplay);\n\t\t\t_values.addChild(watchEntry.valueDisplay);\n\t\t\t_watching.push(watchEntry);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Remove a variable from the watch window.\n\t\t * \n\t\t * @param AnyObject\t\tThe <code>Object</code> containing the variable you want to remove, e.g. this or Player.velocity.\n\t\t * @param VariableName\tThe <code>String</code> name of the variable you want to remove, e.g. \"width\" or \"x\".  If left null, this will remove all variables of that object. \n\t\t */\n\t\tpublic function remove(AnyObject:Object,VariableName:String=null):void\n\t\t{\n\t\t\t//splice out the requested object\n\t\t\tvar watchEntry:WatchEntry;\n\t\t\tvar i:int = _watching.length-1;\n\t\t\twhile(i >= 0)\n\t\t\t{\n\t\t\t\twatchEntry = _watching[i];\n\t\t\t\tif((watchEntry.object == AnyObject) && ((VariableName == null) || (watchEntry.field == VariableName)))\n\t\t\t\t{\n\t\t\t\t\t_watching.splice(i,1);\n\t\t\t\t\t_names.removeChild(watchEntry.nameDisplay);\n\t\t\t\t\t_values.removeChild(watchEntry.valueDisplay);\n\t\t\t\t\twatchEntry.destroy();\n\t\t\t\t}\n\t\t\t\ti--;\n\t\t\t}\n\t\t\twatchEntry = null;\n\t\t\t\n\t\t\t//reset the display heights of the remaining objects\n\t\t\ti = 0;\n\t\t\tvar l:uint = _watching.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\t(_watching[i] as WatchEntry).setY(i*LINE_HEIGHT);\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Remove everything from the watch window.\n\t\t */\n\t\tpublic function removeAll():void\n\t\t{\n\t\t\tvar watchEntry:WatchEntry;\n\t\t\tvar i:int = 0;\n\t\t\tvar l:uint = _watching.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\twatchEntry = _watching.pop();\n\t\t\t\t_names.removeChild(watchEntry.nameDisplay);\n\t\t\t\t_values.removeChild(watchEntry.valueDisplay);\n\t\t\t\twatchEntry.destroy();\n\t\t\t\ti++\n\t\t\t}\n\t\t\t_watching.length = 0;\n\t\t}\n\n\t\t/**\n\t\t * Update all the entries in the watch window.\n\t\t */\n\t\tpublic function update():void\n\t\t{\n\t\t\tediting = false;\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = _watching.length;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\tif(!(_watching[i++] as WatchEntry).updateValue())\n\t\t\t\t\tediting = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Force any watch entries currently being edited to submit their changes.\n\t\t */\n\t\tpublic function submit():void\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = _watching.length;\n\t\t\tvar watchEntry:WatchEntry;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\twatchEntry = _watching[i++] as WatchEntry;\n\t\t\t\tif(watchEntry.editing)\n\t\t\t\t\twatchEntry.submit();\n\t\t\t}\n\t\t\tediting = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Update the Flash shapes to match the new size, and reposition the header, shadow, and handle accordingly.\n\t\t * Also adjusts the width of the entries and stuff, and makes sure there is room for all the entries.\n\t\t */\n\t\toverride protected function updateSize():void\n\t\t{\n\t\t\tif(_height < _watching.length*LINE_HEIGHT + 17)\n\t\t\t\t_height = _watching.length*LINE_HEIGHT + 17;\n\n\t\t\tsuper.updateSize();\n\n\t\t\t_values.x = _width/2 + 2;\n\n\t\t\tvar i:int = 0;\n\t\t\tvar l:uint = _watching.length;\n\t\t\twhile(i < l)\n\t\t\t\t(_watching[i++] as WatchEntry).updateWidth(_width/2,_width/2-10);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/system/debug/WatchEntry.as",
    "content": "package org.flixel.system.debug\n{\n\timport flash.events.KeyboardEvent;\n\timport flash.events.MouseEvent;\n\timport flash.text.TextField;\n\timport flash.text.TextFieldType;\n\timport flash.text.TextFormat;\n\t\n\timport org.flixel.FlxU;\n\n\t/**\n\t * Helper class for the debugger overlay's Watch window.\n\t * Handles the display and modification of game variables on the fly.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class WatchEntry\n\t{\n\t\t/**\n\t\t * The <code>Object</code> being watched.\n\t\t */\n\t\tpublic var object:Object;\n\t\t/**\n\t\t * The member variable of that object.\n\t\t */\n\t\tpublic var field:String;\n\t\t/**\n\t\t * A custom display name for this object, if there is any.\n\t\t */\n\t\tpublic var custom:String;\n\t\t/**\n\t\t * The Flash <code>TextField</code> object used to display this entry's name.\n\t\t */\n\t\tpublic var nameDisplay:TextField;\n\t\t/**\n\t\t * The Flash <code>TextField</code> object used to display and edit this entry's value.\n\t\t */\n\t\tpublic var valueDisplay:TextField;\n\t\t/**\n\t\t * Whether the entry is currently being edited or not.\n\t\t */\n\t\tpublic var editing:Boolean;\n\t\t/**\n\t\t * The value of the field before it was edited.\n\t\t */\n\t\tpublic var oldValue:Object;\n\t\t\n\t\tprotected var _whiteText:TextFormat;\n\t\tprotected var _blackText:TextFormat;\n\t\t\n\t\t/**\n\t\t * Creates a new watch entry in the watch window.\n\t\t * \n\t\t * @param Y\t\t\t\tThe initial height in the Watch window.\n\t\t * @param NameWidth\t\tThe initial width of the name field.\n\t\t * @param ValueWidth\tThe initial width of the value field.\n\t\t * @param Obj\t\t\tThe <code>Object</code> containing the variable we want to watch.\n\t\t * @param Field\t\t\tThe variable name we want to watch.\n\t\t * @param Custom\t\tA custom display name (optional).\n\t\t */\n\t\tpublic function WatchEntry(Y:Number,NameWidth:Number,ValueWidth:Number,Obj:Object,Field:String,Custom:String=null)\n\t\t{\n\t\t\tediting = false;\n\t\t\t\n\t\t\tobject = Obj;\n\t\t\tfield = Field;\n\t\t\tcustom = Custom;\n\t\t\t\n\t\t\t_whiteText = new TextFormat(\"Courier\",12,0xffffff);\n\t\t\t_blackText = new TextFormat(\"Courier\",12,0);\n\t\t\t\n\t\t\tnameDisplay = new TextField();\n\t\t\tnameDisplay.y = Y;\n\t\t\tnameDisplay.multiline = false;\n\t\t\tnameDisplay.selectable = true;\n\t\t\tnameDisplay.defaultTextFormat = _whiteText;\n\t\t\t\n\t\t\tvalueDisplay = new TextField();\n\t\t\tvalueDisplay.y = Y;\n\t\t\tvalueDisplay.height = 15;\n\t\t\tvalueDisplay.multiline = false;\n\t\t\tvalueDisplay.selectable = true;\n\t\t\tvalueDisplay.doubleClickEnabled = true;\n\t\t\tvalueDisplay.addEventListener(KeyboardEvent.KEY_UP,handleKeyUp);\n\t\t\tvalueDisplay.addEventListener(MouseEvent.MOUSE_UP,handleMouseUp);\n\t\t\tvalueDisplay.background = false;\n\t\t\tvalueDisplay.backgroundColor = 0xffffff;\n\t\t\tvalueDisplay.defaultTextFormat = _whiteText;\n\t\t\t\n\t\t\tupdateWidth(NameWidth,ValueWidth);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\tobject = null;\n\t\t\toldValue = null;\n\t\t\tnameDisplay = null;\n\t\t\tfield = null;\n\t\t\tcustom = null;\n\t\t\tvalueDisplay.removeEventListener(MouseEvent.MOUSE_UP,handleMouseUp);\n\t\t\tvalueDisplay.removeEventListener(KeyboardEvent.KEY_UP,handleKeyUp);\n\t\t\tvalueDisplay = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the watch window Y height of the Flash <code>TextField</code> objects.\n\t\t */\n\t\tpublic function setY(Y:Number):void\n\t\t{\n\t\t\tnameDisplay.y = Y;\n\t\t\tvalueDisplay.y = Y;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adjust the width of the Flash <code>TextField</code> objects.\n\t\t */\n\t\tpublic function updateWidth(NameWidth:Number,ValueWidth:Number):void\n\t\t{\n\t\t\tnameDisplay.width = NameWidth;\n\t\t\tvalueDisplay.width = ValueWidth;\n\t\t\tif(custom != null)\n\t\t\t\tnameDisplay.text = custom;\n\t\t\telse\n\t\t\t{\n\t\t\t\tnameDisplay.text = \"\";\n\t\t\t\tif(NameWidth > 120)\n\t\t\t\t\tnameDisplay.appendText(FlxU.getClassName(object,(NameWidth < 240)) + \".\");\n\t\t\t\tnameDisplay.appendText(field);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Update the variable value on display with the current in-game value.\n\t\t */\n\t\tpublic function updateValue():Boolean\n\t\t{\n\t\t\tif(editing)\n\t\t\t\treturn false;\n\t\t\tvalueDisplay.text = object[field].toString();\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * A watch entry was clicked, so flip into edit mode for that entry.\n\t\t * \n\t\t * @param\tFlashEvent\tFlash mouse event.\n\t\t */\n\t\tpublic function handleMouseUp(FlashEvent:MouseEvent):void\n\t\t{\n\t\t\tediting = true;\n\t\t\toldValue = object[field];\n\t\t\tvalueDisplay.type = TextFieldType.INPUT;\n\t\t\tvalueDisplay.setTextFormat(_blackText);\n\t\t\tvalueDisplay.background = true;\n\t\t\t\n\t\t}\n\t\t\n\t\t/**\n\t\t * Check to see if Enter, Tab or Escape were just released.\n\t\t * Enter or Tab submit the change, and Escape cancels it.\n\t\t * \n\t\t * @param\tFlashEvent\tFlash keyboard event.\n\t\t */\n\t\tpublic function handleKeyUp(FlashEvent:KeyboardEvent):void\n\t\t{\n\t\t\tif((FlashEvent.keyCode == 13) || (FlashEvent.keyCode == 9) || (FlashEvent.keyCode == 27)) //enter or tab or escape\n\t\t\t{\n\t\t\t\tif(FlashEvent.keyCode == 27)\n\t\t\t\t\tcancel();\n\t\t\t\telse\n\t\t\t\t\tsubmit();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Cancel the current edits and stop editing.\n\t\t */\n\t\tpublic function cancel():void\n\t\t{\n\t\t\tvalueDisplay.text = oldValue.toString();\n\t\t\tdoneEditing();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Submit the current edits and stop editing.\n\t\t */\n\t\tpublic function submit():void\n\t\t{\n\t\t\tobject[field] = valueDisplay.text;\n\t\t\tdoneEditing();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Helper function, switches the text field back to display mode.\n\t\t */\n\t\tprotected function doneEditing():void\n\t\t{\n\t\t\tvalueDisplay.type = TextFieldType.DYNAMIC;\n\t\t\tvalueDisplay.setTextFormat(_whiteText);\n\t\t\tvalueDisplay.defaultTextFormat = _whiteText;\n\t\t\tvalueDisplay.background = false;\n\t\t\tediting = false;\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/system/input/Input.as",
    "content": "package org.flixel.system.input\n{\n\t/**\n\t * Basic input class that manages the fast-access Booleans and detailed key-state tracking.\n\t * Keyboard extends this with actual specific key data.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class Input\n\t{\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tinternal var _lookup:Object;\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tinternal var _map:Array;\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tinternal const _total:uint = 256;\n\t\t\n\t\t/**\n\t\t * Constructor\n\t\t */\n\t\tpublic function Input()\n\t\t{\n\t\t\t_lookup = new Object();\n\t\t\t_map = new Array(_total);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Updates the key states (for tracking just pressed, just released, etc).\n\t\t */\n\t\tpublic function update():void\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < _total)\n\t\t\t{\n\t\t\t\tvar o:Object = _map[i++];\n\t\t\t\tif(o == null) continue;\n\t\t\t\tif((o.last == -1) && (o.current == -1)) o.current = 0;\n\t\t\t\telse if((o.last == 2) && (o.current == 2)) o.current = 1;\n\t\t\t\to.last = o.current;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Resets all the keys.\n\t\t */\n\t\tpublic function reset():void\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < _total)\n\t\t\t{\n\t\t\t\tvar o:Object = _map[i++];\n\t\t\t\tif(o == null) continue;\n\t\t\t\tthis[o.name] = false;\n\t\t\t\to.current = 0;\n\t\t\t\to.last = 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Check to see if this key is pressed.\n\t\t * \n\t\t * @param\tKey\t\tOne of the key constants listed above (e.g. \"LEFT\" or \"A\").\n\t\t * \n\t\t * @return\tWhether the key is pressed\n\t\t */\n\t\tpublic function pressed(Key:String):Boolean { return this[Key]; }\n\t\t\n\t\t/**\n\t\t * Check to see if this key was just pressed.\n\t\t * \n\t\t * @param\tKey\t\tOne of the key constants listed above (e.g. \"LEFT\" or \"A\").\n\t\t * \n\t\t * @return\tWhether the key was just pressed\n\t\t */\n\t\tpublic function justPressed(Key:String):Boolean { return _map[_lookup[Key]].current == 2; }\n\t\t\n\t\t/**\n\t\t * Check to see if this key is just released.\n\t\t * \n\t\t * @param\tKey\t\tOne of the key constants listed above (e.g. \"LEFT\" or \"A\").\n\t\t * \n\t\t * @return\tWhether the key is just released.\n\t\t */\n\t\tpublic function justReleased(Key:String):Boolean { return _map[_lookup[Key]].current == -1; }\n\t\t\n\t\t/**\n\t\t * If any keys are not \"released\" (0),\n\t\t * this function will return an array indicating\n\t\t * which keys are pressed and what state they are in.\n\t\t * \n\t\t * @return\tAn array of key state data.  Null if there is no data.\n\t\t */\n\t\tpublic function record():Array\n\t\t{\n\t\t\tvar data:Array = null;\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < _total)\n\t\t\t{\n\t\t\t\tvar o:Object = _map[i++];\n\t\t\t\tif((o == null) || (o.current == 0))\n\t\t\t\t\tcontinue;\n\t\t\t\tif(data == null)\n\t\t\t\t\tdata = new Array();\n\t\t\t\tdata.push({code:i-1,value:o.current});\n\t\t\t}\n\t\t\treturn data;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Part of the keystroke recording system.\n\t\t * Takes data about key presses and sets it into array.\n\t\t * \n\t\t * @param\tRecord\tArray of data about key states.\n\t\t */\n\t\tpublic function playback(Record:Array):void\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\tvar l:uint = Record.length;\n\t\t\tvar o:Object;\n\t\t\tvar o2:Object;\n\t\t\twhile(i < l)\n\t\t\t{\n\t\t\t\to = Record[i++];\n\t\t\t\to2 = _map[o.code];\n\t\t\t\to2.current = o.value;\n\t\t\t\tif(o.value > 0)\n\t\t\t\t\tthis[o2.name] = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Look up the key code for any given string name of the key or button.\n\t\t * \n\t\t * @param\tKeyName\t\tThe <code>String</code> name of the key.\n\t\t * \n\t\t * @return\tThe key code for that key.\n\t\t */\n\t\tpublic function getKeyCode(KeyName:String):int\n\t\t{\n\t\t\treturn _lookup[KeyName];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Check to see if any keys are pressed right now.\n\t\t * \n\t\t * @return\tWhether any keys are currently pressed.\n\t\t */\n\t\tpublic function any():Boolean\n\t\t{\n\t\t\tvar i:uint = 0;\n\t\t\twhile(i < _total)\n\t\t\t{\n\t\t\t\tvar o:Object = _map[i++];\n\t\t\t\tif((o != null) && (o.current > 0))\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * An internal helper function used to build the key array.\n\t\t * \n\t\t * @param\tKeyName\t\tString name of the key (e.g. \"LEFT\" or \"A\")\n\t\t * @param\tKeyCode\t\tThe numeric Flash code for this key.\n\t\t */\n\t\tprotected function addKey(KeyName:String,KeyCode:uint):void\n\t\t{\n\t\t\t_lookup[KeyName] = KeyCode;\n\t\t\t_map[KeyCode] = { name: KeyName, current: 0, last: 0 };\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\t_lookup = null;\n\t\t\t_map = null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/system/input/Keyboard.as",
    "content": "package org.flixel.system.input\n{\n\timport flash.events.KeyboardEvent;\n\t\n\t/**\n\t * Keeps track of what keys are pressed and how with handy booleans or strings.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class Keyboard extends Input\n\t{\n\t\tpublic var ESCAPE:Boolean;\n\t\tpublic var F1:Boolean;\n\t\tpublic var F2:Boolean;\n\t\tpublic var F3:Boolean;\n\t\tpublic var F4:Boolean;\n\t\tpublic var F5:Boolean;\n\t\tpublic var F6:Boolean;\n\t\tpublic var F7:Boolean;\n\t\tpublic var F8:Boolean;\n\t\tpublic var F9:Boolean;\n\t\tpublic var F10:Boolean;\n\t\tpublic var F11:Boolean;\n\t\tpublic var F12:Boolean;\n\t\tpublic var ONE:Boolean;\n\t\tpublic var TWO:Boolean;\n\t\tpublic var THREE:Boolean;\n\t\tpublic var FOUR:Boolean;\n\t\tpublic var FIVE:Boolean;\n\t\tpublic var SIX:Boolean;\n\t\tpublic var SEVEN:Boolean;\n\t\tpublic var EIGHT:Boolean;\n\t\tpublic var NINE:Boolean;\n\t\tpublic var ZERO:Boolean;\n\t\tpublic var NUMPADONE:Boolean;\n\t\tpublic var NUMPADTWO:Boolean;\n\t\tpublic var NUMPADTHREE:Boolean;\n\t\tpublic var NUMPADFOUR:Boolean;\n\t\tpublic var NUMPADFIVE:Boolean;\n\t\tpublic var NUMPADSIX:Boolean;\n\t\tpublic var NUMPADSEVEN:Boolean;\n\t\tpublic var NUMPADEIGHT:Boolean;\n\t\tpublic var NUMPADNINE:Boolean;\n\t\tpublic var NUMPADZERO:Boolean;\n\t\tpublic var PAGEUP:Boolean;\n\t\tpublic var PAGEDOWN:Boolean;\n\t\tpublic var HOME:Boolean;\n\t\tpublic var END:Boolean;\n\t\tpublic var INSERT:Boolean;\n\t\tpublic var MINUS:Boolean;\n\t\tpublic var NUMPADMINUS:Boolean;\n\t\tpublic var PLUS:Boolean;\n\t\tpublic var NUMPADPLUS:Boolean;\n\t\tpublic var DELETE:Boolean;\n\t\tpublic var BACKSPACE:Boolean;\n\t\tpublic var TAB:Boolean;\n\t\tpublic var Q:Boolean;\n\t\tpublic var W:Boolean;\n\t\tpublic var E:Boolean;\n\t\tpublic var R:Boolean;\n\t\tpublic var T:Boolean;\n\t\tpublic var Y:Boolean;\n\t\tpublic var U:Boolean;\n\t\tpublic var I:Boolean;\n\t\tpublic var O:Boolean;\n\t\tpublic var P:Boolean;\n\t\tpublic var LBRACKET:Boolean;\n\t\tpublic var RBRACKET:Boolean;\n\t\tpublic var BACKSLASH:Boolean;\n\t\tpublic var CAPSLOCK:Boolean;\n\t\tpublic var A:Boolean;\n\t\tpublic var S:Boolean;\n\t\tpublic var D:Boolean;\n\t\tpublic var F:Boolean;\n\t\tpublic var G:Boolean;\n\t\tpublic var H:Boolean;\n\t\tpublic var J:Boolean;\n\t\tpublic var K:Boolean;\n\t\tpublic var L:Boolean;\n\t\tpublic var SEMICOLON:Boolean;\n\t\tpublic var QUOTE:Boolean;\n\t\tpublic var ENTER:Boolean;\n\t\tpublic var SHIFT:Boolean;\n\t\tpublic var Z:Boolean;\n\t\tpublic var X:Boolean;\n\t\tpublic var C:Boolean;\n\t\tpublic var V:Boolean;\n\t\tpublic var B:Boolean;\n\t\tpublic var N:Boolean;\n\t\tpublic var M:Boolean;\n\t\tpublic var COMMA:Boolean;\n\t\tpublic var PERIOD:Boolean;\n\t\tpublic var NUMPADPERIOD:Boolean;\n\t\tpublic var SLASH:Boolean;\n\t\tpublic var NUMPADSLASH:Boolean;\n\t\tpublic var CONTROL:Boolean;\n\t\tpublic var ALT:Boolean;\n\t\tpublic var SPACE:Boolean;\n\t\tpublic var UP:Boolean;\n\t\tpublic var DOWN:Boolean;\n\t\tpublic var LEFT:Boolean;\n\t\tpublic var RIGHT:Boolean;\n\n\t\tpublic function Keyboard()\n\t\t{\n\t\t\tvar i:uint;\n\t\t\t\n\t\t\t//LETTERS\n\t\t\ti = 65;\n\t\t\twhile(i <= 90)\n\t\t\t\taddKey(String.fromCharCode(i),i++);\n\t\t\t\n\t\t\t//NUMBERS\n\t\t\ti = 48;\n\t\t\taddKey(\"ZERO\",i++);\n\t\t\taddKey(\"ONE\",i++);\n\t\t\taddKey(\"TWO\",i++);\n\t\t\taddKey(\"THREE\",i++);\n\t\t\taddKey(\"FOUR\",i++);\n\t\t\taddKey(\"FIVE\",i++);\n\t\t\taddKey(\"SIX\",i++);\n\t\t\taddKey(\"SEVEN\",i++);\n\t\t\taddKey(\"EIGHT\",i++);\n\t\t\taddKey(\"NINE\",i++);\n\t\t\ti = 96;\n\t\t\taddKey(\"NUMPADZERO\",i++);\n\t\t\taddKey(\"NUMPADONE\",i++);\n\t\t\taddKey(\"NUMPADTWO\",i++);\n\t\t\taddKey(\"NUMPADTHREE\",i++);\n\t\t\taddKey(\"NUMPADFOUR\",i++);\n\t\t\taddKey(\"NUMPADFIVE\",i++);\n\t\t\taddKey(\"NUMPADSIX\",i++);\n\t\t\taddKey(\"NUMPADSEVEN\",i++);\n\t\t\taddKey(\"NUMPADEIGHT\",i++);\n\t\t\taddKey(\"NUMPADNINE\",i++);\n\t\t\taddKey(\"PAGEUP\", 33);\n\t\t\taddKey(\"PAGEDOWN\", 34);\n\t\t\taddKey(\"HOME\", 36);\n\t\t\taddKey(\"END\", 35);\n\t\t\taddKey(\"INSERT\", 45);\n\t\t\t\n\t\t\t//FUNCTION KEYS\n\t\t\ti = 1;\n\t\t\twhile(i <= 12)\n\t\t\t\taddKey(\"F\"+i,111+(i++));\n\t\t\t\n\t\t\t//SPECIAL KEYS + PUNCTUATION\n\t\t\taddKey(\"ESCAPE\",27);\n\t\t\taddKey(\"MINUS\",189);\n\t\t\taddKey(\"NUMPADMINUS\",109);\n\t\t\taddKey(\"PLUS\",187);\n\t\t\taddKey(\"NUMPADPLUS\",107);\n\t\t\taddKey(\"DELETE\",46);\n\t\t\taddKey(\"BACKSPACE\",8);\n\t\t\taddKey(\"LBRACKET\",219);\n\t\t\taddKey(\"RBRACKET\",221);\n\t\t\taddKey(\"BACKSLASH\",220);\n\t\t\taddKey(\"CAPSLOCK\",20);\n\t\t\taddKey(\"SEMICOLON\",186);\n\t\t\taddKey(\"QUOTE\",222);\n\t\t\taddKey(\"ENTER\",13);\n\t\t\taddKey(\"SHIFT\",16);\n\t\t\taddKey(\"COMMA\",188);\n\t\t\taddKey(\"PERIOD\",190);\n\t\t\taddKey(\"NUMPADPERIOD\",110);\n\t\t\taddKey(\"SLASH\",191);\n\t\t\taddKey(\"NUMPADSLASH\",191);\n\t\t\taddKey(\"CONTROL\",17);\n\t\t\taddKey(\"ALT\",18);\n\t\t\taddKey(\"SPACE\",32);\n\t\t\taddKey(\"UP\",38);\n\t\t\taddKey(\"DOWN\",40);\n\t\t\taddKey(\"LEFT\",37);\n\t\t\taddKey(\"RIGHT\",39);\n\t\t\taddKey(\"TAB\",9);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Event handler so FlxGame can toggle keys.\n\t\t * \n\t\t * @param\tFlashEvent\tA <code>KeyboardEvent</code> object.\n\t\t */\n\t\tpublic function handleKeyDown(FlashEvent:KeyboardEvent):void\n\t\t{\n\t\t\tvar object:Object = _map[FlashEvent.keyCode];\n\t\t\tif(object == null) return;\n\t\t\tif(object.current > 0) object.current = 1;\n\t\t\telse object.current = 2;\n\t\t\tthis[object.name] = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Event handler so FlxGame can toggle keys.\n\t\t * \n\t\t * @param\tFlashEvent\tA <code>KeyboardEvent</code> object.\n\t\t */\n\t\tpublic function handleKeyUp(FlashEvent:KeyboardEvent):void\n\t\t{\n\t\t\tvar object:Object = _map[FlashEvent.keyCode];\n\t\t\tif(object == null) return;\n\t\t\tif(object.current > 0) object.current = -1;\n\t\t\telse object.current = 0;\n\t\t\tthis[object.name] = false;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/system/input/Mouse.as",
    "content": "package org.flixel.system.input\n{\n\timport flash.display.Bitmap;\n\timport flash.display.Sprite;\n\timport flash.events.MouseEvent;\n\t\n\timport org.flixel.FlxCamera;\n\timport org.flixel.FlxG;\n\timport org.flixel.FlxPoint;\n\timport org.flixel.FlxSprite;\n\timport org.flixel.FlxU;\n\timport org.flixel.system.replay.MouseRecord;\n\t\n\t/**\n\t * This class helps contain and track the mouse pointer in your game.\n\t * Automatically accounts for parallax scrolling, etc.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class Mouse extends FlxPoint\n\t{\n\t\t[Embed(source=\"../../data/cursor.png\")] protected var ImgDefaultCursor:Class;\n\n\t\t/**\n\t\t * Current \"delta\" value of mouse wheel.  If the wheel was just scrolled up, it will have a positive value.  If it was just scrolled down, it will have a negative value.  If it wasn't just scroll this frame, it will be 0.\n\t\t */\n\t\tpublic var wheel:int;\n\t\t/**\n\t\t * Current X position of the mouse pointer on the screen.\n\t\t */\n\t\tpublic var screenX:int;\n\t\t/**\n\t\t * Current Y position of the mouse pointer on the screen.\n\t\t */\n\t\tpublic var screenY:int;\n\t\t\n\t\t/**\n\t\t * Helper variable for tracking whether the mouse was just pressed or just released.\n\t\t */\n\t\tprotected var _current:int;\n\t\t/**\n\t\t * Helper variable for tracking whether the mouse was just pressed or just released.\n\t\t */\n\t\tprotected var _last:int;\n\t\t/**\n\t\t * A display container for the mouse cursor.\n\t\t * This container is a child of FlxGame and sits at the right \"height\".\n\t\t */\n\t\tprotected var _cursorContainer:Sprite;\n\t\t/**\n\t\t * This is just a reference to the current cursor image, if there is one.\n\t\t */\n\t\tprotected var _cursor:Bitmap;\n\t\t/**\n\t\t * Helper variables for recording purposes.\n\t\t */\n\t\tprotected var _lastX:int;\n\t\tprotected var _lastY:int;\n\t\tprotected var _lastWheel:int;\n\t\tprotected var _point:FlxPoint;\n\t\tprotected var _globalScreenPosition:FlxPoint;\n\t\t\n\t\t/**\n\t\t * Constructor.\n\t\t */\n\t\tpublic function Mouse(CursorContainer:Sprite)\n\t\t{\n\t\t\tsuper();\n\t\t\t_cursorContainer = CursorContainer;\n\t\t\t_lastX = screenX = 0;\n\t\t\t_lastY = screenY = 0;\n\t\t\t_lastWheel = wheel = 0;\n\t\t\t_current = 0;\n\t\t\t_last = 0;\n\t\t\t_cursor = null;\n\t\t\t_point = new FlxPoint();\n\t\t\t_globalScreenPosition = new FlxPoint();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\t_cursorContainer = null;\n\t\t\t_cursor = null;\n\t\t\t_point = null;\n\t\t\t_globalScreenPosition = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Either show an existing cursor or load a new one.\n\t\t * \n\t\t * @param\tGraphic\t\tThe image you want to use for the cursor.\n\t\t * @param\tScale\t\tChange the size of the cursor.  Default = 1, or native size.  2 = 2x as big, 0.5 = half size, etc.\n\t\t * @param\tXOffset\t\tThe number of pixels between the mouse's screen position and the graphic's top left corner.\n\t\t * @param\tYOffset\t\tThe number of pixels between the mouse's screen position and the graphic's top left corner. \n\t\t */\n\t\tpublic function show(Graphic:Class=null,Scale:Number=1,XOffset:int=0,YOffset:int=0):void\n\t\t{\n\t\t\t_cursorContainer.visible = true;\n\t\t\tif(Graphic != null)\n\t\t\t\tload(Graphic,Scale,XOffset,YOffset);\n\t\t\telse if(_cursor == null)\n\t\t\t\tload();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Hides the mouse cursor\n\t\t */\n\t\tpublic function hide():void\n\t\t{\n\t\t\t_cursorContainer.visible = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Read only, check visibility of mouse cursor.\n\t\t */\n\t\tpublic function get visible():Boolean\n\t\t{\n\t\t\treturn _cursorContainer.visible;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Load a new mouse cursor graphic\n\t\t * \n\t\t * @param\tGraphic\t\tThe image you want to use for the cursor.\n\t\t * @param\tScale\t\tChange the size of the cursor.\n\t\t * @param\tXOffset\t\tThe number of pixels between the mouse's screen position and the graphic's top left corner.\n\t\t * @param\tYOffset\t\tThe number of pixels between the mouse's screen position and the graphic's top left corner. \n\t\t */\n\t\tpublic function load(Graphic:Class=null,Scale:Number=1,XOffset:int=0,YOffset:int=0):void\n\t\t{\n\t\t\tif(_cursor != null)\n\t\t\t\t_cursorContainer.removeChild(_cursor);\n\n\t\t\tif(Graphic == null)\n\t\t\t\tGraphic = ImgDefaultCursor;\n\t\t\t_cursor = new Graphic();\n\t\t\t_cursor.x = XOffset;\n\t\t\t_cursor.y = YOffset;\n\t\t\t_cursor.scaleX = Scale;\n\t\t\t_cursor.scaleY = Scale;\n\t\t\t\n\t\t\t_cursorContainer.addChild(_cursor);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Unload the current cursor graphic.  If the current cursor is visible,\n\t\t * then the default system cursor is loaded up to replace the old one.\n\t\t */\n\t\tpublic function unload():void\n\t\t{\n\t\t\tif(_cursor != null)\n\t\t\t{\n\t\t\t\tif(_cursorContainer.visible)\n\t\t\t\t\tload();\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_cursorContainer.removeChild(_cursor)\n\t\t\t\t\t_cursor = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Called by the internal game loop to update the mouse pointer's position in the game world.\n\t\t * Also updates the just pressed/just released flags.\n\t\t * \n\t\t * @param\tX\t\t\tThe current X position of the mouse in the window.\n\t\t * @param\tY\t\t\tThe current Y position of the mouse in the window.\n\t\t * @param\tXScroll\t\tThe amount the game world has scrolled horizontally.\n\t\t * @param\tYScroll\t\tThe amount the game world has scrolled vertically.\n\t\t */\n\t\tpublic function update(X:int,Y:int):void\n\t\t{\n\t\t\t_globalScreenPosition.x = X;\n\t\t\t_globalScreenPosition.y = Y;\n\t\t\tupdateCursor();\n\t\t\tif((_last == -1) && (_current == -1))\n\t\t\t\t_current = 0;\n\t\t\telse if((_last == 2) && (_current == 2))\n\t\t\t\t_current = 1;\n\t\t\t_last = _current;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function for helping to update the mouse cursor and world coordinates.\n\t\t */\n\t\tprotected function updateCursor():void\n\t\t{\n\t\t\t//actually position the flixel mouse cursor graphic\n\t\t\t_cursorContainer.x = _globalScreenPosition.x;\n\t\t\t_cursorContainer.y = _globalScreenPosition.y;\n\t\t\t\n\t\t\t//update the x, y, screenX, and screenY variables based on the default camera.\n\t\t\t//This is basically a combination of getWorldPosition() and getScreenPosition()\n\t\t\tvar camera:FlxCamera = FlxG.camera;\n\t\t\tscreenX = (_globalScreenPosition.x - camera.x)/camera.zoom;\n\t\t\tscreenY = (_globalScreenPosition.y - camera.y)/camera.zoom;\n\t\t\tx = screenX + camera.scroll.x;\n\t\t\ty = screenY + camera.scroll.y;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fetch the world position of the mouse on any given camera.\n\t\t * NOTE: Mouse.x and Mouse.y also store the world position of the mouse cursor on the main camera.\n\t\t * \n\t\t * @param Camera\tIf unspecified, first/main global camera is used instead.\n\t\t * @param Point\t\tAn existing point object to store the results (if you don't want a new one created). \n\t\t * \n\t\t * @return The mouse's location in world space.\n\t\t */\n\t\tpublic function getWorldPosition(Camera:FlxCamera=null,Point:FlxPoint=null):FlxPoint\n\t\t{\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\tif(Point == null)\n\t\t\t\tPoint = new FlxPoint();\n\t\t\tgetScreenPosition(Camera,_point);\n\t\t\tPoint.x = _point.x + Camera.scroll.x;\n\t\t\tPoint.y = _point.y + Camera.scroll.y;\n\t\t\treturn Point;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fetch the screen position of the mouse on any given camera.\n\t\t * NOTE: Mouse.screenX and Mouse.screenY also store the screen position of the mouse cursor on the main camera.\n\t\t * \n\t\t * @param Camera\tIf unspecified, first/main global camera is used instead.\n\t\t * @param Point\t\tAn existing point object to store the results (if you don't want a new one created). \n\t\t * \n\t\t * @return The mouse's location in screen space.\n\t\t */\n\t\tpublic function getScreenPosition(Camera:FlxCamera=null,Point:FlxPoint=null):FlxPoint\n\t\t{\n\t\t\tif(Camera == null)\n\t\t\t\tCamera = FlxG.camera;\n\t\t\tif(Point == null)\n\t\t\t\tPoint = new FlxPoint();\n\t\t\tPoint.x = (_globalScreenPosition.x - Camera.x)/Camera.zoom;\n\t\t\tPoint.y = (_globalScreenPosition.y - Camera.y)/Camera.zoom;\n\t\t\treturn Point;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Resets the just pressed/just released flags and sets mouse to not pressed.\n\t\t */\n\t\tpublic function reset():void\n\t\t{\n\t\t\t_current = 0;\n\t\t\t_last = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Check to see if the mouse is pressed.\n\t\t * \n\t\t * @return\tWhether the mouse is pressed.\n\t\t */\n\t\tpublic function pressed():Boolean { return _current > 0; }\n\t\t\n\t\t/**\n\t\t * Check to see if the mouse was just pressed.\n\t\t * \n\t\t * @return Whether the mouse was just pressed.\n\t\t */\n\t\tpublic function justPressed():Boolean { return _current == 2; }\n\t\t\n\t\t/**\n\t\t * Check to see if the mouse was just released.\n\t\t * \n\t\t * @return\tWhether the mouse was just released.\n\t\t */\n\t\tpublic function justReleased():Boolean { return _current == -1; }\n\t\t\n\t\t/**\n\t\t * Event handler so FlxGame can update the mouse.\n\t\t * \n\t\t * @param\tFlashEvent\tA <code>MouseEvent</code> object.\n\t\t */\n\t\tpublic function handleMouseDown(FlashEvent:MouseEvent):void\n\t\t{\n\t\t\tif(_current > 0) _current = 1;\n\t\t\telse _current = 2;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Event handler so FlxGame can update the mouse.\n\t\t * \n\t\t * @param\tFlashEvent\tA <code>MouseEvent</code> object.\n\t\t */\n\t\tpublic function handleMouseUp(FlashEvent:MouseEvent):void\n\t\t{\n\t\t\tif(_current > 0) _current = -1;\n\t\t\telse _current = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Event handler so FlxGame can update the mouse.\n\t\t * \n\t\t * @param\tFlashEvent\tA <code>MouseEvent</code> object.\n\t\t */\n\t\tpublic function handleMouseWheel(FlashEvent:MouseEvent):void\n\t\t{\n\t\t\twheel = FlashEvent.delta;\n\t\t}\n\t\t\n\t\t/**\n\t\t * If the mouse changed state or is pressed, return that info now\n\t\t * \n\t\t * @return\tAn array of key state data.  Null if there is no data.\n\t\t */\n\t\tpublic function record():MouseRecord\n\t\t{\n\t\t\tif((_lastX == _globalScreenPosition.x) && (_lastY == _globalScreenPosition.y) && (_current == 0) && (_lastWheel == wheel))\n\t\t\t\treturn null;\n\t\t\t_lastX = _globalScreenPosition.x;\n\t\t\t_lastY = _globalScreenPosition.y;\n\t\t\t_lastWheel = wheel;\n\t\t\treturn new MouseRecord(_lastX,_lastY,_current,_lastWheel);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Part of the keystroke recording system.\n\t\t * Takes data about key presses and sets it into array.\n\t\t * \n\t\t * @param\tKeyStates\tArray of data about key states.\n\t\t */\n\t\tpublic function playback(Record:MouseRecord):void\n\t\t{\n\t\t\t_current = Record.button;\n\t\t\twheel = Record.wheel;\n\t\t\t_globalScreenPosition.x = Record.x;\n\t\t\t_globalScreenPosition.y = Record.y;\n\t\t\tupdateCursor();\n\t\t}\n\t}\n}"
  },
  {
    "path": "org/flixel/system/replay/FrameRecord.as",
    "content": "package org.flixel.system.replay\n{\n\t\n\t/**\n\t * Helper class for the new replay system.  Represents all the game inputs for one \"frame\" or \"step\" of the game loop.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class FrameRecord\n\t{\n\t\t/**\n\t\t * Which frame of the game loop this record is from or for.\n\t\t */\n\t\tpublic var frame:int;\n\t\t/**\n\t\t * An array of simple integer pairs referring to what key is pressed, and what state its in.\n\t\t */\n\t\tpublic var keys:Array;\n\t\t/**\n\t\t * A container for the 4 mouse state integers.\n\t\t */\n\t\tpublic var mouse:MouseRecord;\n\t\t\n\t\t/**\n\t\t * Instantiate array new frame record.\n\t\t */\n\t\tpublic function FrameRecord()\n\t\t{\n\t\t\tframe = 0;\n\t\t\tkeys = null;\n\t\t\tmouse = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Load this frame record with input data from the input managers.\n\t\t * \n\t\t * @param Frame\t\tWhat frame it is.\n\t\t * @param Keys\t\tKeyboard data from the keyboard manager.\n\t\t * @param Mouse\t\tMouse data from the mouse manager.\n\t\t * \n\t\t * @return A reference to this <code>FrameRecord</code> object.\n\t\t * \n\t\t */\n\t\tpublic function create(Frame:Number,Keys:Array=null,Mouse:MouseRecord=null):FrameRecord\n\t\t{\n\t\t\tframe = Frame;\n\t\t\tkeys = Keys;\n\t\t\tmouse = Mouse;\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clean up memory.\n\t\t */\n\t\tpublic function destroy():void\n\t\t{\n\t\t\tkeys = null;\n\t\t\tmouse = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Save the frame record data to array simple ASCII string.\n\t\t * \n\t\t * @return\tA <code>String</code> object containing the relevant frame record data.\n\t\t */\n\t\tpublic function save():String\n\t\t{\n\t\t\tvar output:String = frame+\"k\";\n\t\t\t\n\t\t\tif(keys != null)\n\t\t\t{\n\t\t\t\tvar object:Object;\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar l:uint = keys.length;\n\t\t\t\twhile(i < l)\n\t\t\t\t{\n\t\t\t\t\tif(i > 0)\n\t\t\t\t\t\toutput += \",\";\n\t\t\t\t\tobject = keys[i++];\n\t\t\t\t\toutput += object.code+\":\"+object.value;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\toutput += \"m\";\n\t\t\tif(mouse != null)\n\t\t\t\toutput += mouse.x + \",\" + mouse.y + \",\" + mouse.button + \",\" + mouse.wheel;\n\t\t\t\n\t\t\treturn output;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Load the frame record data from array simple ASCII string.\n\t\t * \n\t\t * @param\tData\tA <code>String</code> object containing the relevant frame record data.\n\t\t */\n\t\tpublic function load(Data:String):FrameRecord\n\t\t{\n\t\t\tvar i:uint;\n\t\t\tvar l:uint;\n\t\t\t\n\t\t\t//get frame number\n\t\t\tvar array:Array = Data.split(\"k\");\n\t\t\tframe = int(array[0] as String);\n\t\t\t\n\t\t\t//split up keyboard and mouse data\n\t\t\tarray = (array[1] as String).split(\"m\");\n\t\t\tvar keyData:String = array[0];\n\t\t\tvar mouseData:String = array[1];\n\t\t\t\n\t\t\t//parse keyboard data\n\t\t\tif(keyData.length > 0)\n\t\t\t{\n\t\t\t\t//get keystroke data pairs\n\t\t\t\tarray = keyData.split(\",\");\n\t\t\t\t\n\t\t\t\t//go through each data pair and enter it into this frame's key state\n\t\t\t\tvar keyPair:Array;\n\t\t\t\ti = 0;\n\t\t\t\tl = array.length;\n\t\t\t\twhile(i < l)\n\t\t\t\t{\n\t\t\t\t\tkeyPair = (array[i++] as String).split(\":\");\n\t\t\t\t\tif(keyPair.length == 2)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(keys == null)\n\t\t\t\t\t\t\tkeys = new Array();\n\t\t\t\t\t\tkeys.push({code:int(keyPair[0] as String),value:int(keyPair[1] as String)});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//mouse data is just 4 integers, easy peezy\n\t\t\tif(mouseData.length > 0)\n\t\t\t{\n\t\t\t\tarray = mouseData.split(\",\");\n\t\t\t\tif(array.length >= 4)\n\t\t\t\t\tmouse = new MouseRecord(int(array[0] as String),int(array[1] as String),int(array[2] as String),int(array[3] as String));\n\t\t\t}\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "org/flixel/system/replay/MouseRecord.as",
    "content": "package org.flixel.system.replay\n{\n\t/**\n\t * A helper class for the frame records, part of the replay/demo/recording system.\n\t * \n\t * @author Adam Atomic\n\t */\n\tpublic class MouseRecord\n\t{\n\t\t/**\n\t\t * The main X value of the mouse in screen space.\n\t\t */\n\t\tpublic var x:int;\n\t\t/**\n\t\t * The main Y value of the mouse in screen space.\n\t\t */\n\t\tpublic var y:int;\n\t\t/**\n\t\t * The state of the left mouse button.\n\t\t */\n\t\tpublic var button:int;\n\t\t/**\n\t\t * The state of the mouse wheel.\n\t\t */\n\t\tpublic var wheel:int;\n\t\t\n\t\t/**\n\t\t * Instantiate a new mouse input record.\n\t\t *  \n\t\t * @param X\t\t\tThe main X value of the mouse in screen space.\n\t\t * @param Y\t\t\tThe main Y value of the mouse in screen space.\n\t\t * @param Button\tThe state of the left mouse button.\n\t\t * @param Wheel\t\tThe state of the mouse wheel.\n\t\t */\n\t\tpublic function MouseRecord(X:int,Y:int,Button:int,Wheel:int)\n\t\t{\n\t\t\tx = X;\n\t\t\ty = Y;\n\t\t\tbutton = Button;\n\t\t\twheel = Wheel;\n\t\t}\n\t}\n}"
  },
  {
    "path": "todo.txt",
    "content": "\n\nx +assets Player\nx +assets Grass eating animation\nx +assets Farmer\nx +assets Shovel/Build animation\nx +assets Rabbit w/ arrow\nx +assets Troll w/ crown\nx +assets Treeline\nx +assets Wall\nx +assets Hill\nx +assets Stakes\nx +assets Palisade\nx +assets Stone wall\nx +assets Strong stone wall\nx +assets Scaffolding\nx +assets Campfire\nx +assets Lanterns/Torches\nx +assets Fireflies\nx +assets Fog\nx +assets Castle \nx +assets Banner (1)\nx +assets Platform w/ stakes (2)\nx +assets Watchtower (2 + 1)\nx +assets Stone tower 2 + 2\nx +assets Castle (6)\nx +assets Farmland\nx +assets Shops\nx +assets Sun/Moon\nx +assets Fix shop graphic to be more clear\n  \nx +code Remove coin indicator when no money\nx +code Update cash sack at start\nx +code Replace castle walls \nx +code Wall decay\nx +code Wall guards\nx +code Menu\nx +code Coin destinations\nx +code Money Indicator\nx +code Rig ripple size to weather\nx +code Fix wonky weather\n\nx +code Make hunters on castle shoot faster\nx +code +assets sparkle effect in stead of flicker when get coin\nx +code big trolls shouldn't steal coins\nx +assets Tighten map\n+error checkWork: Cannot property on null reference\nx +visuals phase 20 too dark\nx +assets kindom border indicator\nx +balance phase 28 nothing happens\nx +balance phase 32 way too easy\nx +visuals phase 35 weather glitch\nx +balance phase 36 make longer/harder\nx +visuals phase 37 lower contrast\nx +visuals phase 40 glitch\nx +balance reduce troll cooldown\nx +visuals increase sparkle lifetime\n\nx +visuals weather glitch in phase 36\nx +visuals weather glitch in phase 40\nx +sound day music in phase 22 lasts too long\nx +sound day music in phase 27 clips too\nx +sound day music in phase 31 clips.\nx +sound day music clips in phase 35\nx +sound make sound for civ. getting hit by troll\nx +balance increase jumpheight from night 2. It's about halfway up the lowest wall now\nx +balance more trolls in phase 24\nx +balance trolls in phase 28 still don't scale walls\nx +balance wave in phase 36 is still pretty easy\nx +code check archer behavior, all seem to be guarding the right side.\nx +code check if walls are repaired\nx +code big trolls hitbox\nx +balance night 2 (green) too jumpy\nx +code castle coin indicator too high\n\nx +code cycle phase consists of final night, DAYPASTEL\n\nx +code fix jumping height\nx +code indicate low money\nx +code add some dust when building\nx +code text is broken\nx +code skip to night with progress\nx +code output progress\nx +asset duck/cower animation for beggars\nx +code buy indicator appears further to middle than it disappears, also, it disappears when buying\nx +code max rate for farmland\nx +balance day 5 should last a little longer\nx +balance day 6 should last a little longer too\nx +balance trolls should spread out a little more\nx +code walls should look broken sooner, have a little more health\nx +code resume from last daybreak with a nice fx\nx +code wall damage gibs spawn too low (something with baseline offset?)\nx +visual switch first boss night with D9's night\nx +code walls don't repair\nx +testers don't get why horse is slow\nx +testers don't see night count\nx +testers have too much money\nx +testers build castle too soon\nx +testers castle is too profitable\nx +testers shouldn't get tip (expansion) at night\nx +code mochi api\nx +visual ease up on the fx\nx +code music clip in night 4\nx night eight too dark\nx night eight is way easy\nx daypastel is too green\nx Ok, totaal geen idee hoe dat bouwen werkt en als shit in de stijgers staat dan werkt het niet\nx en je zet dingen steeds per ongeluk in de stijgers\nx en wat die zeisen doen snap ik ook niet\nx firstly, als je naar de rand loopt stopt de camera wel maar de koning niet, die loopt van het scherm af gewoon door\nx de uitleg tekst hangt boven te drukke achtergrond om te lezen\nx misschien in de lucht of een fijner font (halve pixels ipv hele pixels zeg maar)\nx als je bij de eerste nacht rechts staat met je koning wordt je aangevallen terwijl die lange pan naar links gedaan wordt\n\nhighscore screen is ugly\nx goal is not clear\nshow coin count more clearly\nx make trolls jump on each other's heads\nx night before day 8 too cray fx\nx higher jumps in cyclic phase\nwalls should let trolls out when retreating\nnerf 'inner castle' strategy\nramp difficulty at high phases"
  },
  {
    "path": "weathers.json",
    "content": "{\n  \"NIGHTTEMP\":\n  {\n    \"saturation\": \"0.0\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFF6a6d55\", \n    \"sunTint\": \"0xffffff\", \n    \"haze\": \"0xFF999d7c\", \n    \"fog\": \"1.0\", \n    \"wind\": \"0.2\", \n    \"horizon\": \"0xFF6a6d55\", \n    \"ambient\": \"0xFFFF0000\", \n    \"timeOfDay\": \"0.0\", \n    \"contrast\": \"-0.2\", \n    \"darknessColor\": \"0x88111114\"\n  },\n\n  \"DAWNTEMP\":\n  {\n    \"saturation\": \"0.0\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFF6a6d55\", \n    \"sunTint\": \"0xffffff\", \n    \"haze\": \"0xFF999d7c\", \n    \"fog\": \"1.0\", \n    \"wind\": \"0.2\", \n    \"horizon\": \"0xFF6a6d55\", \n    \"ambient\": \"0xFFFF0000\", \n    \"timeOfDay\": \"0.25\", \n    \"contrast\": \"-0.2\", \n    \"darknessColor\": \"0x88111114\"\n  },\n\n  \"DAYTEMP\":\n  {\n    \"saturation\": \"0.0\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFF6a6d55\", \n    \"sunTint\": \"0xffffff\", \n    \"haze\": \"0xFF999d7c\", \n    \"fog\": \"1.0\", \n    \"wind\": \"0.2\", \n    \"horizon\": \"0xFF6a6d55\", \n    \"ambient\": \"0xFFFF0000\", \n    \"timeOfDay\": \"0.5\", \n    \"contrast\": \"-0.2\", \n    \"darknessColor\": \"0x88111114\"\n  },\n\n  \"DUSKTEMP\":\n  {\n    \"saturation\": \"0.0\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFF6a6d55\", \n    \"sunTint\": \"0xffffff\", \n    \"haze\": \"0xFF999d7c\", \n    \"fog\": \"1.0\", \n    \"wind\": \"0.2\", \n    \"horizon\": \"0xFF6a6d55\", \n    \"ambient\": \"0xFFFF0000\", \n    \"timeOfDay\": \"0.75\", \n    \"contrast\": \"-0.2\", \n    \"darknessColor\": \"0x88111114\"\n  },\n\n  \"FOGGY\": \n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFF6a6d55\", \n    \"sunTint\": \"0xffffff\", \n    \"haze\": \"0xFF999d7c\", \n    \"fog\": \"1.0\", \n    \"wind\": \"0.2\", \n    \"horizon\": \"0xFF6a6d55\", \n    \"ambient\": \"0x330000FF\", \n    \"timeOfDay\": \"0.25\", \n    \"contrast\": \"-0.2\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  , \n  \"DAWN\":\n  {\n    \"saturation\": \"0.8\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFF8C8CA6\", \n    \"sunTint\": \"0xff6d40\", \n    \"haze\": \"0x66f3f1e8\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFFCF7968\", \n    \"ambient\": \"0x11FF0000\", \n    \"timeOfDay\": \"0.28\", \n    \"contrast\": \"0.5\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"SUNNY\": \n  {\n    \"saturation\": \"0.8\", \n    \"darkness\": \"0.0\", \n    \"sky\": \"0xFF98BEEC\", \n    \"sunTint\": \"0xfff766\", \n    \"haze\": \"0xCCf3f1e8\", \n    \"fog\": \"0.0\", \n    \"wind\": \"1.0\", \n    \"horizon\": \"0xFFC4DAF1\", \n    \"ambient\": \"0x44FFBB7F\", \n    \"timeOfDay\": \"0.6\", \n    \"contrast\": \"0.8\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  , \n  \"EVENING\":\n  {\n    \"saturation\": \"0.8\", \n    \"darkness\": \"0.1\", \n    \"sky\": \"0xFFFF7F51\", \n    \"horizon\": \"0xFFFFDF54\",\n    \"sunTint\": \"0xFFFF7038\", \n    \"haze\": \"0x99FF9068\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"ambient\": \"0x33DE5E37\", \n    \"timeOfDay\": \"0.70\", \n    \"contrast\": \"0.7\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  , \n  \n  \"NIGHT\": \n  {\n    \"saturation\": \"0.8\", \n    \"darkness\": \"0.4\", \n    \"sky\": \"0xFF005EA5\", \n    \"sunTint\": \"0xDDDDFF\", \n    \"haze\": \"0xFF333333\", \n    \"fog\": \"0.2\", \n    \"wind\": \"0.2\", \n    \"horizon\": \"0xFF002E80\", \n    \"ambient\": \"0x110000FF\", \n    \"timeOfDay\": \"0\", \n    \"contrast\": \"0.5\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"DAWNLIGHTPINK\":\n  {\n    \"saturation\": \"0.8\", \n    \"darkness\": \"0.1\", \n    \"sky\": \"0xFF8C8CA6\", \n    \"sunTint\": \"0xF9B340\", \n    \"haze\": \"0xAAf3f1e8\", \n    \"fog\": \"0.5\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFFCF7968\", \n    \"ambient\": \"0x22FF84DA\", \n    \"timeOfDay\": \"0.28\", \n    \"contrast\": \"0.5\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \n  \"DAYWINDYCLEAR\":\n  {\n    \"saturation\": \"1.0\", \n    \"darkness\": \"0.0\", \n    \"sky\": \"0xFF64A3EA\", \n    \"sunTint\": \"0xF7E9AA\", \n    \"haze\": \"0x22f3f1e8\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.5\", \n    \"horizon\": \"0xFF86BAEF\", \n    \"ambient\": \"0x33F99100\", \n    \"timeOfDay\": \"0.45\", \n    \"contrast\": \"1.0\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"DUSKYELLOW\":\n  {\n    \"saturation\": \"0.9\", \n    \"darkness\": \"0.0\", \n    \"sky\": \"0xFF8BB8E8\", \n    \"sunTint\": \"0xF4EED0\", \n    \"haze\": \"0x88f3f1e8\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFFEDC99A\", \n    \"ambient\": \"0x44F79A42\", \n    \"timeOfDay\": \"0.651\", \n    \"contrast\": \"0.8\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  , \n  \"EVENINGORANGE\":\n  {\n    \"saturation\": \"0.8\", \n    \"darkness\": \"0.1\", \n    \"sky\": \"0xFF8BB8E8\", \n    \"horizon\": \"0xFFEDC99A\",\n    \"sunTint\": \"0xFFFF7038\", \n    \"haze\": \"0xFFFF9068\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"ambient\": \"0x33DE5E37\", \n    \"timeOfDay\": \"0.70\", \n    \"contrast\": \"0.7\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"NIGHTGREEN\": \n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.45\", \n    \"sky\": \"0xFF005EA5\", \n    \"sunTint\": \"0xDDDDFF\", \n    \"haze\": \"0xFFB8F2BB\", \n    \"fog\": \"0.4\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFF002E80\", \n    \"ambient\": \"0x2254FFAF\", \n    \"timeOfDay\": \"0.85\", \n    \"contrast\": \"0.0\", \n    \"darknessColor\": \"0x88263529\"\n  }\n  ,\n  \"DAWNGREY\":\n  {\n    \"saturation\": \"0.5\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFFC4AD99\", \n    \"sunTint\": \"0xF9B340\", \n    \"haze\": \"0xAAf3f1e8\", \n    \"fog\": \"0.5\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFFCECECE\", \n    \"ambient\": \"0x22FF84DA\", \n    \"timeOfDay\": \"0.31\", \n    \"contrast\": \"0.5\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"DAYBLEAK\":\n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.0\", \n    \"sky\": \"0xFFA0C2E8\", \n    \"horizon\": \"0xFFA6C9ED\", \n    \"sunTint\": \"0xF7E9AA\", \n    \"haze\": \"0xFFf3f1e8\", \n    \"fog\": \"1.0\", \n    \"wind\": \"0.5\", \n    \"ambient\": \"0x33F7E0C3\", \n    \"timeOfDay\": \"0.45\", \n    \"contrast\": \"0.0\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"DUSKWARM\":\n  {\n    \"saturation\": \"0.9\", \n    \"darkness\": \"0.0\", \n    \"sky\": \"0xFF8BB8E8\", \n    \"sunTint\": \"0xF4EED0\", \n    \"haze\": \"0x88f3f1e8\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFFEDC99A\", \n    \"ambient\": \"0x44F79A42\", \n    \"timeOfDay\": \"0.651\", \n    \"contrast\": \"0.8\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\"EVENINGBLACK\":\n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.3\", \n    \"sky\": \"0xFF333333\", \n    \"horizon\": \"0xFFEDC99A\",\n    \"sunTint\": \"0xFFFF7038\", \n    \"haze\": \"0xFFFF9090\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"ambient\": \"0x339f6b5c\", \n    \"timeOfDay\": \"0.70\", \n    \"contrast\": \"0.0\", \n    \"darknessColor\": \"0x88111114\"\n  } \n  ,\n  \"NIGHTDARK\": \n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.75\", \n    \"sky\": \"0xFF002E33\", \n    \"sunTint\": \"0x65a2cb\", \n    \"haze\": \"0xFF555555\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFF002E80\", \n    \"ambient\": \"0x4454AACF\", \n    \"timeOfDay\": \"0.85\", \n    \"contrast\": \"0.4\", \n    \"darknessColor\": \"0xFF263529\"\n  }\n  ,\n  \"DAWNBLEAK\":\n  {\n    \"saturation\": \"0.9\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFFC4AD99\", \n    \"sunTint\": \"0xF9B340\", \n    \"haze\": \"0xAAf3f1e8\", \n    \"fog\": \"0.5\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFFCECECE\", \n    \"ambient\": \"0x22FF84DA\", \n    \"timeOfDay\": \"0.31\", \n    \"contrast\": \"0.5\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"DAWNEARLY\":\n  {\n    \"saturation\": \"0.9\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFFC4AD99\", \n    \"sunTint\": \"0xF9B340\", \n    \"haze\": \"0xAAf3f1e8\", \n    \"fog\": \"0.5\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFFCECECE\", \n    \"ambient\": \"0x22FF84DA\", \n    \"timeOfDay\": \"0.19\", \n    \"contrast\": \"0.5\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,  \"DAYSOFT\":\n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.0\", \n    \"sky\": \"0xFFA0C2E8\", \n    \"horizon\": \"0xFFA6C9ED\", \n    \"sunTint\": \"0xF7E9AA\", \n    \"haze\": \"0x22f3f1e8\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"ambient\": \"0x33F7E0C3\", \n    \"timeOfDay\": \"0.45\", \n    \"contrast\": \"0.0\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\"EVENINGMONOTONE\":\n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.3\", \n    \"sky\": \"0xFF333333\", \n    \"horizon\": \"0xFFEDEDED\",\n    \"sunTint\": \"0xAAAAAA\", \n    \"haze\": \"0xFFFF9090\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"ambient\": \"0x33666666\", \n    \"timeOfDay\": \"0.70\", \n    \"contrast\": \"0.0\", \n    \"darknessColor\": \"0x88111114\"\n  } \n  ,\n  \"NIGHTSUPERDARK\": \n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.7\", \n    \"sky\": \"0xFF000000\", \n    \"sunTint\": \"0x65a2cb\", \n    \"haze\": \"0xFFFFFFFF\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFF002E80\", \n    \"ambient\": \"0x4454AACF\", \n    \"timeOfDay\": \"0.85\", \n    \"contrast\": \"0.4\", \n    \"darknessColor\": \"0xFF263529\"\n  }\n  ,\n  \"EVENINGFOGGY\": \n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.3\", \n    \"sky\": \"0xFFd56c47\", \n    \"sunTint\": \"0xffd9c8\", \n    \"haze\": \"0xFFd5d9ff\", \n    \"fog\": \"1.0\", \n    \"wind\": \"0.2\", \n    \"horizon\": \"0xFF6a6d55\", \n    \"ambient\": \"0x440000FF\", \n    \"timeOfDay\": \"0.7\", \n    \"contrast\": \"-0.1\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"NIGHTFOGGY\": \n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.7\", \n    \"sky\": \"0xFF25229d\", \n    \"sunTint\": \"0xffd9c8\", \n    \"haze\": \"0xFFd5d9ff\", \n    \"fog\": \"1.0\", \n    \"wind\": \"0.2\", \n    \"horizon\": \"0xFF6a6d55\", \n    \"ambient\": \"0x7763709d\", \n    \"timeOfDay\": \"0.8\", \n    \"contrast\": \"-0.1\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"DAYMONOCHROME\":\n  {\n    \"saturation\": \"0.25\", \n    \"darkness\": \"0.0\", \n    \"sky\": \"0xFF80A2C8\", \n    \"horizon\": \"0xFFA6C9ED\", \n    \"sunTint\": \"0xF7E9AA\", \n    \"haze\": \"0xFFf3f1e8\", \n    \"fog\": \"1.0\", \n    \"wind\": \"0.5\", \n    \"ambient\": \"0x33F7E0C3\", \n    \"timeOfDay\": \"0.45\", \n    \"contrast\": \"0.4\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"DUSKPINK\":\n  {\n    \"saturation\": \"0.9\", \n    \"darkness\": \"0.0\", \n    \"sky\": \"0xFF8C8CA6\", \n    \"sunTint\": \"0xF9B340\", \n    \"haze\": \"0xAAf3c1e8\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFFEDC99A\", \n    \"ambient\": \"0x44F79A42\", \n    \"timeOfDay\": \"0.651\", \n    \"contrast\": \"0.8\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"NIGHTCLEAR\": \n  {\n    \"saturation\": \"0.8\", \n    \"darkness\": \"0.4\", \n    \"sky\": \"0xFF005EA5\", \n    \"sunTint\": \"0xDDDDFF\", \n    \"haze\": \"0x44434e87\", \n    \"fog\": \"0.1\", \n    \"wind\": \"0.3\", \n    \"horizon\": \"0xFF002E80\", \n    \"ambient\": \"0x110000FF\", \n    \"timeOfDay\": \"0.1\", \n    \"contrast\": \"-0.1\", \n    \"darknessColor\": \"0x88111114\"\n  },\n  \"DAYCLEARCOLD\":\n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.0\", \n    \"sky\": \"0xFFC9E3EA\", \n    \"horizon\": \"0xFFC9E3EA\", \n    \"sunTint\": \"0xF7E9AA\", \n    \"haze\": \"0x33C9E3EA\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.5\", \n    \"ambient\": \"0x33F7E0C3\", \n    \"timeOfDay\": \"0.45\", \n    \"contrast\": \"0.2\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"DAWNCLEARORANGE\":\n  {\n    \"saturation\": \"0.8\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFF97A7B4\", \n    \"sunTint\": \"0xFAFDC9\", \n    \"haze\": \"0x88FDB24C\", \n    \"horizon\": \"0xFFF9A04F\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"ambient\": \"0x11FF0000\", \n    \"timeOfDay\": \"0.28\", \n    \"contrast\": \"0.5\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"DUSKCLEAR\":\n  {\n    \"saturation\": \"0.9\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFF513744\", \n    \"sunTint\": \"0xF9B340\", \n    \"haze\": \"0xAAC9976D\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFFC69875\", \n    \"ambient\": \"0x22360A00\", \n    \"timeOfDay\": \"0.651\", \n    \"contrast\": \"0.45\", \n    \"darknessColor\": \"0x88111114\"\n  }\n  ,\n  \"NIGHTREDMOON\":\n  {\n    \"saturation\": \"0.9\", \n    \"darkness\": \"0.4\", \n    \"sky\": \"0xFF142744\", \n    \"sunTint\": \"0xC73800\", \n    \"haze\": \"0x665C5D9E\", \n    \"fog\": \"0.1\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFFAD2E21\", \n    \"ambient\": \"0x220E0B62\", \n    \"timeOfDay\": \"0.1\", \n    \"contrast\": \"0.2\", \n    \"darknessColor\": \"0x880E0B62\"\n  }\n  ,\n  \"DAWNREDMOON\":\n  {\n    \"saturation\": \"0.9\", \n    \"darkness\": \"0.2\", \n    \"sky\": \"0xFF16549F\", \n    \"sunTint\": \"0xE76833\", \n    \"haze\": \"0xbb5C5D9E\", \n    \"fog\": \"0.1\", \n    \"wind\": \"0.1\", \n    \"horizon\": \"0xFFFF9286\", \n    \"ambient\": \"0x110E0B22\", \n    \"timeOfDay\": \"0.2\", \n    \"contrast\": \"0.0\", \n    \"darknessColor\": \"0x880E0B62\"\n  }\n  ,\n  \"DAYORANGESKY\":\n  {\n    \"saturation\": \"0.7\", \n    \"darkness\": \"0.1\", \n    \"sky\": \"0xFFADA290\", \n    \"sunTint\": \"0xF9F8E6\", \n    \"haze\": \"0x445A432C\", \n    \"fog\": \"0.3\", \n    \"wind\": \"0.7\", \n    \"horizon\": \"0xFFDCAB4F\", \n    \"ambient\": \"0x110E0B22\", \n    \"timeOfDay\": \"0.4\", \n    \"contrast\": \"0.2\", \n    \"darknessColor\": \"0x880E0B62\"\n  }\n  ,\n  \"DUSKFOGGY\":\n  {\n    \"saturation\": \"0.6\", \n    \"contrast\": \"0.1\", \n    \"ambient\": \"0x330E0B22\", \n    \"sky\": \"0xFFB29C8F\", \n    \"horizon\": \"0xFF3D6BCD\", \n    \"haze\": \"0x00000000\", \n    \"sunTint\": \"0xF9F8E6\", \n    \"fog\": \"0.8\", \n    \"wind\": \"0.4\", \n    \"timeOfDay\": \"0.75\", \n    \"darkness\": \"0.25\", \n    \"darknessColor\": \"0x880E0B62\"\n  }\n  ,\n  \"NIGHTPURPLE\":\n  {\n    \"saturation\": \"0.8\", \n    \"contrast\": \"1.4\", \n    \"ambient\": \"0x33886AAA\", \n    \"sky\": \"0xFF57577D\", \n    \"horizon\": \"0xFF4D4658\", \n    \"haze\": \"0x88886AAA\", \n    \"sunTint\": \"0xF9F8E6\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.2\", \n    \"timeOfDay\": \"0.9\", \n    \"darkness\": \"0.3\", \n    \"darknessColor\": \"0x88990BBB\"\n  }\n  ,\n  \"DAWNBRIGHT\":\n  {\n    \"saturation\": \"0.8\", \n    \"contrast\": \"1.4\", \n    \"ambient\": \"0xff886A00\", \n    \"sky\": \"0xFF57577D\", \n    \"horizon\": \"0xFFEEEE88\", \n    \"haze\": \"0x00886AAA\", \n    \"sunTint\": \"0xF9F8E6\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.2\", \n    \"timeOfDay\": \"0.3\", \n    \"darkness\": \"0.15\", \n    \"darknessColor\": \"0x88000BBB\"\n  }\n  ,\n  \"DAYPASTEL\":\n  {\n    \"saturation\": \"1.0\", \n    \"contrast\": \"1.0\", \n    \"ambient\": \"0x44886A00\", \n    \"sky\": \"0xFF3090F6\", \n    \"horizon\": \"0xFFEEEE88\", \n    \"haze\": \"0xDD657A8F\", \n    \"sunTint\": \"0xF9F8E6\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.3\", \n    \"timeOfDay\": \"0.55\", \n    \"darkness\": \"0.0\", \n    \"darknessColor\": \"0x88000BBB\"\n  }\n  ,\n  \"DUSKTAN\":\n  {\n    \"saturation\": \"0.8\", \n    \"contrast\": \"0.5\", \n    \"ambient\": \"0xFF886A00\", \n    \"sky\": \"0xFF52424C\", \n    \"horizon\": \"0xFFFFBA3B\", \n    \"haze\": \"0x55C18F90\", \n    \"sunTint\": \"0xF9F8E6\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.3\", \n    \"timeOfDay\": \"0.7\", \n    \"darkness\": \"0.1\", \n    \"darknessColor\": \"0x88330B33\"\n  }\n  ,\n  \"NIGHTSHINE\":\n  {\n    \"saturation\": \"0.5\", \n    \"contrast\": \"4.0\", \n    \"ambient\": \"0x00000000\", \n    \"sky\": \"0xFF000000\", \n    \"horizon\": \"0xFFAAAAFF\", \n    \"haze\": \"0x00886AAA\", \n    \"sunTint\": \"0xF9F8E6\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.2\", \n    \"timeOfDay\": \"0.9\", \n    \"darkness\": \"0.35\", \n    \"darknessColor\": \"0x88222255\"\n  }\n  ,\n  \"DAWNBROWN\":\n  {\n    \"saturation\": \"0.8\", \n    \"contrast\": \"0.7\", \n    \"ambient\": \"0x55AD3200\", \n    \"sky\": \"0xFFC0AFBD\", \n    \"horizon\": \"0xFF94A9B6\", \n    \"haze\": \"0x99AAAAAA\", \n    \"sunTint\": \"0xF9F8E6\", \n    \"fog\": \"0.2\", \n    \"wind\": \"0.2\", \n    \"timeOfDay\": \"0.28\", \n    \"darkness\": \"0.0\", \n    \"darknessColor\": \"0x88222255\"\n  }\n  ,\n  \"DAYDUSTY\":\n  {\n    \"saturation\": \"0.8\", \n    \"contrast\": \"0.2\", \n    \"ambient\": \"0x55f5db04\", \n    \"sky\": \"0xFF5d9df5\", \n    \"horizon\": \"0xFF94A9B6\", \n    \"haze\": \"0x99AAAAAA\", \n    \"sunTint\": \"0xF9F8E6\", \n    \"fog\": \"0.2\", \n    \"wind\": \"0.2\", \n    \"timeOfDay\": \"0.4\", \n    \"darkness\": \"0.0\", \n    \"darknessColor\": \"0x88222255\"\n  }\n   ,\n  \"DUSKRED\":\n  {\n    \"saturation\": \"0.8\", \n    \"contrast\": \"0.1\", \n    \"ambient\": \"0x55f5db04\", \n    \"sky\": \"0xFFd06219\", \n    \"horizon\": \"0xFFf2d407\", \n    \"haze\": \"0x99AAAAAA\", \n    \"sunTint\": \"0xf27612\", \n    \"fog\": \"0.2\", \n    \"wind\": \"0.2\", \n    \"timeOfDay\": \"0.651\", \n    \"darkness\": \"0.2\", \n    \"darknessColor\": \"0x88000000\"\n  }\n  ,\n  \"NIGHTLONG\":\n  {\n    \"saturation\": \"1.0\", \n    \"contrast\": \"0.3\", \n    \"ambient\": \"0x55acc857\", \n    \"sky\": \"0xFF7399c8\", \n    \"horizon\": \"0xFF7399c8\", \n    \"haze\": \"0xFF000000\", \n    \"sunTint\": \"0x162039\", \n    \"fog\": \"0.0\", \n    \"wind\": \"0.1\", \n    \"timeOfDay\": \"0.9\", \n    \"darkness\": \"0.4\", \n    \"darknessColor\": \"0x88000000\"\n  }\n\n\n  \n}"
  }
]