[
  {
    "path": ".gitignore",
    "content": "\n### ACTIONSCRIPT ###\n\n# Build and Release Folders\nbin/\nbin-debug/\nbin-release/\n\n# Project property files\n.actionScriptProperties\n.flexProperties\n.settings/\n.project\n\n\n### OS SPECIAL FILES ###\n\n# Windows\nThumbs.db\nehthumbs.db\nDesktop.ini\n$RECYCLE.BIN/\n\n# OSX (MAC)\n.DS_Store\n.AppleDouble\n.LSOverride\nIcon\n._*\n.Spotlight-V100\n.Trashes\n\n# Linux\n.*\n!.gitignore\n*~\n\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "## v1.9 Released ##\n\n#### 10th October 2011\n\nFlxBar - v1.6 Lots of bug fixes, more documentation, 2 new test cases, ability to set currentValue added\n\n#### 9th October 2011\n\nFlxCollision - v1.6 Fixed bug in pixelPerfectCheck that stopped non-square rotated objects from colliding properly (thanks to joon on the flixel forums for spotting)\nFlxWeapon - v1.3 Added bullet elasticity and bulletsFired counter\n\n#### 15th August 2011\n\nFlxWeapon - v1.2 Added useParentDirection boolean\nFlxControlHandler - v1.8 Added isPressedUp/Down/Left/Right handlers\nFlxVelocity - v1.6 New Method: velocityFromFacing\n\n#### 11th August 2011\n\nCreated WeaponTest9 - destructable terrain\n\n#### 8th August 2011\n\nGlitchFX - v1.2 Fixed updateFromSource github issue #8 (thanks CoderBrandon)\nFlxControlHandler - v1.7 Modified update function so gravity is applied constantly\nSeveral new demos created\n\n#### 4th August 2011\n\nFlxCoreUtils - v1.1 Added get mouseIndex and gameContainer\nFlxColor - v1.5 Added RGBtoWebString\n\n#### 3rd August 2011\n\nFlxWeapon - v1.1 Added pre-fire, fire and post-fire callbacks and sound support, rnd factors, boolean returns and currentBullet\nBullet - v1.1 Updated to support fire callbacks, sounds, random variances and lifespan\nFlxKongregate - v1.0 First release\n\n\n## v1.8 Released ##\n\n#### 31st July 2011\n\nFlxDelay - v1.4 Modified abort so it no longer runs the stop callback (thanks to Cambrian-Man)\n\n#### 29th July 2011\n\nFlxFlod : Added full FlxFlectrum support\nFlxFlectrum - new class\n\n#### 28th July 2011\n\nFlxExtendedSprite : Added Gravity, Friction and Tolerance support\nFlxButtonPlus : Added scrollFactor to buttonNormal and buttonHighlight\n \n#### 27th July 2011\n\nAdded createCameraWall to FlxCollision and created lots more tests\nFlxMouseControl: Added Mouse Zone, Mouse Speed and refactored addToStack process\n\n#### 21st July 2011\n\nFlxMouseControl and FlxExtendedSprite given a serious overhaul and now provide for totally draggable sprites!\n\n#### 21st June 2011\n\nAdded support for fixed widths in FlxBitmapFont, and the ability to align the text left/right/center within that width.\nUpdated BitmapFontTest3 to demonstrate this.\n\n"
  },
  {
    "path": "LICENSE.md",
    "content": "Simplified BSD License\n======================\n\nCopyright &copy; 2011, Richard Davey  \nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met: \n\n1. Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer. \n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution. \n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &ldquo;AS IS&rdquo; AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nThe views and conclusions contained in the software and documentation are those\nof the authors and should not be interpreted as representing official policies, \neither expressed or implied, of the FreeBSD Project.\n"
  },
  {
    "path": "README.md",
    "content": "Flixel Power Tools\n==================\n\nVersion 1.9 (final release)\n\nNovember 28th 2013\n\nBy Richard Davey, [Photon Storm](http://www.photonstorm.com)\n\nThe [Flixel Power Tools](http://www.photonstorm.com/flixel-power-tools) are a package\nof classes designed to provide extra functionality to your Flixel 2.5+ games.\n\n\nQuick Install Guide\n-------------------\n\nCopy the `src` and `lib` folders into your ActionScript project. All the classes for Flixel Power Tools should be contained in\n\n\tsrc/org/flixel/plugin/photonstorm\n\nNow read the \"Getting Started Guide\" in the `Docs` folder; it contains important information that will \nhelp you compile!\n\n\nGetting Started Guide\n---------------------\n\nThere is a comprehensive Getting Started Guide in both Word and PDF format in the `Docs` branch:\n\nhttps://github.com/FlixelCommunity/Flixel-Power-Tools/tree/docs\n\nDocumentation is also provided built-in to the classes. AS3 IDEs such as FlashDevelop will\nprovide context-sensitive help for all classes and functions in the Flixel Power Tools.\n\nFinally check out the home page at http://www.photonstorm.com/flixel-power-tools for updates.\n\n\nTest Suite\n----------\n\nGet the full Test Suite from here:\n\nhttps://github.com/FlixelCommunity/Flixel-Power-Tools/tree/test-suite\n\nThe Flixel Power Tools come with a comprehensive Test Suite. Use it to visually see the \ntools in action, and then learn from the source code and comments within.\n\nTo run the Test Suite launch the following SWF:\n\n    Test Suite/bin/FlixelPowerTools.swf\n\nIf you don't have Flash Player installed locally then open `index.html` in a browser.\n\n\nClasses\n-------\n\nThe following classes are currently in the Flixel Power Tools:\n\n* FlxBar\n* FlxBitmapFont\n* FlxButtonPlus\n* FlxCollision\n* FlxColor\n* FlxControl (includes FlxControlHandler)\n* FlxCoreUtils\n* FlxDelay\n* FlxDisplay\n* FlxExtendedSprite\n* FlxFlod (includes FlxFlectrum)\n* FlxGradient\n* FlxGridOverlay\n* FlxLinkedGroup\n* FlxMath\n* FlxMouseControl\n* FlxScreenGrab\n* FlxScrollingText\n* FlxScrollZone\n* FlxSpecialFX\n* FlxVelocity\n* FlxWeapon\n\nAPIs Include\n\n* FlxKongregate\n\nSpecial FX Includes\n\n* BlurFX\n* CenterSlideFX\n* FloodFillFX\n* GlitchFX\n* PlasmaFX\n* RainbowLineFX\n* RevealFX\n* SineWaveFX\n* StarfieldFX\n\nContributing\n------------\n\nI'm afraid that the Flixel Power Tools are no longer maintained by myself. I have moved on to [other things](http://phaser.io).\n\nI would strongly suggest you start using the [Flixel Commmunity](https://github.com/FlixelCommunity) version of Flixel which contains updated versions of these tools.\n\nLicense\n-------\n\nCopyright 2011 Richard Davey. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are\npermitted provided that the following conditions are met:\n\n   1. Redistributions of source code must retain the above copyright notice, this list of\n      conditions and the following disclaimer.\n\n   2. Redistributions in binary form must reproduce the above copyright notice, this list\n      of conditions and the following disclaimer in the documentation and/or other materials\n      provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY RICHARD DAVEY ``AS IS'' AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RICHARD DAVEY OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\nADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nThe views and conclusions contained in the software and documentation are those of the\nauthors and should not be interpreted as representing official policies, either expressed\nor implied, of the FreeBSD Project.\n\n[1]: https://github.com/photonstorm/Flixel-Power-Tools/issues\n[fpt]: https://github.com/photonstorm/Flixel-Power-Tools\n[ff]: http://flixel.org/forums/\n"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/API/FlxKongregate.as",
    "content": "/**\n * FlxKongregate\n * -- Part of the Flixel Power Tools set\n * \n * v1.0 First release\n * \n * @version 1.0 - August 1st 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.API \n{\n\timport flash.display.DisplayObject;\n\timport flash.display.Loader;\n\timport flash.errors.IOError;\n\timport flash.events.Event;\n\timport flash.events.IOErrorEvent;\n\timport flash.net.URLRequest;\n\timport flash.system.Security;\n\t\n\timport org.flixel.*;\n\t\n\t/**\n\t *\tAllows for easy access to the Kongregate API\n\t * \n\t *\tTodo: Add in the functions for Chat Integration - you can still use them via the FlxKongregate.api object.\n\t */\n\tpublic class FlxKongregate \n\t{\n\t\t/**\n\t\t * The Kongregate API object. You can make calls directly to this once the API has connected.\n\t\t */\n\t\tpublic static var api:*;\n\t\t\n\t\t/**\n\t\t * true if the API has loaded otherwise false. Loaded is not the same thing as connected, it just means it's ready for the connection.\n\t\t */\n\t\tpublic static var hasLoaded:Boolean = false;\n\t\t\n\t\t/**\n\t\t * Is the game running locally in Shadow API mode (true) or from Kongregates servers (false)\n\t\t */\n\t\tpublic static var isLocal:Boolean = false;\n\t\t\n\t\tprivate static var shadowAPI:String = \"http://www.kongregate.com/flash/API_AS3_Local.swf\";\n\t\tprivate static var apiLoader:Loader;\n\t\tprivate static var loadCallback:Function;\n\t\t\n\t\tpublic function FlxKongregate() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Loads the Kongregate API and if successful connects to the service.\n\t\t * Note that your game must have access to Stage by this point.\n\t\t * \n\t\t * @param\tcallback\tThis function is called if the API loads successfully. Do not call any API function until this has happened.\n\t\t */\n\t\tpublic static function init(callback:Function):void\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tvar parameters:Object = FlxG.stage.loaderInfo.parameters;\n\t\t\t}\n\t\t\tcatch (e:Error)\n\t\t\t{\n\t\t\t\tthrow new Error(\"FlxKongregate: No access to FlxG.stage - only call this once your game has access to the display list\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tvar apiPath:String;\n\t\t\t\n\t\t\tif (parameters.kongregate_api_path)\n\t\t\t{\n\t\t\t\tSecurity.allowDomain(parameters.kongregate_api_path);\n\t\t\t\tapiPath = parameters.kongregate_api_path;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tSecurity.allowDomain(shadowAPI);\n\t\t\t\tapiPath = shadowAPI;\n\t\t\t\tisLocal = true;\n\t\t\t}\n\t\t\t\n\t\t\tloadCallback = callback;\n\t\t\t\n\t\t\tapiLoader = new Loader();\n\t\t\tapiLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, apiLoadComplete, false, 0, true);\n\t\t\tapiLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, apiLoadError, false, 0, true);\n\t\t\tapiLoader.load(new URLRequest(apiPath));\n\t\t\t\n\t\t\tFlxG.stage.addChild(apiLoader);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Remove the API from memory (when possible) and removes it from the display list also\n\t\t */\n\t\tpublic static function disconnect():void\n\t\t{\n\t\t\tapi = null;\n\t\t\t\n\t\t\thasLoaded = false;\n\t\t\t\n\t\t\tFlxG.stage.removeChild(apiLoader);\n\t\t}\n\t\t\n\t\tprivate static function apiLoadComplete(event:Event):void\n\t\t{\n\t\t\tapi = event.target.content;\n\t\t\t\n\t\t\thasLoaded = true;\n\n\t\t\tSecurity.allowDomain(api.loaderInfo.url);\n\n\t\t\tif (loadCallback is Function)\n\t\t\t{\n\t\t\t\tloadCallback.call();\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tprivate static function apiLoadError(error:IOError):void\n\t\t{\n\t\t\ttrace(\"Error loading Kongregate API\", error);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Use the addLoadListener function to register an event listener which will be triggered when content of the specified type is loaded by the user.\n\t\t * These MUST be set-up *before* you call FlxKongregate.connect()\n\t\t * See: http://www.kongregate.com/developer_center/docs/shared-content-api\n\t\t * \n\t\t * @param\tcontentType\t\tType of content to listen for\n\t\t * @param\tcallback\t\tFunction to call when content load request has been made\n\t\t */\n\t\tpublic static function addLoadListener(contentType:String, callback:Function):void\n\t\t{\n\t\t\tapi.sharedContent.addLoadListener(contentType, callback);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Register an event listener with the API. Useful for capturing guest to user login requests for example.\n\t\t * See: http://www.kongregate.com/developer_center/docs/handling-guests\n\t\t * \n\t\t * @param\tcontentType\t\tThe event to listen for (i.e. \"login\")\n\t\t * @param\tcallback\t\tFuncation to call when this event is received\n\t\t */\n\t\tpublic static function addEventListener(contentType:String, callback:Function):void\n\t\t{\n\t\t\tapi.services.addEventListener(contentType, callback);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Connect to the Kongregate API. This should be called only after the init callback reports a succesful load of the API\n\t\t */\n\t\tpublic static function connect():void\n\t\t{\n\t\t\tif (hasLoaded)\n\t\t\t{\n\t\t\t\tapi.services.connect();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * The isGuest function can be called to determine if the player is currently signed into Kongregate or not\n\t\t */\n\t\tpublic static function get isGuest():Boolean\n\t\t{\n\t\t\treturn api.services.isGuest();\n\t\t}\n\t\t\n\t\t/**\n\t\t * You can use the getUsername() function to retrieve the username of the current player. It will begin with Guest if the user is not signed in.\n\t\t */\n\t\tpublic static function get getUserName():String\n\t\t{\n\t\t\treturn api.services.getUsername();\n\t\t}\n\t\t\n\t\t/**\n\t\t * You can use the getUserId() function to retrieve the unique user id of the current player. It will return 0 if the user is not signed in.\n\t\t */\n\t\tpublic static function get getUserId():Number\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\treturn api.services.getUserId();\n\t\t\t}\n\t\t\tcatch (e:Error)\n\t\t\t{\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\t\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * If you are using the Authentication API you can use the getGameAuthToken function to get the player's game authentication token.\n\t\t */\n\t\tpublic static function get getGameAuthToken():String\n\t\t{\n\t\t\treturn api.services.getGameAuthToken();\n\t\t}\n\t\t\n\t\t/**\n\t\t * If the player is a guest, and you want to display the sign-in/registration UI to them you can use the showSignInBox function.\n\t\t */\n\t\tpublic static function showSignInBox():void\n\t\t{\n\t\t\tif (api.services.isGuest())\n\t\t\t{\n\t\t\t\tapi.services.showSignInBox();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * This call works the same way as showSigninBox, but it focuses the registration form rather than the sign-in form.\n\t\t */\n\t\tpublic static function showRegistrationBox():void\n\t\t{\n\t\t\tif (api.services.isGuest())\n\t\t\t{\n\t\t\t\tapi.services.showRegistrationBox();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * If a player is logged-in and you want to allow them to post a shout on their profile page, you may bring up the shout box, optionally populated with some initial content.\n\t\t * \n\t\t * @param\tmessage\t\tThe optional initial content\n\t\t */\n\t\tpublic static function showShoutBox(message:String = \"\"):void\n\t\t{\n\t\t\tif (api.services.isGuest() == false)\n\t\t\t{\n\t\t\t\tapi.services.showShoutBox(message);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * If you need to resize your game's enclosing container, you may do so with resizeGame call. The enclosing iframe will resize around your game.\n\t\t * Games may not be resized smaller than their initial dimensions. This call requires special permission from Kongregate to use.\n\t\t * \n\t\t * @param\twidth\t\tNew width (in pixels) of the container\n\t\t * @param\theight\t\tNew height (in pixels) of the container\n\t\t */\n\t\tpublic static function resizeGame(width:int, height:int):void\n\t\t{\n\t\t\tapi.services.resizeGame(width, height);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Submit a statistic to the Kongregate server. Make sure you have defined the stat before calling this.\n\t\t * See the Kongregate API documentation for details.\n\t\t * \n\t\t * @param\tname\t\tThe name of the statistic\n\t\t * @param\tvalue\t\tThe value to submit (will be converted to an integer server-side)\n\t\t */\n\t\tpublic static function submitStats(name:String, value:Number):void\n\t\t{\n\t\t\tapi.stats.submit(name, value);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Bring up the \"purchase items\" dialog box by using the purchaseItems method on the microtransaction services object.\n\t\t * Your game must be in the Kongregate Microtransactions beta to use this function.\n\t\t * See: http://www.kongregate.com/developer_center/docs/microtransaction-client-api\n\t\t * \n\t\t * @param\titems\t\tThe array of item identifier strings or item/metadata objects.\n\t\t * @param\tcallback\tThe callback function\n\t\t */\n\t\tpublic static function purchaseItem(items:Array, callback:Function):void\n\t\t{\n\t\t\tapi.mtx.purchaseItems(items, callback);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Request the inventory of any user.\n\t\t * Your game must be in the Kongregate Microtransactions beta to use this function.\n\t\t * See: http://www.kongregate.com/developer_center/docs/microtransaction-client-api\n\t\t * \n\t\t * @param\tusername\tThe username to request inventory for, or null for the current player\n\t\t * @param\tcallback\tThe callback function\n\t\t */\n\t\tpublic static function requestUserItemList(username:String, callback:Function):void\n\t\t{\n\t\t\tapi.mtx.requestUserItemList(username, callback);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Display the Kred purchasing Dialog.\n\t\t * Your game must be in the Kongregate Microtransactions beta to use this function.\n\t\t * See: http://www.kongregate.com/developer_center/docs/microtransaction-client-api\n\t\t * \n\t\t * @param\tpurchaseMethod\t The purchase method to display. Should be \"offers\" or \"mobile\"\n\t\t */\n\t\tpublic static function showKredPurchaseDialog(purchaseMethod:String):void\n\t\t{\n\t\t\tapi.mtx.showKredPurchaseDialog(purchaseMethod);\n\t\t}\n\t\t\n\t\t/**\n\t\t * The browse function causes a list of shared content to appear in the user's browser.\n\t\t * This will allow them to view, rate, or load shared content for your game.\n\t\t * See: http://www.kongregate.com/developer_center/docs/shared-content-api\n\t\t * \n\t\t * @param\tcontentType\t\tType of content to browse\n\t\t * @param\tsortOrder\t\tOptional constant specifying how to sort content (see API docs)\n\t\t * @param\tlabel\t\t\tOptional, only browse content saved with the specified label\n\t\t */\n\t\tpublic static function browseSharedContent(contentType:String, sortOrder:String=null, label:String=null):void\n\t\t{\n\t\t\tapi.sharedContent.browse(contentType, sortOrder, label);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Use the save function to submit shared content on the Kongregate back-end.\n\t\t * See: http://www.kongregate.com/developer_center/docs/shared-content-api\n\t\t * \n\t\t * @param\ttype\t\tType of content the user wishes to save, 12 characters max.\n\t\t * @param\tcontent\t\tValue of content to be saved. We strongly recommend keeping these values under 100K.\n\t\t * @param\tcallback\tFunction to call when save has finished.\n\t\t * @param\tthumb\t\tOptional but highly recommended! Send us a DisplayObject that we will snapshotted and used as a thumbnail for the content.\n\t\t * @param\tlabel\t\tOptional, label for sub-classing the shared content.\n\t\t */\n\t\tpublic static function saveSharedContent(type:String, content:String, callback:Function, thumb:DisplayObject = null, label:String = null):void\n\t\t{\n\t\t\tapi.sharedContent.save(type, content, callback, thumb, label);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Export a DisplayObject to be converted to a user avatar. It is highly recommended that avatars be at least 40 x 40px.\n\t\t * See: http://www.kongregate.com/developer_center/docs/avatar-api\n\t\t * \n\t\t * @param\tavatar\t\tCan be null, but highly recommended that you send yourself. If null, we will snapshot the stage.\n\t\t * @param\tcallback\tFunction to call when content load request has been made\n\t\t */\n\t\tpublic static function submitAvatar(avatar:DisplayObject, callback:Function):void\n\t\t{\n\t\t\tapi.images.submitAvatar(avatar, callback);\n\t\t}\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/BaseTypes/Bullet.as",
    "content": "/**\n * Bullet\n * -- Part of the Flixel Power Tools set\n * \n * v1.2 Removed \"id\" and used the FlxSprite ID value instead\n * v1.1 Updated to support fire callbacks, sounds, random variances and lifespan\n * v1.0 First release\n * \n * @version 1.2 - October 10th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.BaseTypes \n{\n\timport org.flixel.FlxPoint;\n\timport org.flixel.FlxSprite;\n\timport org.flixel.plugin.photonstorm.FlxMath;\n\timport org.flixel.plugin.photonstorm.FlxVelocity;\n\timport org.flixel.plugin.photonstorm.FlxWeapon;\n\timport flash.utils.getTimer;\n\n\tpublic class Bullet extends FlxSprite\n\t{\n\t\tprotected var weapon:FlxWeapon;\n\t\t\n\t\tprotected var bulletSpeed:int;\n\t\t\n\t\t//\tAcceleration or Velocity?\n\t\tpublic var accelerates:Boolean;\n\t\tpublic var xAcceleration:int;\n\t\tpublic var yAcceleration:int;\n\t\t\n\t\tpublic var rndFactorAngle:uint;\n\t\tpublic var rndFactorSpeed:uint;\n\t\tpublic var rndFactorLifeSpan:uint;\n\t\tpublic var lifespan:uint;\n\t\tpublic var launchTime:uint;\n\t\tpublic var expiresTime:uint;\n\t\t\n\t\tprotected var animated:Boolean;\n\t\t\n\t\tpublic function Bullet(weapon:FlxWeapon, id:uint)\n\t\t{\n\t\t\tsuper(0, 0);\n\t\t\t\n\t\t\tthis.weapon = weapon;\n\t\t\tthis.ID = id;\n\t\t\t\n\t\t\t//\tSafe defaults\n\t\t\taccelerates = false;\n\t\t\tanimated = false;\n\t\t\tbulletSpeed = 0;\n\t\t\t\n\t\t\texists = false;\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\toverride public function addAnimation(Name:String, Frames:Array, FrameRate:Number = 0, Looped:Boolean = true):void\n\t\t{\n\t\t\tsuper.addAnimation(Name, Frames, FrameRate, Looped);\n\t\t\t\n\t\t\tanimated = true;\n\t\t}\n\t\t\n\t\tpublic function fire(fromX:int, fromY:int, velX:int, velY:int):void\n\t\t{\n\t\t\tx = fromX + FlxMath.rand( -weapon.rndFactorPosition.x, weapon.rndFactorPosition.x);\n\t\t\ty = fromY + FlxMath.rand( -weapon.rndFactorPosition.y, weapon.rndFactorPosition.y);\n\t\t\t\n\t\t\tif (accelerates)\n\t\t\t{\n\t\t\t\tacceleration.x = xAcceleration + FlxMath.rand( -weapon.rndFactorSpeed, weapon.rndFactorSpeed);\n\t\t\t\tacceleration.y = yAcceleration + FlxMath.rand( -weapon.rndFactorSpeed, weapon.rndFactorSpeed);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvelocity.x = velX + FlxMath.rand( -weapon.rndFactorSpeed, weapon.rndFactorSpeed);\n\t\t\t\tvelocity.y = velY + FlxMath.rand( -weapon.rndFactorSpeed, weapon.rndFactorSpeed);\n\t\t\t}\n\t\t\t\n\t\t\tpostFire();\n\t\t}\n\t\t\n\t\tpublic function fireAtMouse(fromX:int, fromY:int, speed:int):void\n\t\t{\n\t\t\tx = fromX + FlxMath.rand( -weapon.rndFactorPosition.x, weapon.rndFactorPosition.x);\n\t\t\ty = fromY + FlxMath.rand( -weapon.rndFactorPosition.y, weapon.rndFactorPosition.y);\n\t\t\t\n\t\t\tif (accelerates)\n\t\t\t{\n\t\t\t\tFlxVelocity.accelerateTowardsMouse(this, speed + FlxMath.rand( -weapon.rndFactorSpeed, weapon.rndFactorSpeed), maxVelocity.x, maxVelocity.y);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tFlxVelocity.moveTowardsMouse(this, speed + FlxMath.rand( -weapon.rndFactorSpeed, weapon.rndFactorSpeed));\n\t\t\t}\n\t\t\t\n\t\t\tpostFire();\n\t\t}\n\t\t\n\t\tpublic function fireAtPosition(fromX:int, fromY:int, toX:int, toY:int, speed:int):void\n\t\t{\n\t\t\tx = fromX + FlxMath.rand( -weapon.rndFactorPosition.x, weapon.rndFactorPosition.x);\n\t\t\ty = fromY + FlxMath.rand( -weapon.rndFactorPosition.y, weapon.rndFactorPosition.y);\n\t\t\t\n\t\t\tif (accelerates)\n\t\t\t{\n\t\t\t\tFlxVelocity.accelerateTowardsPoint(this, new FlxPoint(toX, toY), speed + FlxMath.rand( -weapon.rndFactorSpeed, weapon.rndFactorSpeed), maxVelocity.x, maxVelocity.y);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tFlxVelocity.moveTowardsPoint(this, new FlxPoint(toX, toY), speed + FlxMath.rand( -weapon.rndFactorSpeed, weapon.rndFactorSpeed));\n\t\t\t}\n\t\t\t\n\t\t\tpostFire();\n\t\t}\n\t\t\n\t\tpublic function fireAtTarget(fromX:int, fromY:int, target:FlxSprite, speed:int):void\n\t\t{\n\t\t\tx = fromX + FlxMath.rand( -weapon.rndFactorPosition.x, weapon.rndFactorPosition.x);\n\t\t\ty = fromY + FlxMath.rand( -weapon.rndFactorPosition.y, weapon.rndFactorPosition.y);\n\t\t\t\n\t\t\tif (accelerates)\n\t\t\t{\n\t\t\t\tFlxVelocity.accelerateTowardsObject(this, target, speed + FlxMath.rand( -weapon.rndFactorSpeed, weapon.rndFactorSpeed), maxVelocity.x, maxVelocity.y);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tFlxVelocity.moveTowardsObject(this, target, speed + FlxMath.rand( -weapon.rndFactorSpeed, weapon.rndFactorSpeed));\n\t\t\t}\n\t\t\t\n\t\t\tpostFire();\n\t\t}\n\t\t\n\t\tpublic function fireFromAngle(fromX:int, fromY:int, fireAngle:int, speed:int):void\n\t\t{\n\t\t\tx = fromX + FlxMath.rand( -weapon.rndFactorPosition.x, weapon.rndFactorPosition.x);\n\t\t\ty = fromY + FlxMath.rand( -weapon.rndFactorPosition.y, weapon.rndFactorPosition.y);\n\t\t\t\n\t\t\tvar newVelocity:FlxPoint = FlxVelocity.velocityFromAngle(fireAngle + FlxMath.rand( -weapon.rndFactorAngle, weapon.rndFactorAngle), speed + FlxMath.rand( -weapon.rndFactorSpeed, weapon.rndFactorSpeed));\n\t\t\t\n\t\t\tif (accelerates)\n\t\t\t{\n\t\t\t\tacceleration.x = newVelocity.x;\n\t\t\t\tacceleration.y = newVelocity.y;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvelocity.x = newVelocity.x;\n\t\t\t\tvelocity.y = newVelocity.y;\n\t\t\t}\n\t\t\t\n\t\t\tpostFire();\n\t\t}\n\t\t\n\t\tprivate function postFire():void\n\t\t{\n\t\t\tif (animated)\n\t\t\t{\n\t\t\t\tplay(\"fire\");\n\t\t\t}\n\t\t\t\n\t\t\tif (weapon.bulletElasticity > 0)\n\t\t\t{\n\t\t\t\telasticity = weapon.bulletElasticity;\n\t\t\t}\n\t\t\t\n\t\t\texists = true;\n\t\t\t\n\t\t\tlaunchTime = getTimer();\n\t\t\t\n\t\t\tif (weapon.bulletLifeSpan > 0)\n\t\t\t{\n\t\t\t\tlifespan = weapon.bulletLifeSpan + FlxMath.rand( -weapon.rndFactorLifeSpan, weapon.rndFactorLifeSpan);\n\t\t\t\texpiresTime = getTimer() + lifespan;\n\t\t\t}\n\t\t\t\n\t\t\tif (weapon.onFireCallback is Function)\n\t\t\t{\n\t\t\t\tweapon.onFireCallback.apply();\n\t\t\t}\n\t\t\t\n\t\t\tif (weapon.onFireSound)\n\t\t\t{\n\t\t\t\tweapon.onFireSound.play();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic function set xGravity(gx:int):void\n\t\t{\n\t\t\tacceleration.x = gx;\n\t\t}\n\t\t\n\t\tpublic function set yGravity(gy:int):void\n\t\t{\n\t\t\tacceleration.y = gy;\n\t\t}\n\t\t\n\t\tpublic function set maxVelocityX(mx:int):void\n\t\t{\n\t\t\tmaxVelocity.x = mx;\n\t\t}\n\t\t\n\t\tpublic function set maxVelocityY(my:int):void\n\t\t{\n\t\t\tmaxVelocity.y = my;\n\t\t}\n\t\t\n\t\toverride public function update():void\n\t\t{\n\t\t\tif (lifespan > 0 && getTimer() > expiresTime)\n\t\t\t{\n\t\t\t\tkill();\n\t\t\t}\n\t\t\t\n\t\t\tif (FlxMath.pointInFlxRect(x, y, weapon.bounds) == false)\n\t\t\t{\n\t\t\t\tkill();\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/BaseTypes/MouseSpring.as",
    "content": "package org.flixel.plugin.photonstorm.BaseTypes \n{\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.FlxExtendedSprite;\n\t\n\tpublic class MouseSpring \n\t{\n\t\tpublic var sprite:FlxExtendedSprite;\n\t\t\n\t\t/**\n\t\t * The tension of the spring, smaller numbers create springs closer to the mouse pointer\n\t\t * @default 0.1\n\t\t */\n\t\tpublic var tension:Number = 0.1;\n\t\t\n\t\t/**\n\t\t * The friction applied to the spring as it moves\n\t\t * @default 0.95\n\t\t */\n\t\tpublic var friction:Number = 0.95;\n\t\t\n\t\t/**\n\t\t * The gravity controls how far \"down\" the spring hangs (use a negative value for it to hang up!)\n\t\t * @default 0\n\t\t */\n\t\tpublic var gravity:Number = 0;\n\t\t\n\t\tprivate var retainVelocity:Boolean = false;\n\t\t\n\t\tprivate var vx:Number = 0;\n\t\tprivate var vy:Number = 0;\n\t\n\t\tprivate var dx:Number = 0;\n\t\tprivate var dy:Number = 0;\n\t\t\n\t\tprivate var ax:Number = 0;\n\t\tprivate var ay:Number = 0;\n\t\t\n\t\t/**\n\t\t * Adds a spring between the mouse and a Sprite.\n\t\t * \n\t\t * @param\tsprite\t\t\t\tThe FlxExtendedSprite to which this spring is attached\n\t\t * @param\tretainVelocity\t\ttrue to retain the velocity of the spring when the mouse is released, or false to clear it\n\t\t * @param\ttension\t\t\t\tThe tension of the spring, smaller numbers create springs closer to the mouse pointer\n\t\t * @param\tfriction\t\t\tThe friction applied to the spring as it moves\n\t\t * @param\tgravity\t\t\t\tThe gravity controls how far \"down\" the spring hangs (use a negative value for it to hang up!)\n\t\t */\n\t\tpublic function MouseSpring(sprite:FlxExtendedSprite, retainVelocity:Boolean = false, tension:Number = 0.1, friction:Number = 0.95, gravity:Number = 0)\n\t\t{\n\t\t\tthis.sprite = sprite;\n\t\t\tthis.retainVelocity = retainVelocity;\n\t\t\tthis.tension = tension;\n\t\t\tthis.friction = friction;\n\t\t\tthis.gravity = gravity;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Updates the spring physics and repositions the sprite\n\t\t */\n\t\tpublic function update():void\n\t\t{\n\t\t\tdx = FlxG.mouse.x - sprite.springX;\n\t\t\tdy = FlxG.mouse.y - sprite.springY;\n\t\t\t\n\t\t\tax = dx * tension;\n\t\t\tay = dy * tension;\n\t\t\t\n\t\t\tvx += ax;\n\t\t\tvy += ay;\n\t\t\t\n\t\t\tvy += gravity;\n\t\t\tvx *= friction;\n\t\t\tvy *= friction;\n\t\t\t\n\t\t\tsprite.x += vx;\n\t\t\tsprite.y += vy;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Resets the internal spring physics\n\t\t */\n\t\tpublic function reset():void\n\t\t{\n\t\t\tvx = 0;\n\t\t\tvy = 0;\n\t\t\n\t\t\tdx = 0;\n\t\t\tdy = 0;\n\t\t\t\n\t\t\tax = 0;\n\t\t\tay = 0;\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FX/BaseFX.as",
    "content": "/**\n * BaseFX - Special FX Plugin\n * -- Part of the Flixel Power Tools set\n * \n * v1.1 Fixed some documentation\n * v1.0 First release\n * \n * @version 1.1 - June 10th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.FX \n{\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport org.flixel.FlxSprite;\n\timport flash.display.BitmapData;\n\t\n\tpublic class BaseFX \n\t{\n\t\t/**\n\t\t * Set to false to stop this effect being updated by the FlxSpecialFX Plugin. Set to true to enable.\n\t\t */\n\t\tpublic var active:Boolean;\n\t\t\n\t\t/**\n\t\t * The FlxSprite into which the effect is drawn. Add this to your FlxState / FlxGroup to display the effect.\n\t\t */\n\t\tpublic var sprite:FlxSprite;\n\t\t\n\t\t/**\n\t\t * A scratch bitmapData used to build-up the effect before passing to sprite.pixels\n\t\t */\n\t\tinternal var canvas:BitmapData;\n\t\t\n\t\t/**\n\t\t * TODO A snapshot of the sprite background before the effect is applied\n\t\t */\n\t\tinternal var back:BitmapData;\n\t\t\n\t\tinternal var image:BitmapData;\n\t\tinternal var sourceRef:FlxSprite;\n\t\tinternal var updateFromSource:Boolean;\n\t\tinternal var clsRect:Rectangle;\n\t\tinternal var clsPoint:Point;\n\t\tinternal var clsColor:uint;\n\t\t\n\t\t//\tFor staggered drawing updates\n\t\tinternal var updateLimit:uint = 0;\n\t\tinternal var lastUpdate:uint = 0;\n\t\tinternal var ready:Boolean = false;\n\t\t\n\t\tinternal var copyRect:Rectangle;\n\t\tinternal var copyPoint:Point;\n\t\t\n\t\tpublic function BaseFX() \n\t\t{\n\t\t\tactive = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Starts the effect runnning\n\t\t * \n\t\t * @param\tdelay\tHow many \"game updates\" should pass between each update? If your game runs at 30fps a value of 0 means it will do 30 updates per second. A value of 1 means it will do 15 updates per second, etc.\n\t\t */\n\t\tpublic function start(delay:uint = 0):void\n\t\t{\n\t\t\tupdateLimit = delay;\n\t\t\tlastUpdate = 0;\n\t\t\tready = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Pauses the effect from running. The draw function is still called each loop, but the pixel data is stopped from updating.<br>\n\t\t * To disable the SpecialFX Plugin from calling the FX at all set the \"active\" parameter to false.\n\t\t */\n\t\tpublic function stop():void\n\t\t{\n\t\t\tready = false;\n\t\t}\n\t\t\n\t\tpublic function destroy():void\n\t\t{\n\t\t\tif (sprite)\n\t\t\t{\n\t\t\t\tsprite.kill();\n\t\t\t}\n\t\t\t\n\t\t\tif (canvas)\n\t\t\t{\n\t\t\t\tcanvas.dispose();\n\t\t\t}\n\t\t\t\n\t\t\tif (back)\n\t\t\t{\n\t\t\t\tback.dispose();\n\t\t\t}\n\t\t\t\n\t\t\tif (image)\n\t\t\t{\n\t\t\t\timage.dispose();\n\t\t\t}\n\t\t\t\n\t\t\tsourceRef = null;\n\t\t\t\n\t\t\tactive = false;\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FX/BlurFX.as",
    "content": "/**\n * BlurFX - Special FX Plugin\n * -- Part of the Flixel Power Tools set\n * \n * v1.0 First release\n * \n * @version 1.0 - June 10th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.FX \n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport flash.utils.Dictionary;\n\timport flash.filters.BlurFilter;\n\t\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.*;\n\t\n\t/**\n\t * Creates a blur effect\n\t */\n\tpublic class BlurFX extends BaseFX\n\t{\n\t\tprivate var objects:Array;\n\t\tprivate var blurFilter:BlurFilter;\n\t\t\n\t\tpublic function BlurFX() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new BlurFX the given width/height in size.<br>\n\t\t * The blur X / Y / Quality parameters all control the strength of the effect.<br>\n\t\t * Add the resulting FlxSprite to your display to see the effect.\n\t\t * \n\t\t * @param\twidth\t\t\tThe width (in pixels) of the resulting FlxSprite containing the Blur effect\n\t\t * @param\theight\t\t\tThe height (in pixels) of the resulting FlxSprite containing the Blur effect\n\t\t * @param\tblurX\t\t\tThe amount of horizontal blur.\n\t\t * @param\tblurY\t\t\tThe amount of vertical blur.\n\t\t * @param\tblurQuality\t\tThe number of times to perform the blur. Default is 1 (fastest, single pass) up to a maxium of 15 (very VERY expensive!)\n\t\t * \n\t\t * @return\tAn FlxSprite containing the updating blur effect\n\t\t */\n\t\tpublic function create(width:int, height:int, blurX:Number, blurY:Number, blurQuality:int = 1):FlxSprite\n\t\t{\n\t\t\tsprite = new FlxSprite(0, 0).makeGraphic(width, height, 0x0, true);\n\t\t\t\n\t\t\tobjects = new Array;\n\t\t\t\n\t\t\tblurFilter = new BlurFilter(blurX, blurY, blurQuality);\n\t\t\t\n\t\t\tcopyPoint = new Point(0, 0);\n\t\t\tcopyRect = new Rectangle(0, 0, width, height);\n\t\t\t\n\t\t\treturn sprite;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adds an FlxSprite to the BlurFX. Every loop this sprite will be drawn to the FX and then blurred if the FlxSprite is both onScreen() and visible.\n\t\t * \n\t\t * @param\tsource\t\tThe FlxSprite to add to the blur effect\n\t\t * @param\tautoRemove\tIf true and the FlxSprite.exists value ever equals false then BlurFX will automatically remove it\n\t\t */\n\t\tpublic function addSprite(source:FlxSprite, autoRemove:Boolean = true):void\n\t\t{\n\t\t\tobjects.push( { sprite: source, autoRemove: autoRemove } );\n\t\t\t\n\t\t\tif (active == false)\n\t\t\t{\n\t\t\t\tactive = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes the FlxSprite from the effect\n\t\t * \n\t\t * @param\tsource\t\tThe FlxSprite to remove from the blur effect\n\t\t */\n\t\tpublic function removeSprite(source:FlxSprite):void\n\t\t{\n\t\t\tfor (var i:int = 0; i < objects.length; i++)\n\t\t\t{\n\t\t\t\tif (objects[i].sprite == source)\n\t\t\t\t{\n\t\t\t\t\tobjects.splice(i, 1);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic function draw():void\n\t\t{\n\t\t\tif (ready)\n\t\t\t{\n\t\t\t\t//\tWrite every object to the canvas\n\t\t\t\tfor each (var obj:Object in objects)\n\t\t\t\t{\n\t\t\t\t\t//\tRemoval check\n\t\t\t\t\tif (obj.sprite.exists == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tremoveSprite(obj.sprite);\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 (obj.sprite.visible && obj.sprite.onScreen())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsprite.stamp(obj.sprite, obj.sprite.x, obj.sprite.y);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//\tWe'll use the update timer to control how often the blur is run, not how often the objects are drawn\n\t\t\t\tif (lastUpdate != updateLimit)\n\t\t\t\t{\n\t\t\t\t\tlastUpdate++;\n\t\t\t\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//\tThen blur it\n\t\t\t\tsprite.pixels.applyFilter(sprite.pixels, copyRect, copyPoint, blurFilter);\n\t\t\t\t\n\t\t\t\tlastUpdate = 0;\n\t\t\t\t\n\t\t\t\tsprite.dirty = true;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FX/CenterSlideFX.as",
    "content": "/**\n * CenterSlideFX - Special FX Plugin\n * -- Part of the Flixel Power Tools set\n * \n * v1.1 Refactored main loop a little and added reverse function\n * v1.0 First release\n * \n * @version 1.1 - June 13th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.FX \n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.*;\n\t\n\t/**\n\t * Makes an image expand or collapse from its center\n\t */\n\tpublic class CenterSlideFX extends BaseFX\n\t{\n\t\t/**\n\t\t * True when the effect has completed. False while the effect is running.\n\t\t */\n\t\tpublic var complete:Boolean;\n\t\t\n\t\t/**\n\t\t * A function that is called once the effect is has finished running and is complete\n\t\t */\n\t\tpublic var completeCallback:Function;\n\t\t\n\t\tprivate var pixels:uint;\n\t\tprivate var direction:uint;\n\t\t\n\t\tprivate var sideA:Rectangle;\n\t\tprivate var sideB:Rectangle;\n\t\tprivate var pointA:Point;\n\t\tprivate var pointB:Point;\n\t\t\n\t\tpublic static const REVEAL_VERTICAL:uint = 0;\n\t\tpublic static const REVEAL_HORIZONTAL:uint = 1;\n\t\tpublic static const HIDE_VERTICAL:uint = 2;\n\t\tpublic static const HIDE_HORIZONTAL:uint = 3;\n\t\t\n\t\tpublic function CenterSlideFX() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new CenterSlide effect from the given FlxSprite. The original sprite remains unmodified.<br>\n\t\t * The resulting FlxSprite will take on the same width / height and x/y coordinates of the source FlxSprite.\n\t\t * \n\t\t * @param\tsource\t\t\t\tThe FlxSprite providing the image data for this effect. The resulting FlxSprite takes on the source width, height and x/y position.\n\t\t * @param\tdirection\t\t\tREVEAL_VERTICAL, REVEAL_HORIZONTAL, HIDE_VERTICAL or HIDE_HORIZONTAL\n\t\t * @param\tpixels\t\t\t\tHow many pixels to slide update (default 1)\n\t\t * @param\tbackgroundColor\t\tThe background colour of the FlxSprite the effect is drawn in to (default 0x0 = transparent)\n\t\t * \n\t\t * @return\tAn FlxSprite with the effect running through it, which should be started with a call to CenterSlideFX.start()\n\t\t */\n\t\tpublic function createFromFlxSprite(source:FlxSprite, direction:uint = 0, pixels:uint = 1, backgroundColor:uint = 0x0):FlxSprite\n\t\t{\n\t\t\treturn create(source.pixels, source.x, source.y, direction, pixels, backgroundColor);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new CenterSlide effect from the given Class (which must contain a Bitmap) usually from an Embedded bitmap.\n\t\t * \n\t\t * @param\tsource\t\t\t\tThe Class providing the bitmapData for this effect, usually from an Embedded bitmap.\n\t\t * @param\tx\t\t\t\t\tThe x coordinate (in game world pixels) that the resulting FlxSprite will be created at.\n\t\t * @param\ty\t\t\t\t\tThe x coordinate (in game world pixels) that the resulting FlxSprite will be created at.\n\t\t * @param\tdirection\t\t\tREVEAL_VERTICAL, REVEAL_HORIZONTAL, HIDE_VERTICAL or HIDE_HORIZONTAL\n\t\t * @param\tpixels\t\t\t\tHow many pixels to slide update (default 1)\n\t\t * @param\tbackgroundColor\t\tThe background colour of the FlxSprite the effect is drawn in to (default 0x0 = transparent)\n\t\t * \n\t\t * @return\tAn FlxSprite with the effect running through it, which should be started with a call to CenterSlideFX.start()\n\t\t */\n\t\tpublic function createFromClass(source:Class, x:int, y:int, direction:uint = 0, pixels:uint = 1, backgroundColor:uint = 0x0):FlxSprite\n\t\t{\n\t\t\treturn create((new source).bitmapData, x, y, direction, pixels, backgroundColor);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new CenterSlide effect from the given bitmapData.\n\t\t * \n\t\t * @param\tsource\t\t\t\tThe bitmapData image to use for this effect.\n\t\t * @param\tx\t\t\t\t\tThe x coordinate (in game world pixels) that the resulting FlxSprite will be created at.\n\t\t * @param\ty\t\t\t\t\tThe x coordinate (in game world pixels) that the resulting FlxSprite will be created at.\n\t\t * @param\tdirection\t\t\tREVEAL_VERTICAL, REVEAL_HORIZONTAL, HIDE_VERTICAL or HIDE_HORIZONTAL\n\t\t * @param\tpixels\t\t\t\tHow many pixels to slide update (default 1)\n\t\t * @param\tbackgroundColor\t\tThe background colour of the FlxSprite the effect is drawn in to (default 0x0 = transparent)\n\t\t * \n\t\t * @return\tAn FlxSprite with the effect running through it, which should be started with a call to CenterSlideFX.start()\n\t\t */\n\t\tpublic function createFromBitmapData(source:BitmapData, x:int, y:int, direction:uint = 0, pixels:uint = 1, backgroundColor:uint = 0x0):FlxSprite\n\t\t{\n\t\t\treturn create(source, x, y, direction, pixels, backgroundColor);\n\t\t}\n\t\t\n\t\tprivate function create(source:BitmapData, x:int, y:int, direction:uint = 0, pixels:uint = 1, backgroundColor:uint = 0x0):FlxSprite\n\t\t{\n\t\t\tsprite = new FlxSprite(x, y).makeGraphic(source.width, source.height, backgroundColor);\n\t\t\t\n\t\t\tcanvas = new BitmapData(source.width, source.height, true, backgroundColor);\n\t\t\t\n\t\t\timage = source.clone();\n\t\t\t\n\t\t\tclsRect = new Rectangle(0, 0, canvas.width, canvas.height);\n\t\t\tclsColor = backgroundColor;\n\t\t\t\n\t\t\tthis.direction = direction;\n\t\t\tthis.pixels = pixels;\n\t\t\t\n\t\t\tvar midway:int = int(source.height / 2);\n\t\t\t\n\t\t\tswitch (direction)\n\t\t\t{\n\t\t\t\tcase REVEAL_VERTICAL:\n\t\t\t\t\tsideA = new Rectangle(0, 0, source.width, pixels);\n\t\t\t\t\tsideB = new Rectangle(0, source.height - pixels, source.width, pixels);\n\t\t\t\t\tpointA = new Point(0, midway);\n\t\t\t\t\tpointB = new Point(0, midway);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase REVEAL_HORIZONTAL:\n\t\t\t\t\tmidway = int(source.width / 2);\n\t\t\t\t\tsideA = new Rectangle(0, 0, pixels, source.height);\n\t\t\t\t\tsideB = new Rectangle(source.width - pixels, 0, pixels, source.height);\n\t\t\t\t\tpointA = new Point(midway, 0);\n\t\t\t\t\tpointB = new Point(midway, 0);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase HIDE_VERTICAL:\n\t\t\t\t\tcanvas = image.clone();\n\t\t\t\t\tsprite.pixels = canvas;\n\t\t\t\t\tsprite.dirty = true;\n\t\t\t\t\tsideA = new Rectangle(0, 0, source.width, midway);\n\t\t\t\t\tsideB = new Rectangle(0, midway, source.width, source.height - midway);\n\t\t\t\t\tpointA = new Point(0, 0);\n\t\t\t\t\tpointB = new Point(0, midway);\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase HIDE_HORIZONTAL:\n\t\t\t\t\tcanvas = image.clone();\n\t\t\t\t\tsprite.pixels = canvas;\n\t\t\t\t\tsprite.dirty = true;\n\t\t\t\t\tmidway = int(source.width / 2);\n\t\t\t\t\tsideA = new Rectangle(0, 0, midway, source.height);\n\t\t\t\t\tsideB = new Rectangle(midway, 0, source.width - midway, source.height);\n\t\t\t\t\tpointA = new Point(0, 0);\n\t\t\t\t\tpointB = new Point(midway, 0);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tactive = true;\n\t\t\tcomplete = false;\n\t\t\t\n\t\t\treturn sprite;\n\t\t}\n\t\t\n\t\tpublic function reverse():void\n\t\t{\n\t\t\tif (direction == REVEAL_VERTICAL)\n\t\t\t{\n\t\t\t\tdirection = HIDE_VERTICAL;\n\t\t\t\tcomplete = false;\n\t\t\t}\n\t\t\telse if (direction == REVEAL_HORIZONTAL)\n\t\t\t{\n\t\t\t\tdirection = HIDE_HORIZONTAL;\n\t\t\t\tcomplete = false;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic function draw():void\n\t\t{\n\t\t\tif (ready && complete == false)\n\t\t\t{\n\t\t\t\tif (lastUpdate != updateLimit)\n\t\t\t\t{\n\t\t\t\t\tlastUpdate++;\n\t\t\t\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcanvas.fillRect(clsRect, clsColor);\n\t\t\t\tcanvas.copyPixels(image, sideA, pointA, null, null, true);\n\t\t\t\tcanvas.copyPixels(image, sideB, pointB, null, null, true);\n\t\t\t\t\n\t\t\t\tswitch (direction)\n\t\t\t\t{\n\t\t\t\t\tcase REVEAL_VERTICAL:\n\t\t\t\t\t\tsideA.height += pixels;\n\t\t\t\t\t\tpointA.y -= pixels;\n\t\t\t\t\t\tsideB.height += pixels;\n\t\t\t\t\t\tsideB.y -= pixels;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase REVEAL_HORIZONTAL:\n\t\t\t\t\t\tsideA.width += pixels;\n\t\t\t\t\t\tpointA.x -= pixels;\n\t\t\t\t\t\tsideB.width += pixels;\n\t\t\t\t\t\tsideB.x -= pixels;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase HIDE_VERTICAL:\n\t\t\t\t\t\tsideA.height -= pixels;\n\t\t\t\t\t\tpointA.y += pixels;\n\t\t\t\t\t\tsideB.height -= pixels;\n\t\t\t\t\t\tsideB.y += pixels;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase HIDE_HORIZONTAL:\n\t\t\t\t\t\tsideA.width -= pixels;\n\t\t\t\t\t\tpointA.x += pixels;\n\t\t\t\t\t\tsideB.width -= pixels;\n\t\t\t\t\t\tsideB.x += pixels;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//\tAre we finished?\n\t\t\t\tif ((direction == REVEAL_VERTICAL && pointA.y < 0) || (direction == REVEAL_HORIZONTAL && pointA.x < 0))\n\t\t\t\t{\n\t\t\t\t\tcanvas = image.clone();\n\t\t\t\t\tcomplete = true;\n\t\t\t\t}\n\t\t\t\telse if ((direction == HIDE_VERTICAL && sideA.height <= 0) || (direction == HIDE_HORIZONTAL && sideA.width <= 0))\n\t\t\t\t{\n\t\t\t\t\tcanvas.fillRect(clsRect, clsColor);\n\t\t\t\t\tcomplete = true;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tlastUpdate = 0;\n\t\t\t\t\n\t\t\t\tsprite.pixels = canvas;\n\t\t\t\tsprite.dirty = true;\n\t\t\t\t\n\t\t\t\tif (complete && completeCallback is Function)\n\t\t\t\t{\n\t\t\t\t\tcompleteCallback.call();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FX/FloodFillFX.as",
    "content": "/**\n * FloodFillFX - Special FX Plugin\n * -- Part of the Flixel Power Tools set\n * \n * v1.1 Renamed - was \"DropDown\", but now a more accurate \"flood fill\"\n * v1.0 First release\n * \n * @version 1.1 - May 31st 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.FX \n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.*;\n\t\n\t/**\n\t * Creates a flood fill effect FlxSprite, useful for bringing in images in cool ways\n\t */\n\tpublic class FloodFillFX extends BaseFX\n\t{\n\t\tprivate var complete:Boolean;\n\t\tprivate var chunk:uint;\n\t\tprivate var offset:uint;\n\t\tprivate var dropDirection:uint;\n\t\tprivate var dropRect:Rectangle;\n\t\tprivate var dropPoint:Point;\n\t\tprivate var dropY:uint;\n\t\t\n\t\tpublic function FloodFillFX() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new Flood Fill effect from the given image\n\t\t * \n\t\t * @param\tsource\t\t\t\tThe source image bitmapData to use for the drop\n\t\t * @param\tx\t\t\t\t\tThe x coordinate to place the resulting effect sprite\n\t\t * @param\ty\t\t\t\t\tThe y coordinate to place the resulting effect sprite\n\t\t * @param\twidth\t\t\t\tThe width of the resulting effet sprite. Doesn't have to match the source image\n\t\t * @param\theight\t\t\t\tThe height of the resulting effet sprite. Doesn't have to match the source image\n\t\t * @param\tdirection\t\t\t0 = Top to bottom. 1 = Bottom to top. 2 = Left to Right. 3 = Right to Left.\n\t\t * @param\tpixels\t\t\t\tHow many pixels to drop per update (default 1)\n\t\t * @param\tsplit\t\t\t\tBoolean (default false) - if split it will drop from opposite sides at the same time\n\t\t * @param\tbackgroundColor\t\tThe background colour of the FlxSprite the effect is drawn in to (default 0x0 = transparent)\n\t\t * \n\t\t * @return\tAn FlxSprite with the effect ready to run in it\n\t\t */\n\t\tpublic function create(source:FlxSprite, x:int, y:int, width:uint, height:uint, direction:uint = 0, pixels:uint = 1, split:Boolean = false, backgroundColor:uint = 0x0):FlxSprite\n\t\t{\n\t\t\tsprite = new FlxSprite(x, y).makeGraphic(width, height, backgroundColor);\n\t\t\t\n\t\t\tcanvas = new BitmapData(width, height, true, backgroundColor);\n\t\t\t\n\t\t\tif (source.pixels.width != width || source.pixels.height != height)\n\t\t\t{\n\t\t\t\timage = new BitmapData(width, height, true, backgroundColor);\n\t\t\t\timage.copyPixels(source.pixels, new Rectangle(0, 0, source.pixels.width, source.pixels.height), new Point(0, height - source.pixels.height));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\timage = source.pixels;\n\t\t\t}\n\t\t\t\n\t\t\toffset = pixels;\n\t\t\t\n\t\t\tdropDirection = direction;\n\t\t\tdropRect = new Rectangle(0, canvas.height - offset, canvas.width, offset);\n\t\t\tdropPoint = new Point(0, 0);\n\t\t\tdropY = canvas.height;\n\t\t\t\n\t\t\tactive = true;\n\t\t\t\n\t\t\treturn sprite;\n\t\t}\n\t\t\n\t\tpublic function draw():void\n\t\t{\n\t\t\tif (ready && complete == false)\n\t\t\t{\n\t\t\t\tif (lastUpdate != updateLimit)\n\t\t\t\t{\n\t\t\t\t\tlastUpdate++;\n\t\t\t\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcanvas.lock();\n\t\t\t\t\n\t\t\t\tswitch (dropDirection)\n\t\t\t\t{\n\t\t\t\t\t//\tDropping Down\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\n\t\t\t\t\t\t//\tGet a pixel strip from the picture (starting at the bottom and working way up)\n\t\t\t\t\t\tfor (var y:int = 0; y < dropY; y += offset)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdropPoint.y = y;\n\t\t\t\t\t\t\tcanvas.copyPixels(image, dropRect, dropPoint);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tdropY -= offset;\n\t\t\t\t\t\t\n\t\t\t\t\t\tdropRect.y -= offset;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (dropY <= 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcomplete = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tlastUpdate = 0;\n\t\t\t\t\n\t\t\t\tcanvas.unlock();\n\t\t\t\t\n\t\t\t\tsprite.pixels = canvas;\n\t\t\t\tsprite.dirty = true;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FX/GlitchFX.as",
    "content": "/**\n * GlitchFX - Special FX Plugin\n * -- Part of the Flixel Power Tools set\n * \n * v1.2 Fixed updateFromSource github issue #8 (thanks CoderBrandon)\n * v1.1 Added changeGlitchValues support\n * v1.0 First release\n * \n * @version 1.2 - August 8th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.FX \n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.*;\n\t\n\t/**\n\t * Creates a static / glitch / monitor-corruption style effect on an FlxSprite\n\t * \n\t * TODO:\n\t * \n\t * Add reduction from really high glitch value down to zero, will smooth the image into place and look cool :)\n\t * Add option to glitch vertically?\n\t * \n\t */\n\tpublic class GlitchFX extends BaseFX\n\t{\n\t\tprivate var glitchSize:uint;\n\t\tprivate var glitchSkip:uint;\n\t\t\n\t\tpublic function GlitchFX() \n\t\t{\n\t\t}\n\t\t\n\t\tpublic function createFromFlxSprite(source:FlxSprite, maxGlitch:uint, maxSkip:uint, autoUpdate:Boolean = false, backgroundColor:uint = 0x0):FlxSprite\n\t\t{\n\t\t\tsprite = new FlxSprite(source.x, source.y).makeGraphic(source.width + maxGlitch, source.height, backgroundColor);\n\t\t\t\n\t\t\tcanvas = new BitmapData(sprite.width, sprite.height, true, backgroundColor);\n\t\t\t\n\t\t\timage = source.pixels;\n\t\t\t\n\t\t\tupdateFromSource = autoUpdate;\n\t\t\t\n\t\t\tif (updateFromSource)\n\t\t\t{\n\t\t\t\tsourceRef = source;\n\t\t\t}\n\t\t\t\n\t\t\tglitchSize = maxGlitch;\n\t\t\tglitchSkip = maxSkip;\n\t\t\t\n\t\t\tclsColor = backgroundColor;\n\t\t\tclsRect = new Rectangle(0, 0, canvas.width, canvas.height);\n\t\t\t\n\t\t\tcopyPoint = new Point(0, 0);\n\t\t\tcopyRect = new Rectangle(0, 0, image.width, 1);\n\t\t\t\n\t\t\tactive = true;\n\t\t\t\n\t\t\treturn sprite;\n\t\t}\n\t\t\n\t\tpublic function changeGlitchValues(maxGlitch:uint, maxSkip:uint):void\n\t\t{\n\t\t\tglitchSize = maxGlitch;\n\t\t\tglitchSkip = maxSkip;\n\t\t}\n\t\t\n\t\tpublic function draw():void\n\t\t{\n\t\t\tif (ready)\n\t\t\t{\n\t\t\t\tif (lastUpdate != updateLimit)\n\t\t\t\t{\n\t\t\t\t\tlastUpdate++;\n\t\t\t\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (updateFromSource && sourceRef.exists)\n\t\t\t\t{\n\t\t\t\t\timage = sourceRef.framePixels;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcanvas.lock();\n\t\t\t\tcanvas.fillRect(clsRect, clsColor);\n\t\t\t\t\n\t\t\t\tvar rndSkip:uint = 1 + int(Math.random() * glitchSkip);\n\t\t\t\t\n\t\t\t\tcopyRect.y = 0;\n\t\t\t\tcopyPoint.y = 0;\n\t\t\t\tcopyRect.height = rndSkip;\n\t\t\t\t\n\t\t\t\tfor (var y:int = 0; y < sprite.height; y += rndSkip)\n\t\t\t\t{\n\t\t\t\t\tcopyPoint.x = int(Math.random() * glitchSize);\n\t\t\t\t\tcanvas.copyPixels(image, copyRect, copyPoint);\n\t\t\t\t\t\n\t\t\t\t\tcopyRect.y += rndSkip;\n\t\t\t\t\tcopyPoint.y += rndSkip;\n\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\tcanvas.unlock();\n\t\t\t\t\n\t\t\t\tlastUpdate = 0;\n\t\t\t\t\n\t\t\t\tsprite.pixels = canvas;\n\t\t\t\tsprite.dirty = true;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FX/PlasmaFX.as",
    "content": "/**\n * PlasmaFX - Special FX Plugin\n * -- Part of the Flixel Power Tools set\n * \n * v1.4 Moved to the new Special FX Plugins\n * v1.3 Colours updated to include alpha values\n * v1.2 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.4 - May 8th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.FX \n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.*;\n\t\n\t/**\n\t * Creates a plasma effect FlxSprite\n\t */\n\t\n\tpublic class PlasmaFX extends BaseFX\n\t{\n\t\t//private var pos1:uint;\n\t\t//private var pos2:uint;\n\t\t//private var pos3:uint;\n\t\t//private var pos4:uint;\n\t\t\n\t\tpublic var pos1:uint;\n\t\tpublic var pos2:uint;\n\t\tpublic var pos3:uint;\n\t\tpublic var pos4:uint;\n\t\tpublic var depth:uint = 128;\n\t\t\n\t\tprivate var tpos1:uint;\n\t\tprivate var tpos2:uint;\n\t\tprivate var tpos3:uint;\n\t\tprivate var tpos4:uint;\n\t\t\n\t\tprivate var aSin:Array;\n\t\t//private var previousColour:uint;\n\t\tprivate var colours:Array;\n\t\tprivate var step:uint = 0;\n\t\tprivate var span:uint;\n\t\t\n\t\tpublic function PlasmaFX():void\n\t\t{\n\t\t}\n\t\t\n\t\tpublic function create(x:int, y:int, width:uint, height:uint, scaleX:uint = 1, scaleY:uint = 1):FlxSprite\n\t\t{\n\t\t\tsprite = new FlxSprite(x, y).makeGraphic(width, height, 0x0);\n\t\t\t\n\t\t\tif (scaleX != 1 || scaleY != 1)\n\t\t\t{\n\t\t\t\tsprite.scale = new FlxPoint(scaleX, scaleY);\n\t\t\t\tsprite.x += width / scaleX;\n\t\t\t\tsprite.y += height / scaleY;\n\t\t\t}\n\t\t\t\n\t\t\tcanvas = new BitmapData(width, height, true, 0x0);\n\t\t\t\n\t\t\tcolours = FlxColor.getHSVColorWheel();\n\t\t\t\n\t\t\t//colours = FlxColor.getHSVColorWheel(140);\t// now supports alpha :)\n\t\t\t//colours = FlxGradient.createGradientArray(1, 360, [0xff000000, 0xff000000, 0xff000000, 0x00000000, 0xff000000], 2);\t//\tLovely black reveal for over an image\n\t\t\t//colours = FlxGradient.createGradientArray(1, 360, [0xff0000FF, 0xff000000, 0xff8F107C, 0xff00FFFF, 0xff0000FF], 1); // lovely purple black blue thingy\n\t\t\t\n\t\t\tspan = colours.length - 1;\n\t\t\t\n\t\t\taSin = new Array(512);\n\t\t\t\n\t\t\tfor (var i:int = 0; i < 512; i++)\n\t\t\t{\n\t\t\t\t//var rad:Number = (i * 0.703125) * 0.0174532;\n\t\t\t\tvar rad:Number = (i * 0.703125) * 0.0174532;\n\t\t\t\t\n\t\t\t\t//\tAny power of 2!\n\t\t\t\t//\thttp://www.vaughns-1-pagers.com/computer/powers-of-2.htm\n\t\t\t\t//\t256, 512, 1024, 2048, 4096, 8192, 16384\n\t\t\t\taSin[i] = Math.sin(rad) * 1024;\n\t\t\t\t\n\t\t\t\t//aSin[i] = Math.cos(rad) * 1024;\n\t\t\t}\n\t\t\t\n\t\t\tactive = true;\n\t\t\t\n\t\t\ttpos1 = 293;\n\t\t\ttpos2 = 483;\n\t\t\ttpos3 = 120;\n\t\t\ttpos4 = 360;\n\t\t\t\n\t\t\tpos1 = 0;\n\t\t\tpos2 = 5;\n\t\t\tpos3 = 0;\n\t\t\tpos4 = 0;\n\t\t\t\n\t\t\treturn sprite;\n\t\t}\n\t\t\n\t\tpublic function draw():void\n\t\t{\n\t\t\tif (step < 10)\n\t\t\t{\n\t\t\t\t//trace(step, tpos1, tpos2, tpos3, tpos4, pos1, pos2, pos3, pos4, index);\n\t\t\t\tstep++;\n\t\t\t}\n\t\t\t\n\t\t\ttpos4 = pos4;\n\t\t\ttpos3 = pos3;\n\t\t\t\n\t\t\tcanvas.lock();\n\t\t\t\n\t\t\tfor (var y:int = 0; y < canvas.height; y++)\n\t\t\t{\n\t\t\t\ttpos1 = pos1 + 5;\n\t\t\t\ttpos2 = pos2 + 3;\n\t\t\t\t\n\t\t\t\t//tpos1 = pos1;\n\t\t\t\t//tpos2 = pos2;\n\t\t\t\t\n\t\t\t\ttpos2 &= 511;\n\t\t\t\ttpos3 &= 511;\n\t\t\t\t\n\t\t\t\tfor (var x:int = 0; x < canvas.width; x++)\n\t\t\t\t{\n\t\t\t\t\ttpos1 &= 511;\n\t\t\t\t\ttpos2 &= 511;\n\t\t\t\t\t\n\t\t\t\t\tvar x2:int = aSin[tpos1] + aSin[tpos2] + aSin[tpos3] + aSin[tpos4];\n\t\t\t\t\n\t\t\t\t\t//var index:int = depth + (x2 >> 4);\n\t\t\t\t\tvar index:int = depth + (x2 >> 4);\n\t\t\t\t\t//p = (128 + (p >> 4)) & 255;\n\n\t\t\t\t\t\n\t\t\t\t\tif (index <= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tindex += span;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (index >= span)\n\t\t\t\t\t{\n\t\t\t\t\t\tindex -= span;\n\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\tcanvas.setPixel32(x, y, colours[index]);\n\t\t\t\t\t\n\t\t\t\t\ttpos1 += 5;\n\t\t\t\t\ttpos2 += 3;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ttpos3 += 1;\n\t\t\t\ttpos4 += 3;\n\t\t\t}\n\t\t\t\n\t\t\tcanvas.unlock();\n\t\t\t\n\t\t\tsprite.pixels = canvas;\n\t\t\tsprite.dirty = true;\n\t\t\t\n\t\t\tpos1 += 4;\t// horizontal shift\n\t\t\tpos3 += 2;\t// vertical shift\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FX/RainbowLineFX.as",
    "content": "/**\n * RainbowLineFX - A Special FX Plugin\n * -- Part of the Flixel Power Tools set\n * \n * v1.0 Built into the new FlxSpecialFX system\n * \n * @version 1.0 - May 9th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n * @see Requires FlxGradient, FlxMath\n*/\n\npackage org.flixel.plugin.photonstorm.FX \n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.*;\n\t\n\t/**\n\t * Creates a Rainbow Line Effect - typically a rainbow sequence of color values passing through a 1px high line\n\t */\n\tpublic class RainbowLineFX extends BaseFX\n\t{\n\t\tprivate var lineColors:Array;\n\t\tprivate var maxColor:uint;\n\t\tprivate var currentColor:uint;\n\t\tprivate var fillRect:Rectangle;\n\t\tprivate var speed:uint;\n\t\tprivate var chunk:uint;\n\t\tprivate var direction:uint;\n\t\tprivate var setPixel:Boolean;\n\t\t\n\t\tpublic function RainbowLineFX() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a Color Line FlxSprite.\n\t\t * \n\t\t * @param\tx\t\t\tThe x coordinate of the FlxSprite in game world pixels\n\t\t * @param\ty\t\t\tThe y coordinate of the FlxSprite in game world pixels\n\t\t * @param\twidth\t\tThe width of the FlxSprite in pixels\n\t\t * @param\theight\t\tThe height of the FlxSprite in pixels\n\t\t * @param\tcolors\t\tAn Array of color values used to create the line. If null (default) the HSV Color Wheel is used, giving a full spectrum rainbow effect\n\t\t * @param\tcolorWidth\tThe width of the color range controls how much interpolation occurs between each color in the colors array (default 360)\n\t\t * @param\tcolorSpeed\tThe speed at which the Rainbow Line cycles through its colors (default 1)\n\t\t * @param\tstepSize\tThe size of each \"chunk\" of the Rainbow Line - use a higher value for a more retro look (default 1)\n\t\t * @param\tfadeWidth\tIf you want the Line to fade from fadeColor to the first color in the colors array, and then out again, set this value to the amount of transition you want (128 looks good)\n\t\t * @param\tfadeColor\tThe default fade color is black, but if you need to alpha it, or change for a different color, set it here\n\t\t * \n\t\t * @return\tAn FlxSprite which automatically updates each draw() to cycle the colors through it\n\t\t */\n\t\tpublic function create(x:int, y:int, width:uint, height:uint = 1, colors:Array = null, colorWidth:uint = 360, colorSpeed:uint = 1, stepSize:uint = 1, fadeWidth:uint = 128, fadeColor:uint = 0xff000000):FlxSprite\n\t\t{\n\t\t\tsprite = new FlxSprite(x, y).makeGraphic(width, height, 0x0);\n\t\t\t\n\t\t\tcanvas = new BitmapData(width, height, true, 0x0);\n\t\t\t\n\t\t\tif (colors is Array)\n\t\t\t{\n\t\t\t\tlineColors = FlxGradient.createGradientArray(1, colorWidth, colors);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tlineColors = FlxColor.getHSVColorWheel();\n\t\t\t}\n\t\t\t\n\t\t\tcurrentColor = 0;\n\t\t\tmaxColor = lineColors.length - 1;\n\t\t\t\n\t\t\tif (fadeWidth != 0)\n\t\t\t{\n\t\t\t\tvar blackToFirst:Array = FlxGradient.createGradientArray(1, fadeWidth, [ fadeColor, fadeColor, fadeColor, lineColors[0] ]);\n\t\t\t\tvar lastToBlack:Array = FlxGradient.createGradientArray(1, fadeWidth, [ lineColors[maxColor], fadeColor, fadeColor, fadeColor, fadeColor ]);\n\t\t\t\t\n\t\t\t\tvar fadingColours:Array = blackToFirst.concat(lineColors);\n\t\t\t\tfadingColours = fadingColours.concat(lastToBlack);\n\t\t\t\t\n\t\t\t\tlineColors = fadingColours;\n\t\t\t\n\t\t\t\tmaxColor = lineColors.length - 1;\n\t\t\t}\n\t\t\t\n\t\t\tdirection = 0;\n\t\t\tsetPixel = false;\n\t\t\tspeed = colorSpeed;\n\t\t\tchunk = stepSize;\n\t\t\tfillRect = new Rectangle(0, 0, chunk, height);\n\t\t\t\n\t\t\tif (height == 1 && chunk == 1)\n\t\t\t{\n\t\t\t\tsetPixel = true;\n\t\t\t}\n\t\t\t\n\t\t\tactive = true;\n\t\t\t\n\t\t\treturn sprite;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Change the colors cycling through the line by passing in a new array of color values\n\t\t * \n\t\t * @param\tcolors\t\t\t\tAn Array of color values used to create the line. If null (default) the HSV Color Wheel is used, giving a full spectrum rainbow effect\n\t\t * @param\tcolorWidth\t\t\tThe width of the color range controls how much interpolation occurs between each color in the colors array (default 360)\n\t\t * @param\tresetCurrentColor\tIf true the color pointer is returned to the start of the new color array, otherwise remains where it is\n\t\t * @param\tfadeWidth\t\t\tIf you want the Rainbow Line to fade from black to the first color in the colors array, and then out again, set this value to the amount of transition you want (128 looks good)\n\t\t * @param\tfadeColor\t\t\tThe default fade color is black, but if you need to alpha it, or change for a different color, set it here\n\t\t */\n\t\tpublic function updateColors(colors:Array, colorWidth:uint = 360, resetCurrentColor:Boolean = false, fadeWidth:uint = 128, fadeColor:uint = 0xff000000):void\n\t\t{\n\t\t\tif (colors is Array)\n\t\t\t{\n\t\t\t\tlineColors = FlxGradient.createGradientArray(1, colorWidth, colors);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tlineColors = FlxColor.getHSVColorWheel();\n\t\t\t}\n\t\t\t\n\t\t\tmaxColor = lineColors.length - 1;\n\t\t\t\n\t\t\tif (fadeWidth != 0)\n\t\t\t{\n\t\t\t\tvar blackToFirst:Array = FlxGradient.createGradientArray(1, fadeWidth, [ 0xff000000, 0xff000000, 0xff000000, lineColors[0] ]);\n\t\t\t\tvar lastToBlack:Array = FlxGradient.createGradientArray(1, fadeWidth, [ lineColors[maxColor], 0xff000000, 0xff000000, 0xff000000, 0xff000000 ]);\n\t\t\t\t\n\t\t\t\tvar fadingColours:Array = blackToFirst.concat(lineColors);\n\t\t\t\tfadingColours = fadingColours.concat(lastToBlack);\n\t\t\t\t\n\t\t\t\tlineColors = fadingColours;\n\t\t\t\n\t\t\t\tmaxColor = lineColors.length - 1;\n\t\t\t}\n\t\t\t\n\t\t\tif (currentColor > maxColor || resetCurrentColor)\n\t\t\t{\n\t\t\t\tcurrentColor = 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Doesn't need to be called directly as it's called by the FlxSpecialFX Plugin.<br>\n\t\t * Set active to false if you wish to disable the effect.<br>\n\t\t * Pass the effect to FlxSpecialFX.erase() if you wish to destroy this effect.\n\t\t */\n\t\tpublic function draw():void\n\t\t{\n\t\t\tcanvas.lock();\n\t\t\n\t\t\tfillRect.x = 0;\n\t\t\t\n\t\t\tfor (var x:int = 0; x < canvas.width; x = x + chunk)\n\t\t\t{\n\t\t\t\tvar c:int = FlxMath.wrapValue(currentColor + x, 1, maxColor);\n\t\t\t\t\n\t\t\t\tif (setPixel)\n\t\t\t\t{\n\t\t\t\t\tcanvas.setPixel32(x, 0, lineColors[c]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcanvas.fillRect(fillRect, lineColors[c]);\n\t\t\t\t\tfillRect.x += chunk;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tcanvas.unlock();\n\t\t\t\n\t\t\tif (direction == 0)\n\t\t\t{\n\t\t\t\tcurrentColor += speed;\n\t\t\t\t\n\t\t\t\tif (currentColor >= maxColor)\n\t\t\t\t{\n\t\t\t\t\tcurrentColor = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcurrentColor -= speed;\n\t\t\t\t\n\t\t\t\tif (currentColor < 0)\n\t\t\t\t{\n\t\t\t\t\tcurrentColor = maxColor;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tsprite.pixels = canvas;\n\t\t\tsprite.dirty = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the speed at which the Line cycles through its colors\n\t\t */\n\t\tpublic function set colorSpeed(value:uint):void \n\t\t{\n\t\t\tif (value < maxColor)\n\t\t\t{\n\t\t\t\tspeed = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * The speed at which the Line cycles through its colors\n\t\t */\n\t\tpublic function get colorSpeed():uint\n\t\t{\n\t\t\treturn speed;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the size of each \"chunk\" of the Line. Use a higher value for a more retro look\n\t\t */\n\t\tpublic function set stepSize(value:uint):void \n\t\t{\n\t\t\tif (value < canvas.width && value > 0)\n\t\t\t{\n\t\t\t\tcanvas.fillRect(new Rectangle(0, 0, canvas.width, canvas.height), 0x0);\n\t\t\t\tchunk = value;\n\t\t\t\t\n\t\t\t\tfillRect.x = 0;\n\t\t\t\tfillRect.width = chunk;\n\t\t\t\t\n\t\t\t\tif (value > 1)\n\t\t\t\t{\n\t\t\t\t\tsetPixel = false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tsetPixel = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * The size of each \"chunk\" of the Line\n\t\t */\n\t\tpublic function get stepSize():uint\n\t\t{\n\t\t\treturn chunk;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Changes the color cycle direction.\n\t\t * \n\t\t * @param\tnewDirection\t0 = Colors cycle incrementally (line looks like it is moving to the left), 1 = Colors decrement (line moves to the right)\n\t\t */\n\t\tpublic function setDirection(newDirection:uint):void\n\t\t{\n\t\t\tif (newDirection == 0 || newDirection == 1)\n\t\t\t{\n\t\t\t\tdirection = newDirection;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FX/RevealFX.as",
    "content": "/**\n * RevealFX - Special FX Plugin\n * -- Part of the Flixel Power Tools set\n * \n * v1.1 Added changeGlitchValues support\n * v1.0 First release\n * \n * @version 1.1 - June 13th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.FX \n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.*;\n\t\n\t/**\n\t * Creates a static / glitch / monitor-corruption style effect on an FlxSprite\n\t * \n\t * TODO:\n\t * \n\t * Add reduction from really high glitch value down to zero, will smooth the image into place and look cool :)\n\t * Add option to glitch vertically?\n\t * \n\t */\n\tpublic class RevealFX extends BaseFX\n\t{\n\t\tprivate var glitchSize:uint;\n\t\tprivate var glitchSkip:uint;\n\t\t\n\t\tpublic function RevealFX() \n\t\t{\n\t\t}\n\t\t\n\t\tpublic function createFromFlxSprite(source:FlxSprite, maxGlitch:uint, maxSkip:uint, autoUpdate:Boolean = false, backgroundColor:uint = 0x0):FlxSprite\n\t\t{\n\t\t\tsprite = new FlxSprite(source.x, source.y).makeGraphic(source.width + maxGlitch, source.height, backgroundColor);\n\t\t\t\n\t\t\tcanvas = new BitmapData(sprite.width, sprite.height, true, backgroundColor);\n\t\t\t\n\t\t\timage = source.pixels;\n\t\t\t\n\t\t\tupdateFromSource = autoUpdate;\n\t\t\t\n\t\t\tglitchSize = maxGlitch;\n\t\t\tglitchSkip = maxSkip;\n\t\t\t\n\t\t\tclsColor = backgroundColor;\n\t\t\tclsRect = new Rectangle(0, 0, canvas.width, canvas.height);\n\t\t\t\n\t\t\tcopyPoint = new Point(0, 0);\n\t\t\tcopyRect = new Rectangle(0, 0, image.width, 1);\n\t\t\t\n\t\t\tactive = true;\n\t\t\t\n\t\t\treturn sprite;\n\t\t}\n\t\t\n\t\tpublic function changeGlitchValues(maxGlitch:uint, maxSkip:uint):void\n\t\t{\n\t\t\tglitchSize = maxGlitch;\n\t\t\tglitchSkip = maxSkip;\n\t\t}\n\t\t\n\t\tpublic function draw():void\n\t\t{\n\t\t\tif (ready)\n\t\t\t{\n\t\t\t\tif (lastUpdate != updateLimit)\n\t\t\t\t{\n\t\t\t\t\tlastUpdate++;\n\t\t\t\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (updateFromSource && sourceRef.exists)\n\t\t\t\t{\n\t\t\t\t\timage = sourceRef.framePixels;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcanvas.lock();\n\t\t\t\tcanvas.fillRect(clsRect, clsColor);\n\t\t\t\t\n\t\t\t\tvar rndSkip:uint = 1 + int(Math.random() * glitchSkip);\n\t\t\t\t\n\t\t\t\tcopyRect.y = 0;\n\t\t\t\tcopyPoint.y = 0;\n\t\t\t\tcopyRect.height = rndSkip;\n\t\t\t\t\n\t\t\t\tfor (var y:int = 0; y < sprite.height; y += rndSkip)\n\t\t\t\t{\n\t\t\t\t\tcopyPoint.x = int(Math.random() * glitchSize);\n\t\t\t\t\tcanvas.copyPixels(image, copyRect, copyPoint);\n\t\t\t\t\t\n\t\t\t\t\tcopyRect.y += rndSkip;\n\t\t\t\t\tcopyPoint.y += rndSkip;\n\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\tcanvas.unlock();\n\t\t\t\t\n\t\t\t\tlastUpdate = 0;\n\t\t\t\t\n\t\t\t\tsprite.pixels = canvas;\n\t\t\t\tsprite.dirty = true;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FX/SineWaveFX.as",
    "content": "/**\n * SineWaveFX - Special FX Plugin\n * -- Part of the Flixel Power Tools set\n * \n * v1.0 First release\n * \n * @version 1.0 - May 21st 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.FX \n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.*;\n\t\n\t/**\n\t * Creates a sine-wave effect through an FlxSprite which can be applied vertically or horizontally\n\t */\n\tpublic class SineWaveFX extends BaseFX\n\t{\n\t\tprivate var waveType:uint;\n\t\tprivate var waveVertical:Boolean;\n\t\tprivate var waveLength:uint;\n\t\tprivate var waveSize:uint;\n\t\tprivate var waveFrequency:Number;\n\t\tprivate var wavePixelChunk:uint;\n\t\tprivate var waveData:Array;\n\t\tprivate var waveDataCounter:uint = 0;\n\t\tprivate var waveLoopCallback:Function;\n\t\t\n\t\tpublic static const WAVETYPE_VERTICAL_SINE:uint = 0;\n\t\tpublic static const WAVETYPE_VERTICAL_COSINE:uint = 1;\n\t\tpublic static const WAVETYPE_HORIZONTAL_SINE:uint = 2;\n\t\tpublic static const WAVETYPE_HORIZONTAL_COSINE:uint = 3;\n\t\t\n\t\tpublic function SineWaveFX() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new SineWaveFX Effect from the given FlxSprite. The original sprite remains unmodified.<br>\n\t\t * The resulting FlxSprite will take on the same width / height and x/y coordinates of the source FlxSprite.<br>\n\t\t * For really cool effects you can SineWave an FlxSprite that is constantly updating (either through animation or an FX chain).\n\t\t * \n\t\t * @param\tsource\t\t\t\tThe FlxSprite providing the image data for this effect. The resulting FlxSprite takes on the source width, height, x/y positions and scrollfactor.\n\t\t * @param\ttype\t\t\t\tWAVETYPE_VERTICAL_SINE, WAVETYPE_VERTICAL_COSINE, WAVETYPE_HORIZONTAL_SINE or WAVETYPE_HORIZONTAL_COSINE\n\t\t * @param\tsize\t\t\t\tThe size in pixels of the sine wave. Either the height of the wave or the width (for vertical or horizontal waves)\n\t\t * @param\tlength\t\t\t\tThe length of the wave in pixels. You should usually set this to the width or height of the source image, or a multiple of it.\n\t\t * @param\tfrequency\t\t\tThe frequency of the peaks in the wave. MUST BE AN EVEN NUMBER! 2, 4, 6, 8, etc.\n\t\t * @param\tpixelsPerChunk\t\tHow many pixels to use per step. Higher numbers make a more chunky but faster effect. Make sure source.width/height divides by this value evenly.\n\t\t * @param\tupdateFrame\t\t\tWhen this effect is created it takes a copy of the source image data and stores it. Set this to true to grab a new copy of the image data every frame.\n\t\t * @param\tbackgroundColor\t\tThe background color (0xAARRGGBB format) to draw behind the effect (default 0x0 = transparent)\n\t\t * @return\tAn FlxSprite with the effect running through it, which should be started with a call to SineWaveFX.start()\n\t\t */\n\t\tpublic function createFromFlxSprite(source:FlxSprite, type:uint, size:uint, length:uint, frequency:uint = 2, pixelsPerChunk:uint = 1, updateFrame:Boolean = false, backgroundColor:uint = 0x0):FlxSprite\n\t\t{\n\t\t\tvar result:FlxSprite = create(source.pixels, source.x, source.y, type, size, length, frequency, pixelsPerChunk, backgroundColor);\n\t\t\t\n\t\t\tupdateFromSource = updateFrame;\n\t\t\t\n\t\t\tif (updateFromSource)\n\t\t\t{\n\t\t\t\tsourceRef = source;\n\t\t\t}\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new SineWaveFX Effect from the given Class (which must contain a Bitmap).<br>\n\t\t * If you need to update the source data at run-time then use createFromFlxSprite\n\t\t * \n\t\t * @param\tsource\t\t\t\tThe Class providing the bitmapData for this effect, usually from an Embedded bitmap.\n\t\t * @param\tx\t\t\t\t\tThe x coordinate (in game world pixels) that the resulting FlxSprite will be created at.\n\t\t * @param\ty\t\t\t\t\tThe x coordinate (in game world pixels) that the resulting FlxSprite will be created at.\n\t\t * @param\ttype\t\t\t\tWAVETYPE_VERTICAL_SINE, WAVETYPE_VERTICAL_COSINE, WAVETYPE_HORIZONTAL_SINE or WAVETYPE_HORIZONTAL_COSINE\n\t\t * @param\tsize\t\t\t\tThe size in pixels of the sine wave. Either the height of the wave or the width (for vertical or horizontal waves)\n\t\t * @param\tlength\t\t\t\tThe length of the wave in pixels. You should usually set this to the width or height of the source image, or a multiple of it.\n\t\t * @param\tfrequency\t\t\tThe frequency of the peaks in the wave. MUST BE AN EVEN NUMBER! 2, 4, 6, 8, etc.\n\t\t * @param\tpixelsPerChunk\t\tHow many pixels to use per step. Higher numbers make a more chunky but faster effect. Make sure source.width/height divides by this value evenly.\n\t\t * @param\tbackgroundColor\t\tThe background color in 0xAARRGGBB format to draw behind the effect (default 0x0 = transparent)\n\t\t * @return\tAn FlxSprite with the effect running through it, which should be started with a call to SineWaveFX.start()\n\t\t */\n\t\tpublic function createFromClass(source:Class, x:int, y:int, type:uint, size:uint, length:uint, frequency:uint = 2, pixelsPerChunk:uint = 1, backgroundColor:uint = 0x0):FlxSprite\n\t\t{\n\t\t\tvar result:FlxSprite = create((new source).bitmapData, x, y, type, size, length, frequency, pixelsPerChunk, backgroundColor);\n\t\t\t\n\t\t\tupdateFromSource = false;\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new SineWaveFX Effect from the given bitmapData.<br>\n\t\t * If you need to update the source data at run-time then use createFromFlxSprite\n\t\t * \n\t\t * @param\tsource\t\t\t\tThe bitmapData image to use for this effect.\n\t\t * @param\tx\t\t\t\t\tThe x coordinate (in game world pixels) that the resulting FlxSprite will be created at.\n\t\t * @param\ty\t\t\t\t\tThe x coordinate (in game world pixels) that the resulting FlxSprite will be created at.\n\t\t * @param\ttype\t\t\t\tWAVETYPE_VERTICAL_SINE, WAVETYPE_VERTICAL_COSINE, WAVETYPE_HORIZONTAL_SINE or WAVETYPE_HORIZONTAL_COSINE\n\t\t * @param\tsize\t\t\t\tThe size in pixels of the sine wave. Either the height of the wave or the width (for vertical or horizontal waves)\n\t\t * @param\tlength\t\t\t\tThe length of the wave in pixels. You should usually set this to the width or height of the source image, or a multiple of it.\n\t\t * @param\tfrequency\t\t\tThe frequency of the peaks in the wave. MUST BE AN EVEN NUMBER! 2, 4, 6, 8, etc.\n\t\t * @param\tpixelsPerChunk\t\tHow many pixels to use per step. Higher numbers make a more chunky but faster effect. Make sure source.width/height divides by this value evenly.\n\t\t * @param\tbackgroundColor\t\tThe background color in 0xAARRGGBB format to draw behind the effect (default 0x0 = transparent)\n\t\t * @return\tAn FlxSprite with the effect running through it, which should be started with a call to SineWaveFX.start()\n\t\t */\n\t\tpublic function createFromBitmapData(source:BitmapData, x:int, y:int, type:uint, size:uint, length:uint, frequency:uint = 2, pixelsPerChunk:uint = 1, backgroundColor:uint = 0x0):FlxSprite\n\t\t{\n\t\t\tvar result:FlxSprite = create(source, x, y, type, size, length, frequency, pixelsPerChunk, backgroundColor);\n\t\t\t\n\t\t\tupdateFromSource = false;\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function fed from createFromFlxSprite / createFromClass / createFromBitmapData\n\t\t * \n\t\t * @param\tsource\t\t\t\tThe bitmapData image to use for this effect.\n\t\t * @param\tx\t\t\t\t\tThe x coordinate (in game world pixels) that the resulting FlxSprite will be created at.\n\t\t * @param\ty\t\t\t\t\tThe x coordinate (in game world pixels) that the resulting FlxSprite will be created at.\n\t\t * @param\ttype\t\t\t\tWAVETYPE_VERTICAL_SINE, WAVETYPE_VERTICAL_COSINE, WAVETYPE_HORIZONTAL_SINE or WAVETYPE_HORIZONTAL_COSINE\n\t\t * @param\tsize\t\t\t\tThe size in pixels of the sine wave. Either the height of the wave or the width (for vertical or horizontal waves)\n\t\t * @param\tlength\t\t\t\tThe length of the wave in pixels. You should usually set this to the width or height of the source image, or a multiple of it.\n\t\t * @param\tfrequency\t\t\tThe frequency of the peaks in the wave. MUST BE AN EVEN NUMBER! 2, 4, 6, 8, etc.\n\t\t * @param\tpixelsPerChunk\t\tHow many pixels to use per step. Higher numbers make a more chunky but faster effect. Make sure source.width/height divides by this value evenly.\n\t\t * @param\tbackgroundColor\t\tThe background color in 0xAARRGGBB format to draw behind the effect (default 0x0 = transparent)\n\t\t * @return\tAn FlxSprite with the effect running through it, which should be started with a call to SineWaveFX.start()\n\t\t */\n\t\tprivate function create(source:BitmapData, x:int, y:int, type:uint, size:uint, length:uint, frequency:uint = 2, pixelsPerChunk:uint = 1, backgroundColor:uint = 0x0):FlxSprite\n\t\t{\n\t\t\tif (type == WAVETYPE_VERTICAL_SINE || type == WAVETYPE_VERTICAL_COSINE)\n\t\t\t{\n\t\t\t\twaveVertical = true;\n\t\t\t\t\n\t\t\t\tif (pixelsPerChunk >= source.width)\n\t\t\t\t{\n\t\t\t\t\tthrow new Error(\"SineWaveFX: pixelsPerChunk cannot be >= source.width with WAVETYPE_VERTICAL\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (type == WAVETYPE_HORIZONTAL_SINE || type == WAVETYPE_HORIZONTAL_COSINE)\n\t\t\t{\n\t\t\t\twaveVertical = false;\n\t\t\t\t\n\t\t\t\tif (pixelsPerChunk >= source.height)\n\t\t\t\t{\n\t\t\t\t\tthrow new Error(\"SineWaveFX: pixelsPerChunk cannot be >= source.height with WAVETYPE_HORIZONTAL\");\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tupdateWaveData(type, size, length, frequency, pixelsPerChunk);\n\t\t\t\n\t\t\t//\tThe FlxSprite into which the sine-wave effect is drawn\n\t\t\t\n\t\t\tif (waveVertical)\n\t\t\t{\n\t\t\t\tsprite = new FlxSprite(x, y).makeGraphic(source.width, source.height + (waveSize * 3), backgroundColor);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsprite = new FlxSprite(x, y).makeGraphic(source.width + (waveSize * 3), source.height, backgroundColor);\n\t\t\t}\n\t\t\t\n\t\t\t//\tThe scratch bitmapData where we prepare the final sine-waved image\n\t\t\tcanvas = new BitmapData(sprite.width, sprite.height, true, backgroundColor);\n\t\t\t\n\t\t\t//\tOur local copy of the sprite image data\n\t\t\timage = source.clone();\n\t\t\t\n\t\t\tclsColor = backgroundColor;\n\t\t\tclsRect = new Rectangle(0, 0, canvas.width, canvas.height);\n\t\t\t\n\t\t\tcopyPoint = new Point(0, 0);\n\t\t\t\n\t\t\tif (waveVertical)\n\t\t\t{\n\t\t\t\tcopyRect = new Rectangle(0, 0, wavePixelChunk, image.height);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcopyRect = new Rectangle(0, 0, image.width, wavePixelChunk);\n\t\t\t}\n\t\t\t\n\t\t\tactive = true;\n\t\t\t\n\t\t\treturn sprite;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Update the SineWave data without modifying the source image being used.<br>\n\t\t * This call is fast enough that you can modify it in real-time.\n\t\t * \n\t\t * @param\ttype\t\t\t\tWAVETYPE_VERTICAL_SINE, WAVETYPE_VERTICAL_COSINE, WAVETYPE_HORIZONTAL_SINE or WAVETYPE_HORIZONTAL_COSINE\n\t\t * @param\tsize\t\t\t\tThe size in pixels of the sine wave. Either the height of the wave or the width (for vertical or horizontal waves)\n\t\t * @param\tlength\t\t\t\tThe length of the wave in pixels. You should usually set this to the width or height of the source image, or a multiple of it.\n\t\t * @param\tfrequency\t\t\tThe frequency of the peaks in the wave. MUST BE AN EVEN NUMBER! 2, 4, 6, 8, etc.\n\t\t * @param\tpixelsPerChunk\t\tHow many pixels to use per step. Higher numbers make a more chunky but faster effect. Make sure source.width/height divides by this value evenly.\n\t\t */\n\t\tpublic function updateWaveData(type:uint, size:uint, length:uint, frequency:uint = 2, pixelsPerChunk:uint = 1):void\n\t\t{\n\t\t\tif (type > WAVETYPE_HORIZONTAL_COSINE)\n\t\t\t{\n\t\t\t\tthrow new Error(\"SineWaveFX: Invalid WAVETYPE\");\n\t\t\t}\n\t\t\t\n\t\t\tif (FlxMath.isOdd(frequency))\n\t\t\t{\n\t\t\t\tthrow new Error(\"SineWaveFX: frequency must be an even number\");\n\t\t\t}\n\t\t\t\n\t\t\twaveType = type;\n\t\t\twaveSize = uint(size * 0.5);\n\t\t\twaveLength = uint(length / pixelsPerChunk);\n\t\t\twaveFrequency = frequency;\n\t\t\twavePixelChunk = pixelsPerChunk;\n\t\t\twaveData = FlxMath.sinCosGenerator(waveLength, waveSize, waveSize, waveFrequency);\n\t\t\t\n\t\t\tif (waveType == WAVETYPE_VERTICAL_COSINE || waveType == WAVETYPE_HORIZONTAL_COSINE)\n\t\t\t{\n\t\t\t\twaveData = FlxMath.getCosTable();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Use this to set a function to be called every time the wave has completed one full cycle.<br>\n\t\t * Set to null to remove any previous callback.\n\t\t * \n\t\t * @param\tcallback\t\tThe function to call every time the wave completes a full cycle (duration will vary based on waveLength)\n\t\t */\n\t\tpublic function setLoopCompleteCallback(callback:Function):void\n\t\t{\n\t\t\twaveLoopCallback = callback;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by the FlxSpecialFX plugin. Should not be called directly.\n\t\t */\n\t\tpublic function draw():void\n\t\t{\n\t\t\tif (ready)\n\t\t\t{\n\t\t\t\tif (lastUpdate != updateLimit)\n\t\t\t\t{\n\t\t\t\t\tlastUpdate++;\n\t\t\t\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (updateFromSource && sourceRef.exists)\n\t\t\t\t{\n\t\t\t\t\timage = sourceRef.framePixels;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcanvas.lock();\n\t\t\t\tcanvas.fillRect(clsRect, clsColor);\n\t\t\t\t\n\t\t\t\tvar s:uint = 0;\n\t\t\t\t\n\t\t\t\tcopyRect.x = 0;\n\t\t\t\tcopyRect.y = 0;\n\t\t\t\t\n\t\t\t\tif (waveVertical)\n\t\t\t\t{\n\t\t\t\t\tfor (var x:int = 0; x < image.width; x += wavePixelChunk)\n\t\t\t\t\t{\n\t\t\t\t\t\tcopyPoint.x = x;\n\t\t\t\t\t\tcopyPoint.y = waveSize + (waveSize / 2) + waveData[s];\n\t\t\t\t\t\t\n\t\t\t\t\t\tcanvas.copyPixels(image, copyRect, copyPoint);\n\t\t\t\t\t\t\n\t\t\t\t\t\tcopyRect.x += wavePixelChunk;\n\t\t\t\t\t\t\n\t\t\t\t\t\ts++;\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\tfor (var y:int = 0; y < image.height; y += wavePixelChunk)\n\t\t\t\t\t{\n\t\t\t\t\t\tcopyPoint.x = waveSize + (waveSize / 2) + waveData[s];\n\t\t\t\t\t\tcopyPoint.y = y;\n\t\t\t\t\t\t\n\t\t\t\t\t\tcanvas.copyPixels(image, copyRect, copyPoint);\n\t\t\t\t\t\t\n\t\t\t\t\t\tcopyRect.y += wavePixelChunk;\n\t\t\t\t\t\t\n\t\t\t\t\t\ts++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//\tCycle through the wave data - this is what causes the image to \"undulate\"\n\t\t\t\tvar t:Number = waveData.shift();\n\t\t\t\twaveData.push(t);\n\t\t\t\t\n\t\t\t\twaveDataCounter++;\n\t\t\t\t\n\t\t\t\tif (waveDataCounter == waveData.length)\n\t\t\t\t{\n\t\t\t\t\twaveDataCounter = 0;\n\t\t\t\t\t\n\t\t\t\t\tif (waveLoopCallback is Function)\n\t\t\t\t\t{\n\t\t\t\t\t\twaveLoopCallback.call();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcanvas.unlock();\n\t\t\t\t\n\t\t\t\tlastUpdate = 0;\n\t\t\t\t\n\t\t\t\tsprite.pixels = canvas;\n\t\t\t\tsprite.dirty = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic function toString():String\n\t\t{\n\t\t\tvar output:Array = [ \"Type: \" + waveType, \"Size: \" + waveSize, \"Length: \" + waveLength, \"Frequency: \" + waveFrequency, \"Chunks: \" + wavePixelChunk, \"clsRect: \" + clsRect ];\n\t\t\t\n\t\t\treturn output.join(\",\");\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FX/StarfieldFX.as",
    "content": "/**\n * StarfieldFX - Special FX Plugin\n * -- Part of the Flixel Power Tools set\n * \n * v1.1 StarField moved to the FX Plugin system\n * v1.0 First release\n * \n * @version 1.1 - May 21st 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.FX \n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport flash.utils.getTimer;\n\t\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.*;\n\t\n\t/**\n\t * Creates a 2D or 3D Star Field effect on an FlxSprite for use in your game.\n\t */\n\tpublic class StarfieldFX extends BaseFX\n\t{\n\t\t/**\n\t\t * In a 3D starfield this controls the X coordinate the stars emit from, can be updated in real-time!\n\t\t */\n\t\tpublic var centerX:int;\n\t\t\n\t\t/**\n\t\t * In a 3D starfield this controls the Y coordinate the stars emit from, can be updated in real-time!\n\t\t */\n\t\tpublic var centerY:int;\n\t\t\n\t\t/**\n\t\t * How much to shift on the X axis every update. Negative values move towards the left, positiive to the right. 2D Starfield only. Can also be set via setStarSpeed()\n\t\t */\n\t\tpublic var starXOffset:Number = -1;\n\t\t\n\t\t/**\n\t\t * How much to shift on the Y axis every update. Negative values move up, positiive values move down. 2D Starfield only. Can also be set via setStarSpeed()\n\t\t */\n\t\tpublic var starYOffset:Number = 0;\n\t\t\n\t\tprivate var stars:Array;\n\t\tprivate var starfieldType:int;\n\t\t\n\t\tprivate var backgroundColor:uint = 0xff000000;\n\t\t\n\t\tprivate var updateSpeed:int;\n\t\tprivate var tick:int;\n\t\t\n\t\tprivate var depthColours:Array;\n\t\t\n\t\tpublic static const STARFIELD_TYPE_2D:int = 1;\n\t\tpublic static const STARFIELD_TYPE_3D:int = 2;\n\t\t\n\t\tpublic function StarfieldFX() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Create a new StarField\n\t\t * \n\t\t * @param\tx\t\t\t\tX coordinate of the starfield sprite\n\t\t * @param\ty\t\t\t\tY coordinate of the starfield sprite\n\t\t * @param\twidth\t\t\tThe width of the starfield\n\t\t * @param\theight\t\t\tThe height of the starfield\n\t\t * @param\tquantity\t\tThe number of stars in the starfield (default 200)\n\t\t * @param\ttype\t\t\tType of starfield. Either STARFIELD_TYPE_2D (default, stars move horizontally) or STARFIELD_TYPE_3D (stars flow out from the center)\n\t\t * @param\tupdateInterval\tHow many ms should pass before the next starfield update (default 20)\n\t\t */\n\t\tpublic function create(x:int, y:int, width:uint, height:uint, quantity:uint = 200, type:int = 1, updateInterval:int = 20):FlxSprite\n\t\t{\n\t\t\tsprite = new FlxSprite(x, y).makeGraphic(width, height, backgroundColor);\n\t\t\t\n\t\t\tcanvas = new BitmapData(sprite.width, sprite.height, true, backgroundColor);\n\t\t\t\n\t\t\tstarfieldType = type;\n\t\t\t\n\t\t\tupdateSpeed = speed;\n\t\t\t\n\t\t\t//\tStars come from the middle of the starfield in 3D mode\n\t\t\tcenterX = width >> 1;\n\t\t\tcenterY = height >> 1;\n\t\t\t\t\n\t\t\tclsRect = new Rectangle(0, 0, width, height);\n\t\t\tclsPoint = new Point;\n\t\t\tclsColor = backgroundColor;\n\t\t\t\n\t\t\tstars = new Array();\n\t\t\t\n\t\t\tfor (var i:uint = 0; i < quantity; i++)\n\t\t\t{\n\t\t\t\tvar star:Object = new Object;\n\t\t\t\t\n\t\t\t\tstar.index = i;\n\t\t\t\tstar.x = int(Math.random() * width);\n\t\t\t\tstar.y = int(Math.random() * height);\n\t\t\t\tstar.d = 1;\n\t\t\t\t\n\t\t\t\tif (type == STARFIELD_TYPE_2D)\n\t\t\t\t{\n\t\t\t\t\tstar.speed = 1 + int(Math.random() * 5);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstar.speed = Math.random();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tstar.r = Math.random() * Math.PI * 2;\n\t\t\t\tstar.alpha = 0;\n\t\t\t\t\n\t\t\t\tstars.push(star);\n\t\t\t}\n\t\t\t\n\t\t\t//\tColours array\n\t\t\tif (type == STARFIELD_TYPE_2D)\n\t\t\t{\n\t\t\t\tdepthColours = FlxGradient.createGradientArray(1, 5, [0xff585858, 0xffF4F4F4]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdepthColours = FlxGradient.createGradientArray(1, 300, [0xff292929, 0xffffffff]);\n\t\t\t}\n\t\t\t\n\t\t\tactive = true;\n\t\t\t\n\t\t\treturn sprite;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Change the background color in the format 0xAARRGGBB of the starfield.<br />\n\t\t * Supports alpha, so if you want a transparent background just pass 0x00 as the color.\n\t\t * \n\t\t * @param\tbackgroundColor\n\t\t */\n\t\tpublic function setBackgroundColor(backgroundColor:uint):void\n\t\t{\n\t\t\tclsColor = backgroundColor;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Change the number of layers (depth) and colors used for each layer of the starfield. Change happens immediately.\n\t\t * \n\t\t * @param\tdepth\t\t\tNumber of depths (for a 2D starfield the default is 5)\n\t\t * @param\tlowestColor\t\tThe color given to the stars furthest away from the camera (i.e. the slowest stars), typically the darker colour\n\t\t * @param\thighestColor\tThe color given to the stars cloest to the camera (i.e. the fastest stars), typically the brighter colour\n\t\t */\n\t\tpublic function setStarDepthColors(depth:int, lowestColor:uint = 0xff585858, highestColor:uint = 0xffF4F4F4):void\n\t\t{\n\t\t\t//\tDepth is the same, we just need to update the gradient then\n\t\t\tdepthColours = FlxGradient.createGradientArray(1, depth, [lowestColor, highestColor]);\n\t\t\t\n\t\t\t//\tRun through the stars array, making sure the depths are all within range\n\t\t\tfor each (var star:Object in stars)\n\t\t\t{\n\t\t\t\tstar.speed = 1 + int(Math.random() * depth);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the direction and speed of the 2D starfield (doesn't apply to 3D)<br />\n\t\t * You can combine both X and Y together to make the stars move on a diagnol\n\t\t * \n\t\t * @param\txShift\tHow much to shift on the X axis every update. Negative values move towards the left, positiive to the right\n\t\t * @param\tyShift\tHow much to shift on the Y axis every update. Negative values move up, positiive values move down\n\t\t */\n\t\tpublic function setStarSpeed(xShift:Number, yShift:Number):void\n\t\t{\n\t\t\tstarXOffset = xShift;\n\t\t\tstarYOffset = yShift;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The current update speed\n\t\t */\n\t\tpublic function get speed():int\n\t\t{\n\t\t\treturn updateSpeed;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Change the tick interval on which the update runs. By default the starfield updates once every 20ms. Set to zero to disable totally.\n\t\t */\n\t\tpublic function set speed(newSpeed:int):void\n\t\t{\n\t\t\tupdateSpeed = newSpeed;\n\t\t}\n\t\t\n\t\tprivate function update2DStarfield():void\n\t\t{\n\t\t\tfor each (var star:Object in stars)\n\t\t\t{\n\t\t\t\tstar.x += (starXOffset * star.speed);\n\t\t\t\tstar.y += (starYOffset * star.speed);\n\t\t\t\t\n\t\t\t\tcanvas.setPixel32(star.x, star.y, depthColours[star.speed - 1]);\n\t\t\t\t\n\t\t\t\tif (star.x > sprite.width)\n\t\t\t\t{\n\t\t\t\t\tstar.x = 0;\n\t\t\t\t}\n\t\t\t\telse if (star.x < 0)\n\t\t\t\t{\n\t\t\t\t\tstar.x = sprite.width;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (star.y > sprite.height)\n\t\t\t\t{\n\t\t\t\t\tstar.y = 0;\n\t\t\t\t}\n\t\t\t\telse if (star.y < 0)\n\t\t\t\t{\n\t\t\t\t\tstar.y = sprite.height;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tprivate function update3DStarfield():void\n\t\t{\n\t\t\tfor each (var star:Object in stars)\n\t\t\t{\n\t\t\t\tstar.d *= 1.1;\n\t\t\t\tstar.x = centerX + ((Math.cos(star.r) * star.d) * star.speed);\n\t\t\t\tstar.y = centerY + ((Math.sin(star.r) * star.d) * star.speed);\n\t\t\t\t\n\t\t\t\tstar.alpha = star.d * 2;\n\t\t\t\t\n\t\t\t\tif (star.alpha > 255)\n\t\t\t\t{\n\t\t\t\t\tstar.alpha = 255;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcanvas.setPixel32(star.x, star.y, 0xffffffff);\n\t\t\t\t//canvas.setPixel32(star.x, star.y, FlxColor.getColor32(255, star.alpha, star.alpha, star.alpha));\n\t\t\t\t\n\t\t\t\tif (star.x < 0 || star.x > sprite.width || star.y < 0 || star.y > sprite.height)\n\t\t\t\t{\n\t\t\t\t\tstar.d = 1;\n\t\t\t\t\tstar.r = Math.random() * Math.PI * 2;\n\t\t\t\t\tstar.x = 0;\n\t\t\t\t\tstar.y = 0;\n\t\t\t\t\tstar.speed = Math.random();\n\t\t\t\t\tstar.alpha = 0;\n\t\t\t\t\t\n\t\t\t\t\tstars[star.index] = star;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic function draw():void\n\t\t{\n\t\t\tif (getTimer() > tick)\n\t\t\t{\n\t\t\t\tcanvas.lock();\n\t\t\t\tcanvas.fillRect(clsRect, clsColor);\n\t\t\t\t\n\t\t\t\tif (starfieldType == STARFIELD_TYPE_2D)\n\t\t\t\t{\n\t\t\t\t\tupdate2DStarfield();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tupdate3DStarfield();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcanvas.unlock();\n\t\t\t\t\n\t\t\t\tsprite.pixels = canvas;\n\t\t\t\t\n\t\t\t\tif (updateSpeed > 0)\n\t\t\t\t{\n\t\t\t\t\ttick = getTimer() + updateSpeed;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FX/WowCopperFX.as",
    "content": "/**\n * WowCopperFX - Special FX Plugin\n * -- Part of the Flixel Power Tools set\n * \n * v1.0 First release\n * \n * @version 1.4 - May 8th 2011\n * @link http://www.photonstorm.com\n * @author Original by Mathew Nolan / Flashtro.com\n * @author Ported with permission by Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm.FX \n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Sprite;\n\timport flash.geom.Matrix;\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.*;\n\t\n\t/**\n\t * Creates a WOW Copper effect FlxSprite\n\t */\n\t\n\tpublic class WowCopperFX extends BaseFX\n\t{\n\t\tprivate var colors:Array;\n\t\tprivate var step:uint = 0;\n\t\tprivate var span:uint;\n\t\t\n\t\t\n\t\tprivate var bmp_databg : BitmapData = new BitmapData( 1 , 64 , false , 0x00000100);\n\t\t//private var bmp_objbg : Bitmap = new Bitmap( bmp_databg , PixelSnapping.AUTO , false);\n\t\tprivate var bg2:Sprite = new Sprite;\n\n\t\tprivate var amount:int = 8;\n\t\tprivate var tab:int = 0;\n\t\tprivate var del:int = 0;\n\t\tprivate var max:int = 136;\n\t\t\n\t\tpublic function WowCopperFX():void\n\t\t{\n\t\t}\n\t\t\n\t\tpublic function create(x:int, y:int, width:uint, height:uint):FlxSprite\n\t\t{\n\t\t\tsprite = new FlxSprite(x, y).makeGraphic(width, height, 0x0);\n\t\t\t\n\t\t\tcolors = [0x110011,\n\t\t\t0x220022,\n\t\t\t0x330033,\n\t\t\t0x440044,\n\t\t\t0x550055,\n\t\t\t0x660066,\n\t\t\t0x770077,\n\t\t\t0x880088,\n\t\t\t0x990099,\n\t\t\t0xaa00aa,\n\t\t\t0xbb00bb,\n\t\t\t0xcc00cc,\n\t\t\t0xdd00dd,\n\t\t\t0xee00ee,\n\t\t\t0xff00ff,\n\t\t\t0xff00ff,\n\t\t\t0xee00ee,\n\t\t\t0xdd00dd,\n\t\t\t0xcc00cc,\n\t\t\t0xbb00bb,\n\t\t\t0xaa00aa,\n\t\t\t0x990099,\n\t\t\t0x880088,\n\t\t\t0x770077,\n\t\t\t0x660066,\n\t\t\t0x550055,\n\t\t\t0x440044,\n\t\t\t0x330033,\n\t\t\t0x220022,\n\t\t\t0x110011,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x111100,\n\t\t\t0x222200,\n\t\t\t0x333300,\n\t\t\t0x444400,\n\t\t\t0x555500,\n\t\t\t0x666600,\n\t\t\t0x777700,\n\t\t\t0x888800,\n\t\t\t0x999900,\n\t\t\t0xaaaa00,\n\t\t\t0xbbbb00,\n\t\t\t0xcccc00,\n\t\t\t0xdddd00,\n\t\t\t0xeeee00,\n\t\t\t0xffff00,\n\t\t\t0xffff00,\n\t\t\t0xeeee00,\n\t\t\t0xdddd00,\n\t\t\t0xcccc00,\n\t\t\t0xbbbb00,\n\t\t\t0xaaaa00,\n\t\t\t0x999900,\n\t\t\t0x888800,\n\t\t\t0x777700,\n\t\t\t0x666600,\n\t\t\t0x555500,\n\t\t\t0x444400,\n\t\t\t0x333300,\n\t\t\t0x222200,\n\t\t\t0x111100,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x001111,\n\t\t\t0x002222,\n\t\t\t0x003333,\n\t\t\t0x004444,\n\t\t\t0x005555,\n\t\t\t0x006666,\n\t\t\t0x007777,\n\t\t\t0x008888,\n\t\t\t0x009999,\n\t\t\t0x00aaaa,\n\t\t\t0x00bbbb,\n\t\t\t0x00cccc,\n\t\t\t0x00dddd,\n\t\t\t0x00eeee,\n\t\t\t0x00ffff,\n\t\t\t0x00ffff,\n\t\t\t0x00eeee,\n\t\t\t0x00dddd,\n\t\t\t0x00cccc,\n\t\t\t0x00bbbb,\n\t\t\t0x00aaaa,\n\t\t\t0x009999,\n\t\t\t0x008888,\n\t\t\t0x007777,\n\t\t\t0x006666,\n\t\t\t0x005555,\n\t\t\t0x004444,\n\t\t\t0x003333,\n\t\t\t0x002222,\n\t\t\t0x001111,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x111111,\n\t\t\t0x222222,\n\t\t\t0x333333,\n\t\t\t0x444444,\n\t\t\t0x555555,\n\t\t\t0x666666,\n\t\t\t0x777777,\n\t\t\t0x888888,\n\t\t\t0x999999,\n\t\t\t0xaaaaaa,\n\t\t\t0xbbbbbb,\n\t\t\t0xcccccc,\n\t\t\t0xdddddd,\n\t\t\t0xeeeeee,\n\t\t\t0xffffff,\n\t\t\t0xffffff,\n\t\t\t0xeeeeee,\n\t\t\t0xdddddd,\n\t\t\t0xcccccc,\n\t\t\t0xbbbbbb,\n\t\t\t0xaaaaaa,\n\t\t\t0x999999,\n\t\t\t0x888888,\n\t\t\t0x777777,\n\t\t\t0x666666,\n\t\t\t0x555555,\n\t\t\t0x444444,\n\t\t\t0x333333,\n\t\t\t0x222222,\n\t\t\t0x111111,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001,\n\t\t\t0x000001];\n\t\t\t\n\t\t\t//canvas = new BitmapData(1, 64 , false , 0x00000100);\n\t\t\tcanvas = new BitmapData(width, height, true, 0x0);\n\n\t\t\tactive = true;\n\t\t\t\n\t\t\treturn sprite;\n\t\t}\n\t\t\n\t\tpublic function draw():void\n\t\t{\n\t\t\tif (step < 10)\n\t\t\t{\n\t\t\t\t//trace(step, tpos1, tpos2, tpos3, tpos4, pos1, pos2, pos3, pos4, index);\n\t\t\t\tstep++;\n\t\t\t}\n\t\t\t\n\t\t\t//canvas.setPixel(0, 31, colors[tab]);\n\t\t\tbmp_databg.setPixel(0, 31, colors[tab]);\n\t\t\t\n\t\t\tdel++;\n\t\t\t\n\t\t\tif (del >= 2)\n\t\t\t{\n\t\t\t\tbmp_databg.scroll(0, -1);\n\t\t\t\ttab++;\n\t\t\t\tdel = 0;\n\t\t\t}\n\t\t\t\n\t\t\tif (tab >= colors.length)\n\t\t\t{\n\t\t\t\ttab = 0;\n\t\t\t}\n\t\t\t\n\t\t\tbg2.graphics.clear();\n\t\t\t\n\t\t\tvar bbcb:Matrix = new Matrix;\n\t\t\t\n\t\t\tfor (var i:uint = 0; i < max; i += amount)\n\t\t\t{\n\t\t\t\tbg2.graphics.beginBitmapFill(bmp_databg, bbcb, true, false);\n\t\t\t\tbg2.graphics.moveTo(0, i);\n\t\t\t\tbg2.graphics.lineTo(0, i + amount);\n\t\t\t\tbg2.graphics.lineTo(320, i + amount );\n\t\t\t\tbg2.graphics.lineTo(320, i);\n\t\t\t\tbg2.graphics.endFill();\n\t\t\t\tbbcb.translate(0, 7);\n\t\t\t}\n\t\t\t\n\t\t\tcanvas.draw(bg2);\n\t\t\t\n\t\t\tsprite.pixels = canvas;\n\t\t\tsprite.dirty = true;\n\t\t\t\n\t\t\t/*\n\t\t\tbmp_databg.setPixel(0,31,cols[tab])\n\t\t\tdel++\n\t\t\tif(del>=2){\n\t\t\t\tbmp_databg.scroll(0,-1)\n\t\t\ttab++\n\t\t\tdel=0\n\t\t\t}\n\t\t\tif(tab>=cols.length){\n\t\t\t\ttab=0\n\t\t\t}\n\t\t\t\tbg2.graphics.clear()\n\t\t\tvar bbcb = new flash.geom.Matrix();\n\t\t\tfor (var i:uint=0; i<max; i+=amount) {\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t//m.ty =0\n\t\t\t\t\n\t\t\t\tbg2.graphics.beginBitmapFill(bmp_databg, bbcb,true,false);\n\t\t\t\tbg2.graphics.moveTo(0, i);\n\t\t\t\tbg2.graphics.lineTo(0, i+amount);\n\t\t\t\tbg2.graphics.lineTo(320, i+amount );\n\t\t\t\tbg2.graphics.lineTo(320, i);\n\t\t\t\tbg2.graphics.endFill();\n\t\t\t\tbbcb.translate(0,7)\n\t\t\t\t\t\n\t\t\t}\n\t\t\t*/\n\t\t\t\n\t\t\t\n\t\t\t//canvas.setPixel32(x, y, colours[index]);\n\t\t\t\t\t\n\t\t\t//sprite.pixels = canvas;\n\t\t\t//sprite.dirty = true;\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxBar.as",
    "content": "/**\n * FlxBar\n * -- Part of the Flixel Power Tools set\n * \n * v1.6 Lots of bug fixes, more documentation, 2 new test cases, ability to set currentValue added\n * v1.5 Fixed bug in \"get percent\" function that allows it to work with any value range\n * v1.4 Added support for min/max callbacks and \"kill on min\"\n * v1.3 Renamed from FlxHealthBar and made less specific / far more flexible\n * v1.2 Fixed colour values for fill and gradient to include alpha\n * v1.1 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.6 - October 10th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport org.flixel.*;\n\t\n\t/**\n\t * FlxBar is a quick and easy way to create a graphical bar which can\n\t * be used as part of your UI/HUD, or positioned next to a sprite. It could represent\n\t * a loader, progress or health bar.\n\t */\n\tpublic class FlxBar extends FlxSprite\n\t{\n\t\tprivate var canvas:BitmapData;\n\t\t\n\t\tprivate var barType:uint;\n\t\tprivate var barWidth:uint;\n\t\tprivate var barHeight:uint;\n\t\t\n\t\tprivate var parent:*;\n\t\tprivate var parentVariable:String;\n\t\t\n\t\t/**\n\t\t * fixedPosition controls if the FlxBar sprite is at a fixed location on screen, or tracking its parent\n\t\t */\n\t\tpublic var fixedPosition:Boolean = true;\n\t\t\n\t\t/**\n\t\t * The positionOffset controls how far offset the FlxBar is from the parent sprite (if at all)\n\t\t */\n\t\tpublic var positionOffset:FlxPoint;\n\t\t\n\t\t/**\n\t\t * The minimum value the bar can be (can never be >= max)\n\t\t */\n\t\tprivate var min:Number;\n\t\t\n\t\t/**\n\t\t * The maximum value the bar can be (can never be <= min)\n\t\t */\n\t\tprivate var max:Number;\n\t\t\n\t\t/**\n\t\t * How wide is the range of this bar? (max - min)\n\t\t */\n\t\tprivate var range:Number;\n\t\t\n\t\t/**\n\t\t * What 1% of the bar is equal to in terms of value (range / 100)\n\t\t */\n\t\tprivate var pct:Number;\n\t\t\n\t\t/**\n\t\t * The current value - must always be between min and max\n\t\t */\n\t\tprivate var value:Number;\n\t\t\n\t\t/**\n\t\t * How many pixels = 1% of the bar (barWidth (or height) / 100)\n\t\t */\n\t\tpublic var pxPerPercent:Number;\n\t\t\n\t\tprivate var emptyCallback:Function;\n\t\tprivate var emptyBar:BitmapData;\n\t\tprivate var emptyBarRect:Rectangle;\n\t\tprivate var emptyBarPoint:Point;\n\t\tprivate var emptyKill:Boolean;\n\t\tprivate var zeroOffset:Point = new Point;\n\t\t\n\t\tprivate var filledCallback:Function;\n\t\tprivate var filledBar:BitmapData;\n\t\tprivate var filledBarRect:Rectangle;\n\t\tprivate var filledBarPoint:Point;\n\t\t\n\t\tprivate var fillDirection:uint;\n\t\tprivate var fillHorizontal:Boolean;\n\t\t\n\t\tpublic static const FILL_LEFT_TO_RIGHT:uint = 1;\n\t\tpublic static const FILL_RIGHT_TO_LEFT:uint = 2;\n\t\tpublic static const FILL_TOP_TO_BOTTOM:uint = 3;\n\t\tpublic static const FILL_BOTTOM_TO_TOP:uint = 4;\n\t\tpublic static const FILL_HORIZONTAL_INSIDE_OUT:uint = 5;\n\t\tpublic static const FILL_HORIZONTAL_OUTSIDE_IN:uint = 6;\n\t\tpublic static const FILL_VERTICAL_INSIDE_OUT:uint = 7;\n\t\tpublic static const FILL_VERTICAL_OUTSIDE_IN:uint = 8;\n\t\t\n\t\tprivate static const BAR_FILLED:uint = 1;\n\t\tprivate static const BAR_GRADIENT:uint = 2;\n\t\tprivate static const BAR_IMAGE:uint = 3;\n\t\t\n\t\t/**\n\t\t * Create a new FlxBar Object\n\t\t * \n\t\t * @param\tx\t\t\tThe x coordinate location of the resulting bar (in world pixels)\n\t\t * @param\ty\t\t\tThe y coordinate location of the resulting bar (in world pixels)\n\t\t * @param\tdirection \tOne of the FlxBar.FILL_ constants (such as FILL_LEFT_TO_RIGHT, FILL_TOP_TO_BOTTOM etc)\n\t\t * @param\twidth\t\tThe width of the bar in pixels\n\t\t * @param\theight\t\tThe height of the bar in pixels\n\t\t * @param\tparentRef\tA reference to an object in your game that you wish the bar to track\n\t\t * @param\tvariable\tThe variable of the object that is used to determine the bar position. For example if the parent was an FlxSprite this could be \"health\" to track the health value\n\t\t * @param\tmin\t\t\tThe minimum value. I.e. for a progress bar this would be zero (nothing loaded yet)\n\t\t * @param\tmax\t\t\tThe maximum value the bar can reach. I.e. for a progress bar this would typically be 100.\n\t\t * @param\tborder\t\tInclude a 1px border around the bar? (if true it adds +2 to width and height to accommodate it)\n\t\t */\n\t\tpublic function FlxBar(x:int, y:int, direction:uint = FILL_LEFT_TO_RIGHT, width:int = 100, height:int = 10, parentRef:* = null, variable:String = \"\", min:Number = 0, max:Number = 100, border:Boolean = false):void\n\t\t{\n\t\t\tsuper(x, y);\n\t\t\t\n\t\t\tbarWidth = width;\n\t\t\tbarHeight = height;\n\t\t\t\n\t\t\tif (border)\n\t\t\t{\n\t\t\t\tmakeGraphic(barWidth + 2, barHeight + 2, 0xffffffff, true);\n\t\t\t\tfilledBarPoint = new Point(1, 1);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmakeGraphic(barWidth, barHeight, 0xffffffff, true);\n\t\t\t\tfilledBarPoint = new Point(0, 0);\n\t\t\t}\n\t\t\t\n\t\t\tcanvas = new BitmapData(width, height, true, 0x0);\n\t\t\t\n\t\t\tif (parentRef)\n\t\t\t{\n\t\t\t\tparent = parentRef;\n\t\t\t\tparentVariable = variable;\n\t\t\t}\n\t\t\t\n\t\t\tsetFillDirection(direction);\n\t\t\t\n\t\t\tsetRange(min, max);\n\t\t\t\n\t\t\tcreateFilledBar(0xff005100, 0xff00F400, border);\n\t\t\t\n\t\t\temptyKill = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Track the parent FlxSprites x/y coordinates. For example if you wanted your sprite to have a floating health-bar above their head.\n\t\t * If your health bar is 10px tall and you wanted it to appear above your sprite, then set offsetY to be -10\n\t\t * If you wanted it to appear below your sprite, and your sprite was 32px tall, then set offsetY to be 32. Same applies to offsetX.\n\t\t * \n\t\t * @param\toffsetX\t\tThe offset on X in relation to the origin x/y of the parent\n\t\t * @param\toffsetY\t\tThe offset on Y in relation to the origin x/y of the parent\n\t\t * @see\t\tstopTrackingParent\n\t\t */\n\t\tpublic function trackParent(offsetX:int, offsetY:int):void\n\t\t{\n\t\t\tfixedPosition = false;\n\t\t\t\n\t\t\tpositionOffset = new FlxPoint(offsetX, offsetY);\n\t\t\t\n\t\t\tif (parent.scrollFactor)\n\t\t\t{\n\t\t\t\tscrollFactor.x = parent.scrollFactor.x;\n\t\t\t\tscrollFactor.y = parent.scrollFactor.y;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets a parent for this FlxBar. Instantly replaces any previously set parent and refreshes the bar.\n\t\t * \n\t\t * @param\tparentRef\tA reference to an object in your game that you wish the bar to track\n\t\t * @param\tvariable\tThe variable of the object that is used to determine the bar position. For example if the parent was an FlxSprite this could be \"health\" to track the health value\n\t\t * @param\ttrack\t\tIf you wish the FlxBar to track the x/y coordinates of parent set to true (default false)\n\t\t * @param\toffsetX\t\tThe offset on X in relation to the origin x/y of the parent\n\t\t * @param\toffsetY\t\tThe offset on Y in relation to the origin x/y of the parent\n\t\t */\n\t\tpublic function setParent(parentRef:*, variable:String, track:Boolean = false, offsetX:int = 0, offsetY:int = 0):void\n\t\t{\n\t\t\tparent = parentRef;\n\t\t\tparentVariable = variable;\n\t\t\t\n\t\t\tif (track)\n\t\t\t{\n\t\t\t\ttrackParent(offsetX, offsetY);\n\t\t\t}\n\t\t\t\n\t\t\tupdateValueFromParent();\n\t\t\tupdateBar();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Tells the health bar to stop following the parent sprite. The given posX and posY values are where it will remain on-screen.\n\t\t * \n\t\t * @param\tposX\tX coordinate of the health bar now it's no longer tracking the parent sprite\n\t\t * @param\tposY\tY coordinate of the health bar now it's no longer tracking the parent sprite\n\t\t */\n\t\tpublic function stopTrackingParent(posX:int, posY:int):void\n\t\t{\n\t\t\tfixedPosition = true;\n\t\t\t\n\t\t\tx = posX;\n\t\t\ty = posY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets callbacks which will be triggered when the value of this FlxBar reaches min or max.<br>\n\t\t * Functions will only be called once and not again until the value changes.<br>\n\t\t * Optionally the FlxBar can be killed if it reaches min, but if will fire the empty callback first (if set)\n\t\t * \n\t\t * @param\tonEmpty\t\t\tThe function that is called if the value of this FlxBar reaches min\n\t\t * @param\tonFilled\t\tThe function that is called if the value of this FlxBar reaches max\n\t\t * @param\tkillOnEmpty\t\tIf set it will call FlxBar.kill() if the value reaches min\n\t\t */\n\t\tpublic function setCallbacks(onEmpty:Function, onFilled:Function, killOnEmpty:Boolean = false):void\n\t\t{\n\t\t\tif (onEmpty is Function)\n\t\t\t{\n\t\t\t\temptyCallback = onEmpty;\n\t\t\t}\n\t\t\t\n\t\t\tif (onFilled is Function)\n\t\t\t{\n\t\t\t\tfilledCallback = onFilled;\n\t\t\t}\n\t\t\t\n\t\t\tif (killOnEmpty)\n\t\t\t{\n\t\t\t\temptyKill = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * If this FlxBar should be killed when its value reaches empty, set to true\n\t\t */\n\t\tpublic function set killOnEmpty(value:Boolean):void\n\t\t{\n\t\t\temptyKill = value;\n\t\t}\n\t\t\n\t\tpublic function get killOnEmpty():Boolean\n\t\t{\n\t\t\treturn emptyKill;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the minimum and maximum allowed values for the FlxBar\n\t\t * \n\t\t * @param\tmin\t\t\tThe minimum value. I.e. for a progress bar this would be zero (nothing loaded yet)\n\t\t * @param\tmax\t\t\tThe maximum value the bar can reach. I.e. for a progress bar this would typically be 100.\n\t\t */\n\t\tpublic function setRange(min:Number, max:Number):void\n\t\t{\n\t\t\tif (max <= min)\n\t\t\t{\n\t\t\t\tthrow Error(\"FlxBar: max cannot be less than or equal to min\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tthis.min = min;\n\t\t\tthis.max = max;\n\t\t\t\n\t\t\trange = max - min;\n\t\t\t\n\t\t\tif (range < 100)\n\t\t\t{\n\t\t\t\tpct = range / 100;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpct = range / 100;\n\t\t\t}\n\t\t\t\n\t\t\tif (fillHorizontal)\n\t\t\t{\n\t\t\t\tpxPerPercent = barWidth / 100;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpxPerPercent = barHeight / 100;\n\t\t\t}\n\t\t\t\n\t\t\tif (value)\n\t\t\t{\n\t\t\t\tif (value > max)\n\t\t\t\t{\n\t\t\t\t\tvalue = max;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (value < min)\n\t\t\t\t{\n\t\t\t\t\tvalue = min;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvalue = min;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic function debug():void\n\t\t{\n\t\t\ttrace(\"FlxBar - Min:\", min, \"Max:\", max, \"Range:\", range, \"pct:\", pct, \"pxp:\", pxPerPercent, \"Value:\", value);\n\t\t}\n\t\t\n\t\tpublic function get stats():Object\n\t\t{\n\t\t\tvar data:Object = {\n\t\t\t\tmin: min,\n\t\t\t\tmax: max,\n\t\t\t\trange: range,\n\t\t\t\tpct: pct,\n\t\t\t\tpxPerPct: pxPerPercent,\n\t\t\t\tfillH: fillHorizontal\n\t\t\t}\n\t\t\t\n\t\t\treturn data;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a solid-colour filled health bar in the given colours, with optional 1px thick border.\n\t\t * All colour values are in 0xAARRGGBB format, so if you want a slightly transparent health bar give it lower AA values.\n\t\t * \n\t\t * @param\tempty\t\tThe color of the bar when empty in 0xAARRGGBB format (the background colour)\n\t\t * @param\tfill\t\tThe color of the bar when full in 0xAARRGGBB format (the foreground colour)\n\t\t * @param\tshowBorder\tShould the bar be outlined with a 1px solid border?\n\t\t * @param\tborder\t\tThe border colour in 0xAARRGGBB format\n\t\t */\n\t\tpublic function createFilledBar(empty:uint, fill:uint, showBorder:Boolean = false, border:uint = 0xffffffff):void\n\t\t{\n\t\t\tbarType = BAR_FILLED;\n\t\t\t\n\t\t\tif (showBorder)\n\t\t\t{\n\t\t\t\temptyBar = new BitmapData(barWidth, barHeight, true, border);\n\t\t\t\temptyBar.fillRect(new Rectangle(1, 1, barWidth - 2, barHeight - 2), empty);\n\t\t\t\t\n\t\t\t\tfilledBar = new BitmapData(barWidth, barHeight, true, border);\n\t\t\t\tfilledBar.fillRect(new Rectangle(1, 1, barWidth - 2, barHeight - 2), fill);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\temptyBar = new BitmapData(barWidth, barHeight, true, empty);\n\t\t\t\tfilledBar = new BitmapData(barWidth, barHeight, true, fill);\n\t\t\t}\n\t\t\t\n\t\t\tfilledBarRect = new Rectangle(0, 0, filledBar.width, filledBar.height);\n\t\t\temptyBarRect = new Rectangle(0, 0, emptyBar.width, emptyBar.height);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a gradient filled health bar using the given colour ranges, with optional 1px thick border.\n\t\t * All colour values are in 0xAARRGGBB format, so if you want a slightly transparent health bar give it lower AA values.\n\t\t * \n\t\t * @param\tempty\t\tArray of colour values used to create the gradient of the health bar when empty, each colour must be in 0xAARRGGBB format (the background colour)\n\t\t * @param\tfill\t\tArray of colour values used to create the gradient of the health bar when full, each colour must be in 0xAARRGGBB format (the foreground colour)\n\t\t * @param\tchunkSize\tIf you want a more old-skool looking chunky gradient, increase this value!\n\t\t * @param\trotation\tAngle of the gradient in degrees. 90 = top to bottom, 180 = left to right. Any angle is valid\n\t\t * @param\tshowBorder\tShould the bar be outlined with a 1px solid border?\n\t\t * @param\tborder\t\tThe border colour in 0xAARRGGBB format\n\t\t */\n\t\tpublic function createGradientBar(empty:Array, fill:Array, chunkSize:int = 1, rotation:int = 180, showBorder:Boolean = false, border:uint = 0xffffffff):void\n\t\t{\n\t\t\tbarType = BAR_GRADIENT;\n\t\t\t\n\t\t\tif (showBorder)\n\t\t\t{\n\t\t\t\temptyBar = new BitmapData(barWidth, barHeight, true, border);\n\t\t\t\tFlxGradient.overlayGradientOnBitmapData(emptyBar, barWidth - 2, barHeight - 2, empty, 1, 1, chunkSize, rotation);\n\t\t\t\t\n\t\t\t\tfilledBar = new BitmapData(barWidth, barHeight, true, border);\n\t\t\t\tFlxGradient.overlayGradientOnBitmapData(filledBar, barWidth - 2, barHeight - 2, fill, 1, 1, chunkSize, rotation);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\temptyBar = FlxGradient.createGradientBitmapData(barWidth, barHeight, empty, chunkSize, rotation);\n\t\t\t\tfilledBar = FlxGradient.createGradientBitmapData(barWidth, barHeight, fill, chunkSize, rotation);\n\t\t\t}\n\t\t\t\n\t\t\temptyBarRect = new Rectangle(0, 0, emptyBar.width, emptyBar.height);\n\t\t\tfilledBarRect = new Rectangle(0, 0, filledBar.width, filledBar.height);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a health bar filled using the given bitmap images.\n\t\t * You can provide \"empty\" (background) and \"fill\" (foreground) images. either one or both images (empty / fill), and use the optional empty/fill colour values \n\t\t * All colour values are in 0xAARRGGBB format, so if you want a slightly transparent health bar give it lower AA values.\n\t\t * \n\t\t * @param\tempty\t\t\t\tBitmap image used as the background (empty part) of the health bar, if null the emptyBackground colour is used\n\t\t * @param\tfill\t\t\t\tBitmap image used as the foreground (filled part) of the health bar, if null the fillBackground colour is used\n\t\t * @param\temptyBackground\t\tIf no background (empty) image is given, use this colour value instead. 0xAARRGGBB format\n\t\t * @param\tfillBackground\t\tIf no foreground (fill) image is given, use this colour value instead. 0xAARRGGBB format\n\t\t */\n\t\tpublic function createImageBar(empty:Class = null, fill:Class = null, emptyBackground:uint = 0xff000000, fillBackground:uint = 0xff00ff00):void\n\t\t{\n\t\t\tbarType = BAR_IMAGE;\n\t\t\t\n\t\t\tif (empty == null && fill == null)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif (empty && fill == null)\n\t\t\t{\n\t\t\t\t//\tIf empty is set, but fill is not ...\n\n\t\t\t\temptyBar = Bitmap(new empty).bitmapData.clone();\n\t\t\t\temptyBarRect = new Rectangle(0, 0, emptyBar.width, emptyBar.height);\n\t\t\t\t\n\t\t\t\tbarWidth = emptyBarRect.width;\n\t\t\t\tbarHeight = emptyBarRect.height;\n\t\t\t\t\n\t\t\t\tfilledBar = new BitmapData(barWidth, barHeight, true, fillBackground);\n\t\t\t\tfilledBarRect = new Rectangle(0, 0, barWidth, barHeight);\n\t\t\t}\n\t\t\telse if (empty == null && fill)\n\t\t\t{\n\t\t\t\t//\tIf fill is set, but empty is not ...\n\t\t\n\t\t\t\tfilledBar = Bitmap(new fill).bitmapData.clone();\n\t\t\t\tfilledBarRect = new Rectangle(0, 0, filledBar.width, filledBar.height);\n\t\t\t\t\n\t\t\t\tbarWidth = filledBarRect.width;\n\t\t\t\tbarHeight = filledBarRect.height;\n\t\t\t\t\n\t\t\t\temptyBar = new BitmapData(barWidth, barHeight, true, emptyBackground);\n\t\t\t\temptyBarRect = new Rectangle(0, 0, barWidth, barHeight);\n\t\t\t}\n\t\t\telse if (empty && fill)\n\t\t\t{\n\t\t\t\t//\tIf both are set\n\t\t\t\t\n\t\t\t\temptyBar = Bitmap(new empty).bitmapData.clone();\n\t\t\t\temptyBarRect = new Rectangle(0, 0, emptyBar.width, emptyBar.height);\n\t\t\t\t\n\t\t\t\tfilledBar = Bitmap(new fill).bitmapData.clone();\n\t\t\t\tfilledBarRect = new Rectangle(0, 0, filledBar.width, filledBar.height);\n\t\t\t\t\n\t\t\t\tbarWidth = emptyBarRect.width;\n\t\t\t\tbarHeight = emptyBarRect.height;\n\t\t\t}\n\t\t\t\n\t\t\tcanvas = new BitmapData(barWidth, barHeight, true, 0x0);\n\t\t\t\n\t\t\tif (fillHorizontal)\n\t\t\t{\n\t\t\t\tpxPerPercent = barWidth / 100;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpxPerPercent = barHeight / 100;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the direction from which the health bar will fill-up. Default is from left to right. Change takes effect immediately.\n\t\t * \n\t\t * @param\tdirection \t\t\tOne of the FlxBar.FILL_ constants (such as FILL_LEFT_TO_RIGHT, FILL_TOP_TO_BOTTOM etc)\n\t\t */\n\t\tpublic function setFillDirection(direction:uint):void\n\t\t{\n\t\t\tswitch (direction)\n\t\t\t{\n\t\t\t\tcase FILL_LEFT_TO_RIGHT:\n\t\t\t\tcase FILL_RIGHT_TO_LEFT:\n\t\t\t\tcase FILL_HORIZONTAL_INSIDE_OUT:\n\t\t\t\tcase FILL_HORIZONTAL_OUTSIDE_IN:\n\t\t\t\t\tfillDirection = direction;\n\t\t\t\t\tfillHorizontal = true;\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase FILL_TOP_TO_BOTTOM:\n\t\t\t\tcase FILL_BOTTOM_TO_TOP:\n\t\t\t\tcase FILL_VERTICAL_INSIDE_OUT:\n\t\t\t\tcase FILL_VERTICAL_OUTSIDE_IN:\n\t\t\t\t\tfillDirection = direction;\n\t\t\t\t\tfillHorizontal = false;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprivate function updateValueFromParent():void\n\t\t{\n\t\t\tupdateValue(parent[parentVariable]);\n\t\t}\n\t\t\n\t\tprivate function updateValue(newValue:Number):void\n\t\t{\n\t\t\tif (newValue > max)\n\t\t\t{\n\t\t\t\tnewValue = max;\n\t\t\t}\n\t\t\t\n\t\t\tif (newValue < min)\n\t\t\t{\n\t\t\t\tnewValue = min;\n\t\t\t}\n\t\t\t\n\t\t\tvalue = newValue;\n\t\t\t\n\t\t\tif (value == min && emptyCallback is Function)\n\t\t\t{\n\t\t\t\temptyCallback.call();\n\t\t\t}\n\t\t\t\n\t\t\tif (value == max && filledCallback is Function)\n\t\t\t{\n\t\t\t\tfilledCallback.call();\n\t\t\t}\n\t\t\t\n\t\t\tif (value == min && emptyKill)\n\t\t\t{\n\t\t\t\tkill();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal\n\t\t * Called when the health bar detects a change in the health of the parent.\n\t\t */\n\t\tprivate function updateBar():void\n\t\t{\n\t\t\tif (fillHorizontal)\n\t\t\t{\n\t\t\t\tfilledBarRect.width = int(percent * pxPerPercent);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfilledBarRect.height = int(percent * pxPerPercent);\n\t\t\t}\n\t\t\t\n\t\t\tcanvas.copyPixels(emptyBar, emptyBarRect, zeroOffset);\n\t\t\t\n\t\t\tif (percent > 0)\n\t\t\t{\n\t\t\t\tswitch (fillDirection)\n\t\t\t\t{\n\t\t\t\t\tcase FILL_LEFT_TO_RIGHT:\n\t\t\t\t\tcase FILL_TOP_TO_BOTTOM:\n\t\t\t\t\t\t//\tAlready handled above\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase FILL_BOTTOM_TO_TOP:\n\t\t\t\t\t\tfilledBarRect.y = barHeight - filledBarRect.height;\n\t\t\t\t\t\tfilledBarPoint.y = barHeight - filledBarRect.height;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase FILL_RIGHT_TO_LEFT:\n\t\t\t\t\t\tfilledBarRect.x = barWidth - filledBarRect.width;\n\t\t\t\t\t\tfilledBarPoint.x = barWidth - filledBarRect.width;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase FILL_HORIZONTAL_INSIDE_OUT:\n\t\t\t\t\t\tfilledBarRect.x = int((barWidth / 2) - (filledBarRect.width / 2));\n\t\t\t\t\t\tfilledBarPoint.x = int((barWidth / 2) - (filledBarRect.width / 2));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase FILL_HORIZONTAL_OUTSIDE_IN:\n\t\t\t\t\t\tfilledBarRect.width = int(100 - percent * pxPerPercent);\n\t\t\t\t\t\tfilledBarPoint.x = int((barWidth - filledBarRect.width) / 2);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase FILL_VERTICAL_INSIDE_OUT:\n\t\t\t\t\t\tfilledBarRect.y = int((barHeight / 2) - (filledBarRect.height / 2));\n\t\t\t\t\t\tfilledBarPoint.y = int((barHeight / 2) - (filledBarRect.height / 2));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase FILL_VERTICAL_OUTSIDE_IN:\n\t\t\t\t\t\tfilledBarRect.height = int(100 - percent * pxPerPercent);\n\t\t\t\t\t\tfilledBarPoint.y = int((barHeight- filledBarRect.height) / 2);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcanvas.copyPixels(filledBar, filledBarRect, filledBarPoint);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\tpixels = canvas;\n\t\t}\n\t\t\n\t\toverride public function update():void\n\t\t{\n\t\t\tif (parent)\n\t\t\t{\n\t\t\t\tif (parent[parentVariable] != value)\n\t\t\t\t{\n\t\t\t\t\tupdateValueFromParent();\n\t\t\t\t\tupdateBar();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (fixedPosition == false)\n\t\t\t\t{\n\t\t\t\t\tx = parent.x + positionOffset.x;\n\t\t\t\t\ty = parent.y + positionOffset.y;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * The percentage of how full the bar is (a value between 0 and 100)\n\t\t */\n\t\tpublic function get percent():Number\n\t\t{\n\t\t\tif (value > max)\n\t\t\t{\n\t\t\t\treturn 100;\n\t\t\t}\n\t\t\t\n\t\t\treturn Math.floor((value / range) * 100);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the percentage of how full the bar is (a value between 0 and 100). This changes FlxBar.currentValue\n\t\t */\n\t\tpublic function set percent(newPct:Number):void\n\t\t{\n\t\t\tif (newPct >= 0 && newPct <= 100)\n\t\t\t{\n\t\t\t\tupdateValue(pct * newPct);\n\t\t\t\t\n\t\t\t\tupdateBar();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the current value of the bar (must be between min and max range)\n\t\t */\n\t\tpublic function set currentValue(newValue:Number):void\n\t\t{\n\t\t\tupdateValue(newValue);\n\t\t\t\n\t\t\tupdateBar();\n\t\t}\n\t\t\n\t\t/**\n\t\t * The current actual value of the bar\n\t\t */\n\t\tpublic function get currentValue():Number\n\t\t{\n\t\t\treturn value;\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxBitmapFont.as",
    "content": "/**\n * FlxBitmapFont\n * -- Part of the Flixel Power Tools set\n * \n * v1.4 Changed width/height to characterWidth/Height to avoid confusion and added setFixedWidth\n * v1.3 Exposed character width / height values\n * v1.2 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.4 - June 21st 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n * @see Requires FlxMath\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport org.flixel.*;\n\t\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\t\n\tpublic class FlxBitmapFont extends FlxSprite\n\t{\n\t\t/**\n\t\t * Alignment of the text when multiLine = true or a fixedWidth is set. Set to FlxBitmapFont.ALIGN_LEFT (default), FlxBitmapFont.ALIGN_RIGHT or FlxBitmapFont.ALIGN_CENTER.\n\t\t */\n\t\tpublic var align:String = \"left\";\n\t\t\n\t\t/**\n\t\t * If set to true all carriage-returns in text will form new lines (see align). If false the font will only contain one single line of text (the default)\n\t\t */\n\t\tpublic var multiLine:Boolean = false;\n\t\t\n\t\t/**\n\t\t * Automatically convert any text to upper case. Lots of old bitmap fonts only contain upper-case characters, so the default is true.\n\t\t */\n\t\tpublic var autoUpperCase:Boolean = true;\n\t\t\n\t\t/**\n\t\t * Adds horizontal spacing between each character of the font, in pixels. Default is 0.\n\t\t */\n\t\tpublic var customSpacingX:Number = 0;\n\t\t\n\t\t/**\n\t\t * Adds vertical spacing between each line of multi-line text, set in pixels. Default is 0.\n\t\t */\n\t\tpublic var customSpacingY:uint = 0;\n\t\t\n\t\tprivate var _text:String;\n\t\t\n\t\t/**\n\t\t * Align each line of multi-line text to the left.\n\t\t */\n\t\tpublic static const ALIGN_LEFT:String = \"left\";\n\t\t\n\t\t/**\n\t\t * Align each line of multi-line text to the right.\n\t\t */\n\t\tpublic static const ALIGN_RIGHT:String = \"right\";\n\t\t\n\t\t/**\n\t\t * Align each line of multi-line text in the center.\n\t\t */\n\t\tpublic static const ALIGN_CENTER:String = \"center\";\n\t\t\n\t\t/**\n\t\t * Text Set 1 = !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\n\t\t */\n\t\tpublic static const TEXT_SET1:String = \" !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\";\n\t\t\n\t\t/**\n\t\t * Text Set 2 =  !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\n\t\t */\n\t\tpublic static const TEXT_SET2:String = \" !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\t\t\n\t\t/**\n\t\t * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 \n\t\t */\n\t\tpublic static const TEXT_SET3:String = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 \";\n\t\t\n\t\t/**\n\t\t * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789\n\t\t */\n\t\tpublic static const TEXT_SET4:String = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789\";\n\t\t\n\t\t/**\n\t\t * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789\n\t\t */\n\t\tpublic static const TEXT_SET5:String = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789\";\n\t\t\n\t\t/**\n\t\t * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\\\"(),-.' \n\t\t */\n\t\tpublic static const TEXT_SET6:String = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\\\"(),-.' \";\n\t\t\n\t\t/**\n\t\t * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\\\")28FLRX-'39\n\t\t */\n\t\tpublic static const TEXT_SET7:String = \"AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\\\")28FLRX-'39\";\n\t\t\n\t\t/**\n\t\t * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ\n\t\t */\n\t\tpublic static const TEXT_SET8:String = \"0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\t\t\n\t\t/**\n\t\t * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\\\"?!\n\t\t */\n\t\tpublic static const TEXT_SET9:String = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\\\"?!\";\n\t\t\n\t\t/**\n\t\t * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ\n\t\t */\n\t\tpublic static const TEXT_SET10:String = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\t\t\n\t\t/**\n\t\t * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\\\"-+!?()':;0123456789\n\t\t */\n\t\tpublic static const TEXT_SET11:String = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\\\"-+!?()':;0123456789\";\n\t\t\n\t\t/**\n\t\t * Internval values. All set in the constructor. They should not be changed after that point.\n\t\t */\n\t\tprivate var fontSet:BitmapData;\n\t\tprivate var offsetX:uint;\n\t\tprivate var offsetY:uint;\n\t\tpublic var characterWidth:uint;\n\t\tpublic var characterHeight:uint;\n\t\tprivate var characterSpacingX:uint;\n\t\tprivate var characterSpacingY:uint;\n\t\tprivate var characterPerRow:uint;\n\t\tprivate var grabData:Array\n\t\tprivate var fixedWidth:uint = 0;\n\t\t\n\t\t/**\n\t\t * Loads 'font' and prepares it for use by future calls to .text\n\t\t * \n\t\t * @param\tfont\t\t\tThe font set graphic class (as defined by your embed)\n\t\t * @param\tcharacterWidth\tThe width of each character in the font set.\n\t\t * @param\tcharacterHeight\tThe height of each character in the font set.\n\t\t * @param\tchars\t\t\tThe characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements.\n\t\t * @param\tcharsPerRow\t\tThe number of characters per row in the font set.\n\t\t * @param\txSpacing\t\tIf the characters in the font set have horizontal spacing between them set the required amount here.\n\t\t * @param\tySpacing\t\tIf the characters in the font set have vertical spacing between them set the required amount here\n\t\t * @param\txOffset\t\t\tIf the font set doesn't start at the top left of the given image, specify the X coordinate offset here.\n\t\t * @param\tyOffset\t\t\tIf the font set doesn't start at the top left of the given image, specify the Y coordinate offset here.\n\t\t */\n        public function FlxBitmapFont(font:Class, characterWidth:uint, characterHeight:uint, chars:String, charsPerRow:uint, xSpacing:uint = 0, ySpacing:uint = 0, xOffset:uint = 0, yOffset:uint = 0):void\n        {\n\t\t\t//\tTake a copy of the font for internal use\n\t\t\tfontSet = (new font).bitmapData;\n\t\t\t\n\t\t\tthis.characterWidth = characterWidth;\n\t\t\tthis.characterHeight = characterHeight;\n\t\t\tcharacterSpacingX = xSpacing;\n\t\t\tcharacterSpacingY = ySpacing;\n\t\t\tcharacterPerRow = charsPerRow;\n\t\t\toffsetX = xOffset;\n\t\t\toffsetY = yOffset;\n\t\t\t\n\t\t\tgrabData = new Array();\n\t\t\t\n\t\t\t//\tNow generate our rects for faster copyPixels later on\n\t\t\tvar currentX:uint = offsetX;\n\t\t\tvar currentY:uint = offsetY;\n\t\t\tvar r:uint = 0;\n\t\t\t\n\t\t\tfor (var c:uint = 0; c < chars.length; c++)\n\t\t\t{\n\t\t\t\t//\tThe rect is hooked to the ASCII value of the character\n\t\t\t\tgrabData[chars.charCodeAt(c)] = new Rectangle(currentX, currentY, characterWidth, characterHeight);\n\t\t\t\t\n\t\t\t\tr++;\n\t\t\t\t\n\t\t\t\tif (r == characterPerRow)\n\t\t\t\t{\n\t\t\t\t\tr = 0;\n\t\t\t\t\tcurrentX = offsetX;\n\t\t\t\t\tcurrentY += characterHeight + characterSpacingY;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcurrentX += characterWidth + characterSpacingX;\n\t\t\t\t}\n\t\t\t}\n        }\n\t\t\n\t\t/**\n\t\t * Set this value to update the text in this sprite. Carriage returns are automatically stripped out if multiLine is false. Text is converted to upper case if autoUpperCase is true.\n\t\t * \n\t\t * @return\tvoid\n\t\t */ \n\t\tpublic function set text(content:String):void\n\t\t{\n\t\t\tvar newText:String;\n\t\t\t\n\t\t\tif (autoUpperCase)\n\t\t\t{\n\t\t\t\tnewText = content.toUpperCase();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tnewText = content;\n\t\t\t}\n\t\t\t\n\t\t\t// Smart update: Only change the bitmap data if the string has changed\n\t\t\tif (newText != _text)\n\t\t\t{\n\t\t\t\t_text = newText;\n\t\t\t\t\n\t\t\t\tremoveUnsupportedCharacters(multiLine);\n\t\t\t\t\n\t\t\t\tbuildBitmapFontText();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * If you need this FlxSprite to have a fixed width and custom alignment you can set the width here.<br>\n\t\t * If text is wider than the width specified it will be cropped off.\n\t\t * \n\t\t * @param\twidth\t\t\tWidth in pixels of this FlxBitmapFont. Set to zero to disable and re-enable automatic resizing.\n\t\t * @param\tlineAlignment\tAlign the text within this width. Set to FlxBitmapFont.ALIGN_LEFT (default), FlxBitmapFont.ALIGN_RIGHT or FlxBitmapFont.ALIGN_CENTER.\n\t\t */\n\t\tpublic function setFixedWidth(width:int, lineAlignment:String = \"left\"):void\n\t\t{\n\t\t\tfixedWidth = width;\n\t\t\talign = lineAlignment;\n\t\t}\n\t\t\n\t\tpublic function get text():String\n\t\t{\n\t\t\treturn _text;\n\t\t}\n\t\t\n\t\t/**\n\t\t * A helper function that quickly sets lots of variables at once, and then updates the text.\n\t\t * \n\t\t * @param\tcontent\t\t\t\tThe text of this sprite\n\t\t * @param\tmultiLines\t\t\tSet to true if you want to support carriage-returns in the text and create a multi-line sprite instead of a single line (default is false).\n\t\t * @param\tcharacterSpacing\tTo add horizontal spacing between each character specify the amount in pixels (default 0).\n\t\t * @param\tlineSpacing\t\t\tTo add vertical spacing between each line of text, set the amount in pixels (default 0).\n\t\t * @param\tlineAlignment\t\tAlign each line of multi-line text. Set to FlxBitmapFont.ALIGN_LEFT (default), FlxBitmapFont.ALIGN_RIGHT or FlxBitmapFont.ALIGN_CENTER.\n\t\t * @param\tallowLowerCase\t\tLots of bitmap font sets only include upper-case characters, if yours needs to support lower case then set this to true.\n\t\t */\n\t\tpublic function setText(content:String, multiLines:Boolean = false, characterSpacing:Number = 0, lineSpacing:uint = 0, lineAlignment:String = \"left\", allowLowerCase:Boolean = false):void\n\t\t{\n\t\t\tcustomSpacingX = characterSpacing;\n\t\t\tcustomSpacingY = lineSpacing;\n\t\t\talign = lineAlignment;\n\t\t\tmultiLine = multiLines;\n\t\t\t\n\t\t\tif (allowLowerCase)\n\t\t\t{\n\t\t\t\tautoUpperCase = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tautoUpperCase = true;\n\t\t\t}\n\t\t\t\n\t\t\tif (content.length > 0)\n\t\t\t{\n\t\t\t\ttext = content;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Updates the BitmapData of the Sprite with the text\n\t\t * \n\t\t * @return\tvoid\n\t\t */\n\t\tprivate function buildBitmapFontText():void\n\t\t{\n\t\t\tvar temp:BitmapData;\n\t\t\tvar cx:int = 0;\n\t\t\tvar cy:int = 0;\n\t\t\t\n\t\t\tif (multiLine)\n\t\t\t{\n\t\t\t\tvar lines:Array = _text.split(\"\\n\");\n\t\t\t\n\t\t\t\tif (fixedWidth > 0)\n\t\t\t\t{\n\t\t\t\t\ttemp = new BitmapData(fixedWidth, (lines.length * (characterHeight + customSpacingY)) - customSpacingY, true, 0xf);\n\t\t\t\t}\n\t\t\t\telse if(customSpacingX>0)\n\t\t\t\t{\n\t\t\t\t\ttemp = new BitmapData(getLongestLine() * (characterWidth + customSpacingX), (lines.length * (characterHeight + customSpacingY)) - customSpacingY, true, 0xf);\n\t\t\t\t}else \n\t\t\t\t{\n\t\t\t\t\ttemp = new BitmapData(getLongestLine() * (characterWidth), (lines.length * (characterHeight + customSpacingY)) - customSpacingY, true, 0xf);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//\tLoop through each line of text\n\t\t\t\tfor (var i:uint = 0; i < lines.length; i++)\n\t\t\t\t{\n\t\t\t\t\t//\tThis line of text is held in lines[i] - need to work out the alignment\n\t\t\t\t\tswitch (align)\n\t\t\t\t\t{\n\t\t\t\t\t\tcase ALIGN_LEFT:\n\t\t\t\t\t\t\tcx = 0;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tcase ALIGN_RIGHT:\n\t\t\t\t\t\t\tcx = temp.width - (lines[i].length * (characterWidth + customSpacingX));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tcase ALIGN_CENTER:\n\t\t\t\t\t\t\tcx = (temp.width / 2) - ((lines[i].length * (characterWidth + customSpacingX)) / 2);\n\t\t\t\t\t\t\tcx += customSpacingX / 2;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t//\tSanity checks\n\t\t\t\t\tif (cx < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tcx = 0;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tpasteLine(temp, lines[i], cx, cy, customSpacingX);\n\t\t\t\t\t\n\t\t\t\t\tcy += characterHeight + customSpacingY;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (fixedWidth > 0)\n\t\t\t\t{\n\t\t\t\t\ttemp = new BitmapData(fixedWidth, characterHeight, true, 0xf);\n\t\t\t\t}\n\t\t\t\telse if (customSpacingX>0)\n\t\t\t\t{\n\t\t\t\t\ttemp = new BitmapData(_text.length * (characterWidth + customSpacingX), characterHeight, true, 0xf);\n\t\t\t\t}\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\ttemp = new BitmapData(_text.length * (characterWidth), characterHeight, true, 0xf);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tswitch (align)\n\t\t\t\t{\n\t\t\t\t\tcase ALIGN_LEFT:\n\t\t\t\t\t\tcx = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase ALIGN_RIGHT:\n\t\t\t\t\t\tcx = temp.width - (_text.length * (characterWidth + customSpacingX));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase ALIGN_CENTER:\n\t\t\t\t\t\tcx = (temp.width / 2) - ((_text.length * (characterWidth + customSpacingX)) / 2);\n\t\t\t\t\t\tcx += customSpacingX / 2;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\n\t\t\t\tpasteLine(temp, _text, cx, 0, customSpacingX);\n\t\t\t}\n\t\t\t\n\t\t\tpixels = temp;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns a single character from the font set as an FlxSprite.\n\t\t * \n\t\t * @param\tchar\tThe character you wish to have returned.\n\t\t * \n\t\t * @return\tAn <code>FlxSprite</code> containing a single character from the font set.\n\t\t */\n\t\tpublic function getCharacter(char:String):FlxSprite\n\t\t{\n\t\t\tvar output:FlxSprite = new FlxSprite();\n\t\t\t\n\t\t\tvar temp:BitmapData = new BitmapData(characterWidth, characterHeight, true, 0xf);\n\n\t\t\tif (grabData[char.charCodeAt(0)] is Rectangle && char.charCodeAt(0) != 32)\n\t\t\t{\n\t\t\t\ttemp.copyPixels(fontSet, grabData[char.charCodeAt(0)], new Point(0, 0));\n\t\t\t}\n\t\t\t\n\t\t\toutput.pixels = temp;\n\t\t\t\n\t\t\treturn output;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns a single character from the font set as bitmapData\n\t\t * \n\t\t * @param\tchar\tThe character you wish to have returned.\n\t\t * \n\t\t * @return\t<code>bitmapData</code> containing a single character from the font set.\n\t\t */\n\t\tpublic function getCharacterAsBitmapData(char:String):BitmapData\n\t\t{\n\t\t\tvar temp:BitmapData = new BitmapData(characterWidth, characterHeight, true, 0xf);\n\n\t\t\t//if (grabData[char.charCodeAt(0)] is Rectangle && char.charCodeAt(0) != 32)\n\t\t\tif (grabData[char.charCodeAt(0)] is Rectangle)\n\t\t\t{\n\t\t\t\ttemp.copyPixels(fontSet, grabData[char.charCodeAt(0)], new Point(0, 0));\n\t\t\t}\n\t\t\t\n\t\t\treturn temp;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function that takes a single line of text (2nd parameter) and pastes it into the BitmapData at the given coordinates.\n\t\t * Used by getLine and getMultiLine\n\t\t * \n\t\t * @param\toutput\t\t\tThe BitmapData that the text will be drawn onto\n\t\t * @param\tline\t\t\tThe single line of text to paste\n\t\t * @param\tx\t\t\t\tThe x coordinate\n\t\t * @param\ty\n\t\t * @param\tcustomSpacingX\n\t\t */\n\t\tprivate function pasteLine(output:BitmapData, line:String, x:uint = 0, y:uint = 0, customSpacingX:uint = 0):void\n\t\t{\n\t\t\tfor (var c:uint = 0; c < line.length; c++)\n\t\t\t{\n\t\t\t\t//\tIf it's a space then there is no point copying, so leave a blank space\n\t\t\t\tif (line.charAt(c) == \" \")\n\t\t\t\t{\n\t\t\t\t\tx += characterWidth + customSpacingX;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t//\tIf the character doesn't exist in the font then we don't want a blank space, we just want to skip it\n\t\t\t\t\tif (grabData[line.charCodeAt(c)] is Rectangle)\n\t\t\t\t\t{\n\t\t\t\t\t\toutput.copyPixels(fontSet, grabData[line.charCodeAt(c)], new Point(x, y),null,null,true);\n\t\t\t\t\t\t\n\t\t\t\t\t\tx += characterWidth + customSpacingX;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (x > output.width)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbreak;\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 * Works out the longest line of text in _text and returns its length\n\t\t * \n\t\t * @return\tA value\n\t\t */\n\t\tprivate function getLongestLine():uint\n\t\t{\n\t\t\tvar longestLine:uint = 0;\n\t\t\t\n\t\t\tif (_text.length > 0)\n\t\t\t{\n\t\t\t\tvar lines:Array = _text.split(\"\\n\");\n\t\t\t\t\n\t\t\t\tfor (var i:uint = 0; i < lines.length; i++)\n\t\t\t\t{\n\t\t\t\t\tif (lines[i].length > longestLine)\n\t\t\t\t\t{\n\t\t\t\t\t\tlongestLine = lines[i].length;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn longestLine;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal helper function that removes all unsupported characters from the _text String, leaving only characters contained in the font set.\n\t\t * \n\t\t * @param\tstripCR\t\tShould it strip carriage returns as well? (default = true)\n\t\t * \n\t\t * @return\tA clean version of the string\n\t\t */\n\t\tprivate function removeUnsupportedCharacters(stripCR:Boolean = true):String\n\t\t{\n\t\t\tvar newString:String = \"\";\n\t\t\t\n\t\t\tfor (var c:uint = 0; c < _text.length; c++)\n\t\t\t{\n\t\t\t\tif (grabData[_text.charCodeAt(c)] is Rectangle || _text.charCodeAt(c) == 32 || (stripCR == false && _text.charAt(c) == \"\\n\"))\n\t\t\t\t{\n\t\t\t\t\tnewString = newString.concat(_text.charAt(c));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn newString;\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxButtonPlus.as",
    "content": "/**\n * FlxButtonPlus\n * -- Part of the Flixel Power Tools set\n * \n * v1.5 Added setOnClickCallback\n * v1.4 Added scrollFactor to button and swapped to using mouseInFlxRect so buttons in scrolling worlds work\n * v1.3 Updated gradient colour values to include alpha\n * v1.2 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.5 - August 3rd 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm\n{\n\timport flash.events.MouseEvent;\n\t\n\timport org.flixel.*;\n\t\n\t/**\n\t * A simple button class that calls a function when clicked by the mouse.\n\t */\n\tpublic class FlxButtonPlus extends FlxGroup\n\t{\n\t\tstatic public var NORMAL:uint = 0;\n\t\tstatic public var HIGHLIGHT:uint = 1;\n\t\tstatic public var PRESSED:uint = 2;\n\t\t\n\t\t/**\n\t\t * Set this to true if you want this button to function even while the game is paused.\n\t\t */\n\t\tpublic var pauseProof:Boolean;\n\t\t/**\n\t\t * Shows the current state of the button.\n\t\t */\n\t\tprotected var _status:uint;\n\t\t/**\n\t\t * This function is called when the button is clicked.\n\t\t */\n\t\tprotected var _onClick:Function;\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\n\t\t//\tFlixel Power Tools Modification from here down\n\t\t\n\t\tpublic var buttonNormal:FlxExtendedSprite;\n\t\tpublic var buttonHighlight:FlxExtendedSprite;\n\t\t\n\t\tpublic var textNormal:FlxText;\n\t\tpublic var textHighlight:FlxText;\n\t\t\n\t\t/**\n\t\t * The parameters passed to the _onClick function when the button is clicked\n\t\t */\n\t\tprivate var onClickParams:Array;\n\t\t\n\t\t/**\n\t\t * This function is called when the button is hovered over\n\t\t */\n\t\tprivate var enterCallback:Function;\n\t\t\n\t\t/**\n\t\t * The parameters passed to the enterCallback function when the button is hovered over\n\t\t */\n\t\tprivate var enterCallbackParams:Array;\n\t\t\n\t\t/**\n\t\t * This function is called when the mouse leaves a hovered button (but didn't click)\n\t\t */\n\t\tprivate var leaveCallback:Function;\n\t\t\n\t\t/**\n\t\t * The parameters passed to the leaveCallback function when the hovered button is left\n\t\t */\n\t\tprivate var leaveCallbackParams:Array;\n\t\t\n\t\t/**\n\t\t * The 1px thick border color that is drawn around this button\n\t\t */\n\t\tpublic var borderColor:uint = 0xffffffff;\n\t\t\n\t\t/**\n\t\t * The color gradient of the button in its in-active (not hovered over) state\n\t\t */\n\t\tpublic var offColor:Array = [0xff008000, 0xff00FF00];\n\t\t\n\t\t/**\n\t\t * The color gradient of the button in its hovered state\n\t\t */\n\t\tpublic var onColor:Array = [0xff800000, 0xffff0000];\n\t\t\n\t\tprivate var _x:int;\n\t\tprivate var _y:int;\n\t\tpublic var width:int;\n\t\tpublic var height:int;\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\tCallback\tThe function to call whenever the button is clicked.\n\t\t * @param\tParams\t\tAn optional array of parameters that will be passed to the Callback function\n\t\t * @param\tLabel\t\tText to display on the button\n\t\t * @param\tWidth\t\tThe width of the button.\n\t\t * @param\tHeight\t\tThe height of the button.\n\t\t */\n\t\tpublic function FlxButtonPlus(X:int, Y:int, Callback:Function, Params:Array = null, Label:String = null, Width:int = 100, Height:int = 20):void\n\t\t{\n\t\t\tsuper(4);\n\t\t\t\n\t\t\t_x = X;\n\t\t\t_y = Y;\n\t\t\twidth = Width;\n\t\t\theight = Height;\n\t\t\t_onClick = Callback;\n\t\t\t\n\t\t\tbuttonNormal = new FlxExtendedSprite(X, Y);\n\t\t\tbuttonNormal.makeGraphic(Width, Height, borderColor);\n\t\t\tbuttonNormal.stamp(FlxGradient.createGradientFlxSprite(Width - 2, Height - 2, offColor), 1, 1);\n\t\t\tbuttonNormal.solid = false;\n\t\t\tbuttonNormal.scrollFactor.x = 0;\n\t\t\tbuttonNormal.scrollFactor.y = 0;\n\t\t\t\n\t\t\tbuttonHighlight = new FlxExtendedSprite(X, Y);\n\t\t\tbuttonHighlight.makeGraphic(Width, Height, borderColor);\n\t\t\tbuttonHighlight.stamp(FlxGradient.createGradientFlxSprite(Width - 2, Height - 2, onColor), 1, 1);\n\t\t\tbuttonHighlight.solid = false;\n\t\t\tbuttonHighlight.visible = false;\n\t\t\tbuttonHighlight.scrollFactor.x = 0;\n\t\t\tbuttonHighlight.scrollFactor.y = 0;\n\t\t\t\n\t\t\t\n\t\t\tadd(buttonNormal);\n\t\t\tadd(buttonHighlight);\n\t\t\t\n\t\t\tif (Label != null)\n\t\t\t{\n\t\t\t\ttextNormal = new FlxText(X, Y + 3, Width, Label);\n\t\t\t\ttextNormal.setFormat(null, 8, 0xffffffff, \"center\", 0xff000000);\n\t\t\t\t\n\t\t\t\ttextHighlight = new FlxText(X, Y + 3, Width, Label);\n\t\t\t\ttextHighlight.setFormat(null, 8, 0xffffffff, \"center\", 0xff000000);\n\t\t\t\t\n\t\t\t\tadd(textNormal);\n\t\t\t\tadd(textHighlight);\n\t\t\t}\n\n\t\t\t_status = NORMAL;\n\t\t\t_pressed = false;\n\t\t\t_initialized = false;\n\t\t\tpauseProof = false;\n\t\t\t\n\t\t\tif (Params)\n\t\t\t{\n\t\t\t\tonClickParams = Params;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic function set x(newX:int):void\n\t\t{\n\t\t\t_x = newX;\n\t\t\t\n\t\t\tbuttonNormal.x = _x;\n\t\t\tbuttonHighlight.x = _x;\n\t\t\t\n\t\t\tif (textNormal)\n\t\t\t{\n\t\t\t\ttextNormal.x = _x;\n\t\t\t\ttextHighlight.x = _x;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic function get x():int\n\t\t{\n\t\t\treturn _x;\n\t\t}\n\t\t\n\t\tpublic function set y(newY:int):void\n\t\t{\n\t\t\t_y = newY;\n\t\t\t\n\t\t\tbuttonNormal.y = _y;\n\t\t\tbuttonHighlight.y = _y;\n\t\t\t\n\t\t\tif (textNormal)\n\t\t\t{\n\t\t\t\ttextNormal.y = _y;\n\t\t\t\ttextHighlight.y = _y;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic function get y():int\n\t\t{\n\t\t\treturn _y;\n\t\t}\n\t\t\n\t\t//public function set scrollFactor(value:Number):void\n\t\t//{\n\t\t\t//buttonNormal;\n\t\t\t//buttonHighlight;\n\t\t\t//textNormal;\n\t\t\t//textHighlight;\n\t\t//}\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, onMouseUp);\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 * If you wish to replace the two buttons (normal and hovered-over) with FlxSprites, then pass them here.<br />\n\t\t * Note: The pixel data is extract from the passed FlxSprites and assigned locally, it doesn't actually use the sprites<br />\n\t\t * or keep a reference to them.\n\t\t * \n\t\t * @param\tnormal\t\tThe FlxSprite to use when the button is in-active (not hovered over)\n\t\t * @param\thighlight\tThe FlxSprite to use when the button is hovered-over by the mouse\n\t\t */\n\t\tpublic function loadGraphic(normal:FlxSprite, highlight:FlxSprite):void\n\t\t{\n\t\t\tbuttonNormal.pixels = normal.framePixels;\n\t\t\tbuttonHighlight.pixels = highlight.framePixels;\n\t\t\t\n\t\t\twidth = buttonNormal.width;\n\t\t\theight = buttonNormal.height;\n\n\t\t\tif (_pressed)\n\t\t\t{\n\t\t\t\tbuttonNormal.visible = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbuttonHighlight.visible = false;\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\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\tvar prevStatus:uint = _status;\n\t\t\t\n\t\t\tif (FlxG.mouse.visible)\n\t\t\t{\n\t\t\t\tif (buttonNormal.cameras == null)\n\t\t\t\t{\n\t\t\t\t\tbuttonNormal.cameras = FlxG.cameras;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvar c:FlxCamera;\n\t\t\t\tvar i:uint = 0;\n\t\t\t\tvar l:uint = buttonNormal.cameras.length;\n\t\t\t\tvar offAll:Boolean = true;\n\t\t\t\t\n\t\t\t\twhile(i < l)\n\t\t\t\t{\n\t\t\t\t\tc = buttonNormal.cameras[i++] as FlxCamera;\n\t\t\t\t\t\n\t\t\t\t\tif (FlxMath.mouseInFlxRect(false, buttonNormal.rect))\n\t\t\t\t\t{\n\t\t\t\t\t\toffAll = false;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (FlxG.mouse.justPressed())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_status = PRESSED;\n\t\t\t\t\t\t}\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\t_status = HIGHLIGHT;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\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\t_status = NORMAL;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (_status != prevStatus)\n\t\t\t{\n\t\t\t\tif (_status == NORMAL)\n\t\t\t\t{\n\t\t\t\t\tbuttonNormal.visible = true;\n\t\t\t\t\tbuttonHighlight.visible = false;\n\t\t\t\t\t\n\t\t\t\t\tif (textNormal)\n\t\t\t\t\t{\n\t\t\t\t\t\ttextNormal.visible = true;\n\t\t\t\t\t\ttextHighlight.visible = false;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (leaveCallback is Function)\n\t\t\t\t\t{\n\t\t\t\t\t\tleaveCallback.apply(null, leaveCallbackParams);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (_status == HIGHLIGHT)\n\t\t\t\t{\n\t\t\t\t\tbuttonNormal.visible = false;\n\t\t\t\t\tbuttonHighlight.visible = true;\n\t\t\t\t\t\n\t\t\t\t\tif (textNormal)\n\t\t\t\t\t{\n\t\t\t\t\t\ttextNormal.visible = false;\n\t\t\t\t\t\ttextHighlight.visible = true;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (enterCallback is Function)\n\t\t\t\t\t{\n\t\t\t\t\t\tenterCallback.apply(null, enterCallbackParams);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\toverride public function draw():void\n\t\t{\n\t\t\tsuper.draw();\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{\n\t\t\t\tFlxG.stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);\n\t\t\t}\n\t\t\t\n\t\t\tif (buttonNormal != null)\n\t\t\t{\n\t\t\t\tbuttonNormal.destroy();\n\t\t\t\tbuttonNormal = null;\n\t\t\t}\n\t\t\t\n\t\t\tif (buttonHighlight != null)\n\t\t\t{\n\t\t\t\tbuttonHighlight.destroy();\n\t\t\t\tbuttonHighlight = null;\n\t\t\t}\n\t\t\t\n\t\t\tif (textNormal != null)\n\t\t\t{\n\t\t\t\ttextNormal.destroy();\n\t\t\t\ttextNormal = null;\n\t\t\t}\n\t\t\t\n\t\t\tif (textHighlight != null)\n\t\t\t{\n\t\t\t\ttextHighlight.destroy();\n\t\t\t\ttextHighlight = null;\n\t\t\t}\n\t\t\t\n\t\t\t_onClick = null;\n\t\t\tenterCallback = null;\n\t\t\tleaveCallback = null;\n\t\t\t\n\t\t\tsuper.destroy();\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 onMouseUp(event:MouseEvent):void\n\t\t{\n\t\t\tif (exists && visible && active && (_status == PRESSED) && (_onClick != null) && (pauseProof || !FlxG.paused))\n\t\t\t{\n\t\t\t\t_onClick.apply(null, onClickParams);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * If you want to change the color of this button in its in-active (not hovered over) state, then pass a new array of color values\n\t\t * \n\t\t * @param\tcolors\n\t\t */\n\t\tpublic function updateInactiveButtonColors(colors:Array):void\n\t\t{\n\t\t\toffColor = colors;\n\t\t\t\n\t\t\tbuttonNormal.stamp(FlxGradient.createGradientFlxSprite(width - 2, height - 2, offColor), 1, 1);\n\t\t}\n\t\t\n\t\t/**\n\t\t * If you want to change the color of this button in its active (hovered over) state, then pass a new array of color values\n\t\t * \n\t\t * @param\tcolors\n\t\t */\n\t\tpublic function updateActiveButtonColors(colors:Array):void\n\t\t{\n\t\t\tonColor = colors;\n\t\t\t\n\t\t\tbuttonHighlight.stamp(FlxGradient.createGradientFlxSprite(width - 2, height - 2, onColor), 1, 1);\n\t\t}\n\t\t\n\t\t/**\n\t\t * If this button has text, set this to change the value\n\t\t */\n\t\tpublic function set text(value:String):void\n\t\t{\n\t\t\tif (textNormal && textNormal.text != value)\n\t\t\t{\n\t\t\t\ttextNormal.text = value;\n\t\t\t\ttextHighlight.text = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Center this button (on the X axis) Uses FlxG.width / 2 - button width / 2 to achieve this.<br />\n\t\t * Doesn't take into consideration scrolling\n\t\t */\n\t\tpublic function screenCenter():void\n\t\t{\n\t\t\tbuttonNormal.x = (FlxG.width / 2) - (width / 2);\n\t\t\tbuttonHighlight.x = (FlxG.width / 2) - (width / 2);\n\t\t\t\n\t\t\tif (textNormal)\n\t\t\t{\n\t\t\t\ttextNormal.x = buttonNormal.x;\n\t\t\t\ttextHighlight.x = buttonHighlight.x;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets a callback function for when this button is rolled-over with the mouse\n\t\t * \n\t\t * @param\tcallback\tThe function to call, will be called once when the mouse enters\n\t\t * @param\tparams\t\tAn optional array of parameters to pass to the function\n\t\t */\n\t\tpublic function setMouseOverCallback(callback:Function, params:Array = null):void\n\t\t{\n\t\t\tenterCallback = callback;\n\t\t\t\n\t\t\tenterCallbackParams = params;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets a callback function for when the mouse rolls-out of this button\n\t\t * \n\t\t * @param\tcallback\tThe function to call, will be called once when the mouse leaves the button\n\t\t * @param\tparams\t\tAn optional array of parameters to pass to the function\n\t\t */\n\t\tpublic function setMouseOutCallback(callback:Function, params:Array = null):void\n\t\t{\n\t\t\tleaveCallback = callback;\n\t\t\t\n\t\t\tleaveCallbackParams = params;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets a callback function for when the mouse clicks on this button\n\t\t * \n\t\t * @param\tcallback\tThe function to call whenever the button is clicked.\n\t\t * @param\tparams\t\tAn optional array of parameters that will be passed to the Callback function\n\t\t */\n\t\tpublic function setOnClickCallback(callback:Function, params:Array = null):void\n\t\t{\n\t\t\t_onClick = callback;\n\t\t\t\n\t\t\tif (params)\n\t\t\t{\n\t\t\t\tonClickParams = params;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}\n"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxCollision.as",
    "content": "/**\n * FlxCollision\n * -- Part of the Flixel Power Tools set\n * \n * v1.6 Fixed bug in pixelPerfectCheck that stopped non-square rotated objects from colliding properly (thanks to joon on the flixel forums for spotting)\n * v1.5 Added createCameraWall\n * v1.4 Added pixelPerfectPointCheck()\n * v1.3 Update fixes bug where it wouldn't accurately perform collision on AutoBuffered rotated sprites, or sprites with offsets\n * v1.2 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.6 - October 8th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.display.BitmapData;\n\timport flash.display.Sprite;\n\timport flash.geom.ColorTransform;\n\timport flash.geom.Matrix;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport flash.display.BlendMode;\n\t\n\timport org.flixel.*;\n\t\n\tpublic class FlxCollision \n\t{\n\t\tpublic static var debug:BitmapData = new BitmapData(1, 1, false);\n\t\t\n\t\tpublic static var CAMERA_WALL_OUTSIDE:uint = 0;\n\t\tpublic static var CAMERA_WALL_INSIDE:uint = 1;\n\t\t\n\t\tpublic function FlxCollision() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * A Pixel Perfect Collision check between two FlxSprites.\n\t\t * It will do a bounds check first, and if that passes it will run a pixel perfect match on the intersecting area.\n\t\t * Works with rotated, scaled and animated sprites.\n\t\t * \n\t\t * @param\tcontact\t\t\tThe first FlxSprite to test against\n\t\t * @param\ttarget\t\t\tThe second FlxSprite to test again, sprite order is irrelevant\n\t\t * @param\talphaTolerance\tThe tolerance value above which alpha pixels are included. Default to 255 (must be fully opaque for collision).\n\t\t * @param\tcamera\t\t\tIf the collision is taking place in a camera other than FlxG.camera (the default/current) then pass it here\n\t\t * \n\t\t * @return\tBoolean True if the sprites collide, false if not\n\t\t */\n\t\tpublic static function pixelPerfectCheck(contact:FlxSprite, target:FlxSprite, alphaTolerance:int = 255, camera:FlxCamera = null):Boolean\n\t\t{\n\t\t\tvar pointA:Point = new Point;\n\t\t\tvar pointB:Point = new Point;\n\t\t\t\n\t\t\tif (camera)\n\t\t\t{\n\t\t\t\tpointA.x = contact.x - int(camera.scroll.x * contact.scrollFactor.x) - contact.offset.x;\n\t\t\t\tpointA.y = contact.y - int(camera.scroll.y * contact.scrollFactor.y) - contact.offset.y;\n\t\t\t\t\n\t\t\t\tpointB.x = target.x - int(camera.scroll.x * target.scrollFactor.x) - target.offset.x;\n\t\t\t\tpointB.y = target.y - int(camera.scroll.y * target.scrollFactor.y) - target.offset.y;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpointA.x = contact.x - int(FlxG.camera.scroll.x * contact.scrollFactor.x) - contact.offset.x;\n\t\t\t\tpointA.y = contact.y - int(FlxG.camera.scroll.y * contact.scrollFactor.y) - contact.offset.y;\n\t\t\t\t\n\t\t\t\tpointB.x = target.x - int(FlxG.camera.scroll.x * target.scrollFactor.x) - target.offset.x;\n\t\t\t\tpointB.y = target.y - int(FlxG.camera.scroll.y * target.scrollFactor.y) - target.offset.y;\n\t\t\t}\n\t\t\t\n\t\t\tvar boundsA:Rectangle = new Rectangle(pointA.x, pointA.y, contact.framePixels.width, contact.framePixels.height);\n\t\t\tvar boundsB:Rectangle = new Rectangle(pointB.x, pointB.y, target.framePixels.width, target.framePixels.height);\n\t\t\t\n\t\t\tvar intersect:Rectangle = boundsA.intersection(boundsB);\n\t\t\t\n\t\t\tif (intersect.isEmpty() || intersect.width == 0 || intersect.height == 0)\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\t//\tNormalise the values or it'll break the BitmapData creation below\n\t\t\tintersect.x = Math.floor(intersect.x);\n\t\t\tintersect.y = Math.floor(intersect.y);\n\t\t\tintersect.width = Math.ceil(intersect.width);\n\t\t\tintersect.height = Math.ceil(intersect.height);\n\t\t\t\n\t\t\tif (intersect.isEmpty())\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\t//\tThanks to Chris Underwood for helping with the translate logic :)\n\t\t\t\n\t\t\tvar matrixA:Matrix = new Matrix;\n\t\t\tmatrixA.translate(-(intersect.x - boundsA.x), -(intersect.y - boundsA.y));\n\t\t\t\n\t\t\tvar matrixB:Matrix = new Matrix;\n\t\t\tmatrixB.translate(-(intersect.x - boundsB.x), -(intersect.y - boundsB.y));\n\t\t\t\n\t\t\tvar testA:BitmapData = contact.framePixels;\n\t\t\tvar testB:BitmapData = target.framePixels;\n\t\t\tvar overlapArea:BitmapData = new BitmapData(intersect.width, intersect.height, false);\n\t\t\t\n\t\t\toverlapArea.draw(testA, matrixA, new ColorTransform(1, 1, 1, 1, 255, -255, -255, alphaTolerance), BlendMode.NORMAL);\n\t\t\toverlapArea.draw(testB, matrixB, new ColorTransform(1, 1, 1, 1, 255, 255, 255, alphaTolerance), BlendMode.DIFFERENCE);\n\t\t\t\n\t\t\t//\tDevelopers: If you'd like to see how this works, display it in your game somewhere. Or you can comment it out to save a tiny bit of performance\n\t\t\tdebug = overlapArea;\n\t\t\t\n\t\t\tvar overlap:Rectangle = overlapArea.getColorBoundsRect(0xffffffff, 0xff00ffff);\n\t\t\toverlap.offset(intersect.x, intersect.y);\n\t\t\t\n\t\t\tif (overlap.isEmpty())\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * A Pixel Perfect Collision check between a given x/y coordinate and an FlxSprite<br>\n\t\t * \n\t\t * @param\tpointX\t\t\tThe x coordinate of the point given in local space (relative to the FlxSprite, not game world coordinates)\n\t\t * @param\tpointY\t\t\tThe y coordinate of the point given in local space (relative to the FlxSprite, not game world coordinates)\n\t\t * @param\ttarget\t\t\tThe FlxSprite to check the point against\n\t\t * @param\talphaTolerance\tThe alpha tolerance level above which pixels are counted as colliding. Default to 255 (must be fully transparent for collision)\n\t\t * \n\t\t * @return\tBoolean True if the x/y point collides with the FlxSprite, false if not\n\t\t */\n\t\tpublic static function pixelPerfectPointCheck(pointX:uint, pointY:uint, target:FlxSprite, alphaTolerance:int = 255):Boolean\n\t\t{\n\t\t\t//\tIntersect check\n\t\t\tif (FlxMath.pointInCoordinates(pointX, pointY, target.x, target.y, target.framePixels.width, target.framePixels.height) == false)\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\t//\tHow deep is pointX/Y within the rect?\n\t\t\tvar test:BitmapData = target.framePixels;\n\t\t\t\n\t\t\tif (FlxColor.getAlpha(test.getPixel32(pointX - target.x, pointY - target.y)) >= alphaTolerance)\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a \"wall\" around the given camera which can be used for FlxSprite collision\n\t\t * \n\t\t * @param\tcamera\t\t\t\tThe FlxCamera to use for the wall bounds (can be FlxG.camera for the current one)\n\t\t * @param\tplacement\t\t\tCAMERA_WALL_OUTSIDE or CAMERA_WALL_INSIDE\n\t\t * @param\tthickness\t\t\tThe thickness of the wall in pixels\n\t\t * @param\tadjustWorldBounds\tAdjust the FlxG.worldBounds based on the wall (true) or leave alone (false)\n\t\t * \n\t\t * @return\tFlxGroup The 4 FlxTileblocks that are created are placed into this FlxGroup which should be added to your State\n\t\t */\n\t\tpublic static function createCameraWall(camera:FlxCamera, placement:uint, thickness:uint, adjustWorldBounds:Boolean = false):FlxGroup\n\t\t{\n\t\t\tvar left:FlxTileblock;\n\t\t\tvar right:FlxTileblock;\n\t\t\tvar top:FlxTileblock;\n\t\t\tvar bottom:FlxTileblock;\n\t\t\t\n\t\t\tswitch (placement)\n\t\t\t{\n\t\t\t\tcase CAMERA_WALL_OUTSIDE:\n\t\t\t\t\tleft = new FlxTileblock(camera.x - thickness, camera.y + thickness, thickness, camera.height - (thickness * 2));\n\t\t\t\t\tright = new FlxTileblock(camera.x + camera.width, camera.y + thickness, thickness, camera.height - (thickness * 2));\n\t\t\t\t\ttop = new FlxTileblock(camera.x - thickness, camera.y - thickness, camera.width + thickness * 2, thickness);\n\t\t\t\t\tbottom = new FlxTileblock(camera.x - thickness, camera.height, camera.width + thickness * 2, thickness);\n\t\t\t\t\t\n\t\t\t\t\tif (adjustWorldBounds)\n\t\t\t\t\t{\n\t\t\t\t\t\tFlxG.worldBounds = new FlxRect(camera.x - thickness, camera.y - thickness, camera.width + thickness * 2, camera.height + thickness * 2);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase CAMERA_WALL_INSIDE:\n\t\t\t\t\tleft = new FlxTileblock(camera.x, camera.y + thickness, thickness, camera.height - (thickness * 2));\n\t\t\t\t\tright = new FlxTileblock(camera.x + camera.width - thickness, camera.y + thickness, thickness, camera.height - (thickness * 2));\n\t\t\t\t\ttop = new FlxTileblock(camera.x, camera.y, camera.width, thickness);\n\t\t\t\t\tbottom = new FlxTileblock(camera.x, camera.height - thickness, camera.width, thickness);\n\t\t\t\t\t\n\t\t\t\t\tif (adjustWorldBounds)\n\t\t\t\t\t{\n\t\t\t\t\t\tFlxG.worldBounds = new FlxRect(camera.x, camera.y, camera.width, camera.height);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tvar result:FlxGroup = new FlxGroup(4);\n\t\t\t\n\t\t\tresult.add(left);\n\t\t\tresult.add(right);\n\t\t\tresult.add(top);\n\t\t\tresult.add(bottom);\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxColor.as",
    "content": "﻿/**\n * FlxColor\n * -- Part of the Flixel Power Tools set\n * \n * v1.5 Added RGBtoWebString\n * v1.4 getHSVColorWheel now supports an alpha value per color\n * v1.3 Added getAlphaFloat\n * v1.2 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.5 - August 4th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n * @see Depends upon FlxMath\n*/\n\npackage org.flixel.plugin.photonstorm\n{\n\timport org.flixel.*;\n\t\n\t/**\n\t * <code>FlxColor</code> is a set of fast color manipulation and color harmony methods.<br />\n\t * Can be used for creating gradient maps or general color translation / conversion.\n\t */\n\tpublic class FlxColor\n\t{\n\t\tpublic function FlxColor()\n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Get HSV color wheel values in an array which will be 360 elements in size\n\t\t * \n\t\t * @param\talpha\tAlpha value for each color of the color wheel, between 0 (transparent) and 255 (opaque)\n\t\t * \n\t\t * @return\tArray\n\t\t */\n\t\tpublic static function getHSVColorWheel(alpha:uint = 255):Array\n\t\t{\n\t\t\tvar colors:Array = new Array();\n\t\t\t\n\t\t\tfor (var c:int = 0; c <= 359; c++)\n\t\t\t{\n\t\t\t\tcolors[c] = HSVtoRGB(c, 1.0, 1.0, alpha);\n\t\t\t}\n\t\t\t\n\t\t\treturn colors;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns a Complementary Color Harmony for the given color.\n\t\t * <p>A complementary hue is one directly opposite the color given on the color wheel</p>\n\t\t * <p>Value returned in 0xAARRGGBB format with Alpha set to 255.</p>\n\t\t * \n\t\t * @param\tcolor The color to base the harmony on\n\t\t * \n\t\t * @return 0xAARRGGBB format color value\n\t\t */\n\t\tpublic static function getComplementHarmony(color:uint):uint\n\t\t{\n\t\t\tvar hsv:Object = RGBtoHSV(color);\n\t\t\t\n\t\t\tvar opposite:int = FlxMath.wrapValue(hsv.hue, 180, 359);\n\t\t\t\n\t\t\treturn HSVtoRGB(opposite, 1.0, 1.0);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns an Analogous Color Harmony for the given color.\n\t\t * <p>An Analogous harmony are hues adjacent to each other on the color wheel</p>\n\t\t * <p>Values returned in 0xAARRGGBB format with Alpha set to 255.</p>\n\t\t * \n\t\t * @param\tcolor The color to base the harmony on\n\t\t * @param\tthreshold Control how adjacent the colors will be (default +- 30 degrees)\n\t\t * \n\t\t * @return \tObject containing 3 properties: color1 (the original color), color2 (the warmer analogous color) and color3 (the colder analogous color)\n\t\t */\n\t\tpublic static function getAnalogousHarmony(color:uint, threshold:int = 30):Object\n\t\t{\n\t\t\tvar hsv:Object = RGBtoHSV(color);\n\t\t\t\n\t\t\tif (threshold > 359 || threshold < 0)\n\t\t\t{\n\t\t\t\tthrow Error(\"FlxColor Warning: Invalid threshold given to getAnalogousHarmony()\");\n\t\t\t}\n\t\t\t\n\t\t\tvar warmer:int = FlxMath.wrapValue(hsv.hue, 359 - threshold, 359);\n\t\t\tvar colder:int = FlxMath.wrapValue(hsv.hue, threshold, 359);\n\t\t\t\n\t\t\treturn { color1: color, color2: HSVtoRGB(warmer, 1.0, 1.0), color3: HSVtoRGB(colder, 1.0, 1.0), hue1: hsv.hue, hue2: warmer, hue3: colder }\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns an Split Complement Color Harmony for the given color.\n\t\t * <p>A Split Complement harmony are the two hues on either side of the color's Complement</p>\n\t\t * <p>Values returned in 0xAARRGGBB format with Alpha set to 255.</p>\n\t\t * \n\t\t * @param\tcolor The color to base the harmony on\n\t\t * @param\tthreshold Control how adjacent the colors will be to the Complement (default +- 30 degrees)\n\t\t * \n\t\t * @return \tObject containing 3 properties: color1 (the original color), color2 (the warmer analogous color) and color3 (the colder analogous color)\n\t\t */\n\t\tpublic static function getSplitComplementHarmony(color:uint, threshold:int = 30):Object\n\t\t{\n\t\t\tvar hsv:Object = RGBtoHSV(color);\n\t\t\t\n\t\t\tif (threshold >= 359 || threshold <= 0)\n\t\t\t{\n\t\t\t\tthrow Error(\"FlxColor Warning: Invalid threshold given to getSplitComplementHarmony()\");\n\t\t\t}\n\t\t\t\n\t\t\tvar opposite:int = FlxMath.wrapValue(hsv.hue, 180, 359);\n\t\t\t\n\t\t\tvar warmer:int = FlxMath.wrapValue(hsv.hue, opposite - threshold, 359);\n\t\t\tvar colder:int = FlxMath.wrapValue(hsv.hue, opposite + threshold, 359);\n\t\t\t\n\t\t\tFlxG.log(\"hue: \" + hsv.hue + \" opposite: \" + opposite + \" warmer: \" + warmer + \" colder: \" + colder);\n\t\t\t\n\t\t\t//return { color1: color, color2: HSVtoRGB(warmer, 1.0, 1.0), color3: HSVtoRGB(colder, 1.0, 1.0), hue1: hsv.hue, hue2: warmer, hue3: colder }\n\t\t\t\n\t\t\treturn { color1: color, color2: HSVtoRGB(warmer, hsv.saturation, hsv.value), color3: HSVtoRGB(colder, hsv.saturation, hsv.value), hue1: hsv.hue, hue2: warmer, hue3: colder }\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns a Triadic Color Harmony for the given color.\n\t\t * <p>A Triadic harmony are 3 hues equidistant from each other on the color wheel</p>\n\t\t * <p>Values returned in 0xAARRGGBB format with Alpha set to 255.</p>\n\t\t * \n\t\t * @param\tcolor The color to base the harmony on\n\t\t * \n\t\t * @return \tObject containing 3 properties: color1 (the original color), color2 and color3 (the equidistant colors)\n\t\t */\n\t\tpublic static function getTriadicHarmony(color:uint):Object\n\t\t{\n\t\t\tvar hsv:Object = RGBtoHSV(color);\n\t\t\t\n\t\t\tvar triadic1:int = FlxMath.wrapValue(hsv.hue, 120, 359);\n\t\t\tvar triadic2:int = FlxMath.wrapValue(triadic1, 120, 359);\n\t\t\t\n\t\t\treturn { color1: color, color2: HSVtoRGB(triadic1, 1.0, 1.0), color3: HSVtoRGB(triadic2, 1.0, 1.0) }\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns a String containing handy information about the given color including String hex value,\n\t\t * RGB format information and HSL information. Each section starts on a newline, 3 lines in total.\n\t\t * \n\t\t * @param\tcolor A color value in the format 0xAARRGGBB\n\t\t * \n\t\t * @return\tString containing the 3 lines of information\n\t\t */\n\t\tpublic static function getColorInfo(color:uint):String\n\t\t{\n\t\t\tvar argb:Object = getRGB(color);\n\t\t\tvar hsl:Object = RGBtoHSV(color);\n\t\t\t\n\t\t\t//\tHex format\n\t\t\tvar result:String = RGBtoHexString(color) + \"\\n\";\n\t\t\t\n\t\t\t//\tRGB format\n\t\t\tresult = result.concat(\"Alpha: \" + argb.alpha + \" Red: \" + argb.red + \" Green: \" + argb.green + \" Blue: \" + argb.blue) + \"\\n\";\n\t\t\t\n\t\t\t//\tHSL info\n\t\t\tresult = result.concat(\"Hue: \" + hsl.hue + \" Saturation: \" + hsl.saturation + \" Lightnes: \" + hsl.lightness);\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Return a String representation of the color in the format 0xAARRGGBB\n\t\t * \n\t\t * @param\tcolor The color to get the String representation for\n\t\t * \n\t\t * @return\tA string of length 10 characters in the format 0xAARRGGBB\n\t\t */\n\t\tpublic static function RGBtoHexString(color:uint):String\n\t\t{\n\t\t\tvar argb:Object = getRGB(color);\n\t\t\t\n\t\t\treturn \"0x\" + colorToHexString(argb.alpha) + colorToHexString(argb.red) + colorToHexString(argb.green) + colorToHexString(argb.blue);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Return a String representation of the color in the format #RRGGBB\n\t\t * \n\t\t * @param\tcolor The color to get the String representation for\n\t\t * \n\t\t * @return\tA string of length 10 characters in the format 0xAARRGGBB\n\t\t */\n\t\tpublic static function RGBtoWebString(color:uint):String\n\t\t{\n\t\t\tvar argb:Object = getRGB(color);\n\t\t\t\n\t\t\treturn \"#\" + colorToHexString(argb.red) + colorToHexString(argb.green) + colorToHexString(argb.blue);\n\t\t}\n\n\t\t/**\n\t\t * Return a String containing a hex representation of the given color\n\t\t * \n\t\t * @param\tcolor The color channel to get the hex value for, must be a value between 0 and 255)\n\t\t * \n\t\t * @return\tA string of length 2 characters, i.e. 255 = FF, 0 = 00\n\t\t */\n\t\tpublic static function colorToHexString(color:uint):String\n\t\t{\n\t\t\tvar digits:String = \"0123456789ABCDEF\";\n\t\t\t\n\t\t\tvar lsd:Number = color % 16;\n\t\t\tvar msd:Number = (color - lsd) / 16;\n\t\t\t\n\t\t\tvar hexified:String = digits.charAt(msd) + digits.charAt(lsd);\n\t\t\t\n\t\t\treturn hexified;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Convert a HSV (hue, saturation, lightness) color space value to an RGB color\n\t\t * \n\t\t * @param\th \t\tHue degree, between 0 and 359\n\t\t * @param\ts \t\tSaturation, between 0.0 (grey) and 1.0\n\t\t * @param\tv \t\tValue, between 0.0 (black) and 1.0\n\t\t * @param\talpha\tAlpha value to set per color (between 0 and 255)\n\t\t * \n\t\t * @return 32-bit ARGB color value (0xAARRGGBB)\n\t\t */\n\t\tpublic static function HSVtoRGB(h:Number, s:Number, v:Number, alpha:uint = 255):uint\n\t\t{\n\t\t\tvar result:uint;\n\t\t\t\n\t\t\tif (s == 0.0)\n\t\t\t{\n\t\t\t\tresult = getColor32(alpha, v * 255, v * 255, v * 255);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\th = h / 60.0;\n\t\t\t\tvar f:Number = h - int(h);\n\t\t\t\tvar p:Number = v * (1.0 - s);\n\t\t\t\tvar q:Number = v * (1.0 - s * f);\n\t\t\t\tvar t:Number = v * (1.0 - s * (1.0 - f));\n\t\t\t\t\n\t\t\t\tswitch (int(h))\n\t\t\t\t{\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tresult = getColor32(alpha, v * 255, t * 255, p * 255);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tresult = getColor32(alpha, q * 255, v * 255, p * 255);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tresult = getColor32(alpha, p * 255, v * 255, t * 255);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\tresult = getColor32(alpha, p * 255, q * 255, v * 255);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase 4:\n\t\t\t\t\t\tresult = getColor32(alpha, t * 255, p * 255, v * 255);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tcase 5:\n\t\t\t\t\t\tresult = getColor32(alpha, v * 255, p * 255, q * 255);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tFlxG.log(\"FlxColor Error: HSVtoRGB : Unknown color\");\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Convert an RGB color value to an object containing the HSV color space values: Hue, Saturation and Lightness\n\t\t * \n\t\t * @param\tcolor In format 0xRRGGBB\n\t\t * \n\t\t * @return \tObject with the properties hue (from 0 to 360), saturation (from 0 to 1.0) and lightness (from 0 to 1.0, also available under .value)\n\t\t */\n\t\tpublic static function RGBtoHSV(color:uint):Object\n\t\t{\n\t\t\tvar rgb:Object = getRGB(color);\n\t\t\t\n\t\t\tvar red:Number = rgb.red / 255;\n\t\t\tvar green:Number = rgb.green / 255;\n\t\t\tvar blue:Number = rgb.blue / 255;\n\t\t\t\n\t\t\tvar 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\t\t\tvar hue:Number;\n\t\t\tvar saturation:Number;\n\t\t\t\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\t\t\t//\tKeep the value with 0 to 359\n\t\t\thue *= 360;\n\t\t\thue = Math.round(hue);\n\t\t\t\n\t\t\t//\tTesting\n\t\t\t//saturation *= 100;\n\t\t\t//lightness *= 100;\n\t\t\t\n            return { hue: hue, saturation: saturation, lightness: lightness, value: lightness };\n\t\t}\n\t\t\n        \n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tpublic static function interpolateColor(color1:uint, color2:uint, steps:uint, currentStep:uint, alpha:uint = 255):uint\n        {\n\t\t\tvar src1:Object = getRGB(color1);\n\t\t\tvar src2:Object = getRGB(color2);\n\t\t\t\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\t\t\treturn getColor32(alpha, r, g, b);\n        }\n\t\t\n        public static function interpolateColorWithRGB(color:uint, r2:uint, g2:uint, b2:uint, steps:uint, currentStep:uint):uint\n        {\n\t\t\tvar src:Object = getRGB(color);\n\t\t\t\n            var r:uint = (((r2 - src.red) * currentStep) / steps) + src.red;\n            var g:uint = (((g2 - src.green) * currentStep) / steps) + src.green;\n            var b:uint = (((b2 - src.blue) * currentStep) / steps) + src.blue;\n        \n\t\t\treturn getColor24(r, g, b);\n        }\n\t\t\n        public static function interpolateRGB(r1:uint, g1:uint, b1:uint, r2:uint, g2:uint, b2:uint, steps:uint, currentStep:uint):uint\n        {\n            var r:uint = (((r2 - r1) * currentStep) / steps) + r1;\n            var g:uint = (((g2 - g1) * currentStep) / steps) + g1;\n            var b:uint = (((b2 - b1) * currentStep) / steps) + b1;\n        \n\t\t\treturn getColor24(r, g, b);\n        }\n\t\t\n\t\t/**\n\t\t * Returns a random color value between black and white\n\t\t * <p>Set the min value to start each channel from the given offset.</p>\n\t\t * <p>Set the max value to restrict the maximum color used per channel</p>\n\t\t * \n\t\t * @param\tmin\t\tThe lowest value to use for the color\n\t\t * @param\tmax \tThe highest value to use for the color\n\t\t * @param\talpha\tThe alpha value of the returning color (default 255 = fully opaque)\n\t\t * \n\t\t * @return 32-bit color value with alpha\n\t\t */\n\t\tpublic static function getRandomColor(min:uint = 0, max:uint = 255, alpha:uint = 255):uint\n\t\t{\n\t\t\t//\tSanity checks\n\t\t\tif (max > 255)\n\t\t\t{\n\t\t\t\tFlxG.log(\"FlxColor Warning: getRandomColor - max value too high\");\n\t\t\t\treturn getColor24(255, 255, 255);\n\t\t\t}\n\t\t\t\n\t\t\tif (min > max)\n\t\t\t{\n\t\t\t\tFlxG.log(\"FlxColor Warning: getRandomColor - min value higher than max\");\n\t\t\t\treturn getColor24(255, 255, 255);\n\t\t\t}\n\t\t\t\n\t\t\tvar red:uint = min + int(Math.random() * (max - min));\n\t\t\tvar green:uint = min + int(Math.random() * (max - min));\n\t\t\tvar blue:uint = min + int(Math.random() * (max - min));\n\t\t\t\n\t\t\treturn getColor32(alpha, red, green, blue);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Given an alpha and 3 color values this will return an integer representation of it\n\t\t * \n\t\t * @param\talpha\tThe Alpha value (between 0 and 255)\n\t\t * @param\tred\t\tThe Red channel value (between 0 and 255)\n\t\t * @param\tgreen\tThe Green channel value (between 0 and 255)\n\t\t * @param\tblue\tThe Blue channel value (between 0 and 255)\n\t\t * \n\t\t * @return\tA native color value integer (format: 0xAARRGGBB)\n\t\t */\n\t\tpublic static function getColor32(alpha:uint, red:uint, green:uint, blue:uint):uint\n\t\t{\n\t\t\treturn alpha << 24 | red << 16 | green << 8 | blue;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Given 3 color values this will return an integer representation of it\n\t\t * \n\t\t * @param\tred\t\tThe Red channel value (between 0 and 255)\n\t\t * @param\tgreen\tThe Green channel value (between 0 and 255)\n\t\t * @param\tblue\tThe Blue channel value (between 0 and 255)\n\t\t * \n\t\t * @return\tA native color value integer (format: 0xRRGGBB)\n\t\t */\n\t\tpublic static function getColor24(red:uint, green:uint, blue:uint):uint\n\t\t{\n\t\t\treturn red << 16 | green << 8 | blue;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Return the component parts of a color as an Object with the properties alpha, red, green, blue\n\t\t * \n\t\t * <p>Alpha will only be set if it exist in the given color (0xAARRGGBB)</p>\n\t\t * \n\t\t * @param\tcolor in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB)\n\t\t * \n\t\t * @return Object with properties: alpha, red, green, blue\n\t\t */\n\t\tpublic static function getRGB(color:uint):Object\n\t\t{\n\t\t\tvar alpha:uint = color >>> 24;\n\t\t\tvar red:uint = color >> 16 & 0xFF;\n\t\t\tvar green:uint = color >> 8 & 0xFF;\n\t\t\tvar blue:uint = color & 0xFF;\n\t\t\t\n\t\t\treturn { alpha: alpha, red: red, green: green, blue: blue };\n\t\t}\n\t\t\n\t\t/**\n\t\t * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255\n\t\t * \n\t\t * @param\tcolor\tIn the format 0xAARRGGBB\n\t\t * \n\t\t * @return\tThe Alpha component of the color, will be between 0 and 255 (0 being no Alpha, 255 full Alpha)\n\t\t */\n\t\tpublic static function getAlpha(color:uint):uint\n\t\t{\n\t\t\treturn color >>> 24;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1\n\t\t * \n\t\t * @param\tcolor\tIn the format 0xAARRGGBB\n\t\t * \n\t\t * @return\tThe Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent))\n\t\t */\n\t\tpublic static function getAlphaFloat(color:uint):Number\n\t\t{\n\t\t\tvar f:uint = color >>> 24;\n\t\t\t\n\t\t\treturn f / 255;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255\n\t\t * \n\t\t * @param\tcolor\tIn the format 0xAARRGGBB\n\t\t * \n\t\t * @return\tThe Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red)\n\t\t */\n\t\tpublic static function getRed(color:uint):uint\n\t\t{\n\t\t\treturn color >> 16 & 0xFF;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255\n\t\t * \n\t\t * @param\tcolor\tIn the format 0xAARRGGBB\n\t\t * \n\t\t * @return\tThe Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green)\n\t\t */\n\t\tpublic static function getGreen(color:uint):uint\n\t\t{\n\t\t\treturn color >> 8 & 0xFF;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255\n\t\t * \n\t\t * @param\tcolor\tIn the format 0xAARRGGBB\n\t\t * \n\t\t * @return\tThe Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue)\n\t\t */\n\t\tpublic static function getBlue(color:uint):uint\n\t\t{\n\t\t\treturn color & 0xFF;\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxControl.as",
    "content": "/**\n * FlxControl\n * -- Part of the Flixel Power Tools set\n * \n * v1.1 Fixed and added documentation\n * v1.0 First release\n * \n * @version 1.1 - July 21st 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.utils.Dictionary;\n\timport org.flixel.*;\n\n\tpublic class FlxControl extends FlxBasic\n\t{\n\t\t//\tQuick references\n\t\tpublic static var player1:FlxControlHandler;\n\t\tpublic static var player2:FlxControlHandler;\n\t\tpublic static var player3:FlxControlHandler;\n\t\tpublic static var player4:FlxControlHandler;\n\t\t\n\t\t//\tAdditional control handlers\n\t\tprivate static var members:Dictionary = new Dictionary(true);\n\t\t\n\t\tpublic function FlxControl() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new FlxControlHandler. You can have as many FlxControlHandlers as you like, but you usually only have one per player. The first handler you make\n\t\t * will be assigned to the FlxControl.player1 var. The 2nd to FlxControl.player2 and so on for player3 and player4. Beyond this you need to keep a reference to the\n\t\t * handler yourself.\n\t\t * \n\t\t * @param\tsource\t\t\tThe FlxSprite you want this class to control. It can only control one FlxSprite at once.\n\t\t * @param\tmovementType\tSet to either MOVEMENT_INSTANT or MOVEMENT_ACCELERATES\n\t\t * @param\tstoppingType\tSet to STOPPING_INSTANT, STOPPING_DECELERATES or STOPPING_NEVER\n\t\t * @param\tupdateFacing\tIf true it sets the FlxSprite.facing value to the direction pressed (default false)\n\t\t * @param\tenableArrowKeys\tIf true it will enable all arrow keys (default) - see setCursorControl for more fine-grained control\n\t\t * \n\t\t * @return\tThe new FlxControlHandler\n\t\t */\n\t\tpublic static function create(source:FlxSprite, movementType:int, stoppingType:int, player:int = 1, updateFacing:Boolean = false, enableArrowKeys:Boolean = true):FlxControlHandler\n\t\t{\n\t\t\tvar result:FlxControlHandler;\n\t\t\t\n\t\t\tif (player == 1)\n\t\t\t{\n\t\t\t\tplayer1 = new FlxControlHandler(source, movementType, stoppingType, updateFacing, enableArrowKeys);\n\t\t\t\tmembers[player1] = player1;\n\t\t\t\tresult = player1;\n\t\t\t}\n\t\t\telse if (player == 2)\n\t\t\t{\n\t\t\t\tplayer2 = new FlxControlHandler(source, movementType, stoppingType, updateFacing, enableArrowKeys);\n\t\t\t\tmembers[player2] = player2;\n\t\t\t\tresult = player2;\n\t\t\t}\n\t\t\telse if (player == 3)\n\t\t\t{\n\t\t\t\tplayer3 = new FlxControlHandler(source, movementType, stoppingType, updateFacing, enableArrowKeys);\n\t\t\t\tmembers[player3] = player3;\n\t\t\t\tresult = player3;\n\t\t\t}\n\t\t\telse if (player == 4)\n\t\t\t{\n\t\t\t\tplayer4 = new FlxControlHandler(source, movementType, stoppingType, updateFacing, enableArrowKeys);\n\t\t\t\tmembers[player4] = player4;\n\t\t\t\tresult = player4;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvar newControlHandler:FlxControlHandler = new FlxControlHandler(source, movementType, stoppingType, updateFacing, enableArrowKeys);\n\t\t\t\tmembers[newControlHandler] = newControlHandler;\n\t\t\t\tresult = newControlHandler;\n\t\t\t}\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes an FlxControlHandler \n\t\t * \n\t\t * @param\tsource\tThe FlxControlHandler to delete\n\t\t * @return\tBoolean\ttrue if the FlxControlHandler was removed, otherwise false.\n\t\t */\n\t\tpublic static function remove(source:FlxControlHandler):Boolean\n\t\t{\n\t\t\tif (members[source])\n\t\t\t{\n\t\t\t\tdelete members[source];\n\t\t\t\t\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes all FlxControlHandlers.<br />\n\t\t * This is called automatically if this plugin is ever destroyed.\n\t\t */\n\t\tpublic static function clear():void\n\t\t{\n\t\t\tfor each (var handler:FlxControlHandler in members)\n\t\t\t{\n\t\t\t\tdelete members[handler];\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Starts updating the given FlxControlHandler, enabling keyboard actions for it. If no FlxControlHandler is given it starts updating all FlxControlHandlers currently added.<br />\n\t\t * Updating is enabled by default, but this can be used to re-start it if you have stopped it via stop().<br />\n\t\t * \n\t\t * @param\tsource\tThe FlxControlHandler to start updating on. If left as null it will start updating all handlers.\n\t\t */\n\t\tpublic static function start(source:FlxControlHandler = null):void\n\t\t{\n\t\t\tif (source)\n\t\t\t{\n\t\t\t\tmembers[source].enabled = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor each (var handler:FlxControlHandler in members)\n\t\t\t\t{\n\t\t\t\t\thandler.enabled = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops updating the given FlxControlHandler. If no FlxControlHandler is given it stops updating all FlxControlHandlers currently added.<br />\n\t\t * Updating is enabled by default, but this can be used to stop it, for example if you paused your game (see start() to restart it again).<br />\n\t\t * \n\t\t * @param\tsource\tThe FlxControlHandler to stop updating. If left as null it will stop updating all handlers.\n\t\t */\n\t\tpublic static function stop(source:FlxControlHandler = null):void\n\t\t{\n\t\t\tif (source)\n\t\t\t{\n\t\t\t\tmembers[source].enabled = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor each (var handler:FlxControlHandler in members)\n\t\t\t\t{\n\t\t\t\t\thandler.enabled = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Runs update on all currently active FlxControlHandlers\n\t\t */\n\t\toverride public function update():void\n\t\t{\n\t\t\tfor each (var handler:FlxControlHandler in members)\n\t\t\t{\n\t\t\t\tif (handler.enabled == true)\n\t\t\t\t{\n\t\t\t\t\thandler.update();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Runs when this plugin is destroyed\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tclear();\n\t\t}\n\t\t\n\t}\n\n}\n"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxControlHandler.as",
    "content": "/**\n * FlxControlHandler\n * -- Part of the Flixel Power Tools set\n * \n * v1.8 Added isPressedUp/Down/Left/Right handlers\n * v1.7 Modified update function so gravity is applied constantly\n * v1.6 Thrust and Reverse complete, final few rotation bugs solved. Sounds hooked in for fire, jump, walk and thrust\n * v1.5 Full support for rotation with min/max angle limits\n * v1.4 Fixed bug in runFire causing fireRate to be ignored\n * v1.3 Major refactoring and lots of new enhancements\n * v1.2 First real version deployed to dev\n * v1.1 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.8 - August 16th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.geom.Rectangle;\n\timport org.flixel.*;\n\timport flash.utils.getTimer;\n\t\n\t/**\n\t * Makes controlling an FlxSprite with the keyboard a LOT easier and quicker to set-up!<br>\n\t * Sometimes it's hard to know what values to set, especially if you want gravity, jumping, sliding, etc.<br>\n\t * This class helps sort that - and adds some cool extra functionality too :)\n\t * \n\t * TODO\n\t * ----\n\t * Allow to bind Fire Button to FlxWeapon\n\t * Allow to enable multiple key sets. So cursors and WASD together\n\t * Hot Keys\n\t * Binding of sound effects to keys (seperate from setSounds? as those are event based)\n\t * If moving diagonally compensate speed parameter (times x,y velocities by 0.707 or cos/sin(45))\n\t * Specify animation frames to play based on velocity\n\t * Variable gravity (based on height, the higher the stronger the effect)\n\t */\n\tpublic class FlxControlHandler\n\t{\n\t\t//\tUsed by the FlxControl plugin\n\t\tpublic var enabled:Boolean = false;\n\t\t\n\t\tprivate var entity:FlxSprite = null;\n\t\t\n\t\tprivate var bounds:Rectangle;\n\t\t\n\t\tprivate var up:Boolean;\n\t\tprivate var down:Boolean;\n\t\tprivate var left:Boolean;\n\t\tprivate var right:Boolean;\n\t\tprivate var fire:Boolean;\n\t\tprivate var altFire:Boolean;\n\t\tprivate var jump:Boolean;\n\t\tprivate var altJump:Boolean;\n\t\tprivate var xFacing:Boolean;\n\t\tprivate var yFacing:Boolean;\n\t\tprivate var rotateAntiClockwise:Boolean;\n\t\tprivate var rotateClockwise:Boolean;\n\t\t\n\t\tprivate var upMoveSpeed:int;\n\t\tprivate var downMoveSpeed:int;\n\t\tprivate var leftMoveSpeed:int;\n\t\tprivate var rightMoveSpeed:int;\n\t\tprivate var thrustSpeed:int;\n\t\tprivate var reverseSpeed:int;\n\t\t\n\t\t//\tRotation\n\t\tprivate var thrustEnabled:Boolean;\n\t\tprivate var reverseEnabled:Boolean;\n\t\tprivate var isRotating:Boolean;\n\t\tprivate var antiClockwiseRotationSpeed:Number;\n\t\tprivate var clockwiseRotationSpeed:Number;\n\t\tprivate var enforceAngleLimits:Boolean;\n\t\tprivate var minAngle:int;\n\t\tprivate var maxAngle:int;\n\t\tprivate var capAngularVelocity:Boolean;\n\t\t\n\t\tprivate var xSpeedAdjust:Number = 0;\n\t\tprivate var ySpeedAdjust:Number = 0;\n\t\t\n\t\tprivate var gravityX:int = 0;\n\t\tprivate var gravityY:int = 0;\n\t\t\n\t\tprivate var fireRate:int; \t\t\t// The ms delay between firing when the key is held down\n\t\tprivate var nextFireTime:int; \t\t// The internal time when they can next fire\n\t\tprivate var lastFiredTime:int; \t\t// The internal time of when when they last fired\n\t\tprivate var fireKeyMode:uint;\t\t// The fire key mode\n\t\tprivate var fireCallback:Function;\t// A function to call every time they fire\n\t\t\n\t\tprivate var jumpHeight:int; \t\t// The pixel height amount they jump (drag and gravity also both influence this)\n\t\tprivate var jumpRate:int; \t\t\t// The ms delay between jumping when the key is held down\n\t\tprivate var jumpKeyMode:uint;\t\t// The jump key mode\n\t\tprivate var nextJumpTime:int; \t\t// The internal time when they can next jump\n\t\tprivate var lastJumpTime:int; \t\t// The internal time of when when they last jumped\n\t\tprivate var jumpFromFallTime:int; \t// A short window of opportunity for them to jump having just fallen off the edge of a surface\n\t\tprivate var extraSurfaceTime:int; \t// Internal time of when they last collided with a valid jumpSurface\n\t\tprivate var jumpSurface:uint; \t\t// The surfaces from FlxObject they can jump from (i.e. FlxObject.FLOOR)\n\t\tprivate var jumpCallback:Function;\t// A function to call every time they jump\n\t\t\n\t\tprivate var movement:int;\n\t\tprivate var stopping:int;\n\t\tprivate var rotation:int;\n\t\tprivate var rotationStopping:int;\n\t\tprivate var capVelocity:Boolean;\n\t\t\n\t\tprivate var hotkeys:Array;\t\t\t// TODO\n\t\t\n\t\tprivate var upKey:String;\n\t\tprivate var downKey:String;\n\t\tprivate var leftKey:String;\n\t\tprivate var rightKey:String;\n\t\tprivate var fireKey:String;\n\t\tprivate var altFireKey:String;\t\t// TODO\n\t\tprivate var jumpKey:String;\n\t\tprivate var altJumpKey:String;\t\t// TODO\n\t\tprivate var antiClockwiseKey:String;\n\t\tprivate var clockwiseKey:String;\n\t\tprivate var thrustKey:String;\n\t\tprivate var reverseKey:String;\n\t\t\n\t\t//\tSounds\n\t\tprivate var jumpSound:FlxSound = null;\n\t\tprivate var fireSound:FlxSound = null;\n\t\tprivate var walkSound:FlxSound = null;\n\t\tprivate var thrustSound:FlxSound = null;\n\t\t\n\t\t//\tHelpers\n\t\tpublic var isPressedUp:Boolean = false;\n\t\tpublic var isPressedDown:Boolean = false;\n\t\tpublic var isPressedLeft:Boolean = false;\n\t\tpublic var isPressedRight:Boolean = false;\n\t\t\n\t\t/**\n\t\t * The \"Instant\" Movement Type means the sprite will move at maximum speed instantly, and will not \"accelerate\" (or speed-up) before reaching that speed.\n\t\t */\n\t\tpublic static const MOVEMENT_INSTANT:int = 0;\n\t\t/**\n\t\t * The \"Accelerates\" Movement Type means the sprite will accelerate until it reaches maximum speed.\n\t\t */\n\t\tpublic static const MOVEMENT_ACCELERATES:int = 1;\n\t\t/**\n\t\t * The \"Instant\" Stopping Type means the sprite will stop immediately when no direction keys are being pressed, there will be no deceleration.\n\t\t */\n\t\tpublic static const STOPPING_INSTANT:int = 0;\n\t\t/**\n\t\t * The \"Decelerates\" Stopping Type means the sprite will start decelerating when no direction keys are being pressed. Deceleration continues until the speed reaches zero.\n\t\t */\n\t\tpublic static const STOPPING_DECELERATES:int = 1;\n\t\t/**\n\t\t * The \"Never\" Stopping Type means the sprite will never decelerate, any speed built up will be carried on and never reduce.\n\t\t */\n\t\tpublic static const STOPPING_NEVER:int = 2;\n\t\t\n\t\t/**\n\t\t * The \"Instant\" Movement Type means the sprite will rotate at maximum speed instantly, and will not \"accelerate\" (or speed-up) before reaching that speed.\n\t\t */\n\t\tpublic static const ROTATION_INSTANT:int = 0;\n\t\t/**\n\t\t * The \"Accelerates\" Rotaton Type means the sprite will accelerate until it reaches maximum rotation speed.\n\t\t */\n\t\tpublic static const ROTATION_ACCELERATES:int = 1;\n\t\t/**\n\t\t * The \"Instant\" Stopping Type means the sprite will stop rotating immediately when no rotation keys are being pressed, there will be no deceleration.\n\t\t */\n\t\tpublic static const ROTATION_STOPPING_INSTANT:int = 0;\n\t\t/**\n\t\t * The \"Decelerates\" Stopping Type means the sprite will start decelerating when no rotation keys are being pressed. Deceleration continues until rotation speed reaches zero.\n\t\t */\n\t\tpublic static const ROTATION_STOPPING_DECELERATES:int = 1;\n\t\t/**\n\t\t * The \"Never\" Stopping Type means the sprite will never decelerate, any speed built up will be carried on and never reduce.\n\t\t */\n\t\tpublic static const ROTATION_STOPPING_NEVER:int = 2;\n\t\t\n\t\t/**\n\t\t * This keymode fires for as long as the key is held down\n\t\t */\n\t\tpublic static const KEYMODE_PRESSED:int = 0;\n\t\t\n\t\t/**\n\t\t * This keyboard fires when the key has just been pressed down, and not again until it is released and re-pressed\n\t\t */\n\t\tpublic static const KEYMODE_JUST_DOWN:int = 1;\n\t\t\n\t\t/**\n\t\t * This keyboard fires only when the key has been pressed and then released again\n\t\t */\n\t\tpublic static const KEYMODE_RELEASED:int = 2;\n\t\t\n\t\t/**\n\t\t * Sets the FlxSprite to be controlled by this class, and defines the initial movement and stopping types.<br>\n\t\t * After creating an instance of this class you should call setMovementSpeed, and one of the enableXControl functions if you need more than basic cursors.\n\t\t * \n\t\t * @param\tsource\t\t\tThe FlxSprite you want this class to control. It can only control one FlxSprite at once.\n\t\t * @param\tmovementType\tSet to either MOVEMENT_INSTANT or MOVEMENT_ACCELERATES\n\t\t * @param\tstoppingType\tSet to STOPPING_INSTANT, STOPPING_DECELERATES or STOPPING_NEVER\n\t\t * @param\tupdateFacing\tIf true it sets the FlxSprite.facing value to the direction pressed (default false)\n\t\t * @param\tenableArrowKeys\tIf true it will enable all arrow keys (default) - see setCursorControl for more fine-grained control\n\t\t * \n\t\t * @see\t\tsetMovementSpeed\n\t\t */\n\t\tpublic function FlxControlHandler(source:FlxSprite, movementType:int, stoppingType:int, updateFacing:Boolean = false, enableArrowKeys:Boolean = true)\n\t\t{\n\t\t\tentity = source;\n\t\t\t\n\t\t\tmovement = movementType;\n\t\t\tstopping = stoppingType;\n\t\t\t\n\t\t\txFacing = updateFacing;\n\t\t\tyFacing = updateFacing;\n\t\t\t\n\t\t\tup = false;\n\t\t\tdown = false;\n\t\t\tleft = false;\n\t\t\tright = false;\n\t\t\t\n\t\t\tthrustEnabled = false;\n\t\t\tisRotating = false;\n\t\t\tenforceAngleLimits = false;\n\t\t\trotation = ROTATION_INSTANT;\n\t\t\trotationStopping = ROTATION_STOPPING_INSTANT;\n\t\t\t\n\t\t\tif (enableArrowKeys)\n\t\t\t{\n\t\t\t\tsetCursorControl();\n\t\t\t}\n\t\t\t\n\t\t\tenabled = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the speed at which the sprite will move when a direction key is pressed.<br>\n\t\t * All values are given in pixels per second. So an xSpeed of 100 would move the sprite 100 pixels in 1 second (1000ms)<br>\n\t\t * Due to the nature of the internal Flash timer this amount is not 100% accurate and will vary above/below the desired distance by a few pixels.<br>\n\t\t * \n\t\t * If you need different speed values for left/right or up/down then use setAdvancedMovementSpeed\n\t\t * \n\t\t * @param\txSpeed\t\t\tThe speed in pixels per second in which the sprite will move/accelerate horizontally\n\t\t * @param\tySpeed\t\t\tThe speed in pixels per second in which the sprite will move/accelerate vertically\n\t\t * @param\txSpeedMax\t\tThe maximum speed in pixels per second in which the sprite can move horizontally\n\t\t * @param\tySpeedMax\t\tThe maximum speed in pixels per second in which the sprite can move vertically\n\t\t * @param\txDeceleration\tA deceleration speed in pixels per second to apply to the sprites horizontal movement (default 0)\n\t\t * @param\tyDeceleration\tA deceleration speed in pixels per second to apply to the sprites vertical movement (default 0)\n\t\t */\n\t\tpublic function setMovementSpeed(xSpeed:uint, ySpeed:uint, xSpeedMax:uint, ySpeedMax:uint, xDeceleration:uint = 0, yDeceleration:uint = 0):void\n\t\t{\n\t\t\tleftMoveSpeed = -xSpeed;\n\t\t\trightMoveSpeed = xSpeed;\n\t\t\tupMoveSpeed = -ySpeed;\n\t\t\tdownMoveSpeed = ySpeed;\n\t\t\t\n\t\t\tsetMaximumSpeed(xSpeedMax, ySpeedMax);\n\t\t\tsetDeceleration(xDeceleration, yDeceleration);\n\t\t}\n\t\t\n\t\t/**\n\t\t * If you know you need the same value for the acceleration, maximum speeds and (optionally) deceleration then this is a quick way to set them.\n\t\t * \n\t\t * @param\tspeed\t\t\tThe speed in pixels per second in which the sprite will move/accelerate/decelerate\n\t\t * @param\tacceleration\tIf true it will set the speed value as the deceleration value (default) false will leave deceleration disabled\n\t\t */\n\t\tpublic function setStandardSpeed(speed:uint, acceleration:Boolean = true):void\n\t\t{\n\t\t\tif (acceleration)\n\t\t\t{\n\t\t\t\tsetMovementSpeed(speed, speed, speed, speed, speed, speed);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsetMovementSpeed(speed, speed, speed, speed);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the speed at which the sprite will move when a direction key is pressed.<br>\n\t\t * All values are given in pixels per second. So an xSpeed of 100 would move the sprite 100 pixels in 1 second (1000ms)<br>\n\t\t * Due to the nature of the internal Flash timer this amount is not 100% accurate and will vary above/below the desired distance by a few pixels.<br>\n\t\t * \n\t\t * If you don't need different speed values for every direction on its own then use setMovementSpeed\n\t\t * \n\t\t * @param\tleftSpeed\t\tThe speed in pixels per second in which the sprite will move/accelerate to the left\n\t\t * @param\trightSpeed\t\tThe speed in pixels per second in which the sprite will move/accelerate to the right\n\t\t * @param\tupSpeed\t\t\tThe speed in pixels per second in which the sprite will move/accelerate up\n\t\t * @param\tdownSpeed\t\tThe speed in pixels per second in which the sprite will move/accelerate down\n\t\t * @param\txSpeedMax\t\tThe maximum speed in pixels per second in which the sprite can move horizontally\n\t\t * @param\tySpeedMax\t\tThe maximum speed in pixels per second in which the sprite can move vertically\n\t\t * @param\txDeceleration\tDeceleration speed in pixels per second to apply to the sprites horizontal movement (default 0)\n\t\t * @param\tyDeceleration\tDeceleration speed in pixels per second to apply to the sprites vertical movement (default 0)\n\t\t */\n\t\tpublic function setAdvancedMovementSpeed(leftSpeed:uint, rightSpeed:uint, upSpeed:uint, downSpeed:uint, xSpeedMax:uint, ySpeedMax:uint, xDeceleration:uint = 0, yDeceleration:uint = 0):void\n\t\t{\n\t\t\tleftMoveSpeed = -leftSpeed;\n\t\t\trightMoveSpeed = rightSpeed;\n\t\t\tupMoveSpeed = -upSpeed;\n\t\t\tdownMoveSpeed = downSpeed;\n\t\t\t\n\t\t\tsetMaximumSpeed(xSpeedMax, ySpeedMax);\n\t\t\tsetDeceleration(xDeceleration, yDeceleration);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the speed at which the sprite will rotate when a direction key is pressed.<br>\n\t\t * Use this in combination with setMovementSpeed to create a Thrust like movement system.<br>\n\t\t * All values are given in pixels per second. So an xSpeed of 100 would rotate the sprite 100 pixels in 1 second (1000ms)<br>\n\t\t * Due to the nature of the internal Flash timer this amount is not 100% accurate and will vary above/below the desired distance by a few pixels.<br>\n\t\t */\n\t\tpublic function setRotationSpeed(antiClockwiseSpeed:Number, clockwiseSpeed:Number, speedMax:Number, deceleration:Number):void\n\t\t{\n\t\t\tantiClockwiseRotationSpeed = -antiClockwiseSpeed;\n\t\t\tclockwiseRotationSpeed = clockwiseSpeed;\n\t\t\t\n\t\t\tsetRotationKeys();\n\t\t\tsetMaximumRotationSpeed(speedMax);\n\t\t\tsetRotationDeceleration(deceleration);\n\t\t}\n\t\t\n\t\t/**\n\t\t * \n\t\t * \n\t\t * @param\trotationType\n\t\t * @param\tstoppingType\n\t\t */\n\t\tpublic function setRotationType(rotationType:int, stoppingType:int):void\n\t\t{\n\t\t\trotation = rotationType;\n\t\t\trotationStopping = stoppingType;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the maximum speed (in pixels per second) that the FlxSprite can rotate.<br>\n\t\t * When the FlxSprite is accelerating (movement type MOVEMENT_ACCELERATES) its speed won't increase above this value.<br>\n\t\t * However Flixel allows the velocity of an FlxSprite to be set to anything. So if you'd like to check the value and restrain it, then enable \"limitVelocity\".\n\t\t * \n\t\t * @param\tspeed\t\t\tThe maximum speed in pixels per second in which the sprite can rotate\n\t\t * @param\tlimitVelocity\tIf true the angular velocity of the FlxSprite will be checked and kept within the limit. If false it can be set to anything.\n\t\t */\n\t\tpublic function setMaximumRotationSpeed(speed:Number, limitVelocity:Boolean = true):void\n\t\t{\n\t\t\tentity.maxAngular = speed;\n\t\t\t\n\t\t\tcapAngularVelocity = limitVelocity;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Deceleration is a speed (in pixels per second) that is applied to the sprite if stopping type is \"DECELERATES\" and if no rotation is taking place.<br>\n\t\t * The velocity of the sprite will be reduced until it reaches zero.\n\t\t * \n\t\t * @param\tspeed\t\tThe speed in pixels per second at which the sprite will have its angular rotation speed decreased\n\t\t */\n\t\tpublic function setRotationDeceleration(speed:Number):void\n\t\t{\n\t\t\tentity.angularDrag = speed;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set minimum and maximum angle limits that the Sprite won't be able to rotate beyond.<br>\n\t\t * Values must be between -180 and +180. 0 is pointing right, 90 down, 180 left, -90 up.\n\t\t * \n\t\t * @param\tminimumAngle\tMinimum angle below which the sprite cannot rotate (must be -180 or above)\n\t\t * @param\tmaximumAngle\tMaximum angle above which the sprite cannot rotate (must be 180 or below)\n\t\t */\n\t\tpublic function setRotationLimits(minimumAngle:int, maximumAngle:int):void\n\t\t{\n\t\t\tif (minimumAngle > maximumAngle || minimumAngle < -180 || maximumAngle > 180)\n\t\t\t{\n\t\t\t\tthrow new Error(\"FlxControlHandler setRotationLimits: Invalid Minimum / Maximum angle\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tenforceAngleLimits = true;\n\t\t\t\tminAngle = minimumAngle;\n\t\t\t\tmaxAngle = maximumAngle;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Disables rotation limits set in place by setRotationLimits()\n\t\t */\n\t\tpublic function disableRotationLimits():void\n\t\t{\n\t\t\tenforceAngleLimits = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set which keys will rotate the sprite. The speed of rotation is set in setRotationSpeed.\n\t\t * \n\t\t * @param\tleftRight\t\t\t\tUse the LEFT and RIGHT arrow keys for anti-clockwise and clockwise rotation respectively.\n\t\t * @param\tupDown\t\t\t\t\tUse the UP and DOWN arrow keys for anti-clockwise and clockwise rotation respectively.\n\t\t * @param\tcustomAntiClockwise\t\tThe String value of your own key to use for anti-clockwise rotation (as taken from org.flixel.system.input.Keyboard)\n\t\t * @param\tcustomClockwise\t\t\tThe String value of your own key to use for clockwise rotation (as taken from org.flixel.system.input.Keyboard)\n\t\t */\n\t\tpublic function setRotationKeys(leftRight:Boolean = true, upDown:Boolean = false, customAntiClockwise:String = \"\", customClockwise:String = \"\"):void\n\t\t{\n\t\t\tisRotating = true;\n\t\t\trotateAntiClockwise = true;\n\t\t\trotateClockwise = true;\n\t\t\tantiClockwiseKey = \"LEFT\";\n\t\t\tclockwiseKey = \"RIGHT\";\n\n\t\t\tif (upDown == true)\n\t\t\t{\n\t\t\t\tantiClockwiseKey = \"UP\";\n\t\t\t\tclockwiseKey = \"DOWN\";\n\t\t\t}\n\t\t\t\n\t\t\tif (customAntiClockwise != \"\" && customClockwise != \"\")\n\t\t\t{\n\t\t\t\tantiClockwiseKey = customAntiClockwise;\n\t\t\t\tclockwiseKey = customClockwise;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * If you want to enable a Thrust like motion for your sprite use this to set the speed and keys.<br>\n\t\t * This is usually used in conjunction with Rotation and it will over-ride anything already defined in setMovementSpeed.\n\t\t * \n\t\t * @param\tthrustKey\t\tSpecify the key String (as taken from org.flixel.system.input.Keyboard) to use for the Thrust action\n\t\t * @param\tthrustSpeed\t\tThe speed in pixels per second which the sprite will move. Acceleration or Instant movement is determined by the Movement Type.\n\t\t * @param\treverseKey\t\tIf you want to be able to reverse, set the key string as taken from org.flixel.system.input.Keyboard (defaults to null).\n\t\t * @param\treverseSpeed\tThe speed in pixels per second which the sprite will reverse. Acceleration or Instant movement is determined by the Movement Type.\n\t\t */\n\t\tpublic function setThrust(thrustKey:String, thrustSpeed:Number, reverseKey:String = null, reverseSpeed:Number = 0):void\n\t\t{\n\t\t\tthrustEnabled = false;\n\t\t\treverseEnabled = false;\n\t\t\t\n\t\t\tif (thrustKey)\n\t\t\t{\n\t\t\t\tthis.thrustKey = thrustKey;\n\t\t\t\tthis.thrustSpeed = thrustSpeed;\n\t\t\t\tthrustEnabled = true;\n\t\t\t}\n\t\t\t\n\t\t\tif (reverseKey)\n\t\t\t{\n\t\t\t\tthis.reverseKey = reverseKey;\n\t\t\t\tthis.reverseSpeed = reverseSpeed;\n\t\t\t\treverseEnabled = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the maximum speed (in pixels per second) that the FlxSprite can move. You can set the horizontal and vertical speeds independantly.<br>\n\t\t * When the FlxSprite is accelerating (movement type MOVEMENT_ACCELERATES) its speed won't increase above this value.<br>\n\t\t * However Flixel allows the velocity of an FlxSprite to be set to anything. So if you'd like to check the value and restrain it, then enable \"limitVelocity\".\n\t\t * \n\t\t * @param\txSpeed\t\t\tThe maximum speed in pixels per second in which the sprite can move horizontally\n\t\t * @param\tySpeed\t\t\tThe maximum speed in pixels per second in which the sprite can move vertically\n\t\t * @param\tlimitVelocity\tIf true the velocity of the FlxSprite will be checked and kept within the limit. If false it can be set to anything.\n\t\t */\n\t\tpublic function setMaximumSpeed(xSpeed:uint, ySpeed:uint, limitVelocity:Boolean = true):void\n\t\t{\n\t\t\tentity.maxVelocity.x = xSpeed;\n\t\t\tentity.maxVelocity.y = ySpeed;\n\t\t\t\n\t\t\tcapVelocity = limitVelocity;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Deceleration is a speed (in pixels per second) that is applied to the sprite if stopping type is \"DECELERATES\" and if no acceleration is taking place.<br>\n\t\t * The velocity of the sprite will be reduced until it reaches zero, and can be configured separately per axis.\n\t\t * \n\t\t * @param\txSpeed\t\tThe speed in pixels per second at which the sprite will have its horizontal speed decreased\n\t\t * @param\tySpeed\t\tThe speed in pixels per second at which the sprite will have its vertical speed decreased\n\t\t */\n\t\tpublic function setDeceleration(xSpeed:uint, ySpeed:uint):void\n\t\t{\n\t\t\tentity.drag.x = xSpeed;\n\t\t\tentity.drag.y = ySpeed;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Gravity can be applied to the sprite, pulling it in any direction.<br>\n\t\t * Gravity is given in pixels per second and is applied as acceleration. The speed the sprite reaches under gravity will never exceed the Maximum Movement Speeds set.<br>\n\t\t * If you don't want gravity for a specific direction pass a value of zero.\n\t\t * \n\t\t * @param\txForce\tA positive value applies gravity dragging the sprite to the right. A negative value drags the sprite to the left. Zero disables horizontal gravity.\n\t\t * @param\tyForce\tA positive value applies gravity dragging the sprite down. A negative value drags the sprite up. Zero disables vertical gravity.\n\t\t */\n\t\tpublic function setGravity(xForce:int, yForce:int):void\n\t\t{\n\t\t\tgravityX = xForce;\n\t\t\tgravityY = yForce;\n\t\t\t\n\t\t\tentity.acceleration.x = gravityX;\n\t\t\tentity.acceleration.y = gravityY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Switches the gravity applied to the sprite. If gravity was +400 Y (pulling them down) this will swap it to -400 Y (pulling them up)<br>\n\t\t * To reset call flipGravity again\n\t\t */\n\t\tpublic function flipGravity():void\n\t\t{\n\t\t\tif (gravityX && gravityX != 0)\n\t\t\t{\n\t\t\t\tgravityX = -gravityX;\n\t\t\t\tentity.acceleration.x = gravityX;\n\t\t\t}\n\t\t\t\n\t\t\tif (gravityY && gravityY != 0)\n\t\t\t{\n\t\t\t\tgravityY = -gravityY;\n\t\t\t\tentity.acceleration.y = gravityY;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * TODO\n\t\t * \n\t\t * @param\txFactor\n\t\t * @param\tyFactor\n\t\t */\n\t\tpublic function speedUp(xFactor:Number, yFactor:Number):void\n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * TODO\n\t\t * \n\t\t * @param\txFactor\n\t\t * @param\tyFactor\n\t\t */\n\t\tpublic function slowDown(xFactor:Number, yFactor:Number):void\n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * TODO\n\t\t * \n\t\t * @param\txFactor\n\t\t * @param\tyFactor\n\t\t */\n\t\tpublic function resetSpeeds(resetX:Boolean = true, resetY:Boolean = true):void\n\t\t{\n\t\t\tif (resetX)\n\t\t\t{\n\t\t\t\txSpeedAdjust = 0;\n\t\t\t}\n\t\t\t\n\t\t\tif (resetY)\n\t\t\t{\n\t\t\t\tySpeedAdjust = 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new Hot Key, which can be bound to any function you specify (such as \"swap weapon\", \"quit\", etc)\n\t\t * \n\t\t * @param\tkey\t\t\tThe key to use as the hot key (String from org.flixel.system.input.Keyboard, i.e. \"SPACE\", \"CONTROL\", \"Q\", etc)\n\t\t * @param\tcallback\tThe function to call when the key is pressed\n\t\t * @param\tkeymode\t\tThe keymode that will trigger the callback, either KEYMODE_PRESSED, KEYMODE_JUST_DOWN or KEYMODE_RELEASED\n\t\t */\n\t\tpublic function addHotKey(key:String, callback:Function, keymode:int):void\n\t\t{\n\t\t\t\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes a previously defined hot key\n\t\t * \n\t\t * @param\tkey\t\tThe key to use as the hot key (String from org.flixel.system.input.Keyboard, i.e. \"SPACE\", \"CONTROL\", \"Q\", etc)\n\t\t * @return\ttrue if the key was found and removed, false if the key couldn't be found\n\t\t */\n\t\tpublic function removeHotKey(key:String):Boolean\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set sound effects for the movement events jumping, firing, walking and thrust.\n\t\t * \n\t\t * @param\tjump\tThe FlxSound to play when the user jumps\n\t\t * @param\tfire\tThe FlxSound to play when the user fires\n\t\t * @param\twalk\tThe FlxSound to play when the user walks\n\t\t * @param\tthrust\tThe FlxSound to play when the user thrusts\n\t\t */\n\t\tpublic function setSounds(jump:FlxSound = null, fire:FlxSound = null, walk:FlxSound = null, thrust:FlxSound = null):void\n\t\t{\n\t\t\tif (jump)\n\t\t\t{\n\t\t\t\tjumpSound = jump;\n\t\t\t}\n\t\t\t\n\t\t\tif (fire)\n\t\t\t{\n\t\t\t\tfireSound = fire;\n\t\t\t}\n\t\t\t\n\t\t\tif (walk)\n\t\t\t{\n\t\t\t\twalkSound = walk;\n\t\t\t}\n\t\t\t\n\t\t\tif (thrust)\n\t\t\t{\n\t\t\t\tthrustSound = thrust;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enable a fire button\n\t\t * \n\t\t * @param\tkey\t\t\t\tThe key to use as the fire button (String from org.flixel.system.input.Keyboard, i.e. \"SPACE\", \"CONTROL\")\n\t\t * @param\tkeymode\t\t\tThe FlxControlHandler KEYMODE value (KEYMODE_PRESSED, KEYMODE_JUST_DOWN, KEYMODE_RELEASED)\n\t\t * @param\trepeatDelay\t\tTime delay in ms between which the fire action can repeat (0 means instant, 250 would allow it to fire approx. 4 times per second)\n\t\t * @param\tcallback\t\tA user defined function to call when it fires\n\t\t * @param\taltKey\t\t\tSpecify an alternative fire key that works AS WELL AS the primary fire key (TODO)\n\t\t */\n\t\tpublic function setFireButton(key:String, keymode:uint, repeatDelay:uint, callback:Function, altKey:String = \"\"):void\n\t\t{\n\t\t\tfireKey = key;\n\t\t\tfireKeyMode = keymode;\n\t\t\tfireRate = repeatDelay;\n\t\t\tfireCallback = callback;\n\t\t\t\n\t\t\tif (altKey != \"\")\n\t\t\t{\n\t\t\t\taltFireKey = altKey;\n\t\t\t}\n\t\t\t\n\t\t\tfire = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enable a jump button\n\t\t * \n\t\t * @param\tkey\t\t\t\tThe key to use as the jump button (String from org.flixel.system.input.Keyboard, i.e. \"SPACE\", \"CONTROL\")\n\t\t * @param\tkeymode\t\t\tThe FlxControlHandler KEYMODE value (KEYMODE_PRESSED, KEYMODE_JUST_DOWN, KEYMODE_RELEASED)\n\t\t * @param\theight\t\t\tThe height in pixels/sec that the Sprite will attempt to jump (gravity and acceleration can influence this actual height obtained)\n\t\t * @param\tsurface\t\t\tA bitwise combination of all valid surfaces the Sprite can jump off (from FlxObject, such as FlxObject.FLOOR)\n\t\t * @param\trepeatDelay\t\tTime delay in ms between which the jumping can repeat (250 would be 4 times per second)\n\t\t * @param\tjumpFromFall\tA time in ms that allows the Sprite to still jump even if it's just fallen off a platform, if still within ths time limit\n\t\t * @param\tcallback\t\tA user defined function to call when the Sprite jumps\n\t\t * @param\taltKey\t\t\tSpecify an alternative jump key that works AS WELL AS the primary jump key (TODO)\n\t\t */\n\t\tpublic function setJumpButton(key:String, keymode:uint, height:int, surface:int, repeatDelay:uint = 250, jumpFromFall:int = 0, callback:Function = null, altKey:String = \"\"):void\n\t\t{\n\t\t\tjumpKey = key;\n\t\t\tjumpKeyMode = keymode;\n\t\t\tjumpHeight = height;\n\t\t\tjumpSurface = surface;\n\t\t\tjumpRate = repeatDelay;\n\t\t\tjumpFromFallTime = jumpFromFall;\n\t\t\tjumpCallback = callback;\n\t\t\t\n\t\t\tif (altKey != \"\")\n\t\t\t{\n\t\t\t\taltJumpKey = altKey;\n\t\t\t}\n\t\t\t\n\t\t\tjump = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Limits the sprite to only be allowed within this rectangle. If its x/y coordinates go outside it will be repositioned back inside.<br>\n\t\t * Coordinates should be given in GAME WORLD pixel values (not screen value, although often they are the two same things)\n\t\t * \n\t\t * @param\tx\t\tThe x coordinate of the top left corner of the area (in game world pixels)\n\t\t * @param\ty\t\tThe y coordinate of the top left corner of the area (in game world pixels)\n\t\t * @param\twidth\tThe width of the area (in pixels)\n\t\t * @param\theight\tThe height of the area (in pixels)\n\t\t */\n\t\tpublic function setBounds(x:int, y:int, width:uint, height:uint):void\n\t\t{\n\t\t\tbounds = new Rectangle(x, y, width, height);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clears any previously set sprite bounds\n\t\t */\n\t\tpublic function removeBounds():void\n\t\t{\n\t\t\tbounds = null;\n\t\t}\n\t\t\n\t\tprivate function moveUp():Boolean\n\t\t{\n\t\t\tvar move:Boolean = false;\n\t\t\t\n\t\t\tif (FlxG.keys.pressed(upKey))\n\t\t\t{\n\t\t\t\tmove = true;\n\t\t\t\tisPressedUp = true;\n\t\t\t\t\n\t\t\t\tif (yFacing)\n\t\t\t\t{\n\t\t\t\t\tentity.facing = FlxObject.UP;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (movement == MOVEMENT_INSTANT)\n\t\t\t\t{\n\t\t\t\t\tentity.velocity.y = upMoveSpeed;\n\t\t\t\t}\n\t\t\t\telse if (movement == MOVEMENT_ACCELERATES)\n\t\t\t\t{\n\t\t\t\t\tentity.acceleration.y = upMoveSpeed;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (bounds && entity.y < bounds.top)\n\t\t\t\t{\n\t\t\t\t\tentity.y = bounds.top;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\tprivate function moveDown():Boolean\n\t\t{\n\t\t\tvar move:Boolean = false;\n\t\t\t\n\t\t\tif (FlxG.keys.pressed(downKey))\n\t\t\t{\n\t\t\t\tmove = true;\n\t\t\t\tisPressedDown = true;\n\t\t\t\t\n\t\t\t\tif (yFacing)\n\t\t\t\t{\n\t\t\t\t\tentity.facing = FlxObject.DOWN;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (movement == MOVEMENT_INSTANT)\n\t\t\t\t{\n\t\t\t\t\tentity.velocity.y = downMoveSpeed;\n\t\t\t\t}\n\t\t\t\telse if (movement == MOVEMENT_ACCELERATES)\n\t\t\t\t{\n\t\t\t\t\tentity.acceleration.y = downMoveSpeed;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (bounds && entity.y > bounds.bottom)\n\t\t\t\t{\n\t\t\t\t\tentity.y = bounds.bottom;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\tprivate function moveLeft():Boolean\n\t\t{\n\t\t\tvar move:Boolean = false;\n\t\t\t\n\t\t\tif (FlxG.keys.pressed(leftKey))\n\t\t\t{\n\t\t\t\tmove = true;\n\t\t\t\tisPressedLeft = true;\n\t\t\t\t\n\t\t\t\tif (xFacing)\n\t\t\t\t{\n\t\t\t\t\tentity.facing = FlxObject.LEFT;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (movement == MOVEMENT_INSTANT)\n\t\t\t\t{\n\t\t\t\t\tentity.velocity.x = leftMoveSpeed;\n\t\t\t\t}\n\t\t\t\telse if (movement == MOVEMENT_ACCELERATES)\n\t\t\t\t{\n\t\t\t\t\tentity.acceleration.x = leftMoveSpeed;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (bounds && entity.x < bounds.x)\n\t\t\t\t{\n\t\t\t\t\tentity.x = bounds.x;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\tprivate function moveRight():Boolean\n\t\t{\n\t\t\tvar move:Boolean = false;\n\t\t\t\n\t\t\tif (FlxG.keys.pressed(rightKey))\n\t\t\t{\n\t\t\t\tmove = true;\n\t\t\t\tisPressedRight = true;\n\t\t\t\t\n\t\t\t\tif (xFacing)\n\t\t\t\t{\n\t\t\t\t\tentity.facing = FlxObject.RIGHT;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (movement == MOVEMENT_INSTANT)\n\t\t\t\t{\n\t\t\t\t\tentity.velocity.x = rightMoveSpeed;\n\t\t\t\t}\n\t\t\t\telse if (movement == MOVEMENT_ACCELERATES)\n\t\t\t\t{\n\t\t\t\t\tentity.acceleration.x = rightMoveSpeed;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (bounds && entity.x > bounds.right)\n\t\t\t\t{\n\t\t\t\t\tentity.x = bounds.right;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\tprivate function moveAntiClockwise():Boolean\n\t\t{\n\t\t\tvar move:Boolean = false;\n\t\t\t\n\t\t\tif (FlxG.keys.pressed(antiClockwiseKey))\n\t\t\t{\n\t\t\t\tmove = true;\n\t\t\t\t\n\t\t\t\tif (rotation == ROTATION_INSTANT)\n\t\t\t\t{\n\t\t\t\t\tentity.angularVelocity = antiClockwiseRotationSpeed;\n\t\t\t\t}\n\t\t\t\telse if (rotation == ROTATION_ACCELERATES)\n\t\t\t\t{\n\t\t\t\t\tentity.angularAcceleration = antiClockwiseRotationSpeed;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// TODO - Not quite there yet given the way Flixel can rotate to any valid int angle!\n\t\t\t\tif (enforceAngleLimits)\n\t\t\t\t{\n\t\t\t\t\t//entity.angle = FlxMath.angleLimit(entity.angle, minAngle, maxAngle);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\tprivate function moveClockwise():Boolean\n\t\t{\n\t\t\tvar move:Boolean = false;\n\t\t\t\n\t\t\tif (FlxG.keys.pressed(clockwiseKey))\n\t\t\t{\n\t\t\t\tmove = true;\n\t\t\t\t\n\t\t\t\tif (rotation == ROTATION_INSTANT)\n\t\t\t\t{\n\t\t\t\t\tentity.angularVelocity = clockwiseRotationSpeed;\n\t\t\t\t}\n\t\t\t\telse if (rotation == ROTATION_ACCELERATES)\n\t\t\t\t{\n\t\t\t\t\tentity.angularAcceleration = clockwiseRotationSpeed;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// TODO - Not quite there yet given the way Flixel can rotate to any valid int angle!\n\t\t\t\tif (enforceAngleLimits)\n\t\t\t\t{\n\t\t\t\t\t//entity.angle = FlxMath.angleLimit(entity.angle, minAngle, maxAngle);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\tprivate function moveThrust():Boolean\n\t\t{\n\t\t\tvar move:Boolean = false;\n\t\t\t\n\t\t\tif (FlxG.keys.pressed(thrustKey))\n\t\t\t{\n\t\t\t\tmove = true;\n\t\t\t\t\n\t\t\t\tvar motion:FlxPoint = FlxVelocity.velocityFromAngle(entity.angle, thrustSpeed);\n\t\t\t\t\n\t\t\t\tif (movement == MOVEMENT_INSTANT)\n\t\t\t\t{\n\t\t\t\t\tentity.velocity.x = motion.x;\n\t\t\t\t\tentity.velocity.y = motion.y;\n\t\t\t\t}\n\t\t\t\telse if (movement == MOVEMENT_ACCELERATES)\n\t\t\t\t{\n\t\t\t\t\tentity.acceleration.x = motion.x;\n\t\t\t\t\tentity.acceleration.y = motion.y;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (bounds && entity.x < bounds.x)\n\t\t\t\t{\n\t\t\t\t\tentity.x = bounds.x;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (move && thrustSound)\n\t\t\t{\n\t\t\t\tthrustSound.play(false);\n\t\t\t}\n\t\t\t\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\tprivate function moveReverse():Boolean\n\t\t{\n\t\t\tvar move:Boolean = false;\n\t\t\t\n\t\t\tif (FlxG.keys.pressed(reverseKey))\n\t\t\t{\n\t\t\t\tmove = true;\n\t\t\t\t\n\t\t\t\tvar motion:FlxPoint = FlxVelocity.velocityFromAngle(entity.angle, reverseSpeed);\n\t\t\t\t\n\t\t\t\tif (movement == MOVEMENT_INSTANT)\n\t\t\t\t{\n\t\t\t\t\tentity.velocity.x = -motion.x;\n\t\t\t\t\tentity.velocity.y = -motion.y;\n\t\t\t\t}\n\t\t\t\telse if (movement == MOVEMENT_ACCELERATES)\n\t\t\t\t{\n\t\t\t\t\tentity.acceleration.x = -motion.x;\n\t\t\t\t\tentity.acceleration.y = -motion.y;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (bounds && entity.x < bounds.x)\n\t\t\t\t{\n\t\t\t\t\tentity.x = bounds.x;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\tprivate function runFire():Boolean\n\t\t{\n\t\t\tvar fired:Boolean = false;\n\t\t\t\n\t\t\t//\t0 = Pressed\n\t\t\t//\t1 = Just Down\n\t\t\t//\t2 = Just Released\n\t\t\tif ((fireKeyMode == 0 && FlxG.keys.pressed(fireKey)) || (fireKeyMode == 1 && FlxG.keys.justPressed(fireKey)) || (fireKeyMode == 2 && FlxG.keys.justReleased(fireKey)))\n\t\t\t{\n\t\t\t\tif (fireRate > 0)\n\t\t\t\t{\n\t\t\t\t\tif (getTimer() > nextFireTime)\n\t\t\t\t\t{\n\t\t\t\t\t\tlastFiredTime = getTimer();\n\t\t\t\t\t\t\n\t\t\t\t\t\tfireCallback.call();\n\t\t\t\t\t\t\n\t\t\t\t\t\tfired = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tnextFireTime = lastFiredTime + fireRate;\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\tlastFiredTime = getTimer();\n\t\t\t\t\t\n\t\t\t\t\tfireCallback.call();\n\t\t\t\t\t\n\t\t\t\t\tfired = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (fired && fireSound)\n\t\t\t{\n\t\t\t\tfireSound.play(true);\n\t\t\t}\n\t\t\t\n\t\t\treturn fired;\n\t\t}\n\t\t\n\t\tprivate function runJump():Boolean\n\t\t{\n\t\t\tvar jumped:Boolean = false;\n\t\t\t\n\t\t\t//\tThis should be called regardless if they've pressed jump or not\n\t\t\tif (entity.isTouching(jumpSurface))\n\t\t\t{\n\t\t\t\textraSurfaceTime = getTimer() + jumpFromFallTime;\n\t\t\t}\n\t\t\t\n\t\t\tif ((jumpKeyMode == KEYMODE_PRESSED && FlxG.keys.pressed(jumpKey)) || (jumpKeyMode == KEYMODE_JUST_DOWN && FlxG.keys.justPressed(jumpKey)) || (jumpKeyMode == KEYMODE_RELEASED && FlxG.keys.justReleased(jumpKey)))\n\t\t\t{\n\t\t\t\t//\tSprite not touching a valid jump surface\n\t\t\t\tif (entity.isTouching(jumpSurface) == false)\n\t\t\t\t{\n\t\t\t\t\t//\tThey've run out of time to jump\n\t\t\t\t\tif (getTimer() > extraSurfaceTime)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn jumped;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t//\tStill within the fall-jump window of time, but have jumped recently\n\t\t\t\t\t\tif (lastJumpTime > (extraSurfaceTime - jumpFromFallTime))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treturn jumped;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t//\tIf there is a jump repeat rate set and we're still less than it then return\n\t\t\t\t\tif (getTimer() < nextJumpTime)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn jumped;\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//\tIf there is a jump repeat rate set and we're still less than it then return\n\t\t\t\t\tif (getTimer() < nextJumpTime)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn jumped;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (gravityY > 0)\n\t\t\t\t{\n\t\t\t\t\t//\tGravity is pulling them down to earth, so they are jumping up (negative)\n\t\t\t\t\tentity.velocity.y = -jumpHeight;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t//\tGravity is pulling them up, so they are jumping down (positive)\n\t\t\t\t\tentity.velocity.y = jumpHeight;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (jumpCallback is Function)\n\t\t\t\t{\n\t\t\t\t\tjumpCallback.call();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tlastJumpTime = getTimer();\n\t\t\t\tnextJumpTime = lastJumpTime + jumpRate;\n\t\t\t\t\t\n\t\t\t\tjumped = true;\n\t\t\t}\n\t\t\t\n\t\t\tif (jumped && jumpSound)\n\t\t\t{\n\t\t\t\tjumpSound.play(true);\n\t\t\t}\n\t\t\t\n\t\t\treturn jumped;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by the FlxControl plugin\n\t\t */\n\t\tpublic function update():void\n\t\t{\n\t\t\tif (entity == null)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//\tReset the helper booleans\n\t\t\tisPressedUp = false;\n\t\t\tisPressedDown = false;\n\t\t\tisPressedLeft = false;\n\t\t\tisPressedRight = false;\n\t\t\t\n\t\t\tif (stopping == STOPPING_INSTANT)\n\t\t\t{\n\t\t\t\tif (movement == MOVEMENT_INSTANT)\n\t\t\t\t{\n\t\t\t\t\tentity.velocity.x = 0;\n\t\t\t\t\tentity.velocity.y = 0;\n\t\t\t\t}\n\t\t\t\telse if (movement == MOVEMENT_ACCELERATES)\n\t\t\t\t{\n\t\t\t\t\tentity.acceleration.x = 0;\n\t\t\t\t\tentity.acceleration.y = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (stopping == STOPPING_DECELERATES)\n\t\t\t{\n\t\t\t\tif (movement == MOVEMENT_INSTANT)\n\t\t\t\t{\n\t\t\t\t\tentity.velocity.x = 0;\n\t\t\t\t\tentity.velocity.y = 0;\n\t\t\t\t}\n\t\t\t\telse if (movement == MOVEMENT_ACCELERATES)\n\t\t\t\t{\n\t\t\t\t\t//\tBy default these are zero anyway, so it's safe to set like this\n\t\t\t\t\tentity.acceleration.x = gravityX;\n\t\t\t\t\tentity.acceleration.y = gravityY;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//\tRotation\n\t\t\tif (isRotating)\n\t\t\t{\n\t\t\t\tif (rotationStopping == ROTATION_STOPPING_INSTANT)\n\t\t\t\t{\n\t\t\t\t\tif (rotation == ROTATION_INSTANT)\n\t\t\t\t\t{\n\t\t\t\t\t\tentity.angularVelocity = 0;\n\t\t\t\t\t}\n\t\t\t\t\telse if (rotation == ROTATION_ACCELERATES)\n\t\t\t\t\t{\n\t\t\t\t\t\tentity.angularAcceleration = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (rotationStopping == ROTATION_STOPPING_DECELERATES)\n\t\t\t\t{\n\t\t\t\t\tif (rotation == ROTATION_INSTANT)\n\t\t\t\t\t{\n\t\t\t\t\t\tentity.angularVelocity = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvar hasRotatedAntiClockwise:Boolean = false;\n\t\t\t\tvar hasRotatedClockwise:Boolean = false;\n\t\t\t\t\n\t\t\t\thasRotatedAntiClockwise = moveAntiClockwise();\n\t\t\t\t\n\t\t\t\tif (hasRotatedAntiClockwise == false)\n\t\t\t\t{\n\t\t\t\t\thasRotatedClockwise = moveClockwise();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (rotationStopping == ROTATION_STOPPING_DECELERATES)\n\t\t\t\t{\n\t\t\t\t\tif (rotation == ROTATION_ACCELERATES && hasRotatedAntiClockwise == false && hasRotatedClockwise == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tentity.angularAcceleration = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//\tIf they have got instant stopping with acceleration and are NOT pressing a key, then stop the rotation. Otherwise we let it carry on\n\t\t\t\tif (rotationStopping == ROTATION_STOPPING_INSTANT && rotation == ROTATION_ACCELERATES && hasRotatedAntiClockwise == false && hasRotatedClockwise == false)\n\t\t\t\t{\n\t\t\t\t\tentity.angularVelocity = 0;\n\t\t\t\t\tentity.angularAcceleration = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//\tThrust\n\t\t\tif (thrustEnabled || reverseEnabled)\n\t\t\t{\n\t\t\t\tvar moved:Boolean = false;\n\t\t\t\t\n\t\t\t\tif (thrustEnabled)\n\t\t\t\t{\n\t\t\t\t\tmoved = moveThrust();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (moved == false && reverseEnabled)\n\t\t\t\t{\n\t\t\t\t\tmoved = moveReverse();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvar movedX:Boolean = false;\n\t\t\t\tvar movedY:Boolean = false;\n\t\t\t\t\n\t\t\t\tif (up)\n\t\t\t\t{\n\t\t\t\t\tmovedY = moveUp();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (down && movedY == false)\n\t\t\t\t{\n\t\t\t\t\tmovedY = moveDown();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (left)\n\t\t\t\t{\n\t\t\t\t\tmovedX = moveLeft();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (right && movedX == false)\n\t\t\t\t{\n\t\t\t\t\tmovedX = moveRight();\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (fire)\n\t\t\t{\n\t\t\t\trunFire();\n\t\t\t}\n\t\t\t\n\t\t\tif (jump)\n\t\t\t{\n\t\t\t\trunJump();\n\t\t\t}\n\t\t\t\n\t\t\tif (capVelocity)\n\t\t\t{\n\t\t\t\tif (entity.velocity.x > entity.maxVelocity.x)\n\t\t\t\t{\n\t\t\t\t\tentity.velocity.x = entity.maxVelocity.x;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (entity.velocity.y > entity.maxVelocity.y)\n\t\t\t\t{\n\t\t\t\t\tentity.velocity.y = entity.maxVelocity.y;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (walkSound)\n\t\t\t{\n\t\t\t\tif ((movement == MOVEMENT_INSTANT && entity.velocity.x != 0) || (movement == MOVEMENT_ACCELERATES && entity.acceleration.x != 0))\n\t\t\t\t{\n\t\t\t\t\twalkSound.play(false);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\twalkSound.stop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets Custom Key controls. Useful if none of the pre-defined sets work. All String values should be taken from org.flixel.system.input.Keyboard\n\t\t * Pass a blank (empty) String to disable that key from being checked.\n\t\t * \n\t\t * @param\tcustomUpKey\t\tThe String to use for the Up key.\n\t\t * @param\tcustomDownKey\tThe String to use for the Down key.\n\t\t * @param\tcustomLeftKey\tThe String to use for the Left key.\n\t\t * @param\tcustomRightKey\tThe String to use for the Right key.\n\t\t */\n\t\tpublic function setCustomKeys(customUpKey:String, customDownKey:String, customLeftKey:String, customRightKey:String):void\n\t\t{\n\t\t\tif (customUpKey != \"\")\n\t\t\t{\n\t\t\t\tup = true;\n\t\t\t\tupKey = customUpKey;\n\t\t\t}\n\t\t\t\n\t\t\tif (customDownKey != \"\")\n\t\t\t{\n\t\t\t\tdown = true;\n\t\t\t\tdownKey = customDownKey;\n\t\t\t}\n\t\t\t\n\t\t\tif (customLeftKey != \"\")\n\t\t\t{\n\t\t\t\tleft = true;\n\t\t\t\tleftKey = customLeftKey;\n\t\t\t}\n\t\t\t\n\t\t\tif (customRightKey != \"\")\n\t\t\t{\n\t\t\t\tright = true;\n\t\t\t\trightKey = customRightKey;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enables Cursor/Arrow Key controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.<br>\n\t\t * For example in a Space Invaders game you'd only enable LEFT and RIGHT.\n\t\t * \n\t\t * @param\tallowUp\t\tEnable the UP key\n\t\t * @param\tallowDown\tEnable the DOWN key\n\t\t * @param\tallowLeft\tEnable the LEFT key\n\t\t * @param\tallowRight\tEnable the RIGHT key\n\t\t */\n\t\tpublic function setCursorControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void\n\t\t{\n\t\t\tup = allowUp;\n\t\t\tdown = allowDown;\n\t\t\tleft = allowLeft;\n\t\t\tright = allowRight;\n\t\t\t\n\t\t\tupKey = \"UP\";\n\t\t\tdownKey = \"DOWN\";\n\t\t\tleftKey = \"LEFT\";\n\t\t\trightKey = \"RIGHT\";\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enables WASD controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.<br>\n\t\t * For example in a Space Invaders game you'd only enable LEFT and RIGHT.\n\t\t * \n\t\t * @param\tallowUp\t\tEnable the up (W) key\n\t\t * @param\tallowDown\tEnable the down (S) key\n\t\t * @param\tallowLeft\tEnable the left (A) key\n\t\t * @param\tallowRight\tEnable the right (D) key\n\t\t */\n\t\tpublic function setWASDControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void\n\t\t{\n\t\t\tup = allowUp;\n\t\t\tdown = allowDown;\n\t\t\tleft = allowLeft;\n\t\t\tright = allowRight;\n\t\t\t\n\t\t\tupKey = \"W\";\n\t\t\tdownKey = \"S\";\n\t\t\tleftKey = \"A\";\n\t\t\trightKey = \"D\";\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enables ESDF (home row) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.<br>\n\t\t * For example in a Space Invaders game you'd only enable LEFT and RIGHT.\n\t\t * \n\t\t * @param\tallowUp\t\tEnable the up (E) key\n\t\t * @param\tallowDown\tEnable the down (D) key\n\t\t * @param\tallowLeft\tEnable the left (S) key\n\t\t * @param\tallowRight\tEnable the right (F) key\n\t\t */\n\t\tpublic function setESDFControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void\n\t\t{\n\t\t\tup = allowUp;\n\t\t\tdown = allowDown;\n\t\t\tleft = allowLeft;\n\t\t\tright = allowRight;\n\t\t\t\n\t\t\tupKey = \"E\";\n\t\t\tdownKey = \"D\";\n\t\t\tleftKey = \"S\";\n\t\t\trightKey = \"F\";\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enables IJKL (right-sided or secondary player) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.<br>\n\t\t * For example in a Space Invaders game you'd only enable LEFT and RIGHT.\n\t\t * \n\t\t * @param\tallowUp\t\tEnable the up (I) key\n\t\t * @param\tallowDown\tEnable the down (K) key\n\t\t * @param\tallowLeft\tEnable the left (J) key\n\t\t * @param\tallowRight\tEnable the right (L) key\n\t\t */\n\t\tpublic function setIJKLControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void\n\t\t{\n\t\t\tup = allowUp;\n\t\t\tdown = allowDown;\n\t\t\tleft = allowLeft;\n\t\t\tright = allowRight;\n\t\t\t\n\t\t\tupKey = \"I\";\n\t\t\tdownKey = \"K\";\n\t\t\tleftKey = \"J\";\n\t\t\trightKey = \"L\";\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enables HJKL (Rogue / Net-Hack) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.<br>\n\t\t * For example in a Space Invaders game you'd only enable LEFT and RIGHT.\n\t\t * \n\t\t * @param\tallowUp\t\tEnable the up (K) key\n\t\t * @param\tallowDown\tEnable the down (J) key\n\t\t * @param\tallowLeft\tEnable the left (H) key\n\t\t * @param\tallowRight\tEnable the right (L) key\n\t\t */\n\t\tpublic function setHJKLControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void\n\t\t{\n\t\t\tup = allowUp;\n\t\t\tdown = allowDown;\n\t\t\tleft = allowLeft;\n\t\t\tright = allowRight;\n\t\t\t\n\t\t\tupKey = \"K\";\n\t\t\tdownKey = \"J\";\n\t\t\tleftKey = \"H\";\n\t\t\trightKey = \"L\";\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enables ZQSD (Azerty keyboard) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.<br>\n\t\t * For example in a Space Invaders game you'd only enable LEFT and RIGHT.\n\t\t * \n\t\t * @param\tallowUp\t\tEnable the up (Z) key\n\t\t * @param\tallowDown\tEnable the down (Q) key\n\t\t * @param\tallowLeft\tEnable the left (S) key\n\t\t * @param\tallowRight\tEnable the right (D) key\n\t\t */\n\t\tpublic function setZQSDControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void\n\t\t{\n\t\t\tup = allowUp;\n\t\t\tdown = allowDown;\n\t\t\tleft = allowLeft;\n\t\t\tright = allowRight;\n\t\t\t\n\t\t\tupKey = \"Z\";\n\t\t\tdownKey = \"S\";\n\t\t\tleftKey = \"Q\";\n\t\t\trightKey = \"D\";\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enables Dvoark Simplified Controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.<br>\n\t\t * For example in a Space Invaders game you'd only enable LEFT and RIGHT.\n\t\t * \n\t\t * @param\tallowUp\t\tEnable the up (COMMA) key\n\t\t * @param\tallowDown\tEnable the down (A) key\n\t\t * @param\tallowLeft\tEnable the left (O) key\n\t\t * @param\tallowRight\tEnable the right (E) key\n\t\t */\n\t\tpublic function setDvorakSimplifiedControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void\n\t\t{\n\t\t\tup = allowUp;\n\t\t\tdown = allowDown;\n\t\t\tleft = allowLeft;\n\t\t\tright = allowRight;\n\t\t\t\n\t\t\tupKey = \"COMMA\";\n\t\t\tdownKey = \"O\";\n\t\t\tleftKey = \"A\";\n\t\t\trightKey = \"E\";\n\t\t}\n\t\t\n\t\t/**\n\t\t * Enables Numpad (left-handed) Controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.<br>\n\t\t * For example in a Space Invaders game you'd only enable LEFT and RIGHT.\n\t\t * \n\t\t * @param\tallowUp\t\tEnable the up (NUMPADEIGHT) key\n\t\t * @param\tallowDown\tEnable the down (NUMPADTWO) key\n\t\t * @param\tallowLeft\tEnable the left (NUMPADFOUR) key\n\t\t * @param\tallowRight\tEnable the right (NUMPADSIX) key\n\t\t */\n\t\tpublic function setNumpadControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void\n\t\t{\n\t\t\tup = allowUp;\n\t\t\tdown = allowDown;\n\t\t\tleft = allowLeft;\n\t\t\tright = allowRight;\n\t\t\t\n\t\t\tupKey = \"NUMPADEIGHT\";\n\t\t\tdownKey = \"NUMPADTWO\";\n\t\t\tleftKey = \"NUMPADFOUR\";\n\t\t\trightKey = \"NUMPADSIX\";\n\t\t}\n\t\t\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxCoreUtils.as",
    "content": "/**\n * FlxCoreUtils\n * -- Part of the Flixel Power Tools set\n * \n * v1.1 Added get mouseIndex and gameContainer\n * v1.0 First release with copyObject\n * \n * @version 1.1 - August 4th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.display.Sprite;\n\timport flash.utils.ByteArray;\n\timport org.flixel.*;\n\t\n\tpublic class FlxCoreUtils \n\t{\n\t\t\n\t\tpublic function FlxCoreUtils() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Performs a complete object deep-copy and returns a duplicate (not a reference)\n\t\t * \n\t\t * @param\tvalue\tThe object you want copied\n\t\t * @return\tA copy of this object\n\t\t */\n\t\tpublic static function copyObject(value:Object):Object\n\t\t{\n\t\t\tvar buffer:ByteArray = new ByteArray();\n\t\t\tbuffer.writeObject(value);\n\t\t\tbuffer.position = 0;\n\t\t\tvar result:Object = buffer.readObject();\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns the Display List index of the mouse pointer\n\t\t */\n\t\tpublic static function get mouseIndex():int\n\t\t{\n\t\t\tvar mouseIndex:int = -1;\n\t\t\t\n\t\t\ttry\n\t\t\t{\n\t\t\t\tmouseIndex = FlxG.camera.getContainerSprite().parent.numChildren - 4;\n\t\t\t}\n\t\t\tcatch (e:Error)\n\t\t\t{\n\t\t\t\t//trace\n\t\t\t}\n\t\t\t\n\t\t\treturn mouseIndex;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns the Sprite that FlxGame extends (which contains the cameras, mouse, etc)\n\t\t */\n\t\tpublic static function get gameContainer():Sprite\n\t\t{\n\t\t\treturn Sprite(FlxG.camera.getContainerSprite().parent);\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxDelay.as",
    "content": "/**\n * FlxDelay\n * -- Part of the Flixel Power Tools set\n * \n * v1.4 Modified abort so it no longer runs the stop callback (thanks to Cambrian-Man)\n * v1.3 Added secondsElapsed and secondsRemaining and some more documentation\n * v1.2 Added callback support\n * v1.1 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.4 - July 31st 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.display.Sprite;\n\timport flash.events.Event;\n\timport flash.events.EventDispatcher;\n\timport flash.utils.getTimer;\n\t\n\timport org.flixel.*;\n\t\n\t/**\n\t * A useful timer that can be used to trigger events after certain amounts of time are up.\n\t * Uses getTimer so is low on resources and avoids using Flash events.\n\t * Also takes into consideration the Pause state of your game.\n\t * If your game pauses, when it starts again the timer notices and adjusts the expires time accordingly.\n\t */\n\t\n\tpublic class FlxDelay extends Sprite\n\t{\n\t\t/**\n\t\t * true if the timer is currently running, otherwise false\n\t\t */\n\t\tpublic var isRunning:Boolean;\n\t\t\n\t\t/**\n\t\t * If you wish to call a function once the timer completes, set it here\n\t\t */\n\t\tpublic var callback:Function;\n\t\t\n\t\t/**\n\t\t * The duration of the Delay in milliseconds\n\t\t */\n\t\tpublic var duration:int;\n\t\t\n\t\tprivate var started:int;\n\t\tprivate var expires:int;\n\t\tprivate var pauseStarted:int;\n\t\tprivate var pausedTimerRunning:Boolean;\n\t\tprivate var complete:Boolean;\n\t\t\n\t\t/**\n\t\t * Create a new timer which will run for the given amount of ms (1000 = 1 second real time)\n\t\t * \n\t\t * @param\trunFor\tThe duration of this timer in ms. Call start() to set it going.\n\t\t */\n\t\tpublic function FlxDelay(runFor:int)\n\t\t{\n\t\t\tduration = runFor;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Starts the timer running\n\t\t */\n\t\tpublic function start():void\n\t\t{\n\t\t\tstarted = getTimer();\n\t\t\texpires = started + duration;\n\t\t\tisRunning = true;\n\t\t\tcomplete = false;\n\t\t\t\n\t\t\tpauseStarted = 0;\n\t\t\tpausedTimerRunning = false;\n\t\t\t\n\t\t\taddEventListener(Event.ENTER_FRAME, update, false, 0, true);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Has the timer finished?\n\t\t */\n\t\tpublic function get hasExpired():Boolean\n\t\t{\n\t\t\treturn complete;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Restart the timer using the new duration\n\t\t * \n\t\t * @param\tnewDuration\tThe duration of this timer in ms.\n\t\t */\n\t\tpublic function reset(newDuration:int):void\n\t\t{\n\t\t\tduration = newDuration;\n\t\t\t\n\t\t\tstart();\n\t\t}\n\t\t\n\t\t/**\n\t\t * The amount of seconds that have elapsed since the timer was started\n\t\t */\n\t\tpublic function get secondsElapsed():int\n\t\t{\n\t\t\treturn int((getTimer() - started) / 1000);\n\t\t}\n\t\t\n\t\t/**\n\t\t * The amount of seconds that are remaining until the timer completes\n\t\t */\n\t\tpublic function get secondsRemaining():int\n\t\t{\n\t\t\treturn int((expires - getTimer()) / 1000);\n\t\t}\n\t\t\n\t\tprivate function update(event:Event):void\n\t\t{\n\t\t\t//\tHas the game been paused?\n\t\t\tif (pausedTimerRunning == true && FlxG.paused == false)\n\t\t\t{\n\t\t\t\tpausedTimerRunning = false;\n\t\t\t\t\n\t\t\t\t//\tAdd the time the game was paused for onto the expires timer\n\t\t\t\texpires += (getTimer() - pauseStarted);\n\t\t\t}\n\t\t\telse if (FlxG.paused == true && pausedTimerRunning == false)\n\t\t\t{\n\t\t\t\tpauseStarted = getTimer();\n\t\t\t\tpausedTimerRunning = true;\n\t\t\t}\n\t\t\t\n\t\t\tif (isRunning && pausedTimerRunning == false && getTimer() > expires)\n\t\t\t{\n\t\t\t\tstop();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Abors a currently active timer without firing any callbacks (if set)\n\t\t */\n\t\tpublic function abort():void\n\t\t{\n\t\t\tstop(false);\n\t\t}\n\t\t\n\t\tprivate function stop(runCallback:Boolean = true):void\n\t\t{\n\t\t\tremoveEventListener(Event.ENTER_FRAME, update);\n\t\t\t\n\t\t\tisRunning = false;\n\t\t\tcomplete = true;\n\t\t\t\n\t\t\tif (callback is Function && runCallback == true)\n\t\t\t{\n\t\t\t\tcallback.call();\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxDisplay.as",
    "content": "/**\n * FlxDisplay\n * -- Part of the Flixel Power Tools set\n * \n * v1.3 Added \"screenWrap\", \"alphaMask\" and \"alphaMaskFlxSprite\" methods\n * v1.2 Added \"space\" method\n * v1.1 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.3 - June 15th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.display.BitmapData;\n\timport flash.display.BitmapDataChannel;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport org.flixel.*;\n\t\n\tpublic class FlxDisplay \n\t{\n\t\t\n\t\tpublic function FlxDisplay() \n\t\t{\n\t\t}\n\t\t\n\t\tpublic function pad():void\n\t\t{\n\t\t\t//\tPad the sprite out with empty pixels left/right/above/below it\n\t\t}\n\t\t\n\t\tpublic function flip():void\n\t\t{\n\t\t\t//\tmirror / reverse?\n\t\t\t//\tFlip image data horizontally / vertically without changing the angle\n\t\t}\n\t\t\n\t\t/**\n\t\t * Takes two source images (typically from Embedded bitmaps) and puts the resulting image into the output FlxSprite.<br>\n\t\t * Note: It assumes the source and mask are the same size. Different sizes may result in undesired results.<br>\n\t\t * It works by copying the source image (your picture) into the output sprite. Then it removes all areas of it that do not<br>\n\t\t * have an alpha color value in the mask image. So if you draw a big black circle in your mask with a transparent edge, you'll<br>\n\t\t * get a circular image appear. Look at the mask PNG files in the assets/pics folder for examples.\n\t\t * \n\t\t * @param\tsource\t\tThe source image. Typically the one with the image / picture / texture in it.\n\t\t * @param\tmask\t\tThe mask to apply. Remember the non-alpha zero areas are the parts that will display.\n\t\t * @param\toutput\t\tThe FlxSprite you wish the resulting image to be placed in (will adjust width/height of image)\n\t\t * \n\t\t * @return\tThe output FlxSprite for those that like chaining\n\t\t */\n\t\tpublic static function alphaMask(source:Class, mask:Class, output:FlxSprite):FlxSprite\n\t\t{\n\t\t\tvar data:BitmapData = (new source).bitmapData;\n\t\t\t\n\t\t\tdata.copyChannel((new mask).bitmapData, new Rectangle(0, 0, data.width, data.height), new Point, BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);\n\t\t\t\n\t\t\toutput.pixels = data;\n\t\t\t\n\t\t\treturn output;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Takes the image data from two FlxSprites and puts the resulting image into the output FlxSprite.<br>\n\t\t * Note: It assumes the source and mask are the same size. Different sizes may result in undesired results.<br>\n\t\t * It works by copying the source image (your picture) into the output sprite. Then it removes all areas of it that do not<br>\n\t\t * have an alpha color value in the mask image. So if you draw a big black circle in your mask with a transparent edge, you'll<br>\n\t\t * get a circular image appear. Look at the mask PNG files in the assets/pics folder for examples.\n\t\t * \n\t\t * @param\tsource\t\tThe source FlxSprite. Typically the one with the image / picture / texture in it.\n\t\t * @param\tmask\t\tThe FlxSprite containing the mask to apply. Remember the non-alpha zero areas are the parts that will display.\n\t\t * @param\toutput\t\tThe FlxSprite you wish the resulting image to be placed in (will adjust width/height of image)\n\t\t * \n\t\t * @return\tThe output FlxSprite for those that like chaining\n\t\t */\n\t\tpublic static function alphaMaskFlxSprite(source:FlxSprite, mask:FlxSprite, output:FlxSprite):FlxSprite\n\t\t{\n\t\t\tvar data:BitmapData = source.pixels;\n\t\t\t\n\t\t\tdata.copyChannel(mask.pixels, new Rectangle(0, 0, source.width, source.height), new Point, BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);\n\t\t\t\n\t\t\toutput.pixels = data;\n\t\t\t\n\t\t\treturn output;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Checks the x/y coordinates of the source FlxSprite and keeps them within the area of 0, 0, FlxG.width, FlxG.height (i.e. wraps it around the screen)\n\t\t * \n\t\t * @param\tsource\t\t\t\tThe FlxSprite to keep within the screen\n\t\t */\n\t\tpublic static function screenWrap(source:FlxSprite):void\n\t\t{\n\t\t\tif (source.x < 0)\n\t\t\t{\n\t\t\t\tsource.x = FlxG.width;\n\t\t\t}\n\t\t\telse if (source.x > FlxG.width)\n\t\t\t{\n\t\t\t\tsource.x = 0;\n\t\t\t}\n\t\t\t\n\t\t\tif (source.y < 0)\n\t\t\t{\n\t\t\t\tsource.y = FlxG.height;\n\t\t\t}\n\t\t\telse if (source.y > FlxG.height)\n\t\t\t{\n\t\t\t\tsource.y = 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Takes the bitmapData from the given source FlxSprite and rotates it 90 degrees clockwise.<br>\n\t\t * Can be useful if you need to control a sprite under rotation but it isn't drawn facing right.<br>\n\t\t * This change overwrites FlxSprite.pixels, but will not work with animated sprites.\n\t\t * \n\t\t * @param\tsource\t\tThe FlxSprite who's image data you wish to rotate clockwise\n\t\t */\n\t\tpublic static function rotateClockwise(source:FlxSprite):void\n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Aligns a set of FlxSprites so there is equal spacing between them\n\t\t * \n\t\t * @param\tsprites\t\t\t\tAn Array of FlxSprites\n\t\t * @param\tstartX\t\t\t\tThe base X coordinate to start the spacing from\n\t\t * @param\tstartY\t\t\t\tThe base Y coordinate to start the spacing from\n\t\t * @param\thorizontalSpacing\tThe amount of pixels between each sprite horizontally (default 0)\n\t\t * @param\tverticalSpacing\t\tThe amount of pixels between each sprite vertically (default 0)\n\t\t * @param\tspaceFromBounds\t\tIf set to true the h/v spacing values will be added to the width/height of the sprite, if false it will ignore this\n\t\t */\n\t\tpublic static function space(sprites:Array, startX:int, startY:int, horizontalSpacing:int = 0, verticalSpacing:int = 0, spaceFromBounds:Boolean = false):void\n\t\t{\n\t\t\tvar prevWidth:int = 0;\n\t\t\tvar prevHeight:int = 0;\n\t\t\t\n\t\t\tfor (var i:int = 0; i < sprites.length; i++)\n\t\t\t{\n\t\t\t\tvar sprite:FlxSprite = sprites[i];\n\t\t\t\t\n\t\t\t\tif (spaceFromBounds)\n\t\t\t\t{\n\t\t\t\t\tsprite.x = startX + prevWidth + (i * horizontalSpacing);\n\t\t\t\t\tsprite.y = startY + prevHeight + (i * verticalSpacing);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tsprite.x = startX + (i * horizontalSpacing);\n\t\t\t\t\tsprite.y = startY + (i * verticalSpacing);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Centers the given FlxSprite on the screen, either by the X axis, Y axis, or both\n\t\t * \n\t\t * @param\tsource\tThe FlxSprite to center\n\t\t * @param\txAxis\tBoolean true if you want it centered on X (i.e. in the middle of the screen)\n\t\t * @param\tyAxis\tBoolean\ttrue if you want it centered on Y\n\t\t * \n\t\t * @return\tThe FlxSprite for chaining\n\t\t */\n\t\tpublic static function screenCenter(source:FlxSprite, xAxis:Boolean = true, yAxis:Boolean = false):FlxSprite\n\t\t{\n\t\t\tif (xAxis)\n\t\t\t{\n\t\t\t\tsource.x = (FlxG.width / 2) - (source.width / 2);\n\t\t\t}\n\t\t\t\n\t\t\tif (yAxis)\n\t\t\t{\n\t\t\t\tsource.y = (FlxG.height / 2) - (source.height / 2);\n\t\t\t}\n\n\t\t\treturn source;\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxExplode.as",
    "content": "package org.flixel.plugin.photonstorm \n{\n\t/**\n\t * ...\n\t * @author Richard Davey\n\t */\n\tpublic class FlxExplode \n\t{\n\t\t\n\t\tpublic function FlxExplode() \n\t\t{\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxExtendedSprite.as",
    "content": "/**\n * FlxExtendedSprite\n * -- Part of the Flixel Power Tools set\n * \n * v1.4 Added MouseSpring, plugin checks and all the missing documentation\n * v1.3 Added Gravity, Friction and Tolerance support\n * v1.2 Now works fully with FlxMouseControl to be completely clickable and draggable!\n * v1.1 Added \"setMouseDrag\" and \"mouse over\" states\n * v1.0 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.4 - July 29th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.BaseTypes.MouseSpring;\n\n\t/**\n\t * An enhanced FlxSprite that is capable of receiving mouse clicks, being dragged and thrown, mouse springs, gravity and other useful things\n\t */\n\tpublic class FlxExtendedSprite extends FlxSprite\n\t{\n\t\t/**\n\t\t * Used by FlxMouseControl when multiple sprites overlap and register clicks, and you need to determine which sprite has priority\n\t\t */\n\t\tpublic var priorityID:uint;\n\t\t\n\t\t/**\n\t\t * If the mouse currently pressed down on this sprite?\n\t\t * @default false\n\t\t */\n\t\tpublic var isPressed:Boolean = false;\n\t\t\n\t\t/**\n\t\t * Is this sprite allowed to be clicked?\n\t\t * @default false\n\t\t */\n\t\tpublic var clickable:Boolean = false;\n\t\tprivate var clickOnRelease:Boolean = false;\n\t\tprivate var clickPixelPerfect:Boolean = false;\n\t\tprivate var clickPixelPerfectAlpha:uint;\n\t\tprivate var clickCounter:uint;\n\t\t\n\t\t/**\n\t\t * Function called when the mouse is pressed down on this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int\n\t\t * @default null\n\t\t */\n\t\tpublic var mousePressedCallback:Function;\n\t\t\n\t\t/**\n\t\t * Function called when the mouse is released from this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int\n\t\t * @default null\n\t\t */\n\t\tpublic var mouseReleasedCallback:Function;\n\t\t\n\t\t/**\n\t\t * Is this sprite allowed to be thrown?\n\t\t * @default false\n\t\t */\n\t\tpublic var throwable:Boolean = false;\n\t\tprivate var throwXFactor:int;\n\t\tprivate var throwYFactor:int;\n\t\t\n\t\t/**\n\t\t * Does this sprite have gravity applied to it?\n\t\t * @default false\n\t\t */\n\t\tpublic var hasGravity:Boolean = false;\n\t\t\n\t\t/**\n\t\t * The x axis gravity influence\n\t\t */\n\t\tpublic var gravityX:int;\n\t\t\n\t\t/**\n\t\t * The y axis gravity influence\n\t\t */\n\t\tpublic var gravityY:int;\n\t\t\n\t\t/**\n\t\t * Determines how quickly the Sprite come to rest on the walls if the sprite has x gravity enabled\n\t\t * @default 500\n\t\t */\n\t\tpublic var frictionX:Number;\n\t\t\n\t\t/**\n\t\t * Determines how quickly the Sprite come to rest on the ground if the sprite has y gravity enabled\n\t\t * @default 500\n\t\t */\n\t\tpublic var frictionY:Number;\n\t\t\n\t\t/**\n\t\t * If the velocity.x of this sprite falls between zero and this amount, then the sprite will come to a halt (have velocity.x set to zero)\n\t\t */\n\t\tpublic var toleranceX:Number;\n\t\t\n\t\t/**\n\t\t * If the velocity.y of this sprite falls between zero and this amount, then the sprite will come to a halt (have velocity.y set to zero)\n\t\t */\n\t\tpublic var toleranceY:Number;\n\t\t\n\t\t/**\n\t\t * Is this sprite being dragged by the mouse or not?\n\t\t * @default false\n\t\t */\n\t\tpublic var isDragged:Boolean = false;\n\t\t\n\t\t/**\n\t\t * Is this sprite allowed to be dragged by the mouse? true = yes, false = no\n\t\t * @default false\n\t\t */\n\t\tpublic var draggable:Boolean = false;\n\t\tprivate var dragPixelPerfect:Boolean = false;\n\t\tprivate var dragPixelPerfectAlpha:uint;\n\t\tprivate var dragOffsetX:int;\n\t\tprivate var dragOffsetY:int;\n\t\tprivate var dragFromPoint:Boolean;\n\t\tprivate var allowHorizontalDrag:Boolean = true;\n\t\tprivate var allowVerticalDrag:Boolean = true;\n\t\t\n\t\t/**\n\t\t * Function called when the mouse starts to drag this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int\n\t\t * @default null\n\t\t */\n\t\tpublic var mouseStartDragCallback:Function;\n\t\t\n\t\t/**\n\t\t * Function called when the mouse stops dragging this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int\n\t\t * @default null\n\t\t */\n\t\tpublic var mouseStopDragCallback:Function;\n\t\t\n\t\t/**\n\t\t * An FlxRect region of the game world within which the sprite is restricted during mouse drag\n\t\t * @default null\n\t\t */\n\t\tpublic var boundsRect:FlxRect = null;\n\t\t\n\t\t/**\n\t\t * An FlxSprite the bounds of which this sprite is restricted during mouse drag\n\t\t * @default null\n\t\t */\n\t\tpublic var boundsSprite:FlxSprite = null;\n\t\t\n\t\tprivate var snapOnDrag:Boolean = false;\n\t\tprivate var snapOnRelease:Boolean = false;\n\t\tprivate var snapX:int;\n\t\tprivate var snapY:int;\n\t\t\n\t\t/**\n\t\t * Is this sprite using a mouse spring?\n\t\t * @default false\n\t\t */\n\t\tpublic var hasMouseSpring:Boolean = false;\n\t\t\n\t\t/**\n\t\t * Will the Mouse Spring be active always (false) or only when pressed (true)\n\t\t * @default true\n\t\t */\n\t\tpublic var springOnPressed:Boolean = true;\n\t\t\n\t\t/**\n\t\t * The MouseSpring object which is used to tie this sprite to the mouse\n\t\t */\n\t\tpublic var mouseSpring:MouseSpring;\n\t\t\n\t\t/**\n\t\t * By default the spring attaches to the top left of the sprite. To change this location provide an x offset (in pixels)\n\t\t */\n\t\tpublic var springOffsetX:int;\n\t\t\n\t\t/**\n\t\t * By default the spring attaches to the top left of the sprite. To change this location provide a y offset (in pixels)\n\t\t */\n\t\tpublic var springOffsetY:int;\n\t\t\n\t\t/**\n\t\t * Creates a white 8x8 square <code>FlxExtendedSprite</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 FlxExtendedSprite(X:Number = 0, Y:Number = 0, SimpleGraphic:Class = null)\n\t\t{\n\t\t\tsuper(X, Y, SimpleGraphic);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Allow this Sprite to receive mouse clicks, the total number of times this sprite is clicked is stored in this.clicks<br>\n\t\t * You can add callbacks via mousePressedCallback and mouseReleasedCallback\n\t\t * \n\t\t * @param\tonRelease\t\t\tRegister the click when the mouse is pressed down (false) or when it's released (true). Note that callbacks still fire regardless of this setting.\n\t\t * @param\tpixelPerfect\t\tIf true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box.\n\t\t * @param\talphaThreshold\t\tIf using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255)\n\t\t */\n\t\tpublic function enableMouseClicks(onRelease:Boolean, pixelPerfect:Boolean = false, alphaThreshold:uint = 255):void\n\t\t{\n\t\t\tif (FlxG.getPlugin(FlxMouseControl) == null)\n\t\t\t{\n\t\t\t\tthrow Error(\"FlxExtendedSprite.enableMouseClicks called but FlxMouseControl plugin not activated\");\n\t\t\t}\n\t\t\t\n\t\t\tclickable = true;\n\t\t\t\n\t\t\tclickOnRelease = onRelease;\n\t\t\tclickPixelPerfect = pixelPerfect;\n\t\t\tclickPixelPerfectAlpha = alphaThreshold;\n\t\t\tclickCounter = 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops this sprite from checking for mouse clicks and clears any set callbacks\n\t\t */\n\t\tpublic function disableMouseClicks():void\n\t\t{\n\t\t\tclickable = false;\n\t\t\tmousePressedCallback = null;\n\t\t\tmouseReleasedCallback = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns the number of times this sprite has been clicked (can be reset by setting clicks to zero)\n\t\t */\n\t\tpublic function get clicks():uint\n\t\t{\n\t\t\treturn clickCounter;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the number of clicks this item has received. Usually you'd only set it to zero.\n\t\t */\n\t\tpublic function set clicks(i:uint):void\n\t\t{\n\t\t\tclickCounter = i;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback\n\t\t * \n\t\t * @param\tlockCenter\t\t\tIf false the Sprite will drag from where you click it. If true it will center itself to the tip of the mouse pointer.\n\t\t * @param\tpixelPerfect\t\tIf true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box.\n\t\t * @param\talphaThreshold\t\tIf using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255)\n\t\t * @param\tboundsRect\t\t\tIf you want to restrict the drag of this sprite to a specific FlxRect, pass the FlxRect here, otherwise it's free to drag anywhere\n\t\t * @param\tboundsSprite\t\tIf you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here\n\t\t */\n\t\tpublic function enableMouseDrag(lockCenter:Boolean = false, pixelPerfect:Boolean = false, alphaThreshold:uint = 255, boundsRect:FlxRect = null, boundsSprite:FlxSprite = null):void\n\t\t{\n\t\t\tif (FlxG.getPlugin(FlxMouseControl) == null)\n\t\t\t{\n\t\t\t\tthrow Error(\"FlxExtendedSprite.enableMouseDrag called but FlxMouseControl plugin not activated\");\n\t\t\t}\n\t\t\t\n\t\t\tdraggable = true;\n\t\t\t\n\t\t\tdragFromPoint = lockCenter;\n\t\t\tdragPixelPerfect = pixelPerfect;\n\t\t\tdragPixelPerfectAlpha = alphaThreshold;\n\t\t\t\n\t\t\tif (boundsRect)\n\t\t\t{\n\t\t\t\tthis.boundsRect = boundsRect;\n\t\t\t}\n\t\t\t\n\t\t\tif (boundsSprite)\n\t\t\t{\n\t\t\t\tthis.boundsSprite = boundsSprite;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops this sprite from being able to be dragged. If it is currently the target of an active drag it will be stopped immediately. Also disables any set callbacks.\n\t\t */\n\t\tpublic function disableMouseDrag():void\n\t\t{\n\t\t\tif (isDragged)\n\t\t\t{\n\t\t\t\tFlxMouseControl.dragTarget = null;\n\t\t\t\tFlxMouseControl.isDragging = false;\n\t\t\t}\n\t\t\t\n\t\t\tisDragged = false;\n\t\t\tdraggable = false;\n\t\t\t\n\t\t\tmouseStartDragCallback = null;\n\t\t\tmouseStopDragCallback = null;\n\t\t}\n\t\t \n\t\t/**\n\t\t* Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move!\n\t\t * \n\t\t * @param\tallowHorizontal\t\tTo enable the sprite to be dragged horizontally set to true, otherwise false\n\t\t * @param\tallowVertical\t\tTo enable the sprite to be dragged vertically set to true, otherwise false\n\t\t */\n\t\tpublic function setDragLock(allowHorizontal:Boolean = true, allowVertical:Boolean = true):void\n\t\t{\n\t\t\tallowHorizontalDrag = allowHorizontal;\n\t\t\tallowVerticalDrag = allowVertical;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Make this Sprite throwable by the mouse. The sprite is thrown only when the mouse button is released.\n\t\t * \n\t\t * @param\txFactor\t\tThe sprites velocity is set to FlxMouseControl.speedX * xFactor. Try a value around 50+\n\t\t * @param\tyFactor\t\tThe sprites velocity is set to FlxMouseControl.speedY * yFactor. Try a value around 50+\n\t\t */\n\t\tpublic function enableMouseThrow(xFactor:int, yFactor:int):void\n\t\t{\n\t\t\tif (FlxG.getPlugin(FlxMouseControl) == null)\n\t\t\t{\n\t\t\t\tthrow Error(\"FlxExtendedSprite.enableMouseThrow called but FlxMouseControl plugin not activated\");\n\t\t\t}\n\t\t\t\n\t\t\tthrowable = true;\n\t\t\tthrowXFactor = xFactor;\n\t\t\tthrowYFactor = yFactor;\n\t\t\t\n\t\t\tif (clickable == false && draggable == false)\n\t\t\t{\n\t\t\t\tclickable = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops this sprite from being able to be thrown. If it currently has velocity this is NOT removed from it.\n\t\t */\n\t\tpublic function disableMouseThrow():void\n\t\t{\n\t\t\tthrowable = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Make this Sprite snap to the given grid either during drag or when it's released.\n\t\t * For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels.\n\t\t * \n\t\t * @param\tsnapX\t\tThe width of the grid cell in pixels\n\t\t * @param\tsnapY\t\tThe height of the grid cell in pixels\n\t\t * @param\tonDrag\t\tIf true the sprite will snap to the grid while being dragged\n\t\t * @param\tonRelease\tIf true the sprite will snap to the grid when released\n\t\t */\n\t\tpublic function enableMouseSnap(snapX:int, snapY:int, onDrag:Boolean = true, onRelease:Boolean = false):void\n\t\t{\n\t\t\tsnapOnDrag = onDrag;\n\t\t\tsnapOnRelease = onRelease;\n\t\t\tthis.snapX = snapX;\n\t\t\tthis.snapY = snapY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops the sprite from snapping to a grid during drag or release.\n\t\t */\n\t\tpublic function disableMouseSnap():void\n\t\t{\n\t\t\tsnapOnDrag = false;\n\t\t\tsnapOnRelease = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adds a simple spring between the mouse and this Sprite. The spring can be activated either when the mouse is pressed (default), or enabled all the time.\n\t\t * Note that nearly always the Spring will over-ride any other motion setting the sprite has (like velocity or gravity)\n\t\t * \n\t\t * @param\tonPressed\t\t\ttrue if the spring should only be active when the mouse is pressed down on this sprite\n\t\t * @param\tretainVelocity\t\ttrue to retain the velocity of the spring when the mouse is released, or false to clear it\n\t\t * @param\ttension\t\t\t\tThe tension of the spring, smaller numbers create springs closer to the mouse pointer\n\t\t * @param\tfriction\t\t\tThe friction applied to the spring as it moves\n\t\t * @param\tgravity\t\t\t\tThe gravity controls how far \"down\" the spring hangs (use a negative value for it to hang up!)\n\t\t * \n\t\t * @return\tThe MouseSpring object if you wish to perform further chaining on it. Also available via FlxExtendedSprite.mouseSpring\n\t\t */ \n\t\tpublic function enableMouseSpring(onPressed:Boolean = true, retainVelocity:Boolean = false, tension:Number = 0.1, friction:Number = 0.95, gravity:Number = 0):MouseSpring\n\t\t{\n\t\t\tif (FlxG.getPlugin(FlxMouseControl) == null)\n\t\t\t{\n\t\t\t\tthrow Error(\"FlxExtendedSprite.enableMouseSpring called but FlxMouseControl plugin not activated\");\n\t\t\t}\n\t\t\t\n\t\t\thasMouseSpring = true;\n\t\t\tspringOnPressed = onPressed;\n\t\t\t\n\t\t\tif (mouseSpring == null)\n\t\t\t{\n\t\t\t\tmouseSpring = new MouseSpring(this, retainVelocity, tension, friction, gravity);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmouseSpring.tension = tension;\n\t\t\t\tmouseSpring.friction = friction;\n\t\t\t\tmouseSpring.gravity = gravity;\n\t\t\t}\n\t\t\t\n\t\t\tif (clickable == false && draggable == false)\n\t\t\t{\n\t\t\t\tclickable = true;\n\t\t\t}\n\t\t\t\n\t\t\treturn mouseSpring;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops the sprite to mouse spring from being active\n\t\t */\n\t\tpublic function disableMouseSpring():void\n\t\t{\n\t\t\thasMouseSpring = false;\n\t\t\t\n\t\t\tmouseSpring = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The spring x coordinate in game world space. Consists of sprite.x + springOffsetX\n\t\t */\n\t\tpublic function get springX():int\n\t\t{\n\t\t\treturn x + springOffsetX;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The spring y coordinate in game world space. Consists of sprite.y + springOffsetY\n\t\t */\n\t\tpublic function get springY():int\n\t\t{\n\t\t\treturn y + springOffsetY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Core update loop\n\t\t */\n\t\toverride public function update():void\n\t\t{\n\t\t\tif (draggable && isDragged)\n\t\t\t{\n\t\t\t\tupdateDrag();\n\t\t\t}\n\t\t\t\n\t\t\tif (isPressed == false && FlxG.mouse.justPressed())\n\t\t\t{\n\t\t\t\tcheckForClick();\n\t\t\t}\n\t\t\t\n\t\t\tif (hasGravity)\n\t\t\t{\n\t\t\t\tupdateGravity();\n\t\t\t}\n\t\t\t\n\t\t\tif (hasMouseSpring)\n\t\t\t{\n\t\t\t\tif (springOnPressed == false)\n\t\t\t\t{\n\t\t\t\t\tmouseSpring.update();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (isPressed == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tmouseSpring.update();\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tmouseSpring.reset();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tsuper.update();\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by update, applies friction if the sprite has gravity to stop jittery motion when slowing down\n\t\t */\n\t\tprivate function updateGravity():void\n\t\t{\n\t\t\t//\tA sprite can have horizontal and/or vertical gravity in each direction (positiive / negative)\n\t\t\t\n\t\t\t//\tFirst let's check the x movement\n\t\t\t\n\t\t\tif (velocity.x != 0)\n\t\t\t{\n\t\t\t\tif (acceleration.x < 0)\n\t\t\t\t{\n\t\t\t\t\t//\tGravity is pulling them left\n\t\t\t\t\tif (touching & WALL)\n\t\t\t\t\t{\n\t\t\t\t\t\tdrag.y = frictionY;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif ((wasTouching & WALL) == false)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (velocity.x < toleranceX)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//trace(\"(left) velocity.x\", velocity.x, \"stopped via tolerance break\", toleranceX);\n\t\t\t\t\t\t\t\tvelocity.x = 0;\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\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdrag.y = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (acceleration.x > 0)\n\t\t\t\t{\n\t\t\t\t\t//\tGravity is pulling them right\n\t\t\t\t\tif (touching & WALL)\n\t\t\t\t\t{\n\t\t\t\t\t\t//\tStop them sliding like on ice\n\t\t\t\t\t\tdrag.y = frictionY;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif ((wasTouching & WALL) == false)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (velocity.x > -toleranceX)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//trace(\"(right) velocity.x\", velocity.x, \"stopped via tolerance break\", toleranceX);\n\t\t\t\t\t\t\t\tvelocity.x = 0;\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\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdrag.y = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//\tNow check the y movement\n\t\t\t\n\t\t\tif (velocity.y != 0)\n\t\t\t{\n\t\t\t\tif (acceleration.y < 0)\n\t\t\t\t{\n\t\t\t\t\t//\tGravity is pulling them up (velocity is negative)\n\t\t\t\t\tif (touching & CEILING)\n\t\t\t\t\t{\n\t\t\t\t\t\tdrag.x = frictionX;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif ((wasTouching & CEILING) == false)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (velocity.y < toleranceY)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//trace(\"(down) velocity.y\", velocity.y, \"stopped via tolerance break\", toleranceY);\n\t\t\t\t\t\t\t\tvelocity.y = 0;\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\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdrag.x = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (acceleration.y > 0)\n\t\t\t\t{\n\t\t\t\t\t//\tGravity is pulling them down (velocity is positive)\n\t\t\t\t\tif (touching & FLOOR)\n\t\t\t\t\t{\n\t\t\t\t\t\t//\tStop them sliding like on ice\n\t\t\t\t\t\tdrag.x = frictionX;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif ((wasTouching & FLOOR) == false)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (velocity.y > -toleranceY)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//trace(\"(down) velocity.y\", velocity.y, \"stopped via tolerance break\", toleranceY);\n\t\t\t\t\t\t\t\tvelocity.y = 0;\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\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdrag.x = 0;\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 * Updates the Mouse Drag on this Sprite.\n\t\t */\n\t\tprivate function updateDrag():void\n\t\t{\n\t\t\t//FlxG.mouse.getWorldPosition(null, tempPoint);\n\t\t\t\n\t\t\tif (allowHorizontalDrag)\n\t\t\t{\n\t\t\t\tx = int(FlxG.mouse.x) - dragOffsetX;\n\t\t\t}\n\t\t\t\n\t\t\tif (allowVerticalDrag)\n\t\t\t{\n\t\t\t\ty = int(FlxG.mouse.y) - dragOffsetY;\n\t\t\t}\n\t\t\t\n\t\t\tif (boundsRect)\n\t\t\t{\n\t\t\t\tcheckBoundsRect();\n\t\t\t}\n\n\t\t\tif (boundsSprite)\n\t\t\t{\n\t\t\t\tcheckBoundsSprite();\n\t\t\t}\n\t\t\t\n\t\t\tif (snapOnDrag)\n\t\t\t{\n\t\t\t\tx = int(Math.floor(x / snapX) * snapX);\n\t\t\t\ty = int(Math.floor(y / snapY) * snapY);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Checks if the mouse is over this sprite and pressed, then does a pixel perfect check if needed and adds it to the FlxMouseControl check stack\n\t\t */\n\t\tprivate function checkForClick():void\n\t\t{\n\t\t\tif (mouseOver && FlxG.mouse.justPressed())\n\t\t\t{\n\t\t\t\t//\tIf we don't need a pixel perfect check, then don't bother running one! By this point we know the mouse is over the sprite already\n\t\t\t\tif (clickPixelPerfect == false && dragPixelPerfect == false)\n\t\t\t\t{\n\t\t\t\t\tFlxMouseControl.addToStack(this);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (clickPixelPerfect && FlxCollision.pixelPerfectPointCheck(FlxG.mouse.x, FlxG.mouse.y, this, clickPixelPerfectAlpha))\n\t\t\t\t{\n\t\t\t\t\tFlxMouseControl.addToStack(this);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (dragPixelPerfect && FlxCollision.pixelPerfectPointCheck(FlxG.mouse.x, FlxG.mouse.y, this, dragPixelPerfectAlpha))\n\t\t\t\t{\n\t\t\t\t\tFlxMouseControl.addToStack(this);\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 * Called by FlxMouseControl when this sprite is clicked. Should not usually be called directly.\n\t\t */\n\t\tpublic function mousePressedHandler():void\n\t\t{\n\t\t\tisPressed = true;\n\t\t\t\n\t\t\tif (clickable && clickOnRelease == false)\n\t\t\t{\n\t\t\t\tclickCounter++;\n\t\t\t}\n\t\t\t\n\t\t\tif (mousePressedCallback is Function)\n\t\t\t{\n\t\t\t\tmousePressedCallback.apply(null, [ this, mouseX, mouseY ] );\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by FlxMouseControl when this sprite is released from a click. Should not usually be called directly.\n\t\t */\n\t\tpublic function mouseReleasedHandler():void\n\t\t{\n\t\t\tisPressed = false;\n\t\t\t\n\t\t\tif (isDragged)\n\t\t\t{\n\t\t\t\tstopDrag();\n\t\t\t}\n\t\t\t\n\t\t\tif (clickable && clickOnRelease == true)\n\t\t\t{\n\t\t\t\tclickCounter++;\n\t\t\t}\n\t\t\t\n\t\t\tif (throwable)\n\t\t\t{\n\t\t\t\tvelocity.x = FlxMouseControl.speedX * throwXFactor;\n\t\t\t\tvelocity.y = FlxMouseControl.speedY * throwYFactor;\n\t\t\t}\n\t\t\t\n\t\t\tif (mouseReleasedCallback is Function)\n\t\t\t{\n\t\t\t\tmouseReleasedCallback.apply(null, [ this, mouseX, mouseY ] );\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by FlxMouseControl when Mouse Drag starts on this Sprite. Should not usually be called directly.\n\t\t */\n\t\tpublic function startDrag():void\n\t\t{\n\t\t\tisDragged = true;\n\t\t\t\n\t\t\tif (dragFromPoint == false)\n\t\t\t{\n\t\t\t\tdragOffsetX = int(FlxG.mouse.x) - x;\n\t\t\t\tdragOffsetY = int(FlxG.mouse.y) - y;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//\tMove the sprite to the middle of the mouse\n\t\t\t\tdragOffsetX = (frameWidth / 2);\n\t\t\t\tdragOffsetY = (frameHeight / 2);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Bounds Rect check for the sprite drag\n\t\t */\n\t\tprivate function checkBoundsRect():void\n\t\t{\n\t\t\tif (x < boundsRect.left)\n\t\t\t{\n\t\t\t\tx = boundsRect.x;\n\t\t\t}\n\t\t\telse if ((x + width) > boundsRect.right)\n\t\t\t{\n\t\t\t\tx = boundsRect.right - width;\n\t\t\t}\n\t\t\t\n\t\t\tif (y < boundsRect.top)\n\t\t\t{\n\t\t\t\ty = boundsRect.top;\n\t\t\t}\n\t\t\telse if ((y + height) > boundsRect.bottom)\n\t\t\t{\n\t\t\t\ty = boundsRect.bottom - height;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Parent Sprite Bounds check for the sprite drag\n\t\t */\n\t\tprivate function checkBoundsSprite():void\n\t\t{\n\t\t\tif (x < boundsSprite.x)\n\t\t\t{\n\t\t\t\tx = boundsSprite.x;\n\t\t\t}\n\t\t\telse if ((x + width) > (boundsSprite.x + boundsSprite.width))\n\t\t\t{\n\t\t\t\tx = (boundsSprite.x + boundsSprite.width) - width;\n\t\t\t}\n\t\t\t\n\t\t\tif (y < boundsSprite.y)\n\t\t\t{\n\t\t\t\ty = boundsSprite.y;\n\t\t\t}\n\t\t\telse if ((y + height) > (boundsSprite.y + boundsSprite.height))\n\t\t\t{\n\t\t\t\ty = (boundsSprite.y + boundsSprite.height) - height;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called by FlxMouseControl when Mouse Drag is stopped on this Sprite. Should not usually be called directly.\n\t\t */\n\t\tpublic function stopDrag():void\n\t\t{\n\t\t\tisDragged = false;\n\t\t\t\n\t\t\tif (snapOnRelease)\n\t\t\t{\n\t\t\t\tx = int(Math.floor(x / snapX) * snapX);\n\t\t\t\ty = int(Math.floor(y / snapY) * snapY);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Gravity can be applied to the sprite, pulling it in any direction. Gravity is given in pixels per second and is applied as acceleration.\n\t\t * If you don't want gravity for a specific direction pass a value of zero. To cancel it entirely pass both values as zero.\n\t\t * \n\t\t * @param\tgravityX\tA positive value applies gravity dragging the sprite to the right. A negative value drags the sprite to the left. Zero disables horizontal gravity.\n\t\t * @param\tgravityY\tA positive value applies gravity dragging the sprite down. A negative value drags the sprite up. Zero disables vertical gravity.\n\t\t * @param\tfrictionX\tThe amount of friction applied to the sprite if it hits a wall. Allows it to come to a stop without constantly jittering.\n\t\t * @param\tfrictionY\tThe amount of friction applied to the sprite if it hits the floor/roof. Allows it to come to a stop without constantly jittering.\n\t\t * @param\ttoleranceX\tIf the velocity.x of the sprite falls between 0 and +- this value, it is set to stop (velocity.x = 0)\n\t\t * @param\ttoleranceY\tIf the velocity.y of the sprite falls between 0 and +- this value, it is set to stop (velocity.y = 0)\n\t\t */\n\t\tpublic function setGravity(gravityX:int, gravityY:int, frictionX:Number = 500, frictionY:Number = 500, toleranceX:Number = 10, toleranceY:Number = 10):void\n\t\t{\n\t\t\thasGravity = true;\n\t\t\t\n\t\t\tthis.gravityX = gravityX;\n\t\t\tthis.gravityY = gravityY;\n\t\t\t\n\t\t\tthis.frictionX = frictionX;\n\t\t\tthis.frictionY = frictionY;\n\t\t\t\n\t\t\tthis.toleranceX = toleranceX;\n\t\t\tthis.toleranceY = toleranceY;\n\t\t\t\n\t\t\tif (gravityX == 0 && gravityY == 0)\n\t\t\t{\n\t\t\t\thasGravity = false;\n\t\t\t}\n\t\t\t\n\t\t\tacceleration.x = gravityX;\n\t\t\tacceleration.y = gravityY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Switches the gravity applied to the sprite. If gravity was +400 Y (pulling them down) this will swap it to -400 Y (pulling them up)<br>\n\t\t * To reset call flipGravity again\n\t\t */\n\t\tpublic function flipGravity():void\n\t\t{\n\t\t\tif (gravityX && gravityX != 0)\n\t\t\t{\n\t\t\t\tgravityX = -gravityX;\n\t\t\t\tacceleration.x = gravityX;\n\t\t\t}\n\t\t\t\n\t\t\tif (gravityY && gravityY != 0)\n\t\t\t{\n\t\t\t\tgravityY = -gravityY;\n\t\t\t\tacceleration.y = gravityY;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns an FlxPoint consisting of this sprites world x/y coordinates\n\t\t */\n\t\tpublic function get point():FlxPoint\n\t\t{\n\t\t\treturn _point;\n\t\t}\n\t\t\n\t\tpublic function set point(p:FlxPoint):void\n\t\t{\n\t\t\t_point = p;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Return true if the mouse is over this Sprite, otherwise false. Only takes the Sprites bounding box into consideration and does not check if there \n\t\t * are other sprites potentially on-top of this one. Check the value of this.isPressed if you need to know if the mouse is currently clicked on this sprite.\n\t\t */\n\t\tpublic function get mouseOver():Boolean\n\t\t{\n\t\t\treturn FlxMath.pointInCoordinates(FlxG.mouse.x, FlxG.mouse.y, x, y, width, height);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns how many horizontal pixels the mouse pointer is inside this sprite from the top left corner. Returns -1 if outside.\n\t\t */\n\t\tpublic function get mouseX():int\n\t\t{\n\t\t\tif (mouseOver)\n\t\t\t{\n\t\t\t\treturn FlxG.mouse.x - x;\n\t\t\t}\n\t\t\t\n\t\t\treturn -1;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns how many vertical pixels the mouse pointer is inside this sprite from the top left corner. Returns -1 if outside.\n\t\t */\n\t\tpublic function get mouseY():int\n\t\t{\n\t\t\tif (mouseOver)\n\t\t\t{\n\t\t\t\treturn FlxG.mouse.y - y;\n\t\t\t}\n\t\t\t\n\t\t\treturn -1;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns an FlxRect consisting of the bounds of this Sprite.\n\t\t */\n\t\tpublic function get rect():FlxRect\n\t\t{\n\t\t\t_rect.x = x;\n\t\t\t_rect.y = y;\n\t\t\t_rect.width = width;\n\t\t\t_rect.height = height;\n\t\t\t\n\t\t\treturn _rect;\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxFlectrum.as",
    "content": "/**\n * Flectrum version 1.0 by Christian Corti - Jiggled around a bit to work with Flixel by Richard Davey, 29th July 2011\n * Neoart, Costa Rica\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR\n * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n *\n */\n\npackage org.flixel.plugin.photonstorm\n{\n\timport flash.display.*;\n\timport flash.events.*;\n\timport flash.geom.*;\n\timport flash.utils.*;\n\timport flash.utils.getTimer;\n\timport neoart.flectrum.SoundEx;\n\timport org.flixel.FlxGroup;\n\timport org.flixel.FlxSprite;\n\t\n\tpublic class FlxFlectrum extends FlxGroup\n\t{\n\t\tpublic static const UP:String = \"up\";\n\t\tpublic static const LEFT:String = \"left\";\n\t\tpublic static const DOWN:String = \"down\";\n\t\tpublic static const RIGHT:String = \"right\";\n\t\t\n\t\tpublic static const METER:String = \"meter\";\n\t\t//public static const DECAY:String = \"decay\"; // currently broken\n\t\tpublic static const PEAKS:String = \"peaks\";\n\t\t\n\t\tpublic var backgroundBeat:Boolean;\n\t\t\n\t\tpublic var back:FlxSprite;\n\t\tpublic var front:FlxSprite;\n\n\t\tprotected var currentPeak:int;\n\t\tprotected var lastPeak:int;\n\t\t\n\t\tprotected var canvas:Sprite;\n\t\tprotected var timer:Timer;\n\t\tprotected var meter:BitmapData;\n\t\tprotected var background:Bitmap;\n\t\tprotected var foreground:Bitmap;\n\t\tprotected var buffer:BitmapData;\n\t\tprotected var input:BitmapData;\n\t\tprotected var output:BitmapData;\n\t\t\n\t\tprotected var levels:Vector.<Number>;\n\t\tprotected var spectrum:Vector.<Number>;\n\t\tprotected var destPoint:Point;\n\t\tprotected var sourceRect:Rectangle;\n\t\tprotected var sectionWidth:int;\n\t\tprotected var sectionHeight:int;\n\t\tprotected var realHeight:int;\n\t\t\n\t\tprotected var m_soundEx:SoundEx;\n\t\tprotected var m_direction:String = UP;\n\t\tprotected var m_mode:String = PEAKS;\n\t\tprotected var m_columns:int;\n\t\tprotected var m_columnSize:int = 10;\n\t\tprotected var m_columnSpacing:int = 2;\n\t\tprotected var m_rows:int;\n\t\tprotected var m_rowSize:int = 3;\n\t\tprotected var m_rowSpacing:int = 1;\n\t\tprotected var m_showBackground:Boolean = true;\n\t\tprotected var m_backgroundAlpha:Number = 0.2;\n\t\tprotected var m_decay:Number = 0.02;\n\t\tprotected var m_decayAlpha:uint = 0xd0000000;\n\t\tprotected var m_peaksAlpha:uint = 0xff000000;\n\t\t\n\t\tprotected var m_colors:Array = [0xff3939, 0xffb320, 0xfff820, 0x50d020];\n\t\tprotected var m_alphas:Array = [1, 1, 1, 1];\n\t\tprotected var m_ratios:Array = [20, 105, 145, 250];\n\t\t\n\t\tpublic function FlxFlectrum()\n\t\t{\n\t\t\tsuper(2);\n\t\t}\n\t\t\n\t\tpublic function init(x:int, y:int, soundEx:SoundEx, columns:int = 15, columnSize:int = 10, columnSpacing:int = 0, rows:int = 32, rowSize:int = 3, rowSpacing:int = 0):void\n\t\t{\n\t\t\tthis.soundEx = soundEx;\n\t\t\t\n\t\t\tm_columns = columns;\n\t\t\tm_columnSize = columnSize;\n\t\t\tm_columnSpacing = columnSpacing;\n\t\t\t\n\t\t\tm_rows = rows;\n\t\t\tm_rowSize = rowSize;\n\t\t\tm_rowSpacing = rowSpacing;\n\t\t\t\n\t\t\tfront = new FlxSprite().makeGraphic(1, 1, 0x0);\n\t\t\tfront.solid = false;\n\t\t\t\n\t\t\tback = new FlxSprite().makeGraphic(1, 1, 0x0);\n\t\t\tback.solid = false;\n\t\t\tback.visible = false;\n\t\t\t\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t\t\n\t\t\tcanvas = new Sprite;\n\t\t\tbackground = new Bitmap(null, \"always\", true);\n\t\t\tforeground = new Bitmap(null, \"always\", true);\n\t\t\tlevels = new Vector.<Number>;\n\t\t\tspectrum = new Vector.<Number>;\n\t\t\tdestPoint = new Point();\n\t\t\tsourceRect = new Rectangle();\n\t\t\t\n\t\t\tcurrentPeak = 0;\n\t\t\tlastPeak = 0;\n\t\t\t\n\t\t\ttimer = new Timer(45);\n\t\t\ttimer.addEventListener(TimerEvent.TIMER, peaksHandler);\n\t\t\treset();\n\t\t\t\n\t\t\tadd(back);\n\t\t\tadd(front);\n\t\t}\n\t\t\n\t\tpublic function useBitmap(image:Class):void\n\t\t{\n\t\t\tmeter = Bitmap(new image).bitmapData.clone();\n\t\t\tclone();\n\t\t}\n\t\t\n\t\tpublic function useDraw():void\n\t\t{\n\t\t\tmeter.dispose();\n\t\t\tmeter = null;\n\t\t\tdrawDisplay();\n\t\t}\n\t\t\n\t\tprotected function reset():void\n\t\t{\n\t\t\ttimer.reset();\n\t\t\tlevels.length = m_columns;\n\t\t\tfor (var i:int = 0; i < m_columns; ++i)\n\t\t\t\tlevels[i] = 0;\n\t\t\t\n\t\t\tbackground.alpha = m_backgroundAlpha;\n\t\t\tbackground.rotation = 0;\n\t\t\tbackground.x = 0;\n\t\t\tbackground.y = 0;\n\t\t\tforeground.rotation = 0;\n\t\t\tforeground.x = 0;\n\t\t\tforeground.y = 0;\n\t\t\tif (meter)\n\t\t\t\tclone();\n\t\t\telse\n\t\t\t\tdrawDisplay();\n\t\t}\n\t\t\n\t\tpublic function set x(x:int):void\n\t\t{\n\t\t\tback.x = x;\n\t\t\tfront.x = x;\n\t\t}\n\t\t\n\t\tpublic function get x():int\n\t\t{\n\t\t\treturn front.x;\n\t\t}\n\t\t\n\t\tpublic function set y(y:int):void\n\t\t{\n\t\t\tback.y = y;\n\t\t\tfront.y = y;\n\t\t}\n\t\t\n\t\tpublic function get y():int\n\t\t{\n\t\t\treturn front.y;\n\t\t}\n\t\t\n\t\tprotected function start():void\n\t\t{\n\t\t\tif (!soundEx)\n\t\t\t\treturn;\n\t\t\ttimer.reset();\n\t\t\ttimer.start();\n\t\t}\n\t\t\n\t\tprotected function clone():void\n\t\t{\n\t\t\tsectionWidth = meter.width + m_columnSpacing;\n\t\t\tsectionHeight = m_rowSize + m_rowSpacing;\n\t\t\trealHeight = meter.height + m_rowSpacing;\n\t\t\t\n\t\t\tvar h:int = meter.height, i:int, w:int = m_columns * sectionWidth - m_columnSpacing;\n\t\t\t\n\t\t\toutput = new BitmapData(w, h, true, 0);\n\t\t\tbuffer = output.clone();\n\t\t\toutput.lock();\n\t\t\tdestPoint.x = 0;\n\t\t\t\n\t\t\tfor (i = 0; i < m_columns; ++i)\n\t\t\t{\n\t\t\t\toutput.copyPixels(meter, meter.rect, destPoint);\n\t\t\t\tdestPoint.x += sectionWidth;\n\t\t\t}\n\t\t\t\n\t\t\tm_rows = realHeight / sectionHeight;\n\t\t\t\n\t\t\tif (m_rowSpacing > 0)\n\t\t\t{\n\t\t\t\tsourceRect.width = w;\n\t\t\t\tsourceRect.height = m_rowSpacing;\n\t\t\t\tsourceRect.y = h - sectionHeight;\n\t\t\t\t\n\t\t\t\tfor (i = 0; i < m_rows; ++i)\n\t\t\t\t{\n\t\t\t\t\toutput.fillRect(sourceRect, 0);\n\t\t\t\t\tsourceRect.y -= sectionHeight;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\toutput.unlock();\n\t\t\tdestPoint.x = 0;\n\t\t\tsourceRect.width = m_columnSize = meter.width;\n\t\t\t\n\t\t\tinput = buffer.clone();\n\t\t\tinput.threshold(output, output.rect, destPoint, \"==\", 0xff000000, 0x00ffffff, 0xffffffff, true);\n\t\t\toutput.fillRect(output.rect, 0);\n\t\t\t\n\t\t\tbackground.bitmapData = input;\n\t\t\t\n\t\t\tforeground.bitmapData = output;\n\t\t\t\n\t\t\tif (m_direction != UP)\n\t\t\t\tdirection = m_direction;\n\t\t}\n\t\t\n\t\tpublic function get width():int\n\t\t{\n\t\t\treturn output.width;\n\t\t}\n\t\t\n\t\tpublic function get height():int\n\t\t{\n\t\t\treturn output.height;\n\t\t}\n\t\t\n\t\tprotected function drawDisplay():void\n\t\t{\n\t\t\tsectionWidth = m_columnSize + m_columnSpacing;\n\t\t\tsectionHeight = m_rowSize + m_rowSpacing;\n\t\t\trealHeight = m_rows * sectionHeight;\n\t\t\t\n\t\t\tvar h:int = realHeight - m_rowSpacing, i:int, matrix:Matrix, p:int = m_rowSize, w:int = m_columns * sectionWidth - m_columnSpacing;\n\t\t\t\n\t\t\tif (m_colors.length < 2)\n\t\t\t{\n\t\t\t\tcanvas.graphics.beginFill(m_colors[0], m_alphas[0]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmatrix = new Matrix();\n\t\t\t\tmatrix.createGradientBox(w, h, Math.PI * 0.5, 0, 0);\n\t\t\t\tcanvas.graphics.beginGradientFill(GradientType.LINEAR, m_colors, m_alphas, m_ratios, matrix, SpreadMethod.PAD, InterpolationMethod.LINEAR_RGB);\n\t\t\t}\n\t\t\tcanvas.graphics.drawRect(0, 0, w, h);\n\t\t\tcanvas.graphics.endFill();\n\t\t\t\n\t\t\tfor (i = 0; i < m_rows; ++i)\n\t\t\t{\n\t\t\t\tcanvas.graphics.beginFill(0, 1);\n\t\t\t\tcanvas.graphics.drawRect(0, p, w, m_rowSpacing);\n\t\t\t\tcanvas.graphics.endFill();\n\t\t\t\tp += sectionHeight;\n\t\t\t}\n\t\t\tp = m_columnSize;\n\t\t\t\n\t\t\tfor (i = 1; i < m_columns; ++i)\n\t\t\t{\n\t\t\t\tcanvas.graphics.beginFill(0, 1);\n\t\t\t\tcanvas.graphics.drawRect(p, 0, m_columnSpacing, h);\n\t\t\t\tcanvas.graphics.endFill();\n\t\t\t\tp += sectionWidth;\n\t\t\t}\n\t\t\toutput = new BitmapData(w, h, true, 0);\n\t\t\tbuffer = output.clone();\n\t\t\toutput.draw(canvas);\n\t\t\tcanvas.graphics.clear();\n\t\t\t\n\t\t\tinput = buffer.clone();\n\t\t\tinput.threshold(output, output.rect, destPoint, \"==\", 0xff000000, 0x00ffffff, 0xffffffff, true);\n\t\t\toutput.fillRect(output.rect, 0);\n\t\t\t\n\t\t\tbackground.bitmapData = input;\n\t\t\t\n\t\t\tforeground.bitmapData = output;\n\t\t\t\n\t\t\tsourceRect.width = m_columnSize;\n\t\t\t\n\t\t\tif (m_direction != UP)\n\t\t\t\tdirection = m_direction;\n\t\t}\n\t\t\n\t\tprotected function startHandler(e:Event):void\n\t\t{\n\t\t\tm_soundEx.removeEventListener(SoundEx.SOUND_START, startHandler);\n\t\t\tm_soundEx.addEventListener(SoundEx.SOUND_STOP, stopHandler);\n\t\t\tm_soundEx.addEventListener(Event.SOUND_COMPLETE, stopHandler);\n\t\t\ttimer.removeEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);\n\t\t\ttimer.repeatCount = 0;\n\t\t\tstart();\n\t\t}\n\t\t\n\t\tprotected function stopHandler(e:Event):void\n\t\t{\n\t\t\tvar i:int, t:Number = 0.0;\n\t\t\t\n\t\t\tfor (i = 0; i < m_columns; ++i)\n\t\t\t\tif (levels[i] > t)\n\t\t\t\t\tt = levels[i];\n\t\t\t\n\t\t\tm_soundEx.removeEventListener(Event.SOUND_COMPLETE, stopHandler);\n\t\t\tm_soundEx.removeEventListener(SoundEx.SOUND_STOP, stopHandler);\n\t\t\tm_soundEx.addEventListener(SoundEx.SOUND_START, startHandler);\n\t\t\t\n\t\t\ttimer.reset();\n\t\t\ttimer.repeatCount = int(t / m_decay) + 1;\n\t\t\ttimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);\n\t\t\ttimer.start();\n\t\t}\n\t\t\n\t\tprotected function completeHandler(e:Event):void\n\t\t{\n\t\t\tif (backgroundBeat)\n\t\t\t\tbackground.alpha = m_backgroundAlpha;\n\t\t\ttimer.reset();\n\t\t\ttimer.removeEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);\n\t\t}\n\t\t\n\t\tprotected function meterHandler(e:TimerEvent):void\n\t\t{\n\t\t\tvar h:int, i:int;\n\t\t\tspectrum = m_soundEx.getStereoAdd(m_columns);\n\t\t\tbuffer.fillRect(buffer.rect, 0);\n\t\t\tsourceRect.x = 0;\n\t\t\t\n\t\t\tfor (i = 0; i < m_columns; ++i)\n\t\t\t{\n\t\t\t\th = int(spectrum[i] * m_rows) * sectionHeight;\n\t\t\t\tsourceRect.height = h;\n\t\t\t\tsourceRect.y = realHeight - h;\n\t\t\t\tbuffer.fillRect(sourceRect, 0xff000000);\n\t\t\t\tsourceRect.x += sectionWidth;\n\t\t\t}\n\t\t\toutput.copyPixels(input, input.rect, destPoint, buffer);\n\t\t\tif (backgroundBeat)\n\t\t\t\tbackground.alpha = m_soundEx.peak;\n\t\t\te.updateAfterEvent();\n\t\t}\n\t\t\n\t\tprotected function decayHandler(e:TimerEvent):void\n\t\t{\n\t\t\tvar a:Number, h:int, i:int;\n\t\t\tspectrum = m_soundEx.getStereoSampling(m_columns);\n\t\t\toutput.lock();\n\t\t\tsourceRect.x = 0;\n\t\t\tbuffer.fillRect(buffer.rect, m_decayAlpha);\n\t\t\toutput.copyPixels(output, output.rect, destPoint, buffer);\n\t\t\tbuffer.fillRect(buffer.rect, 0);\n\t\t\t\n\t\t\tfor (i = 0; i < m_columns; ++i)\n\t\t\t{\n\t\t\t\ta = spectrum[i];\n\t\t\t\tif (a > levels[i])\n\t\t\t\t\tlevels[i] = a;\n\t\t\t\th = int(levels[i] * m_rows) * sectionHeight;\n\t\t\t\tsourceRect.height = h;\n\t\t\t\tsourceRect.y = realHeight - h;\n\t\t\t\tbuffer.fillRect(sourceRect, m_peaksAlpha);\n\t\t\t\tsourceRect.x += sectionWidth;\n\t\t\t\tlevels[i] -= m_decay;\n\t\t\t}\n\t\t\toutput.copyPixels(input, input.rect, destPoint, buffer, null, true);\n\t\t\toutput.unlock();\n\t\t\tif (backgroundBeat)\n\t\t\t\tbackground.alpha = m_soundEx.peak;\n\t\t\te.updateAfterEvent();\n\t\t}\n\t\t\n\t\tprotected function peaksHandler(e:TimerEvent):void\n\t\t{\n\t\t\tvar a:Number, h:int, i:int;\n\t\t\tspectrum = m_soundEx.getStereoAdd(m_columns);\n\t\t\tbuffer.fillRect(buffer.rect, 0);\n\t\t\tsourceRect.x = 0;\n\t\t\t\n\t\t\tfor (i = 0; i < m_columns; ++i)\n\t\t\t{\n\t\t\t\ta = spectrum[i];\n\t\t\t\th = int(a * m_rows) * sectionHeight;\n\t\t\t\tsourceRect.height = h;\n\t\t\t\tsourceRect.y = realHeight - h;\n\t\t\t\tbuffer.fillRect(sourceRect, 0xff000000);\n\t\t\t\t\n\t\t\t\tif (a > levels[i])\n\t\t\t\t{\n\t\t\t\t\tlevels[i] = a;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\th = int(levels[i] * m_rows) * sectionHeight;\n\t\t\t\t\tsourceRect.y = realHeight - h;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tsourceRect.height = m_rowSize;\n\t\t\t\tbuffer.fillRect(sourceRect, m_peaksAlpha);\n\t\t\t\tsourceRect.x += sectionWidth;\n\t\t\t\tlevels[i] -= m_decay;\n\t\t\t}\n\t\t\t\n\t\t\toutput.copyPixels(input, input.rect, destPoint, buffer);\n\t\t\t\n\t\t\tif (backgroundBeat)\n\t\t\t{\n\t\t\t\tbackground.alpha = m_soundEx.peak;\n\t\t\t}\n\t\t\t\n\t\t\tcurrentPeak = getTimer();\n\t\t\t\t\n\t\t\te.updateAfterEvent();\n\t\t}\n\t\t\n\t\toverride public function update():void\n\t\t{\n\t\t\t//\tAvoids doing this every single frame, rather only when the meter has peaked\n\t\t\tif (currentPeak > lastPeak)\n\t\t\t{\n\t\t\t\tlastPeak = currentPeak;\n\t\t\t\t\n\t\t\t\tif (foreground)\n\t\t\t\t{\n\t\t\t\t\tfront.pixels = foreground.bitmapData;\n\t\t\t\t\tfront.alpha = foreground.alpha;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (background)\n\t\t\t\t{\n\t\t\t\t\tback.pixels = background.bitmapData;\n\t\t\t\t\tback.alpha = background.alpha;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tsuper.update();\n\t\t}\n\t\t\n\t\tpublic function get soundEx():SoundEx\n\t\t{\n\t\t\treturn m_soundEx;\n\t\t}\n\t\t\n\t\tpublic function set soundEx(value:SoundEx):void\n\t\t{\n\t\t\tif (m_soundEx)\n\t\t\t\tm_soundEx.removeEventListener(SoundEx.SOUND_START, startHandler);\n\t\t\tm_soundEx = value;\n\t\t\tvalue.addEventListener(SoundEx.SOUND_START, startHandler);\n\t\t}\n\t\t\n\t\tpublic function get direction():String\n\t\t{\n\t\t\treturn m_direction;\n\t\t}\n\t\t\n\t\tpublic function set direction(value:String):void\n\t\t{\n\t\t\tif (value == m_direction || !FlxFlectrum[value.toUpperCase()])\n\t\t\t\treturn;\n\t\t\t\n\t\t\tswitch (value)\n\t\t\t{\n\t\t\t\tcase UP: \n\t\t\t\t\tfront.angle = 0;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LEFT: \n\t\t\t\t\tfront.angle = 270;\n\t\t\t\t\tbreak;\n\t\t\t\tcase DOWN: \n\t\t\t\t\tfront.angle = 180;\n\t\t\t\t\tbreak;\n\t\t\t\tcase RIGHT: \n\t\t\t\t\tfront.angle = 90;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tback.angle = front.angle;\n\t\t\tm_direction = value;\n\t\t}\n\t\t\n\t\tpublic function get mode():String\n\t\t{\n\t\t\treturn m_mode;\n\t\t}\n\t\t\n\t\tpublic function set mode(value:String):void\n\t\t{\n\t\t\tif (value == m_mode || !FlxFlectrum[value.toUpperCase()])\n\t\t\t\treturn;\n\t\t\ttimer.removeEventListener(TimerEvent.TIMER, this[m_mode + \"Handler\"]);\n\t\t\ttimer.addEventListener(TimerEvent.TIMER, this[value + \"Handler\"]);\n\t\t\tm_mode = value;\n\t\t}\n\t\t\n\t\tpublic function get delay():int\n\t\t{\n\t\t\treturn timer.delay;\n\t\t}\n\t\t\n\t\tpublic function set delay(value:int):void\n\t\t{\n\t\t\ttimer.delay = value;\n\t\t}\n\t\t\n\t\tpublic function get columns():int\n\t\t{\n\t\t\treturn m_columns;\n\t\t}\n\t\t\n\t\tpublic function set columns(value:int):void\n\t\t{\n\t\t\tif (value == m_columns)\n\t\t\t\treturn;\n\t\t\tif (value < 2)\n\t\t\t\tvalue = 2;\n\t\t\telse if (value > 256)\n\t\t\t\tvalue = 256;\n\t\t\tm_columns = value;\n\t\t\treset();\n\t\t}\n\t\t\n\t\tpublic function get columnSize():int\n\t\t{\n\t\t\treturn m_columnSize;\n\t\t}\n\t\t\n\t\tpublic function set columnSize(value:int):void\n\t\t{\n\t\t\tif (value == m_columnSize)\n\t\t\t\treturn;\n\t\t\tif (value < 1)\n\t\t\t\tvalue = 1;\n\t\t\tm_columnSize = value;\n\t\t\treset();\n\t\t}\n\t\t\n\t\tpublic function get columnSpacing():int\n\t\t{\n\t\t\treturn m_columnSpacing;\n\t\t}\n\t\t\n\t\tpublic function set columnSpacing(value:int):void\n\t\t{\n\t\t\tif (value == m_columnSpacing)\n\t\t\t\treturn;\n\t\t\tm_columnSpacing = value;\n\t\t\treset();\n\t\t}\n\t\t\n\t\tpublic function get rows():int\n\t\t{\n\t\t\treturn m_rows;\n\t\t}\n\t\t\n\t\tpublic function set rows(value:int):void\n\t\t{\n\t\t\tif (value == m_rows)\n\t\t\t\treturn;\n\t\t\tif (value < 3)\n\t\t\t\tvalue = 3;\n\t\t\tm_rows = value;\n\t\t\treset();\n\t\t}\n\t\t\n\t\tpublic function get rowSize():int\n\t\t{\n\t\t\treturn m_rowSize;\n\t\t}\n\t\t\n\t\tpublic function set rowSize(value:int):void\n\t\t{\n\t\t\tif (value == m_rowSize)\n\t\t\t\treturn;\n\t\t\tif (value < 1)\n\t\t\t\tvalue = 1;\n\t\t\tm_rowSize = value;\n\t\t\treset();\n\t\t}\n\t\t\n\t\tpublic function get rowSpacing():int\n\t\t{\n\t\t\treturn m_rowSpacing;\n\t\t}\n\t\t\n\t\tpublic function set rowSpacing(value:int):void\n\t\t{\n\t\t\tif (value == m_rowSpacing)\n\t\t\t\treturn;\n\t\t\tm_rowSpacing = value;\n\t\t\treset();\n\t\t}\n\t\t\n\t\tpublic function get showBackground():Boolean\n\t\t{\n\t\t\treturn m_showBackground;\n\t\t}\n\t\t\n\t\tpublic function set showBackground(value:Boolean):void\n\t\t{\n\t\t\tif (value)\n\t\t\t{\n\t\t\t\tback.visible = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tback.visible = false;\n\t\t\t}\n\t\t\t\n\t\t\tif (value == m_showBackground)\n\t\t\t\treturn;\n\t\t\tm_showBackground = value;\n\t\t\treset();\n\t\t}\n\t\t\n\t\tpublic function get backgroundAlpha():Number\n\t\t{\n\t\t\treturn m_backgroundAlpha;\n\t\t}\n\t\t\n\t\tpublic function set backgroundAlpha(value:Number):void\n\t\t{\n\t\t\tbackground.alpha = m_backgroundAlpha = value;\n\t\t}\n\t\t\n\t\tpublic function get decay():Number\n\t\t{\n\t\t\treturn m_decay;\n\t\t}\n\t\t\n\t\tpublic function set decay(value:Number):void\n\t\t{\n\t\t\tif (value < 0)\n\t\t\t\tvalue = 0;\n\t\t\telse if (value > 1)\n\t\t\t\tvalue = 1;\n\t\t\tm_decay = value;\n\t\t}\n\t\t\n\t\tpublic function get decayAlpha():Number\n\t\t{\n\t\t\treturn m_decayAlpha / 255;\n\t\t}\n\t\t\n\t\tpublic function set decayAlpha(value:Number):void\n\t\t{\n\t\t\tif (value < 0)\n\t\t\t\tvalue = 0;\n\t\t\telse if (value > 1)\n\t\t\t\tvalue = 1;\n\t\t\tm_decayAlpha = int(value * 255) << 24;\n\t\t}\n\t\t\n\t\tpublic function get peaksAlpha():Number\n\t\t{\n\t\t\treturn m_peaksAlpha / 255;\n\t\t}\n\t\t\n\t\tpublic function set peaksAlpha(value:Number):void\n\t\t{\n\t\t\tif (value < 0)\n\t\t\t\tvalue = 0;\n\t\t\telse if (value > 1)\n\t\t\t\tvalue = 1;\n\t\t\tm_peaksAlpha = int(value * 255) << 24;\n\t\t}\n\t}\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxFlod.as",
    "content": "/**\n * FlxFlod\n * -- Part of the Flixel Power Tools set\n * \n * v1.3 Added full FlxFlectrum support\n * v1.2 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.3 - July 29th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport neoart.flectrum.Flectrum;\n\timport neoart.flectrum.SoundEx;\n\timport org.flixel.*;\n\timport neoart.flod.*;\n\t\n\timport flash.utils.ByteArray;\n\timport flash.media.SoundTransform;\n\t\n\t/**\n\t * FlxFlod adds support for the Flod AS3 Replay library by Christian Corti.<br />\n\t * Flod is an incredibly powerful library allowing you to play tracker music from the Amiga / ST / PC (SoundTracker, ProTracker, etc)<br />\n\t * More information about Flod can be found here: http://www.photonstorm.com/flod<br /><br />\n\t * \n\t * This class works without modifying flixel, however the mute/volume/pause/resume commands won't be hooked into flixel.<br />\n\t * You can either use a patched version of Flixel which is provided in this repository:<br />\n\t * flash-game-dev-tips\\Flixel Versions\\Flixel v2.43 Patch 1.0\n\t * <br />\n\t * Or you can patch FlxG manually by doing the following:<br /><br />\n\t * \n\t * 1) Add <code>import com.photonstorm.flixel.FlxFlod;</code> at the top of FlxG.as:<br />\n\t * 2) Find the function <code>static public function set mute(Mute:Boolean):void</code> and add this line at the end of it: <code>FlxFlod.mute = Mute;</code><br />\n\t * 3) Find the function <code>static public function set volume(Volume:Number):void</code> and add this line at the end of it: <code>FlxFlod.volume = Volume;</code><br />\n\t * 4) Find the function <code>static protected function pauseSounds():void</code> and add this line at the end of it: <code>FlxFlod.pause();</code><br />\n\t * 5) Find the function <code>static protected function playSounds():void</code> and add this line at the end of it: <code>FlxFlod.resume();</code><br /><br />\n\t * \n\t * Flixel will now be patched so that any music playing via FlxFlod responds to the global flixel mute, volume and pause controls\n\t */\n\t\n\tpublic class FlxFlod\n\t{\n\t\tprivate static var processor:ModProcessor;\n\t\tprivate static var modStream:ByteArray;\n\t\tprivate static var soundform:SoundTransform = new SoundTransform();\n\t\t\n\t\tprivate static var fadeTimer:FlxDelay;\n\t\t\n\t\tprivate static var callbackHooksCreated:Boolean = false;\n\t\t\n\t\tprivate static var sound:SoundEx = new SoundEx;\n\t\tpublic static var flectrum:FlxFlectrum;\n\t\t\n\t\t/**\n\t\t * Starts playback of a tracker module\n\t\t * \n\t\t * @param\ttoon\tThe music to play\n\t\t * \n\t\t * @return\tBoolean\ttrue if playback started successfully, false if not\n\t\t */\n\t\tpublic static function playMod(toon:Class):Boolean\n\t\t{\n\t\t\tstopMod();\n\t\t\t\n\t\t\tmodStream = new toon() as ByteArray;\n\t\t\t\n\t\t\tprocessor = new ModProcessor();\n\t\t\t\n\t\t\tif (processor.load(modStream))\n\t\t\t{\n\t\t\t\tprocessor.loopSong = true;\n\t\t\t\tprocessor.stereo = 0;\n\t\t\t\tprocessor.play(sound);\n\t\t\t\t\n\t\t\t\tif (processor.soundChannel)\n\t\t\t\t{\n\t\t\t\t\tsoundform.volume = FlxG.volume;\n\t\t\t\t\tprocessor.soundChannel.soundTransform = soundform;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (callbackHooksCreated == false)\n\t\t\t\t{\n\t\t\t\t\tFlxG.volumeHandler = updateVolume;\n\t\t\t\t\tcallbackHooksCreated = true;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn true;\n\t\t\t\t\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a Flectrum (VU Meter / Spectrum Analyser)\n\t\t * \n\t\t * @param\tx\t\t\t\tThe x position of the flectrum in game world coordinates\n\t\t * @param\ty\t\t\t\tThe y position of the flectrum in game world coordinates\n\t\t * @param\tmeter\t\t\tA graphic to use for the meter (bar) of the flectrum. Default null uses a solid fill rectangle.\n\t\t * @param\tshowBackground\tDisplay an alpha background behind the meters\n\t\t * @param\tbackgroundBeat\tMakes the alpha background pulsate in time to the music\n\t\t * @param\tcolumns\t\t\tThe number of columns in the flectrum\n\t\t * @param\tcolumnSize\t\tThe width of each column in pixels - if you use your own meter graphic this value is ignored\n\t\t * @param\tcolumnSpacing\tThe spacing in pixels between each column (meter) of the flectrum\n\t\t * @param\trows\t\t\tThe number of rows in the flectrum\n\t\t * @param\trowSize\t\t\tThe height of each row. Overall flectrum height is rowSize + rowSpacing * rows - if you use your own meter graphic this value is ignored\n\t\t * @param\trowSpacing\t\tThe spacing in pixels between each row of the flectrum - if you use your own meter graphic this value is ignored\n\t\t * \n\t\t * @return\tThe FlxFlectrum instance for further modification. Also available via FlxFlod.flectrum\n\t\t */\n\t\tpublic static function createFlectrum(x:int, y:int, meter:Class = null, showBackground:Boolean = false, backgroundBeat:Boolean = false, columns:int = 15, columnSize:int = 10, columnSpacing:int = 0, rows:int = 32, rowSize:int = 3, rowSpacing:int = 0):FlxFlectrum\n\t\t{\n\t\t\tflectrum = new FlxFlectrum();\n\t\t\t\n\t\t\tflectrum.init(x, y, sound, columns, columnSize, columnSpacing, rows, rowSize, rowSpacing);\n\t\t\t\n\t\t\tif (meter)\n\t\t\t{\n\t\t\t\tflectrum.useBitmap(meter);\n\t\t\t}\n\t\t\t\n\t\t\tflectrum.showBackground = showBackground;\n\t\t\tflectrum.backgroundBeat = backgroundBeat;\n\t\t\t\n\t\t\treturn flectrum;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Pauses playback of this module, if started\n\t\t */\n\t\tpublic static function pause():void\n\t\t{\n\t\t\tif (processor)\n\t\t\t{\n\t\t\t\tprocessor.pause();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Resumes playback of this module if paused\n\t\t */\n\t\tpublic static function resume():void\n\t\t{\n\t\t\tif (processor)\n\t\t\t{\n\t\t\t\tprocessor.resume();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops playback of this module, if started\n\t\t */\n\t\tpublic static function stopMod():void\n\t\t{\n\t\t\tif (processor)\n\t\t\t{\n\t\t\t\tprocessor.stop();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Toggles playback mute\n\t\t */\n\t\tpublic static function set mute(Mute:Boolean):void\n\t\t{\n\t\t\tif (processor)\n\t\t\t{\n\t\t\t\tif (Mute)\n\t\t\t\t{\n\t\t\t\t\tif (processor.soundChannel)\n\t\t\t\t\t{\n\t\t\t\t\t\tsoundform.volume = 0;\n\t\t\t\t\t\tprocessor.soundChannel.soundTransform = soundform;\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 (processor.soundChannel)\n\t\t\t\t\t{\n\t\t\t\t\t\tsoundform.volume = FlxG.volume;\n\t\t\t\t\t\tprocessor.soundChannel.soundTransform = soundform;\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 * Called by FlxG when the volume is adjusted in-game\n\t\t * \n\t\t * @param\tVolume\n\t\t */\n\t\tpublic static function updateVolume(Volume:Number):void\n\t\t{\n\t\t\tvolume = Volume;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the playback volume directly (usually controlled by FlxG.volume)\n\t\t */\n\t\tpublic static function set volume(Volume:Number):void\n\t\t{\n\t\t\tif (processor)\n\t\t\t{\n\t\t\t\tif (processor.soundChannel)\n\t\t\t\t{\n\t\t\t\t\tsoundform.volume = Volume;\n\t\t\t\t\tprocessor.soundChannel.soundTransform = soundform;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Is a tune already playing?\n\t\t */\n\t\tpublic static function get isPlaying():Boolean\n\t\t{\n\t\t\tif (processor)\n\t\t\t{\n\t\t\t\treturn processor.isPlaying;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Is a tune paused?\n\t\t */\n\t\tpublic static function get isPaused():Boolean\n\t\t{\n\t\t\tif (processor)\n\t\t\t{\n\t\t\t\treturn processor.isPaused;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxGradient.as",
    "content": "/**\n * FlxGradient\n * -- Part of the Flixel Power Tools set\n * \n * v1.6 Fixed bug where gradients with chunk sizes > 1 would ignore alpha values\n * v1.5 Alpha values used in the gradient map\n * v1.4 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.6 - May 9th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n * @see Requires FlxMath\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport org.flixel.*;\n\t\n\timport flash.display.Bitmap;\n\timport flash.geom.Matrix;\n\timport flash.display.BitmapData;\n\timport flash.display.Shape;\n\timport flash.display.GradientType; \n\timport flash.display.SpreadMethod;\n\timport flash.display.InterpolationMethod;\n\t\n\t/**\n\t * Adds a set of color gradient creation / rendering functions\n\t */\n\tpublic class FlxGradient\n\t{\n\t\t\n\t\tpublic function FlxGradient() \n\t\t{\n\t\t}\n\t\t\n\t\tpublic static function createGradientMatrix(width:int, height:int, colors:Array, chunkSize:int = 1, rotation:int = 90):Object\n\t\t{\n\t\t\tvar gradientMatrix:Matrix = new Matrix();\n\t\t\t\n\t\t\t//\tRotation (in radians) that the gradient is rotated\n\t\t\tvar rot:Number = FlxMath.asRadians(rotation);\n\t\t\t\n\t\t\t//\tLast 2 values = horizontal and vertical shift (in pixels)\n\t\t\tif (chunkSize == 1)\n\t\t\t{\n\t\t\t\tgradientMatrix.createGradientBox(width, height, rot, 0, 0);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tgradientMatrix.createGradientBox(width, height / chunkSize, rot, 0, 0);\n\t\t\t}\n\t\t\t\n\t\t\t//\tCreate the alpha and ratio arrays\n\t\t\t\n\t\t\tvar alpha:Array = new Array();\n\t\t\t\n\t\t\tfor (var ai:int = 0; ai < colors.length; ai++)\n\t\t\t{\n\t\t\t\talpha.push(FlxColor.getAlphaFloat(colors[ai]));\n\t\t\t}\n\t\t\t\n\t\t\tvar ratio:Array = new Array();\n\t\t\t\n\t\t\tif (colors.length == 2)\n\t\t\t{\n\t\t\t\tratio[0] = 0;\n\t\t\t\tratio[1] = 255;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//\tSpread value\n\t\t\t\tvar spread:int = 255 / (colors.length - 1);\n\t\t\t\t\n\t\t\t\tratio.push(0);\n\t\t\t\t\n\t\t\t\tfor (var ri:int = 1; ri < colors.length - 1; ri++)\n\t\t\t\t{\n\t\t\t\t\tratio.push(ri * spread);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tratio.push(255);\n\t\t\t}\n\t\t\t\n\t\t\treturn { matrix: gradientMatrix, alpha: alpha, ratio: ratio };\n\t\t}\n\t\t\n\t\tpublic static function createGradientArray(width:int, height:int, colors:Array, chunkSize:int = 1, rotation:int = 90, interpolate:Boolean = true):Array\n\t\t{\n\t\t\tvar data:BitmapData = createGradientBitmapData(width, height, colors, chunkSize, rotation, interpolate);\n\t\t\t\n\t\t\tvar result:Array = new Array();\n\t\t\t\n\t\t\tfor (var y:int = 0; y < data.height; y++)\n\t\t\t{\n\t\t\t\tresult.push(data.getPixel32(0, y));\n\t\t\t}\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates an FlxSprite of the given width/height with a colour gradient flowing through it.\n\t\t * \n\t\t * @param\twidth\t\tThe width of the FlxSprite (and therefore gradient)\n\t\t * @param\theight\t\tThe height of the FlxSprite (and therefore gradient)\n\t\t * @param\tcolors\t\tAn array of colour values for the gradient to cycle through\n\t\t * @param\tchunkSize\tIf you want a more old-skool looking chunky gradient, increase this value!\n\t\t * @param\trotation\tAngle of the gradient in degrees. 90 = top to bottom, 180 = left to right. Any angle is valid\n\t\t * @param\tinterpolate\tInterpolate the colours? True uses RGB interpolation, false uses linear RGB\n\t\t * \n\t\t * @return\tAn FlxSprite containing your gradient (if valid parameters given!)\n\t\t */\n\t\tpublic static function createGradientFlxSprite(width:int, height:int, colors:Array, chunkSize:int = 1, rotation:int = 90, interpolate:Boolean = true):FlxSprite\n\t\t{\n\t\t\tvar data:BitmapData = createGradientBitmapData(width, height, colors, chunkSize, rotation, interpolate);\n\t\t\t\n\t\t\tvar dest:FlxSprite = new FlxSprite().makeGraphic(width, height);\n\t\t\t\n\t\t\tdest.pixels = data;\n\t\t\t\n\t\t\treturn dest;\n\t\t}\n\t\t\n\t\tpublic static function createGradientBitmapData(width:int, height:int, colors:Array, chunkSize:int = 1, rotation:int = 90, interpolate:Boolean = true):BitmapData\n\t\t{\n\t\t\t//\tSanity checks\n\t\t\tif (width < 1)\n\t\t\t{\n\t\t\t\twidth = 1;\n\t\t\t}\n\t\t\t\n\t\t\tif (height < 1)\n\t\t\t{\n\t\t\t\theight = 1;\n\t\t\t}\n\t\t\t\n\t\t\tvar gradient:Object = createGradientMatrix(width, height, colors, chunkSize, rotation);\n\t\t\t\n\t\t\tvar s:Shape = new Shape();\n\t\t\t\n\t\t\tif (interpolate)\n\t\t\t{\n\t\t\t\ts.graphics.beginGradientFill(GradientType.LINEAR, colors, gradient.alpha, gradient.ratio, gradient.matrix, SpreadMethod.PAD, InterpolationMethod.RGB, 0);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ts.graphics.beginGradientFill(GradientType.LINEAR, colors, gradient.alpha, gradient.ratio, gradient.matrix, SpreadMethod.PAD, InterpolationMethod.LINEAR_RGB, 0);\n\t\t\t}\n\t\t\t\n\t\t\tif (chunkSize == 1)\n\t\t\t{\n\t\t\t\ts.graphics.drawRect(0, 0, width, height);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ts.graphics.drawRect(0, 0, width, height / chunkSize);\n\t\t\t}\n\n\t\t\tvar data:BitmapData = new BitmapData(width, height, true, 0x0);\n\t\t\t\n\t\t\tif (chunkSize == 1)\n\t\t\t{\n\t\t\t\tdata.draw(s);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvar tempBitmap:Bitmap = new Bitmap(new BitmapData(width, height / chunkSize, true, 0x0));\n\t\t\t\ttempBitmap.bitmapData.draw(s);\n\t\t\t\ttempBitmap.scaleY = chunkSize;\n\t\t\t\t\n\t\t\t\tvar sM:Matrix = new Matrix();\n\t\t\t\tsM.scale(tempBitmap.scaleX, tempBitmap.scaleY);\n\t\t\t\t\n\t\t\t\tdata.draw(tempBitmap, sM);\n\t\t\t}\n\t\t\t\n\t\t\treturn data;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new gradient and overlays that on-top of the given FlxSprite at the destX/destY coordinates (default 0,0)<br />\n\t\t * Use low alpha values in the colours to have the gradient overlay and not destroy the image below\n\t\t * \n\t\t * @param\tdest\t\tThe FlxSprite to overlay the gradient onto\n\t\t * @param\twidth\t\tThe width of the FlxSprite (and therefore gradient)\n\t\t * @param\theight\t\tThe height of the FlxSprite (and therefore gradient)\n\t\t * @param\tcolors\t\tAn array of colour values for the gradient to cycle through\n\t\t * @param\tdestX\t\tThe X offset the gradient is drawn at (default 0)\n\t\t * @param\tdestY\t\tThe Y offset the gradient is drawn at (default 0)\n\t\t * @param\tchunkSize\tIf you want a more old-skool looking chunky gradient, increase this value!\n\t\t * @param\trotation\tAngle of the gradient in degrees. 90 = top to bottom, 180 = left to right. Any angle is valid\n\t\t * @param\tinterpolate\tInterpolate the colours? True uses RGB interpolation, false uses linear RGB\n\t\t * @return\tThe composited FlxSprite (for chaining, if you need)\n\t\t */\n\t\tpublic static function overlayGradientOnFlxSprite(dest:FlxSprite, width:int, height:int, colors:Array, destX:int = 0, destY:int = 0, chunkSize:int = 1, rotation:int = 90, interpolate:Boolean = true):FlxSprite\n\t\t{\n\t\t\tif (width > dest.width)\n\t\t\t{\n\t\t\t\twidth = dest.width;\n\t\t\t}\n\t\t\t\n\t\t\tif (height > dest.height)\n\t\t\t{\n\t\t\t\theight = dest.height;\n\t\t\t}\n\t\t\t\n\t\t\tvar source:FlxSprite = createGradientFlxSprite(width, height, colors, chunkSize, rotation, interpolate);\n\t\t\t\n\t\t\tdest.stamp(source, destX, destY);\n\t\t\t\n\t\t\treturn dest;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new gradient and overlays that on-top of the given BitmapData at the destX/destY coordinates (default 0,0)<br />\n\t\t * Use low alpha values in the colours to have the gradient overlay and not destroy the image below\n\t\t * \n\t\t * @param\tdest\t\tThe BitmapData to overlay the gradient onto\n\t\t * @param\twidth\t\tThe width of the FlxSprite (and therefore gradient)\n\t\t * @param\theight\t\tThe height of the FlxSprite (and therefore gradient)\n\t\t * @param\tcolors\t\tAn array of colour values for the gradient to cycle through\n\t\t * @param\tdestX\t\tThe X offset the gradient is drawn at (default 0)\n\t\t * @param\tdestY\t\tThe Y offset the gradient is drawn at (default 0)\n\t\t * @param\tchunkSize\tIf you want a more old-skool looking chunky gradient, increase this value!\n\t\t * @param\trotation\tAngle of the gradient in degrees. 90 = top to bottom, 180 = left to right. Any angle is valid\n\t\t * @param\tinterpolate\tInterpolate the colours? True uses RGB interpolation, false uses linear RGB\n\t\t * @return\tThe composited BitmapData\n\t\t */\n\t\tpublic static function overlayGradientOnBitmapData(dest:BitmapData, width:int, height:int, colors:Array, destX:int = 0, destY:int = 0, chunkSize:int = 1, rotation:int = 90, interpolate:Boolean = true):BitmapData\n\t\t{\n\t\t\tif (width > dest.width)\n\t\t\t{\n\t\t\t\twidth = dest.width;\n\t\t\t}\n\t\t\t\n\t\t\tif (height > dest.height)\n\t\t\t{\n\t\t\t\theight = dest.height;\n\t\t\t}\n\t\t\t\n\t\t\tvar source:BitmapData = createGradientBitmapData(width, height, colors, chunkSize, rotation, interpolate);\n\t\t\t\n\t\t\tdest.copyPixels(source, new Rectangle(0, 0, source.width, source.height), new Point(destX, destY), null, null, true);\n\t\t\t\n\t\t\treturn dest;\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxGridOverlay.as",
    "content": "/**\n * FlxGridOverlay\n * -- Part of the Flixel Power Tools set\n * \n * v1.1 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.1 - April 23rd 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport org.flixel.*;\n\t\n\tpublic class FlxGridOverlay \n\t{\n\t\tpublic function FlxGridOverlay() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates an FlxSprite of the given width and height filled with a checkerboard pattern.<br />\n\t\t * Each grid cell is the specified width and height, and alternates between two colors.<br />\n\t\t * If alternate is true each row of the pattern will be offset, for a proper checkerboard style. If false each row will be the same colour, creating a striped-pattern effect.<br />\n\t\t * So to create an 8x8 grid you'd call create(8,8)\n\t\t * \n\t\t * @param\tcellWidth\t\tThe grid cell width\n\t\t * @param\tcellHeight\t\tThe grid cell height\n\t\t * @param\twidth\t\t\tThe width of the FlxSprite. If -1 it will be the size of the game (FlxG.width)\n\t\t * @param\theight\t\t\tThe height of the FlxSprite. If -1 it will be the size of the game (FlxG.height)\n\t\t * @param\taddLegend\t\tTODO\n\t\t * @param\talternate\t\tShould the pattern alternate on each new row? Default true = checkerboard effect. False = vertical stripes\n\t\t * @param\tcolor1\t\t\tThe first fill colour in 0xAARRGGBB format\n\t\t * @param\tcolor2\t\t\tThe second fill colour in 0xAARRGGBB format\n\t\t * \n\t\t * @return\tFlxSprite of given width/height\n\t\t */\n\t\tpublic static function create(cellWidth:int, cellHeight:int, width:int = -1, height:int = -1, addLegend:Boolean = false, alternate:Boolean = true, color1:uint = 0xffe7e6e6, color2:uint = 0xffd9d5d5):FlxSprite\n\t\t{\n\t\t\tif (width == -1)\n\t\t\t{\n\t\t\t\twidth = FlxG.width;\n\t\t\t}\n\t\t\t\n\t\t\tif (height == -1)\n\t\t\t{\n\t\t\t\theight = FlxG.height;\n\t\t\t}\n\t\t\t\n\t\t\tif (width < cellWidth || height < cellHeight)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t\n\t\t\tvar grid:BitmapData = createGrid(cellWidth, cellHeight, width, height, alternate, color1, color2);\n\t\t\t\n\t\t\tvar output:FlxSprite = new FlxSprite().makeGraphic(width, height);\n\t\t\t\n\t\t\toutput.pixels = grid;\n\t\t\toutput.dirty = true;\n\t\t\t\n\t\t\treturn output;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a checkerboard pattern of the given width/height and overlays it onto the given FlxSprite.<br />\n\t\t * Each grid cell is the specified width and height, and alternates between two colors.<br />\n\t\t * If alternate is true each row of the pattern will be offset, for a proper checkerboard style. If false each row will be the same colour, creating a striped-pattern effect.<br />\n\t\t * So to create an 8x8 grid you'd call create(8,8,\n\t\t * \n\t\t * @param\tsource\t\t\tThe FlxSprite you wish to draw the grid on-top of. This updates its pixels value, not just the current frame (don't use animated sprites!)\n\t\t * @param\tcellWidth\t\tThe grid cell width\n\t\t * @param\tcellHeight\t\tThe grid cell height\n\t\t * @param\twidth\t\t\tThe width of the FlxSprite. If -1 it will be the size of the game (FlxG.width)\n\t\t * @param\theight\t\t\tThe height of the FlxSprite. If -1 it will be the size of the game (FlxG.height)\n\t\t * @param\taddLegend\t\tTODO\n\t\t * @param\talternate\t\tShould the pattern alternate on each new row? Default true = checkerboard effect. False = vertical stripes\n\t\t * @param\tcolor1\t\t\tThe first fill colour in 0xAARRGGBB format\n\t\t * @param\tcolor2\t\t\tThe second fill colour in 0xAARRGGBB format\n\t\t * \n\t\t * @return\tThe modified source FlxSprite\n\t\t */\n\t\tpublic static function overlay(source:FlxSprite, cellWidth:int, cellHeight:int, width:int = -1, height:int = -1, addLegend:Boolean = false, alternate:Boolean = true, color1:uint = 0x88e7e6e6, color2:uint = 0x88d9d5d5):FlxSprite\n\t\t{\n\t\t\tif (width == -1)\n\t\t\t{\n\t\t\t\twidth = FlxG.width;\n\t\t\t}\n\t\t\t\n\t\t\tif (height == -1)\n\t\t\t{\n\t\t\t\theight = FlxG.height;\n\t\t\t}\n\t\t\t\n\t\t\tif (width < cellWidth || height < cellHeight)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t\n\t\t\tvar grid:BitmapData = createGrid(cellWidth, cellHeight, width, height, alternate, color1, color2);\n\t\t\t\n\t\t\tvar pixels:BitmapData = source.pixels;\n\t\t\t\n\t\t\tpixels.copyPixels(grid, new Rectangle(0, 0, width, height), new Point(0, 0), null, null, true);\n\t\t\t\n\t\t\tsource.pixels = pixels;\n\t\t\t\n\t\t\treturn source;\n\t\t}\n\t\t\n\t\tpublic static function addLegend(source:FlxSprite, cellWidth:int, cellHeight:int, xAxis:Boolean = true, yAxis:Boolean = true):FlxSprite\n\t\t{\n\t\t\tif (cellWidth > source.width)\n\t\t\t{\n\t\t\t\tthrow Error(\"cellWidth larger than FlxSprites width\");\n\t\t\t\treturn source;\n\t\t\t}\n\t\t\t\n\t\t\tif (cellHeight > source.height)\n\t\t\t{\n\t\t\t\tthrow Error(\"cellHeight larger than FlxSprites height\");\n\t\t\t\treturn source;\n\t\t\t}\n\t\t\t\n\t\t\tif (source.width < cellWidth || source.height < cellHeight)\n\t\t\t{\n\t\t\t\tthrow Error(\"source FlxSprite width or height smaller than requested cell width or height\");\n\t\t\t\treturn source;\n\t\t\t}\n\t\t\t\n\t\t\t//\tValid cell width/height and source to work on\n\t\t\t\n\t\t\treturn source;\n\t\t\t\n\t\t}\n\t\t\n\t\tpublic static function createGrid(cellWidth:int, cellHeight:int, width:int, height:int, alternate:Boolean, color1:uint, color2:uint):BitmapData\n\t\t{\n\t\t\t//\tHow many cells can we fit into the width/height? (round it UP if not even, then trim back)\n\t\t\t\n\t\t\tvar rowColor:uint = color1;\n\t\t\tvar lastColor:uint = color1;\n\t\t\tvar grid:BitmapData = new BitmapData(width, height, true);\n\t\t\t\n\t\t\t//\tIf there aren't an even number of cells in a row then we need to swap the lastColor value\n\t\t\t\n\t\t\tfor (var y:int = 0; y <= height; y += cellHeight)\n\t\t\t{\n\t\t\t\tif (y > 0 && lastColor == rowColor && alternate)\n\t\t\t\t{\n\t\t\t\t\t(lastColor == color1) ? lastColor = color2 : lastColor = color1;\n\t\t\t\t}\n\t\t\t\telse if (y > 0 && lastColor != rowColor && alternate == false)\n\t\t\t\t{\n\t\t\t\t\t(lastColor == color2) ? lastColor = color1 : lastColor = color2;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfor (var x:int = 0; x <= width; x += cellWidth)\n\t\t\t\t{\n\t\t\t\t\tif (x == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\trowColor = lastColor;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tgrid.fillRect(new Rectangle(x, y, cellWidth, cellHeight), lastColor);\n\t\t\t\t\t\n\t\t\t\t\tif (lastColor == color1)\n\t\t\t\t\t{\n\t\t\t\t\t\tlastColor = color2;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tlastColor = color1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn grid;\n\t\t}\n\t\t\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxLinkedGroup.as",
    "content": "package org.flixel.plugin.photonstorm \n{\n\timport org.flixel.FlxGroup;\n\timport org.flixel.FlxSprite;\n\timport flash.utils.getTimer;\n\n\tpublic class FlxLinkedGroup extends FlxGroup\n\t{\n\t\t//private var queue\n\t\t\n\t\t\n\t\tpublic function FlxLinkedGroup(MaxSize:uint = 0)\n\t\t{\n\t\t\tsuper(MaxSize);\n\t\t}\n\t\t\n\t\tpublic function addX(newX:int):void\n\t\t{\n\t\t\tfor each (var s:FlxSprite in members)\n\t\t\t{\n\t\t\t\ts.x += newX;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic function angle(newX:int):void\n\t\t{\n\t\t\tfor each (var s:FlxSprite in members)\n\t\t\t{\n\t\t\t\ts.angle += newX;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxMath.as",
    "content": "/**\n * FlxMath\n * -- Part of the Flixel Power Tools set\n * \n * v1.7 Added mouseInFlxRect\n * v1.6 Added wrapAngle, angleLimit and more documentation\n * v1.5 Added pointInCoordinates, pointInFlxRect and pointInRectangle\n * v1.4 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.7 - June 28th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.geom.Rectangle;\n\t\n\timport org.flixel.*;\n\t\n\t/**\n\t * Adds a set of fast Math functions and extends a few commonly used ones\n\t */\n\tpublic class FlxMath\n\t{\n\t\tpublic static var getrandmax:int = int.MAX_VALUE;\n\t\tprivate static var mr:uint = 0;\n\t\tprivate static var cosTable:Array = new Array;\n\t\tprivate static var sinTable:Array = new Array;\n\t\t\n\t\tprivate static var coefficient1:Number = Math.PI / 4;\n\t\tprivate static const RADTODEG:Number = 180 / Math.PI;\n\t\tprivate static const DEGTORAD:Number = Math.PI / 180;\n\t\t\n\t\tpublic function FlxMath() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns true if the given x/y coordinate is within the given rectangular block\n\t\t * \n\t\t * @param\tpointX\t\tThe X value to test\n\t\t * @param\tpointY\t\tThe Y value to test\n\t\t * @param\trectX\t\tThe X value of the region to test within\n\t\t * @param\trectY\t\tThe Y value of the region to test within\n\t\t * @param\trectWidth\tThe width of the region to test within\n\t\t * @param\trectHeight\tThe height of the region to test within\n\t\t * \n\t\t * @return\ttrue if pointX/pointY is within the region, otherwise false\n\t\t */\n\t\tpublic static function pointInCoordinates(pointX:int, pointY:int, rectX:int, rectY:int, rectWidth:int, rectHeight:int):Boolean\n\t\t{\n\t\t\tif (pointX >= rectX && pointX <= (rectX + rectWidth))\n\t\t\t{\n\t\t\t\tif (pointY >= rectY && pointY <= (rectY + rectHeight))\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns true if the given x/y coordinate is within the given rectangular block\n\t\t * \n\t\t * @param\tpointX\t\tThe X value to test\n\t\t * @param\tpointY\t\tThe Y value to test\n\t\t * @param\trect\t\tThe FlxRect to test within\n\t\t * @return\ttrue if pointX/pointY is within the FlxRect, otherwise false\n\t\t */\n\t\tpublic static function pointInFlxRect(pointX:int, pointY:int, rect:FlxRect):Boolean\n\t\t{\n\t\t\tif (pointX >= rect.x && pointX <= rect.right && pointY >= rect.y && pointY <= rect.bottom)\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns true if the mouse world x/y coordinate are within the given rectangular block\n\t\t * \n\t\t * @param\tuseWorldCoords\tIf true the world x/y coordinates of the mouse will be used, otherwise screen x/y\n\t\t * @param\trect\t\t\tThe FlxRect to test within. If this is null for any reason this function always returns true.\n\t\t * \n\t\t * @return\ttrue if mouse is within the FlxRect, otherwise false\n\t\t */\n\t\tpublic static function mouseInFlxRect(useWorldCoords:Boolean, rect:FlxRect):Boolean\n\t\t{\n\t\t\tif (rect == null)\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\tif (useWorldCoords)\n\t\t\t{\n\t\t\t\treturn pointInFlxRect(FlxG.mouse.x, FlxG.mouse.y, rect);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn pointInFlxRect(FlxG.mouse.screenX, FlxG.mouse.screenY, rect);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns true if the given x/y coordinate is within the Rectangle\n\t\t * \n\t\t * @param\tpointX\t\tThe X value to test\n\t\t * @param\tpointY\t\tThe Y value to test\n\t\t * @param\trect\t\tThe Rectangle to test within\n\t\t * @return\ttrue if pointX/pointY is within the Rectangle, otherwise false\n\t\t */\n\t\tpublic static function pointInRectangle(pointX:int, pointY:int, rect:Rectangle):Boolean\n\t\t{\n\t\t\tif (pointX >= rect.x && pointX <= rect.right && pointY >= rect.y && pointY <= rect.bottom)\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * A faster (but much less accurate) version of Math.atan2(). For close range / loose comparisons this works very well, \n\t\t * but avoid for long-distance or high accuracy simulations.\n\t\t * Based on: http://blog.gamingyourway.com/PermaLink,guid,78341247-3344-4a7a-acb2-c742742edbb1.aspx\n\t\t * <p>\n\t\t * Computes and returns the angle of the point y/x in radians, when measured counterclockwise from a circle's x axis \n\t\t * (where 0,0 represents the center of the circle). The return value is between positive pi and negative pi. \n\t\t * Note that the first parameter to atan2 is always the y coordinate.\n\t\t * </p>\n\t\t * @param y The y coordinate of the point\n\t\t * @param x The x coordinate of the point\n\t\t * @return The angle of the point x/y in radians\n\t\t */\n\t\tpublic static function atan2(y:Number, x:Number):Number\n\t\t{\n\t\t\tvar absY:Number = y;\n\t\t\tvar coefficient2:Number = 3 * coefficient1;\n\t\t\tvar r:Number;\n\t\t\tvar angle:Number;\n\t\t\t\n\t\t\tif (absY < 0)\n\t\t\t{\n\t\t\t\tabsY = -absY;\n\t\t\t}\n\n\t\t\tif (x >= 0)\n\t\t\t{\n\t\t\t\tr = (x - absY) / (x + absY);\n\t\t\t\tangle = coefficient1 - coefficient1 * r;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tr = (x + absY) / (absY - x);\n\t\t\t\tangle = coefficient2 - coefficient1 * r;\n\t\t\t}\n    \n\t\t\treturn y < 0 ? -angle : angle;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Generate a sine and cosine table simultaneously and extremely quickly. Based on research by Franky of scene.at\n\t\t * <p>\n\t\t * The parameters allow you to specify the length, amplitude and frequency of the wave. Once you have called this function\n\t\t * you should get the results via getSinTable() and getCosTable(). This generator is fast enough to be used in real-time.\n\t\t * </p>\n\t\t * @param length \t\tThe length of the wave\n\t\t * @param sinAmplitude \tThe amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value\n\t\t * @param cosAmplitude \tThe amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value\n\t\t * @param frequency \tThe frequency of the sine and cosine table data\n\t\t * @return\tReturns the sine table\n\t\t * @see getSinTable\n\t\t * @see getCosTable\n\t\t */\n\t\tpublic static function sinCosGenerator(length:uint, sinAmplitude:Number = 1.0, cosAmplitude:Number = 1.0, frequency:Number = 1.0):Array\n\t\t{\n\t\t\tvar sin:Number = sinAmplitude;\n\t\t\tvar cos:Number = cosAmplitude;\n\t\t\tvar frq:Number = frequency * Math.PI / length;\n\t\t\t\n\t\t\tcosTable = new Array();\n\t\t\tsinTable = new Array();\n\t\t\t\n\t\t\tfor (var c:uint = 0; c < length; c++)\n\t\t\t{\n\t\t\t\tcos -= sin * frq;\n\t\t\t\tsin += cos * frq;\n\t\t\t\t\n\t\t\t\tcosTable[c] = cos;\n\t\t\t\tsinTable[c] = sin;\n\t\t\t}\n\t\t\t\n\t\t\treturn sinTable;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns the sine table generated by sinCosGenerator(), or an empty array object if not yet populated\n\t\t * @return Array of sine wave data\n\t\t * @see sinCosGenerator\n\t\t */\n\t\tpublic static function getSinTable():Array\n\t\t{\n\t\t\treturn sinTable;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns the cosine table generated by sinCosGenerator(), or an empty array object if not yet populated\n\t\t * @return Array of cosine wave data\n\t\t * @see sinCosGenerator\n\t\t */\n\t\tpublic static function getCosTable():Array\n\t\t{\n\t\t\treturn cosTable;\n\t\t}\n\t\t\n\t\t/**\n\t\t * A faster version of Math.sqrt\n\t\t * <p>\n\t\t * Computes and returns the square root of the specified number.\n\t\t * </p>\n\t\t * @link http://osflash.org/as3_speed_optimizations#as3_speed_tests\n\t\t * @param val A number greater than or equal to 0\n\t\t * @return If the parameter val is greater than or equal to zero, a number; otherwise NaN (not a number).\n\t\t */\n\t\tpublic static function sqrt(val:Number):Number\n\t\t{\n\t\t\tif (isNaN(val))\n\t\t\t{\n\t\t\t\treturn NaN;\n\t\t\t}\n\t\t\t\n\t\t\tvar thresh:Number = 0.002;\n\t\t\tvar b:Number = val * 0.25;\n\t\t\tvar a:Number;\n\t\t\tvar c:Number;\n\t\t\t\n\t\t\tif (val == 0)\n\t\t\t{\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\t\n\t\t\tdo {\n\t\t\t\tc = val / b;\n\t\t\t\tb = (b + c) * 0.5;\n\t\t\t\ta = b - c;\n\t\t\t\tif (a < 0) a = -a;\n\t\t\t}\n\t\t\twhile (a > thresh);\n\t\t\t\n\t\t\treturn b;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Generates a small random number between 0 and 65535 very quickly\n\t\t * <p>\n\t\t * Generates a small random number between 0 and 65535 using an extremely fast cyclical generator, \n\t\t * with an even spread of numbers. After the 65536th call to this function the value resets.\n\t\t * </p>\n\t\t * @return A pseudo random value between 0 and 65536 inclusive.\n\t\t */\n\t\tpublic static function miniRand():int\n\t\t{\n\t\t\tvar result:uint = mr;\n\t\t\t\n\t\t\tresult++;\n\t\t\tresult *= 75;\n\t\t\tresult %= 65537;\n\t\t\tresult--;\n\t\t\t\n\t\t\tmr++;\n\t\t\t\n\t\t\tif (mr == 65536)\n\t\t\t{\n\t\t\t\tmr = 0;\n\t\t\t}\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Generate a random integer\n\t\t * <p>\n\t\t * If called without the optional min, max arguments rand() returns a peudo-random integer between 0 and getrandmax().\n\t\t * If you want a random number between 5 and 15, for example, (inclusive) use rand(5, 15)\n\t\t * Parameter order is insignificant, the return will always be between the lowest and highest value.\n\t\t * </p>\n\t\t * @param min The lowest value to return (default: 0)\n\t\t * @param max The highest value to return (default: getrandmax)\n\t\t * @param excludes An Array of integers that will NOT be returned (default: null)\n\t\t * @return A pseudo-random value between min (or 0) and max (or getrandmax, inclusive)\n\t\t */\n\t\tpublic static function rand(min:Number = NaN, max:Number = NaN, excludes:Array = null):int\n\t\t{\n\t\t\tif (isNaN(min))\n\t\t\t{\n\t\t\t\tmin = 0;\n\t\t\t}\n\t\t\t\n\t\t\tif (isNaN(max))\n\t\t\t{\n\t\t\t\tmax = getrandmax;\n\t\t\t}\n\t\t\t\n\t\t\tif (min == max)\n\t\t\t{\n\t\t\t\treturn min;\n\t\t\t}\n\t\t\t\n\t\t\tif (excludes != null)\n\t\t\t{\n\t\t\t\t//\tSort the exclusion array\n\t\t\t\texcludes.sort(Array.NUMERIC);\n\t\t\t\t\n\t\t\t\tvar result:int;\n\t\t\t\t\n\t\t\t\tdo {\n\t\t\t\t\tif (min < max)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = min + Math.floor(Math.random() * (max + 1 - min)); // Math.floor and adding 1 makes this inclusive\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = max + Math.floor(Math.random() * (min + 1 - max));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\twhile (excludes.indexOf(result) >= 0);\n\t\t\t\t\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//\tReverse check\n\t\t\t\tif (min < max)\n\t\t\t\t{\n\t\t\t\t\treturn min + Math.floor(Math.random() * (max + 1 - min));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn max + Math.floor(Math.random() * (min + 1 - max));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Generate a random float (number)\n\t\t * <p>\n\t\t * If called without the optional min, max arguments rand() returns a peudo-random float between 0 and getrandmax().\n\t\t * If you want a random number between 5 and 15, for example, (inclusive) use rand(5, 15)\n\t\t * Parameter order is insignificant, the return will always be between the lowest and highest value.\n\t\t * </p>\n\t\t * @param min The lowest value to return (default: 0)\n\t\t * @param max The highest value to return (default: getrandmax)\n\t\t * @return A pseudo random value between min (or 0) and max (or getrandmax, inclusive)\n\t\t */\n\t\tpublic static function randFloat(min:Number = NaN, max:Number = NaN):Number\n\t\t{\n\t\t\tif (isNaN(min))\n\t\t\t{\n\t\t\t\tmin = 0;\n\t\t\t}\n\t\t\t\n\t\t\tif (isNaN(max))\n\t\t\t{\n\t\t\t\tmax = getrandmax;\n\t\t\t}\n\t\t\t\n\t\t\tif (min == max)\n\t\t\t{\n\t\t\t\treturn min;\n\t\t\t}\n\t\t\telse if (min < max)\n\t\t\t{\n\t\t\t\treturn min + (Math.random() * (max - min + 1));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn max + (Math.random() * (min - max + 1));\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Generate a random boolean result based on the chance value\n\t\t * <p>\n\t\t * Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance\n\t\t * of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed.\n\t\t * </p>\n\t\t * @param chance The chance of receiving the value. Should be given as a uint between 0 and 100 (effectively 0% to 100%)\n\t\t * @return true if the roll passed, or false\n\t\t */\n\t\tpublic static function chanceRoll(chance:uint = 50):Boolean\n\t\t{\n\t\t\tif (chance <= 0)\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse if (chance >= 100)\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (Math.random() * 100 >= chance)\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adds the given amount to the value, but never lets the value go over the specified maximum\n\t\t * \n\t\t * @param value The value to add the amount to\n\t\t * @param amount The amount to add to the value\n\t\t * @param max The maximum the value is allowed to be\n\t\t * @return The new value\n\t\t */\n\t\tpublic static function maxAdd(value:int, amount:int, max:int):int\n\t\t{\n\t\t\tvalue += amount;\n\t\t\t\n\t\t\tif (value > max)\n\t\t\t{\n\t\t\t\tvalue = max;\n\t\t\t}\n\t\t\t\n\t\t\treturn value;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.\n\t\t * <p>Values must be positive integers, and are passed through Math.abs</p>\n\t\t * \n\t\t * @param value The value to add the amount to\n\t\t * @param amount The amount to add to the value\n\t\t * @param max The maximum the value is allowed to be\n\t\t * @return The wrapped value\n\t\t */\n\t\tpublic static function wrapValue(value:int, amount:int, max:int):int\n\t\t{\n\t\t\tvar diff:int;\n\n\t\t\tvalue = Math.abs(value);\n\t\t\tamount = Math.abs(amount);\n\t\t\tmax = Math.abs(max);\n\t\t\t\n\t\t\tdiff = (value + amount) % max;\n\t\t\t\n\t\t\treturn diff;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Finds the length of the given vector\n\t\t * \n\t\t * @param\tdx\n\t\t * @param\tdy\n\t\t * \n\t\t * @return\n\t\t */\n        public static function vectorLength(dx:Number, dy:Number):Number\n        {\n            return Math.sqrt(dx * dx + dy * dy);\n        }\n\t\t\n\t\t/**\n\t\t * Finds the dot product value of two vectors\n\t\t * \n\t\t * @param\tax\t\tVector X\n\t\t * @param\tay\t\tVector Y\n\t\t * @param\tbx\t\tVector X\n\t\t * @param\tby\t\tVector Y\n\t\t * \n\t\t * @return\tDot product\n\t\t */\n        public static function dotProduct(ax:Number, ay:Number, bx:Number, by:Number):Number\n        {\n            return ax * bx + ay * by;\n        }\n        \n\t\t/**\n\t\t * Randomly returns either a 1 or -1\n\t\t * \n\t\t * @return\t1 or -1\n\t\t */\n        public static function randomSign():Number\n        {\n            return (Math.random() > 0.5) ? 1 : -1;\n        }\n\t\t\n\t\t/**\n\t\t * Returns true if the number given is odd.\n\t\t * \n\t\t * @param\tn\tThe number to check\n\t\t * \n\t\t * @return\tTrue if the given number is odd. False if the given number is even.\n\t\t */\n\t\tpublic static function isOdd(n:Number):Boolean\n\t\t{\n\t\t\tif (n & 1)\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns true if the number given is even.\n\t\t * \n\t\t * @param\tn\tThe number to check\n\t\t * \n\t\t * @return\tTrue if the given number is even. False if the given number is odd.\n\t\t */\n\t\tpublic static function isEven(n:Number):Boolean\n\t\t{\n\t\t\tif (n & 1)\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Keeps an angle value between -180 and +180<br>\n\t\t * Should be called whenever the angle is updated on the FlxSprite to stop it from going insane.\n\t\t * \n\t\t * @param\tangle\tThe angle value to check\n\t\t * \n\t\t * @return\tThe new angle value, returns the same as the input angle if it was within bounds\n\t\t */\n\t\tpublic static function wrapAngle(angle:Number):int\n\t\t{\n\t\t\tvar result:int = int(angle);\n\t\t\t\n\t\t\tif (angle > 180)\n\t\t\t{\n\t\t\t\tresult = -180;\n\t\t\t}\n\t\t\telse if (angle < -180)\n\t\t\t{\n\t\t\t\tresult = 180;\n\t\t\t}\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Keeps an angle value between the given min and max values\n\t\t * \n\t\t * @param\tangle\tThe angle value to check. Must be between -180 and +180\n\t\t * @param\tmin\t\tThe minimum angle that is allowed (must be -180 or greater)\n\t\t * @param\tmax\t\tThe maximum angle that is allowed (must be 180 or less)\n\t\t * \n\t\t * @return\tThe new angle value, returns the same as the input angle if it was within bounds\n\t\t */\n\t\tpublic static function angleLimit(angle:int, min:int, max:int):int\n\t\t{\n\t\t\tvar result:int = angle;\n\t\t\t\n\t\t\tif (angle > max)\n\t\t\t{\n\t\t\t\tresult = max;\n\t\t\t}\n\t\t\telse if (angle < min)\n\t\t\t{\n\t\t\t\tresult = min;\n\t\t\t}\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Converts a Radian value into a Degree\n\t\t * <p>\n\t\t * Converts the radians value into degrees and returns\n\t\t * </p>\n\t\t * @param radians The value in radians\n\t\t * @return Number Degrees\n\t\t */\n\t\tpublic static function asDegrees(radians:Number):Number\n\t\t{\n\t\t\treturn radians * RADTODEG;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Converts a Degrees value into a Radian\n\t\t * <p>\n\t\t * Converts the degrees value into radians and returns\n\t\t * </p>\n\t\t * @param degrees The value in degrees\n\t\t * @return Number Radians\n\t\t */\n\t\tpublic static function asRadians(degrees:Number):Number\n\t\t{\n\t\t\treturn degrees * DEGTORAD;\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxMouseControl.as",
    "content": "/**\n * FlxMouseControl\n * -- Part of the Flixel Power Tools set\n * \n * v1.2 Added Mouse Zone, Mouse Speed and refactored addToStack process\n * v1.1 Moved to a native plugin\n * v1.0 First release\n * \n * @version 1.2 - July 28th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport org.flixel.*;\n\t\n\tpublic class FlxMouseControl 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\tpublic static const ASCENDING:int = -1;\n\t\t\n\t\t/**\n\t\t * Use with <code>sort()</code> to sort in descending order.\n\t\t */\n\t\tpublic static const DESCENDING:int = 1;\n\t\t\n\t\t/**\n\t\t * The value that the FlxExtendedSprites are sorted by before deciding which is \"on-top\" for click select\n\t\t */\n\t\tpublic static var sortIndex:String = \"y\";\n\t\t\n\t\t/**\n\t\t * The sorting order. If the sortIndex is \"y\" and the order is ASCENDING then a sprite with a Y value of 200 would be \"on-top\" of one with a Y value of 100.\n\t\t */\n\t\tpublic static var sortOrder:int = ASCENDING;\n\t\t\n\t\t/**\n\t\t * Is the mouse currently dragging a sprite? If you have just clicked but NOT yet moved the mouse then this might return false.\n\t\t */\n\t\tpublic static var isDragging:Boolean = false;\n\t\t\n\t\t/**\n\t\t * The FlxExtendedSprite that is currently being dragged, if any.\n\t\t */\n\t\tpublic static var dragTarget:FlxExtendedSprite;\n\t\t\n\t\t/**\n\t\t * The FlxExtendedSprite that currently has the mouse button pressed on it\n\t\t */\n\t\tpublic static var clickTarget:FlxExtendedSprite;\n\t\tprivate static var clickStack:Array = new Array;\n\t\tprivate static var clickCoords:FlxPoint;\n\t\tprivate static var hasClickTarget:Boolean = false;\n\t\t\n\t\tprivate static var oldX:int;\n\t\tprivate static var oldY:int;\n\t\t\n\t\t/**\n\t\t * The speed the mouse is moving on the X axis in pixels per frame\n\t\t */\n\t\tpublic static var speedX:int;\n\t\t\n\t\t/**\n\t\t * The speed the mouse is moving on the Y axis in pixels per frame\n\t\t */\n\t\tpublic static var speedY:int;\n\t\t\n\t\t/**\n\t\t * The mouse can be set to only be active within a specific FlxRect region of the game world.\n\t\t * If outside this FlxRect no clicks, drags or throws will be processed.\n\t\t * If the mouse leaves this region while still dragging then the sprite is automatically dropped and its release handler is called.\n\t\t * Set the FlxRect to null to disable the zone.\n\t\t */\n\t\tpublic static var mouseZone:FlxRect;\n\t\t\n\t\t/**\n\t\t * Instead of using a mouseZone (which is calculated in world coordinates) you can limit the mouse to the FlxG.camera.deadzone area instead.\n\t\t * If set to true the mouse will use the camera deadzone. If false (or the deadzone is null) no check will take place.\n\t\t * Note that this takes priority over the mouseZone above. If the mouseZone and deadzone are set, the deadzone is used.\n\t\t */\n\t\tpublic static var linkToDeadZone:Boolean = false;\n\t\t\n\t\tpublic function FlxMouseControl() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adds the given FlxExtendedSprite to the stack of potential sprites that were clicked, the stack is then sorted and the final sprite is selected from that\n\t\t * \n\t\t * @param\titem\tThe FlxExtendedSprite that was clicked by the mouse\n\t\t */\n\t\tpublic static function addToStack(item:FlxExtendedSprite):void\n\t\t{\n\t\t\tif (mouseZone is FlxRect)\n\t\t\t{\n\t\t\t\tif (FlxMath.pointInFlxRect(FlxG.mouse.x, FlxG.mouse.y, mouseZone) == true)\n\t\t\t\t{\n\t\t\t\t\tclickStack.push(item);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tclickStack.push(item);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Main Update Loop - checks mouse status and updates FlxExtendedSprites accordingly\n\t\t */\n\t\toverride public function update():void\n\t\t{\n\t\t\t//\tUpdate mouse speed\n\t\t\tspeedX = FlxG.mouse.screenX - oldX;\n\t\t\tspeedY = FlxG.mouse.screenY - oldY;\n\t\t\t\n\t\t\toldX = FlxG.mouse.screenX;\n\t\t\toldY = FlxG.mouse.screenY;\n\t\t\t\n\t\t\t//\tIs the mouse currently pressed down on a target?\n\t\t\tif (hasClickTarget)\n\t\t\t{\n\t\t\t\tif (FlxG.mouse.pressed())\n\t\t\t\t{\n\t\t\t\t\t//\tHas the mouse moved? If so then we're candidate for a drag\n\t\t\t\t\tif (isDragging == false && clickTarget.draggable && (clickCoords.x != FlxG.mouse.x || clickCoords.y != FlxG.mouse.y))\n\t\t\t\t\t{\n\t\t\t\t\t\t//\tDrag on\n\t\t\t\t\t\tisDragging = true;\n\t\t\t\t\t\t\n\t\t\t\t\t\tdragTarget = clickTarget;\n\t\t\t\t\t\t\n\t\t\t\t\t\tdragTarget.startDrag();\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\treleaseMouse();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (linkToDeadZone)\n\t\t\t\t{\n\t\t\t\t\tif (FlxMath.mouseInFlxRect(false, FlxG.camera.deadzone) == false)\n\t\t\t\t\t{\n\t\t\t\t\t\treleaseMouse();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (FlxMath.mouseInFlxRect(true, mouseZone) == false)\n\t\t\t\t{\n\t\t\t\t\t//\tIs a mouse zone enabled? In which case check if we're still in it\n\t\t\t\t\treleaseMouse();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//\tNo target, but is the mouse down?\n\t\t\t\t\n\t\t\t\tif (FlxG.mouse.justPressed())\n\t\t\t\t{\n\t\t\t\t\tclickStack.length = 0;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//\tIf you are wondering how the brand new array can have anything in it by now, it's because FlxExtendedSprite\n\t\t\t\t//\tadds itself to the clickStack\n\t\t\t\t\n\t\t\t\tif (FlxG.mouse.pressed() && clickStack.length > 0)\n\t\t\t\t{\n\t\t\t\t\tassignClickedSprite();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function used to release the click / drag targets and reset the mouse state\n\t\t */\n\t\tprivate function releaseMouse():void\n\t\t{\n\t\t\t//\tMouse is no longer down, so tell the click target it's free - this will also stop dragging if happening\n\t\t\tclickTarget.mouseReleasedHandler();\n\t\t\t\n\t\t\thasClickTarget = false;\n\t\t\tclickTarget = null;\n\t\t\t\n\t\t\tisDragging = false;\n\t\t\tdragTarget = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Once the clickStack is created this sorts it and then picks the sprite with the highest priority (based on sortIndex and sortOrder)\n\t\t */\n\t\tprivate function assignClickedSprite():void\n\t\t{\n\t\t\t//\tIf there is more than one potential target then sort them\n\t\t\tif (clickStack.length > 1)\n\t\t\t{\n\t\t\t\tclickStack.sort(sortHandler);\n\t\t\t}\n\t\t\t\n\t\t\tclickTarget = clickStack.pop();\n\t\t\t\n\t\t\tclickCoords = clickTarget.point;\n\t\t\t\n\t\t\thasClickTarget = true;\n\t\t\t\n\t\t\tclickTarget.mousePressedHandler();\n\t\t\t\n\t\t\tclickStack.length = 0;\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 \titem1\tThe first object being sorted.\n\t\t * @param\titem2\tThe second object being sorted.\n\t\t * \n\t\t * @return\tAn integer value: -1 (item1 before item2), 0 (same), or 1 (item1 after item2)\n\t\t */\n\t\tprivate function sortHandler(item1:FlxExtendedSprite, item2:FlxExtendedSprite):int\n\t\t{\n\t\t\tif (item1[sortIndex] < item2[sortIndex])\n\t\t\t{\n\t\t\t\treturn sortOrder;\n\t\t\t}\n\t\t\telse if (item1[sortIndex] > item2[sortIndex])\n\t\t\t{\n\t\t\t\treturn -sortOrder;\n\t\t\t}\n\t\t\t\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes all references to any click / drag targets and resets this class\n\t\t */\n\t\tpublic static function clear():void\n\t\t{\n\t\t\thasClickTarget = false;\n\t\t\t\n\t\t\tif (clickTarget)\n\t\t\t{\n\t\t\t\tclickTarget.mouseReleasedHandler();\n\t\t\t}\n\t\t\t\n\t\t\tclickTarget = null;\n\t\t\t\n\t\t\tisDragging = false;\n\t\t\t\n\t\t\tif (dragTarget)\n\t\t\t{\n\t\t\t\tdragTarget.stopDrag();\n\t\t\t}\n\t\t\t\n\t\t\tspeedX = 0;\n\t\t\tspeedY = 0;\n\t\t\tdragTarget = null;\n\t\t\tmouseZone = null;\n\t\t\tlinkToDeadZone = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Runs when this plugin is destroyed\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tclear();\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxPowerTools.as",
    "content": "/**\n * Flixel Power Tools\n * \n * Version information and constants the other classes in this package can reference\n * \n * @version 1.9\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\tpublic class FlxPowerTools \n\t{\n\t\tpublic static const LIBRARY_NAME:String = \"flixel power tools\";\n\t\tpublic static const LIBRARY_MAJOR_VERSION:int = 1;\n\t\tpublic static const LIBRARY_MINOR_VERSION:int = 9;\n\t\t\n\t\tpublic function FlxPowerTools() \n\t\t{\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxScreenGrab.as",
    "content": "/**\n * FlxScreenGrab\n * -- Part of the Flixel Power Tools set\n * \n * v1.0 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.0 - April 28th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport org.flixel.*;\n\timport flash.geom.Rectangle;\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.geom.Matrix;\n\timport flash.net.FileReference;\n\timport flash.utils.ByteArray;\n\timport flash.utils.getTimer;\n\t\n\t/**\n\t * Captures a screen grab of the game and stores it locally, optionally saving as a PNG.\n\t */\n\tpublic class FlxScreenGrab extends FlxBasic\n\t{\n\t\tpublic static var screenshot:Bitmap;\n\t\tprivate static var hotkey:String = \"\";\n\t\tprivate static var autoSave:Boolean = false;\n\t\tprivate static var autoHideMouse:Boolean = false;\n\t\tprivate static var region:Rectangle;\n\t\t\n\t\tpublic function FlxScreenGrab() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Defines the region of the screen that should be captured. If you need it to be a fixed location then use this.<br />\n\t\t * If you want to grab the whole SWF size, you don't need to set this as that is the default.<br />\n\t\t * Remember that if your game is running in a zoom mode > 1 you need to account for this here.\n\t\t * \n\t\t * @param\tx\t\tThe x coordinate (in Flash display space, not Flixel game world)\n\t\t * @param\ty\t\tThe y coordinate (in Flash display space, not Flixel game world)\n\t\t * @param\twidth\tThe width of the grab region\n\t\t * @param\theight\tThe height of the grab region\n\t\t */\n\t\tpublic static function defineCaptureRegion(x:int, y:int, width:int, height:int):void\n\t\t{\n\t\t\tregion = new Rectangle(x, y, width, height);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clears a previously defined capture region\n\t\t */\n\t\tpublic static function clearCaptureRegion():void\n\t\t{\n\t\t\tregion = null;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Specify which key will capture a screen shot. Use the String value of the key in the same way FlxG.keys does (so \"F1\" for example)<br />\n\t\t * Optionally save the image to a file immediately. This uses the file systems \"Save as\" dialog window and pauses your game during the process.<br />\n\t\t * \n\t\t * @param\tkey\t\t\tString The key you press to capture the screen (i.e. \"F1\", \"SPACE\", etc - see system.input.Keyboard.as source for reference)\n\t\t * @param\tsaveToFile\tBoolean If set to true it will immediately encodes the grab to a PNG and open a \"Save As\" dialog window when the hotkey is pressed\n\t\t * @param\thideMouse\tBoolean If set to true the mouse will be hidden before capture and displayed afterwards when the hotkey is pressed\n\t\t */\n\t\tpublic static function defineHotKey(key:String, saveToFile:Boolean = false, hideMouse:Boolean = false):void\n\t\t{\n\t\t\thotkey = key;\n\t\t\tautoSave = saveToFile;\n\t\t\tautoHideMouse = hideMouse;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Clears a previously defined hotkey\n\t\t */\n\t\tpublic static function clearHotKey():void\n\t\t{\n\t\t\thotkey = \"\";\n\t\t\tautoSave = false;\n\t\t\tautoHideMouse = false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Takes a screen grab immediately of the given region or a previously defined region\n\t\t * \n\t\t * @param\tcaptureRegion\tA Rectangle area to capture. This over-rides that set by \"defineCaptureRegion\". If neither are set the full SWF size is used.\n\t\t * @param\tsaveToFile\tBoolean If set to true it will immediately encode the grab to a PNG and open a \"Save As\" dialog window\n\t\t * @param\thideMouse\tBoolean If set to true the mouse will be hidden before capture and displayed again afterwards\n\t\t * @return\tBitmap\t\tThe screen grab as a Flash Bitmap image\n\t\t */\n\t\tpublic static function grab(captureRegion:Rectangle = null, saveToFile:Boolean = false, hideMouse:Boolean = false):Bitmap\n\t\t{\n\t\t\tvar bounds:Rectangle;\n\t\t\t\n\t\t\tif (captureRegion)\n\t\t\t{\n\t\t\t\tbounds = new Rectangle(captureRegion.x, captureRegion.y, captureRegion.width, captureRegion.height);\n\t\t\t}\n\t\t\telse if (region)\n\t\t\t{\n\t\t\t\tbounds = new Rectangle(region.x, region.y, region.width, region.height);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbounds = new Rectangle(0, 0, FlxG.stage.stageWidth, FlxG.stage.stageHeight);\n\t\t\t}\n\t\t\t\n\t\t\tvar theBitmap:Bitmap = new Bitmap(new BitmapData(bounds.width, bounds.height, true, 0x0));\n\t\t\t\n\t\t\tvar m:Matrix = new Matrix(1, 0, 0, 1, -bounds.x, -bounds.y);\n\t\t\t\n\t\t\tif (autoHideMouse || hideMouse)\n\t\t\t{\n\t\t\t\tFlxG.mouse.hide();\n\t\t\t}\n\t\t\t\n\t\t\ttheBitmap.bitmapData.draw(FlxG.stage, m);\n\t\t\t\n\t\t\tif (autoHideMouse || hideMouse)\n\t\t\t{\n\t\t\t\tFlxG.mouse.show();\n\t\t\t}\n\t\t\t\n\t\t\tscreenshot = theBitmap;\n\t\t\t\n\t\t\tif (saveToFile || autoSave)\n\t\t\t{\n\t\t\t\tsave();\n\t\t\t}\n\t\t\t\n\t\t\treturn theBitmap;\n\t\t}\n\t\t\n\t\tprivate static function save(filename:String = \"\"):void\n\t\t{\n\t\t\tif (screenshot.bitmapData == null)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tvar png:ByteArray = PNGEncoder.encode(screenshot.bitmapData);\n\t\t\t\n\t\t\tvar file:FileReference = new FileReference();\n\t\t\t\n\t\t\tif (filename == \"\")\n\t\t\t{\n\t\t\t\tfilename = \"grab\" + getTimer().toString() + \".png\";\n\t\t\t}\n\t\t\telse if (filename.substr( -4) != \".png\")\n\t\t\t{\n\t\t\t\tfilename = filename.concat(\".png\");\n\t\t\t}\n\t\t\t\n\t\t\tfile.save(png, filename);\n\t\t}\n\t\t\n\t\toverride public function update():void\n\t\t{\n\t\t\tif (hotkey != \"\")\n\t\t\t{\n\t\t\t\tif (FlxG.keys.justReleased(hotkey))\n\t\t\t\t{\n\t\t\t\t\ttrace(\"key pressed\");\n\t\t\t\t\tgrab();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tclearCaptureRegion();\n\t\t\tclearHotKey();\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxScrollZone.as",
    "content": "/**\n * FlxScrollZone\n * -- Part of the Flixel Power Tools set\n * \n * v1.4 Added \"clearRegion\" support for when you use Sprites with transparency and renamed parameter to onlyScrollOnscreen\n * v1.3 Swapped plugin update for draw, now smoother / faster in some fps cases\n * v1.2 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.4 - May 16th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm. My thanks to Ralph Hauwert for help with this.\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.display.BitmapData;\n\timport flash.display.Sprite;\n\timport flash.geom.Matrix;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport flash.utils.Dictionary;\n\timport org.flixel.*;\n\t\n\t/**\n\t * FlxScrollZone allows you to scroll the content of an FlxSprites bitmapData in any direction you like.\n\t */\n\tpublic class FlxScrollZone extends FlxBasic\n\t{\n\t\tprivate static var members:Dictionary = new Dictionary(true);\n\t\tprivate static var zeroPoint:Point = new Point;\n\t\t\n\t\tpublic function FlxScrollZone() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Add an FlxSprite to the Scroll Manager, setting up one scrolling region. <br />\n\t\t * To add extra scrolling regions on the same sprite use addZone()\n\t\t * \n\t\t * @param\tsource\t\t\t\tThe FlxSprite to apply the scroll to\n\t\t * @param\tregion\t\t\t\tThe region, specified as a Rectangle, of the FlxSprite that you wish to scroll\n\t\t * @param\tdistanceX\t\t\tThe distance in pixels you want to scroll on the X axis. Negative values scroll left. Positive scroll right. Floats allowed (0.5 would scroll at half speed)\n\t\t * @param\tdistanceY\t\t\tThe distance in pixels you want to scroll on the Y axis. Negative values scroll up. Positive scroll down. Floats allowed (0.5 would scroll at half speed)\n\t\t * @param\tonlyScrollOnscreen\tOnly update this FlxSprite if visible onScreen (default true) Saves performance by not scrolling offscreen sprites, but this isn't always desirable\n\t\t * @param\tclearRegion\t\t\tSet to true if you want to clear the scrolling area of the FlxSprite with a 100% transparent fill before applying the scroll texture (default false)\n\t\t * @see\t\tcreateZone\n\t\t */\n\t\tpublic static function add(source:FlxSprite, region:Rectangle, distanceX:Number, distanceY:Number, onlyScrollOnscreen:Boolean = true, clearRegion:Boolean = false):void\n\t\t{\n\t\t\tif (members[source])\n\t\t\t{\n\t\t\t\tthrow Error(\"FlxSprite already exists in FlxScrollZone, use addZone to add a new scrolling region to an already added FlxSprite\");\n\t\t\t}\n\t\t\t\n\t\t\tvar data:Object = new Object();\n\t\t\t\n\t\t\tdata.source = source;\n\t\t\tdata.scrolling = true;\n\t\t\tdata.onlyScrollOnscreen = onlyScrollOnscreen;\n\t\t\tdata.zones = new Array;\n\t\t\t\n\t\t\tmembers[source] = data;\n\t\t\t\n\t\t\tcreateZone(source, region, distanceX, distanceY, clearRegion);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a new scrolling region to an FlxSprite already in the Scroll Manager (see add())<br />\n\t\t * \n\t\t * @param\tsource\t\t\t\tThe FlxSprite to apply the scroll to\n\t\t * @param\tregion\t\t\t\tThe region, specified as a Rectangle, of the FlxSprite that you wish to scroll\n\t\t * @param\tdistanceX\t\t\tThe distance in pixels you want to scroll on the X axis. Negative values scroll left. Positive scroll right. Floats allowed (0.5 would scroll at half speed)\n\t\t * @param\tdistanceY\t\t\tThe distance in pixels you want to scroll on the Y axis. Negative values scroll up. Positive scroll down. Floats allowed (0.5 would scroll at half speed)\n\t\t * @param\tclearRegion\t\t\tSet to true if you want to fill the scroll region of the FlxSprite with a 100% transparent fill before scrolling it (default false)\n\t\t */\n\t\tpublic static function createZone(source:FlxSprite, region:Rectangle, distanceX:Number, distanceY:Number, clearRegion:Boolean = false):void\n\t\t{\n\t\t\tvar texture:BitmapData = new BitmapData(region.width, region.height, true, 0x00000000);\n\t\t\ttexture.copyPixels(source.framePixels, region, zeroPoint, null, null, true);\n\t\t\t\n\t\t\tvar data:Object = new Object();\n\t\t\t\n\t\t\tdata.buffer = new Sprite;\n\t\t\tdata.texture = texture;\n\t\t\tdata.region = region;\n\t\t\tdata.clearRegion = clearRegion;\n\t\t\tdata.distanceX = distanceX;\n\t\t\tdata.distanceY = distanceY;\n\t\t\tdata.scrollMatrix = new Matrix();\n\t\t\tdata.drawMatrix = new Matrix(1, 0, 0, 1, region.x, region.y);\n\t\t\t\n\t\t\tmembers[source].zones.push(data);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the draw Matrix for the given FlxSprite scroll zone<br />\n\t\t * Warning: Modify this at your own risk!\n\t\t * \n\t\t * @param\tsource\t\tThe FlxSprite to set the draw matrix on\n\t\t * @param\tmatrix\t\tThe Matrix to use during the scroll update draw \n\t\t * @param\tzone\t\tIf the FlxSprite has more than 1 scrolling zone, use this to target which zone to apply the update to (default 0)\n\t\t * @return\tMatrix\t\tThe draw matrix used in the scroll update\n\t\t */\n\t\tpublic static function updateDrawMatrix(source:FlxSprite, matrix:Matrix, zone:int = 0):void\n\t\t{\n\t\t\tmembers[source].zones[zone].drawMatrix = matrix;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns the draw Matrix for the given FlxSprite scroll zone\n\t\t * \n\t\t * @param\tsource\t\tThe FlxSprite to get the draw matrix from\n\t\t * @param\tzone\t\tIf the FlxSprite has more than 1 scrolling zone, use this to target which zone to apply the update to (default 0)\n\t\t * @return\tMatrix\t\tThe draw matrix used in the scroll update\n\t\t */\n\t\tpublic static function getDrawMatrix(source:FlxSprite, zone:int = 0):Matrix\n\t\t{\n\t\t\treturn members[source].zones[zone].drawMatrix;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes an FlxSprite and all of its scrolling zones. Note that it doesn't restore the sprite bitmapData.\n\t\t * \n\t\t * @param\tsource\tThe FlxSprite to remove all scrolling zones for.\n\t\t * @return\tBoolean\ttrue if the FlxSprite was removed, otherwise false.\n\t\t */\n\t\tpublic static function remove(source:FlxSprite):Boolean\n\t\t{\n\t\t\tif (members[source])\n\t\t\t{\n\t\t\t\tdelete members[source];\n\t\t\t\t\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes all FlxSprites, and all of their scrolling zones.<br />\n\t\t * This is called automatically if the plugin is ever destroyed.\n\t\t */\n\t\tpublic static function clear():void\n\t\t{\n\t\t\tfor each (var obj:Object in members)\n\t\t\t{\n\t\t\t\tdelete members[obj.source];\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Update the distance in pixels to scroll on the X axis.\n\t\t * \n\t\t * @param\tsource\t\tThe FlxSprite to apply the scroll to\n\t\t * @param\tdistanceX\tThe distance in pixels you want to scroll on the X axis. Negative values scroll left. Positive scroll right. Floats allowed (0.5 would scroll at half speed)\n\t\t * @param\tzone\t\tIf the FlxSprite has more than 1 scrolling zone, use this to target which zone to apply the update to (default 0)\n\t\t */\n\t\tpublic static function updateX(source:FlxSprite, distanceX:Number, zone:int = 0):void\n\t\t{\n\t\t\tmembers[source].zones[zone].distanceX = distanceX;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Update the distance in pixels to scroll on the X axis.\n\t\t * \n\t\t * @param\tsource\t\tThe FlxSprite to apply the scroll to\n\t\t * @param\tdistanceY\tThe distance in pixels you want to scroll on the Y axis. Negative values scroll up. Positive scroll down. Floats allowed (0.5 would scroll at half speed)\n\t\t * @param\tzone\t\tIf the FlxSprite has more than 1 scrolling zone, use this to target which zone to apply the update to (default 0)\n\t\t */\n\t\tpublic static function updateY(source:FlxSprite, distanceY:Number, zone:int = 0):void\n\t\t{\n\t\t\tmembers[source].zones[zone].distanceY = distanceY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Starts scrolling on the given FlxSprite. If no FlxSprite is given it starts scrolling on all FlxSprites currently added.<br />\n\t\t * Scrolling is enabled by default, but this can be used to re-start it if you have stopped it via stopScrolling.<br />\n\t\t * \n\t\t * @param\tsource\tThe FlxSprite to start scrolling on. If left as null it will start scrolling on all sprites.\n\t\t */\n\t\tpublic static function startScrolling(source:FlxSprite = null):void\n\t\t{\n\t\t\tif (source)\n\t\t\t{\n\t\t\t\tmembers[source].scrolling = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor each (var obj:Object in members)\n\t\t\t\t{\n\t\t\t\t\tobj.scrolling = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops scrolling on the given FlxSprite. If no FlxSprite is given it stops scrolling on all FlxSprites currently added.<br />\n\t\t * Scrolling is enabled by default, but this can be used to stop it.<br />\n\t\t * \n\t\t * @param\tsource\tThe FlxSprite to stop scrolling on. If left as null it will stop scrolling on all sprites.\n\t\t */\n\t\tpublic static function stopScrolling(source:FlxSprite = null):void\n\t\t{\n\t\t\tif (source)\n\t\t\t{\n\t\t\t\tmembers[source].scrolling = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor each (var obj:Object in members)\n\t\t\t\t{\n\t\t\t\t\tobj.scrolling = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\toverride public function draw():void\n\t\t{\n\t\t\tfor each (var obj:Object in members)\n\t\t\t{\n\t\t\t\tif ((obj.onlyScrollOnscreen == true && obj.source.onScreen()) && obj.scrolling == true && obj.source.exists)\n\t\t\t\t{\n\t\t\t\t\tscroll(obj);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tprivate function scroll(data:Object):void\n\t\t{\n\t\t\t//\tLoop through the scroll zones defined in this object\n\t\t\tfor each (var zone:Object in data.zones)\n\t\t\t{\n\t\t\t\tzone.scrollMatrix.tx += zone.distanceX;\n\t\t\t\tzone.scrollMatrix.ty += zone.distanceY;\n\t\t\t\t\n\t\t\t\tzone.buffer.graphics.clear();\n\t\t\t\tzone.buffer.graphics.beginBitmapFill(zone.texture, zone.scrollMatrix, true, false);\n\t\t\t\tzone.buffer.graphics.drawRect(0, 0, zone.region.width, zone.region.height);\n\t\t\t\tzone.buffer.graphics.endFill();\n\t\t\t\t\n\t\t\t\tif (zone.clearRegion)\n\t\t\t\t{\n\t\t\t\t\tdata.source.pixels.fillRect(zone.region, 0x0);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tdata.source.pixels.draw(zone.buffer, zone.drawMatrix);\n\t\t\t}\n\t\t\t\n\t\t\tdata.source.dirty = true;\n\t\t}\n\t\t\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tclear();\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxScrollingText.as",
    "content": "/**\n * FlxScrollingText\n * -- Part of the Flixel Power Tools set\n * \n * v1.0 First version released\n * \n * @version 1.0 - May 5th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\timport flash.utils.Dictionary;\n\timport flash.utils.getTimer;\n\t\n\timport org.flixel.*;\n\t\n\t/**\n\t * FlxScrollingText takes an FlxBitmapFont object and creates a horizontally scrolling FlxSprite from it\n\t */\n\tpublic class FlxScrollingText extends FlxBasic\n\t{\n\t\tprivate static var members:Dictionary = new Dictionary(true);\n\t\tprivate static var zeroPoint:Point = new Point;\n\t\n\t\tpublic function FlxScrollingText() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adds an FlxBitmapFont to the Scrolling Text Manager and returns an FlxSprite which contains the text scroller in it.<br />\n\t\t * The FlxSprite will automatically update itself via this plugin, but can be treated as a normal FlxSprite in all other regards<br />\n\t\t * re: positioning, collision, rotation, etc.\n\t\t * \n\t\t * @param\tbitmapFont\t\t\tA pre-prepared FlxBitmapFont object (see the Test Suite examples for details on how this works)\n\t\t * @param\tregion\t\t\t\tA Rectangle that defines the size of the scrolling FlxSprite. The sprite will be placed at region.x/y and be region.width/height in size.\n\t\t * @param\tpixels\t\t\t\tThe number of pixels to scroll per step. For a smooth (but slow) scroll use low values. Keep the value proportional to the font width, so if the font width is 16 use a value like 1, 2, 4 or 8.\n\t\t * @param\tsteps\t\t\t\tHow many steps should pass before the text is next scrolled? Default 0 means every step we scroll. Higher values slow things down.\n\t\t * @param\ttext\t\t\t\tThe default text for your scrolling message. Can be changed in real-time via the addText method.\n\t\t * @param\tonlyScrollOnscreen\tOnly update the text scroller when this FlxSprite is visible on-screen? Default true.\n\t\t * @param\tloopOnWrap\t\t\tWhen the scroller reaches the end of the given \"text\" should it wrap to the start? Default true. If false it will clear the screen then set itself to not update.\n\t\t * \n\t\t * @return\tAn FlxSprite of size region.width/height, positioned at region.x/y, that auto-updates its contents while this plugin runs\n\t\t */\n\t\tpublic static function add(bitmapFont:FlxBitmapFont, region:Rectangle, pixels:uint = 1, steps:uint = 0, text:String = \"FLIXEL ROCKS!\", onlyScrollOnscreen:Boolean = true, loopOnWrap:Boolean = true):FlxSprite\n\t\t{\n\t\t\tvar data:Object = new Object;\n\t\t\t\n\t\t\t//\tSanity checks\n\t\t\tif (pixels > bitmapFont.characterWidth)\n\t\t\t{\n\t\t\t\tpixels = bitmapFont.characterWidth;\n\t\t\t}\n\t\t\t\n\t\t\tif (pixels == 0)\n\t\t\t{\n\t\t\t\tpixels = 1;\n\t\t\t}\n\t\t\t\n\t\t\tif (text == \"\")\n\t\t\t{\n\t\t\t\ttext = \" \";\n\t\t\t}\n\t\t\t\n\t\t\tdata.bitmapFont = bitmapFont;\n\t\t\tdata.bitmapChar = FlxBitmapFont(data.bitmapFont).getCharacterAsBitmapData(text.charAt(0));\n\t\t\tdata.charWidth = bitmapFont.characterWidth;\n\t\t\tdata.charHeight = bitmapFont.characterHeight;\n\t\t\tdata.shiftRect = new Rectangle(pixels, 0, region.width - pixels, region.height);\n\t\t\tdata.bufferRect = new Rectangle(0, 0, region.width, region.height);\n\t\t\tdata.slice = new Rectangle(0, 0, pixels, data.charHeight);\n\t\t\tdata.endPoint = new Point(region.width - pixels, 0);\n\t\t\tdata.x = 0;\n\t\t\t\n\t\t\tdata.sprite = new FlxSprite(region.x, region.y).makeGraphic(region.width, region.height, 0x0, true);\n\t\t\tdata.buffer = new BitmapData(region.width, region.height, true, 0x0);\n\t\t\t\n\t\t\tdata.region = region;\n\t\t\tdata.step = steps;\n\t\t\tdata.maxStep = steps;\n\t\t\tdata.pixels = pixels;\n\t\t\tdata.clearCount = 0;\n\t\t\tdata.clearDistance = region.width - pixels;\n\t\t\t\n\t\t\tdata.text = text;\n\t\t\tdata.currentChar = 0;\n\t\t\tdata.maxChar = text.length;\n\t\t\t\n\t\t\tdata.wrap = loopOnWrap;\n\t\t\tdata.complete = false;\n\t\t\tdata.scrolling = true;\n\t\t\tdata.onScreenScroller = onlyScrollOnscreen;\n\t\t\t\n\t\t\tscroll(data);\n\t\t\t\n\t\t\tmembers[data.sprite] = data;\n\t\t\t\n\t\t\treturn data.sprite;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Adds or replaces the text in the given Text Scroller.<br />\n\t\t * Can be called while the scroller is still active.\n\t\t * \n\t\t * @param\tsource\t\tThe FlxSprite Text Scroller you wish to update (must have been added to FlxScrollingText via a call to add()\n\t\t * @param\ttext\t\tThe text to add or update to the Scroller\n\t\t * @param\toverwrite\tIf true the given text will fully replace the previous scroller text. If false it will be appended to the end (default)\n\t\t */\n\t\tpublic static function addText(source:FlxSprite, text:String, overwrite:Boolean = false):void\n\t\t{\n\t\t\tif (overwrite)\n\t\t\t{\n\t\t\t\tmembers[source].text = text;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmembers[source].text = String(members[source].text).concat(text);\n\t\t\t}\n\t\t\t\t\n\t\t\tmembers[source].maxChar = members[source].text.length;\n\t\t}\n\t\t\n\t\toverride public function draw():void\n\t\t{\n\t\t\tfor each (var obj:Object in members)\n\t\t\t{\n\t\t\t\tif (obj && (obj.onScreenScroller == true && obj.sprite.onScreen()) && obj.scrolling == true && obj.sprite.exists)\n\t\t\t\t{\n\t\t\t\t\tscroll(obj);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tprivate static function scroll(data:Object):void\n\t\t{\n\t\t\t//\tHave we reached enough steps?\n\t\t\t\n\t\t\tif (data.maxStep > 0 && (data.step < data.maxStep))\n\t\t\t{\n\t\t\t\tdata.step++;\n\t\t\t\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//\tIt's time to render, so reset the step counter and lets go\n\t\t\t\tdata.step = 0;\n\t\t\t}\n\t\t\t\n\t\t\t//\tCLS\n\t\t\tdata.buffer.fillRect(data.bufferRect, 0x0);\n\t\t\t\n\t\t\t//\tShift the current contents of the buffer along by \"speed\" pixels\n\t\t\tdata.buffer.copyPixels(data.sprite.pixels, data.shiftRect, zeroPoint, null, null, true);\n\t\t\t\n\t\t\t//\tCopy the side of the character\n\t\t\tif (data.complete == false)\n\t\t\t{\n\t\t\t\tdata.buffer.copyPixels(data.bitmapChar, data.slice, data.endPoint, null, null, true);\n\t\t\t\t\n\t\t\t\t//\tUpdate\n\t\t\t\tdata.x += data.pixels;\n\t\t\t\t\n\t\t\t\tif (data.x >= data.charWidth)\n\t\t\t\t{\n\t\t\t\t\t//\tGet the next character\n\t\t\t\t\tdata.currentChar++;\n\t\t\t\t\t\n\t\t\t\t\tif (data.currentChar > data.maxChar)\n\t\t\t\t\t{\n\t\t\t\t\t\t//\tAt the end of the text\n\t\t\t\t\t\tif (data.wrap)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdata.currentChar = 0;\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\tdata.complete = true;\n\t\t\t\t\t\t\tdata.clearCount = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (data.complete == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tdata.bitmapChar = FlxBitmapFont(data.bitmapFont).getCharacterAsBitmapData(String(data.text).charAt(data.currentChar));\n\t\t\t\t\t\tdata.x = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (data.complete == false)\n\t\t\t\t{\n\t\t\t\t\tdata.slice.x = data.x;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdata.clearCount += data.pixels;\n\t\t\t\t\n\t\t\t\t//\tIt's all over now\n\t\t\t\tif (data.clearCount >= data.clearDistance)\n\t\t\t\t{\n\t\t\t\t\t//\tNo point updating something that has since left the screen\n\t\t\t\t\tdata.scrolling = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tdata.sprite.pixels = data.buffer.clone();\n\t\t\tdata.sprite.dirty = true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes all FlxSprites<br />\n\t\t * This is called automatically if the plugin is destroyed, but should be called manually by you if you change States<br />\n\t\t * as all the FlxSprites will be destroyed by Flixel otherwise\n\t\t */\n\t\tpublic static function clear():void\n\t\t{\n\t\t\tfor each (var obj:Object in members)\n\t\t\t{\n\t\t\t\tdelete members[obj.sprite];\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Starts scrolling on the given FlxSprite. If no FlxSprite is given it starts scrolling on all FlxSprites currently added.<br />\n\t\t * Scrolling is enabled by default, but this can be used to re-start it if you have stopped it via stopScrolling.<br />\n\t\t * \n\t\t * @param\tsource\tThe FlxSprite to start scrolling on. If left as null it will start scrolling on all sprites.\n\t\t */\n\t\tpublic static function startScrolling(source:FlxSprite = null):void\n\t\t{\n\t\t\tif (source)\n\t\t\t{\n\t\t\t\tmembers[source].scrolling = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor each (var obj:Object in members)\n\t\t\t\t{\n\t\t\t\t\tobj.scrolling = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops scrolling on the given FlxSprite. If no FlxSprite is given it stops scrolling on all FlxSprites currently added.<br />\n\t\t * Scrolling is enabled by default, but this can be used to stop it.<br />\n\t\t * \n\t\t * @param\tsource\tThe FlxSprite to stop scrolling on. If left as null it will stop scrolling on all sprites.\n\t\t */\n\t\tpublic static function stopScrolling(source:FlxSprite = null):void\n\t\t{\n\t\t\tif (source)\n\t\t\t{\n\t\t\t\tmembers[source].scrolling = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor each (var obj:Object in members)\n\t\t\t\t{\n\t\t\t\t\tobj.scrolling = false;\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 the given FlxSprite is a Scrolling Text, and is actively scrolling or not<br />\n\t\t * Note: If the text is set to only scroll when on-screen, but if off-screen when this is called, it will still return true.\n\t\t * \n\t\t * @param\tsource\tThe FlxSprite to check for scrolling on.\n\t\t * @return\tBoolean true is the FlxSprite was found and is scrolling, otherwise false\n\t\t */\n\t\tpublic static function isScrolling(source:FlxSprite):Boolean\n\t\t{\n\t\t\tif (members[source])\n\t\t\t{\n\t\t\t\treturn members[source].scrolling;\n\t\t\t}\n\t\t\t\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes an FlxSprite from the Text Scroller. Note that it doesn't restore the sprite bitmapData.\n\t\t * \n\t\t * @param\tsource\tThe FlxSprite to remove scrolling for.\n\t\t * @return\tBoolean\ttrue if the FlxSprite was removed, otherwise false.\n\t\t */\n\t\tpublic static function remove(source:FlxSprite):Boolean\n\t\t{\n\t\t\tif (members[source])\n\t\t\t{\n\t\t\t\tdelete members[source];\n\t\t\t\t\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tclear();\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxSpecialFX.as",
    "content": "/**\n * FlxSpecialFX\n * -- Part of the Flixel Power Tools set\n * \n * v1.6 Added WowCopperFX\n * v1.5 Added RevealFX\n * v1.4 Added BlurFX and CenterSlideFX\n * v1.3 Renamed DropDown to FloodFill\n * v1.2 Added GlitchFX and StarfieldFX\n * v1.1 Added SineWaveFX\n * v1.0 First release of the new FlxSpecialFX system\n * \n * @version 1.6 - September 19th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.utils.Dictionary;\n\timport org.flixel.*;\n\timport org.flixel.plugin.photonstorm.FX.BlurFX;\n\timport org.flixel.plugin.photonstorm.FX.CenterSlideFX;\n\timport org.flixel.plugin.photonstorm.FX.FloodFillFX;\n\timport org.flixel.plugin.photonstorm.FX.GlitchFX;\n\timport org.flixel.plugin.photonstorm.FX.PlasmaFX;\n\timport org.flixel.plugin.photonstorm.FX.RainbowLineFX;\n\timport org.flixel.plugin.photonstorm.FX.RevealFX;\n\timport org.flixel.plugin.photonstorm.FX.SineWaveFX;\n\timport org.flixel.plugin.photonstorm.FX.StarfieldFX;\n\timport org.flixel.plugin.photonstorm.FX.WowCopperFX;\n\t\n\t/**\n\t * FlxSpecialFX is a single point of access to all of the FX Plugins available in the Flixel Power Tools\n\t */\n\tpublic class FlxSpecialFX extends FlxBasic\n\t{\n\t\tprivate static var members:Dictionary = new Dictionary(true);\n\t\t\n\t\tpublic function FlxSpecialFX() \n\t\t{\n\t\t}\n\t\t\n\t\t//\tTHE SPECIAL FX PLUGINS AVAILABLE\n\t\t\n\t\t/**\n\t\t * Creates a Plama field Effect\n\t\t * \n\t\t * @return\tPlasmaFX\n\t\t */\n\t\tpublic static function plasma():PlasmaFX\n\t\t{\n\t\t\tvar temp:PlasmaFX = new PlasmaFX;\n\t\t\t\n\t\t\tmembers[temp] = temp;\n\t\t\t\n\t\t\treturn members[temp];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a Rainbow Line Effect\n\t\t * \n\t\t * @return\tRainbowLineFX\n\t\t */\n\t\tpublic static function rainbowLine():RainbowLineFX\n\t\t{\n\t\t\tvar temp:RainbowLineFX = new RainbowLineFX;\n\t\t\t\n\t\t\tmembers[temp] = temp;\n\t\t\t\n\t\t\treturn members[temp];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a Flood Fill Effect\n\t\t * \n\t\t * @return\tFloodFillFX\n\t\t */\n\t\tpublic static function floodFill():FloodFillFX\n\t\t{\n\t\t\tvar temp:FloodFillFX = new FloodFillFX;\n\t\t\t\n\t\t\tmembers[temp] = temp;\n\t\t\t\n\t\t\treturn members[temp];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a Sine Wave Down Effect\n\t\t * \n\t\t * @return\tSineWaveFX\n\t\t */\n\t\tpublic static function sineWave():SineWaveFX\n\t\t{\n\t\t\tvar temp:SineWaveFX = new SineWaveFX;\n\t\t\t\n\t\t\tmembers[temp] = temp;\n\t\t\t\n\t\t\treturn members[temp];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a Glitch Effect\n\t\t * \n\t\t * @return\tGlitchFX\n\t\t */\n\t\tpublic static function glitch():GlitchFX\n\t\t{\n\t\t\tvar temp:GlitchFX = new GlitchFX;\n\t\t\t\n\t\t\tmembers[temp] = temp;\n\t\t\t\n\t\t\treturn members[temp];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a 2D or 3D Starfield Effect\n\t\t * \n\t\t * @return\tStarfieldFX\n\t\t */\n\t\tpublic static function starfield():StarfieldFX\n\t\t{\n\t\t\tvar temp:StarfieldFX = new StarfieldFX;\n\t\t\t\n\t\t\tmembers[temp] = temp;\n\t\t\t\n\t\t\treturn members[temp];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a Blur Effect\n\t\t * \n\t\t * @return\tBlurFX\n\t\t */\n\t\tpublic static function blur():BlurFX\n\t\t{\n\t\t\tvar temp:BlurFX = new BlurFX;\n\t\t\t\n\t\t\tmembers[temp] = temp;\n\t\t\t\n\t\t\treturn members[temp];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a Center Slide Effect\n\t\t * \n\t\t * @return\tCenterSlideFX\n\t\t */\n\t\tpublic static function centerSlide():CenterSlideFX\n\t\t{\n\t\t\tvar temp:CenterSlideFX = new CenterSlideFX\n\t\t\t\n\t\t\tmembers[temp] = temp;\n\t\t\t\n\t\t\treturn members[temp];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a Reveal Effect\n\t\t * \n\t\t * @return\tRevealFX\n\t\t */\n\t\tpublic static function reveal():RevealFX\n\t\t{\n\t\t\tvar temp:RevealFX = new RevealFX\n\t\t\t\n\t\t\tmembers[temp] = temp;\n\t\t\t\n\t\t\treturn members[temp];\n\t\t}\n\t\t\n\t\t/**\n\t\t * Creates a WOW Copper Effect\n\t\t * \n\t\t * @return\tWowCopperFX\n\t\t */\n\t\tpublic static function wowCopper():WowCopperFX\n\t\t{\n\t\t\tvar temp:WowCopperFX = new WowCopperFX\n\t\t\t\n\t\t\tmembers[temp] = temp;\n\t\t\t\n\t\t\treturn members[temp];\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t//\tGLOBAL FUNCTIONS\n\t\t\n\t\t/**\n\t\t * Starts the given FX Plugin running\n\t\t * \n\t\t * @param\tsource\tA reference to the FX Plugin you wish to run. If null it will start all currently added FX Plugins\n\t\t */\n\t\tpublic static function startFX(source:Class = null):void\n\t\t{\n\t\t\tif (source)\n\t\t\t{\n\t\t\t\tmembers[source].active = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor each (var obj:Object in members)\n\t\t\t\t{\n\t\t\t\t\tobj.active = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Stops the given FX Plugin running\n\t\t * \n\t\t * @param\tsource\tA reference to the FX Plugin you wish to stop. If null it will stop all currently added FX Plugins\n\t\t */\n\t\tpublic static function stopFX(source:Class = null):void\n\t\t{\n\t\t\tif (source)\n\t\t\t{\n\t\t\t\tmembers[source].active = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor each (var obj:Object in members)\n\t\t\t\t{\n\t\t\t\t\tobj.active = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns the active state of the given FX Plugin running\n\t\t * \n\t\t * @param\tsource\tA reference to the FX Plugin you wish to run. If null it will start all currently added FX Plugins\n\t\t * @return\tBoolean\ttrue if the FX Plugin is active, false if not\n\t\t */\n\t\tpublic static function isActive(source:Class):Boolean\n\t\t{\n\t\t\tif (members[source])\n\t\t\t{\n\t\t\t\treturn members[source].active;\n\t\t\t}\n\t\t\t\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Called automatically by Flixels Plugin handler\n\t\t */\n\t\toverride public function draw():void\n\t\t{\n\t\t\tif (FlxG.paused)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tfor each (var obj:Object in members)\n\t\t\t{\n\t\t\t\tif (obj.active)\n\t\t\t\t{\n\t\t\t\t\tobj.draw();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes a FX Plugin from the Special FX Handler\n\t\t * \n\t\t * @param\tsource\tThe FX Plugin to remove\n\t\t * @return\tBoolean\ttrue if the plugin was removed, otherwise false.\n\t\t */\n\t\tpublic static function remove(source:Object):Boolean\n\t\t{\n\t\t\tif (members[source])\n\t\t\t{\n\t\t\t\tmembers[source].destroy();\n\t\t\t\t\n\t\t\t\tdelete members[source];\n\t\t\t\t\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Removes all FX Plugins<br>\n\t\t * This is called automatically if the plugin is destroyed, but should be called manually by you if you change States\n\t\t */\n\t\tpublic static function clear():void\n\t\t{\n\t\t\tfor each (var obj:Object in members)\n\t\t\t{\n\t\t\t\tremove(obj);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Destroys all FX Plugins currently added and then destroys this instance of the FlxSpecialFX Plugin\n\t\t */\n\t\toverride public function destroy():void\n\t\t{\n\t\t\tclear();\n\t\t}\n\t\t\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxVelocity.as",
    "content": "/**\n * FlxVelocity\n * -- Part of the Flixel Power Tools set\n * \n * v1.6 New method: velocityFromFacing\n * v1.5 New methods: velocityFromAngle, accelerateTowardsObject, accelerateTowardsMouse, accelerateTowardsPoint\n * v1.4 New methods: moveTowardsPoint, distanceToPoint, angleBetweenPoint\n * v1.3 Updated for the Flixel 2.5 Plugin system\n * \n * @version 1.6 - August 15th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n * @see Depends on FlxMath\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport flash.accessibility.Accessibility;\n\timport org.flixel.*;\n\t\n\tpublic class FlxVelocity \n\t{\n\t\t\n\t\tpublic function FlxVelocity() \n\t\t{\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the source FlxSprite x/y velocity so it will move directly towards the destination FlxSprite at the speed given (in pixels per second)<br>\n\t\t * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>\n\t\t * Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>\n\t\t * The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>\n\t\t * If you need the object to accelerate, see accelerateTowardsObject() instead\n\t\t * Note: Doesn't take into account acceleration, maxVelocity or drag (if you set drag or acceleration too high this object may not move at all)\n\t\t * \n\t\t * @param\tsource\t\tThe FlxSprite on which the velocity will be set\n\t\t * @param\tdest\t\tThe FlxSprite where the source object will move to\n\t\t * @param\tspeed\t\tThe speed it will move, in pixels per second (default is 60 pixels/sec)\n\t\t * @param\tmaxTime\t\tTime given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms\n\t\t */\n\t\tpublic static function moveTowardsObject(source:FlxSprite, dest:FlxSprite, speed:int = 60, maxTime:int = 0):void\n\t\t{\n\t\t\tvar a:Number = angleBetween(source, dest);\n\t\t\t\n\t\t\tif (maxTime > 0)\n\t\t\t{\n\t\t\t\tvar d:int = distanceBetween(source, dest);\n\t\t\t\t\n\t\t\t\t//\tWe know how many pixels we need to move, but how fast?\n\t\t\t\tspeed = d / (maxTime / 1000);\n\t\t\t}\n\t\t\t\n\t\t\tsource.velocity.x = Math.cos(a) * speed;\n\t\t\tsource.velocity.y = Math.sin(a) * speed;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the x/y acceleration on the source FlxSprite so it will move towards the destination FlxSprite at the speed given (in pixels per second)<br>\n\t\t * You must give a maximum speed value, beyond which the FlxSprite won't go any faster.<br>\n\t\t * If you don't need acceleration look at moveTowardsObject() instead.\n\t\t * \n\t\t * @param\tsource\t\t\tThe FlxSprite on which the acceleration will be set\n\t\t * @param\tdest\t\t\tThe FlxSprite where the source object will move towards\n\t\t * @param\tspeed\t\t\tThe speed it will accelerate in pixels per second\n\t\t * @param\txSpeedMax\t\tThe maximum speed in pixels per second in which the sprite can move horizontally\n\t\t * @param\tySpeedMax\t\tThe maximum speed in pixels per second in which the sprite can move vertically\n\t\t */\n\t\tpublic static function accelerateTowardsObject(source:FlxSprite, dest:FlxSprite, speed:int, xSpeedMax:uint, ySpeedMax:uint):void\n\t\t{\n\t\t\tvar a:Number = angleBetween(source, dest);\n\t\t\t\n\t\t\tsource.velocity.x = 0;\n\t\t\tsource.velocity.y = 0;\n\t\t\t\n\t\t\tsource.acceleration.x = int(Math.cos(a) * speed);\n\t\t\tsource.acceleration.y = int(Math.sin(a) * speed);\n\t\t\t\n\t\t\tsource.maxVelocity.x = xSpeedMax;\n\t\t\tsource.maxVelocity.y = ySpeedMax;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Move the given FlxSprite towards the mouse pointer coordinates at a steady velocity\n\t\t * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>\n\t\t * Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>\n\t\t * The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>\n\t\t * \n\t\t * @param\tsource\t\tThe FlxSprite to move\n\t\t * @param\tspeed\t\tThe speed it will move, in pixels per second (default is 60 pixels/sec)\n\t\t * @param\tmaxTime\t\tTime given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms\n\t\t */\n\t\tpublic static function moveTowardsMouse(source:FlxSprite, speed:int = 60, maxTime:int = 0):void\n\t\t{\n\t\t\tvar a:Number = angleBetweenMouse(source);\n\t\t\t\n\t\t\tif (maxTime > 0)\n\t\t\t{\n\t\t\t\tvar d:int = distanceToMouse(source);\n\t\t\t\t\n\t\t\t\t//\tWe know how many pixels we need to move, but how fast?\n\t\t\t\tspeed = d / (maxTime / 1000);\n\t\t\t}\n\t\t\t\n\t\t\tsource.velocity.x = Math.cos(a) * speed;\n\t\t\tsource.velocity.y = Math.sin(a) * speed;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the x/y acceleration on the source FlxSprite so it will move towards the mouse coordinates at the speed given (in pixels per second)<br>\n\t\t * You must give a maximum speed value, beyond which the FlxSprite won't go any faster.<br>\n\t\t * If you don't need acceleration look at moveTowardsMouse() instead.\n\t\t * \n\t\t * @param\tsource\t\t\tThe FlxSprite on which the acceleration will be set\n\t\t * @param\tspeed\t\t\tThe speed it will accelerate in pixels per second\n\t\t * @param\txSpeedMax\t\tThe maximum speed in pixels per second in which the sprite can move horizontally\n\t\t * @param\tySpeedMax\t\tThe maximum speed in pixels per second in which the sprite can move vertically\n\t\t */\n\t\tpublic static function accelerateTowardsMouse(source:FlxSprite, speed:int, xSpeedMax:uint, ySpeedMax:uint):void\n\t\t{\n\t\t\tvar a:Number = angleBetweenMouse(source);\n\t\t\t\n\t\t\tsource.velocity.x = 0;\n\t\t\tsource.velocity.y = 0;\n\t\t\t\n\t\t\tsource.acceleration.x = int(Math.cos(a) * speed);\n\t\t\tsource.acceleration.y = int(Math.sin(a) * speed);\n\t\t\t\n\t\t\tsource.maxVelocity.x = xSpeedMax;\n\t\t\tsource.maxVelocity.y = ySpeedMax;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the x/y velocity on the source FlxSprite so it will move towards the target coordinates at the speed given (in pixels per second)<br>\n\t\t * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>\n\t\t * Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>\n\t\t * The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>\n\t\t * \n\t\t * @param\tsource\t\tThe FlxSprite to move\n\t\t * @param\ttarget\t\tThe FlxPoint coordinates to move the source FlxSprite towards\n\t\t * @param\tspeed\t\tThe speed it will move, in pixels per second (default is 60 pixels/sec)\n\t\t * @param\tmaxTime\t\tTime given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms\n\t\t */\n\t\tpublic static function moveTowardsPoint(source:FlxSprite, target:FlxPoint, speed:int = 60, maxTime:int = 0):void\n\t\t{\n\t\t\tvar a:Number = angleBetweenPoint(source, target);\n\t\t\t\n\t\t\tif (maxTime > 0)\n\t\t\t{\n\t\t\t\tvar d:int = distanceToPoint(source, target);\n\t\t\t\t\n\t\t\t\t//\tWe know how many pixels we need to move, but how fast?\n\t\t\t\tspeed = d / (maxTime / 1000);\n\t\t\t}\n\t\t\t\n\t\t\tsource.velocity.x = Math.cos(a) * speed;\n\t\t\tsource.velocity.y = Math.sin(a) * speed;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the x/y acceleration on the source FlxSprite so it will move towards the target coordinates at the speed given (in pixels per second)<br>\n\t\t * You must give a maximum speed value, beyond which the FlxSprite won't go any faster.<br>\n\t\t * If you don't need acceleration look at moveTowardsPoint() instead.\n\t\t * \n\t\t * @param\tsource\t\t\tThe FlxSprite on which the acceleration will be set\n\t\t * @param\ttarget\t\t\tThe FlxPoint coordinates to move the source FlxSprite towards\n\t\t * @param\tspeed\t\t\tThe speed it will accelerate in pixels per second\n\t\t * @param\txSpeedMax\t\tThe maximum speed in pixels per second in which the sprite can move horizontally\n\t\t * @param\tySpeedMax\t\tThe maximum speed in pixels per second in which the sprite can move vertically\n\t\t */\n\t\tpublic static function accelerateTowardsPoint(source:FlxSprite, target:FlxPoint, speed:int, xSpeedMax:uint, ySpeedMax:uint):void\n\t\t{\n\t\t\tvar a:Number = angleBetweenPoint(source, target);\n\t\t\t\n\t\t\tsource.velocity.x = 0;\n\t\t\tsource.velocity.y = 0;\n\t\t\t\n\t\t\tsource.acceleration.x = int(Math.cos(a) * speed);\n\t\t\tsource.acceleration.y = int(Math.sin(a) * speed);\n\t\t\t\n\t\t\tsource.maxVelocity.x = xSpeedMax;\n\t\t\tsource.maxVelocity.y = ySpeedMax;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Find the distance (in pixels, rounded) between two FlxSprites, taking their origin into account\n\t\t * \n\t\t * @param\ta\tThe first FlxSprite\n\t\t * @param\tb\tThe second FlxSprite\n\t\t * @return\tint\tDistance (in pixels)\n\t\t */\n\t\tpublic static function distanceBetween(a:FlxSprite, b:FlxSprite):int\n\t\t{\n\t\t\tvar dx:Number = (a.x + a.origin.x) - (b.x + b.origin.x);\n\t\t\tvar dy:Number = (a.y + a.origin.y) - (b.y + b.origin.y);\n\t\t\t\n\t\t\treturn int(FlxMath.vectorLength(dx, dy));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Find the distance (in pixels, rounded) from an FlxSprite to the given FlxPoint, taking the source origin into account\n\t\t * \n\t\t * @param\ta\t\tThe first FlxSprite\n\t\t * @param\ttarget\tThe FlxPoint\n\t\t * @return\tint\t\tDistance (in pixels)\n\t\t */\n\t\tpublic static function distanceToPoint(a:FlxSprite, target:FlxPoint):int\n\t\t{\n\t\t\tvar dx:Number = (a.x + a.origin.x) - (target.x);\n\t\t\tvar dy:Number = (a.y + a.origin.y) - (target.y);\n\t\t\t\n\t\t\treturn int(FlxMath.vectorLength(dx, dy));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Find the distance (in pixels, rounded) from the object x/y and the mouse x/y\n\t\t * \n\t\t * @param\ta\tThe FlxSprite to test against\n\t\t * @return\tint\tThe distance between the given sprite and the mouse coordinates\n\t\t */\n\t\tpublic static function distanceToMouse(a:FlxSprite):int\n\t\t{\n\t\t\tvar dx:Number = (a.x + a.origin.x) - FlxG.mouse.screenX;\n\t\t\tvar dy:Number = (a.y + a.origin.y) - FlxG.mouse.screenY;\n\t\t\t\n\t\t\treturn int(FlxMath.vectorLength(dx, dy));\n\t\t}\n\t\t\n\t\t/**\n\t\t * Find the angle (in radians) between an FlxSprite and an FlxPoint. The source sprite takes its x/y and origin into account.\n\t\t * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)\n\t\t * \n\t\t * @param\ta\t\t\tThe FlxSprite to test from\n\t\t * @param\ttarget\t\tThe FlxPoint to angle the FlxSprite towards\n\t\t * @param\tasDegrees\tIf you need the value in degrees instead of radians, set to true\n\t\t * \n\t\t * @return\tNumber The angle (in radians unless asDegrees is true)\n\t\t */\n\t\tpublic static function angleBetweenPoint(a:FlxSprite, target:FlxPoint, asDegrees:Boolean = false):Number\n        {\n\t\t\tvar dx:Number = (target.x) - (a.x + a.origin.x);\n\t\t\tvar dy:Number = (target.y) - (a.y + a.origin.y);\n\t\t\t\n\t\t\tif (asDegrees)\n\t\t\t{\n\t\t\t\treturn FlxMath.asDegrees(Math.atan2(dy, dx));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn Math.atan2(dy, dx);\n\t\t\t}\n        }\n\t\t\n\t\t/**\n\t\t * Find the angle (in radians) between the two FlxSprite, taking their x/y and origin into account.\n\t\t * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)\n\t\t * \n\t\t * @param\ta\t\t\tThe FlxSprite to test from\n\t\t * @param\tb\t\t\tThe FlxSprite to test to\n\t\t * @param\tasDegrees\tIf you need the value in degrees instead of radians, set to true\n\t\t * \n\t\t * @return\tNumber The angle (in radians unless asDegrees is true)\n\t\t */\n\t\tpublic static function angleBetween(a:FlxSprite, b:FlxSprite, asDegrees:Boolean = false):Number\n        {\n\t\t\tvar dx:Number = (b.x + b.origin.x) - (a.x + a.origin.x);\n\t\t\tvar dy:Number = (b.y + b.origin.y) - (a.y + a.origin.y);\n\t\t\t\n\t\t\tif (asDegrees)\n\t\t\t{\n\t\t\t\treturn FlxMath.asDegrees(Math.atan2(dy, dx));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn Math.atan2(dy, dx);\n\t\t\t}\n        }\n\t\t\n\t\t/**\n\t\t * Given the angle and speed calculate the velocity and return it as an FlxPoint\n\t\t * \n\t\t * @param\tangle\tThe angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)\n\t\t * @param\tspeed\tThe speed it will move, in pixels per second sq\n\t\t * \n\t\t * @return\tAn FlxPoint where FlxPoint.x contains the velocity x value and FlxPoint.y contains the velocity y value\n\t\t */\n\t\tpublic static function velocityFromAngle(angle:int, speed:int):FlxPoint\n\t\t{\n\t\t\tvar a:Number = FlxMath.asRadians(angle);\n\t\t\t\n\t\t\tvar result:FlxPoint = new FlxPoint;\n\t\t\t\n\t\t\tresult.x = int(Math.cos(a) * speed);\n\t\t\tresult.y = int(Math.sin(a) * speed);\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Given the FlxSprite and speed calculate the velocity and return it as an FlxPoint based on the direction the sprite is facing\n\t\t * \n\t\t * @param\tparent\tThe FlxSprite to get the facing value from\n\t\t * @param\tspeed\tThe speed it will move, in pixels per second sq\n\t\t * \n\t\t * @return\tAn FlxPoint where FlxPoint.x contains the velocity x value and FlxPoint.y contains the velocity y value\n\t\t */\n\t\tpublic static function velocityFromFacing(parent:FlxSprite, speed:int):FlxPoint\n\t\t{\n\t\t\tvar a:Number;\n\t\t\t\n\t\t\tif (parent.facing == FlxObject.LEFT)\n\t\t\t{\n\t\t\t\ta = FlxMath.asRadians(180);\n\t\t\t}\n\t\t\telse if (parent.facing == FlxObject.RIGHT)\n\t\t\t{\n\t\t\t\ta = FlxMath.asRadians(0);\n\t\t\t}\n\t\t\telse if (parent.facing == FlxObject.UP)\n\t\t\t{\n\t\t\t\ta = FlxMath.asRadians( -90);\n\t\t\t}\n\t\t\telse if (parent.facing == FlxObject.DOWN)\n\t\t\t{\n\t\t\t\ta = FlxMath.asRadians(90);\n\t\t\t}\n\t\t\t\n\t\t\tvar result:FlxPoint = new FlxPoint;\n\t\t\t\n\t\t\tresult.x = int(Math.cos(a) * speed);\n\t\t\tresult.y = int(Math.sin(a) * speed);\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Find the angle (in radians) between an FlxSprite and the mouse, taking their x/y and origin into account.\n\t\t * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)\n\t\t * \n\t\t * @param\ta\t\t\tThe FlxObject to test from\n\t\t * @param\tasDegrees\tIf you need the value in degrees instead of radians, set to true\n\t\t * \n\t\t * @return\tNumber The angle (in radians unless asDegrees is true)\n\t\t */\n\t\tpublic static function angleBetweenMouse(a:FlxSprite, asDegrees:Boolean = false):Number\n\t\t{\n\t\t\t//\tIn order to get the angle between the object and mouse, we need the objects screen coordinates (rather than world coordinates)\n\t\t\tvar p:FlxPoint = a.getScreenXY();\n\t\t\t\n\t\t\tvar dx:Number = FlxG.mouse.screenX - p.x;\n\t\t\tvar dy:Number = FlxG.mouse.screenY - p.y;\n\t\t\t\n\t\t\tif (asDegrees)\n\t\t\t{\n\t\t\t\treturn FlxMath.asDegrees(Math.atan2(dy, dx));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn Math.atan2(dy, dx);\n\t\t\t}\n\t\t}\n        \n\t\t\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/FlxWeapon.as",
    "content": "/**\n * FlxWeapon\n * -- Part of the Flixel Power Tools set\n * \n * v1.3 Added bullet elasticity and bulletsFired counter\n * v1.2 Added useParentDirection boolean\n * v1.1 Added pre-fire, fire and post-fire callbacks and sound support, rnd factors, boolean returns and currentBullet\n * v1.0 First release\n * \n * @version 1.3 - October 9th 2011\n * @link http://www.photonstorm.com\n * @author Richard Davey / Photon Storm\n*/\n\npackage org.flixel.plugin.photonstorm \n{\n\timport org.flixel.*;\n\timport flash.utils.getTimer;\n\timport org.flixel.plugin.photonstorm.BaseTypes.Bullet;\n\timport org.flixel.plugin.photonstorm.FlxVelocity;\n\t\n\t/**\n\t * TODO\n\t * ----\n\t * \n\t * Angled bullets\n\t * Baked Rotation support for angled bullets\n\t * Bullet death styles (particle effects)\n\t * Bullet trails - blur FX style and Missile Command \"draw lines\" style? (could be another FX plugin)\n\t * Homing Missiles\n\t * Bullet uses random sprite from sprite sheet (for rainbow style bullets), or cycles through them in sequence?\n\t * Some Weapon base classes like shotgun, lazer, etc?\n\t */\n\t\n\tpublic class FlxWeapon \n\t{\n\t\t/**\n\t\t * Internal name for this weapon (i.e. \"pulse rifle\")\n\t\t */\n\t\tpublic var name:String;\n\t\t\n\t\t/**\n\t\t * The FlxGroup into which all the bullets for this weapon are drawn. This should be added to your display and collision checked against it.\n\t\t */\n\t\tpublic var group:FlxGroup;\n\t\t\n\t\t//\tBullet values\n\t\tpublic var bounds:FlxRect;\n\t\t\n\t\tprivate var bulletSpeed:uint;\n\t\tprivate var rotateToAngle:Boolean;\n\t\t\n\t\t//\tWhen firing from a fixed position (i.e. Missile Command)\n\t\tprivate var fireFromPosition:Boolean;\n\t\tprivate var fireX:int;\n\t\tprivate var fireY:int;\n\t\t\n\t\tprivate var lastFired:uint = 0;\n\t\tprivate var nextFire:uint = 0;\n\t\tprivate var fireRate:uint = 0;\n\t\t\n\t\t//\tWhen firing from a parent sprites position (i.e. Space Invaders)\n\t\tprivate var fireFromParent:Boolean;\n\t\tprivate var parent:*;\n\t\tprivate var parentXVariable:String;\n\t\tprivate var parentYVariable:String;\n\t\tprivate var positionOffset:FlxPoint;\n\t\tprivate var directionFromParent:Boolean;\n\t\tprivate var angleFromParent:Boolean;\n\t\t\n\t\tprivate var velocity:FlxPoint;\n\t\t\n\t\tpublic var multiShot:uint = 0;\n\t\t\n\t\tpublic var bulletLifeSpan:uint = 0;\n\t\tpublic var bulletElasticity:Number = 0;\n\t\t\n\t\tpublic var rndFactorAngle:uint = 0;\n\t\tpublic var rndFactorLifeSpan:uint = 0;\n\t\tpublic var rndFactorSpeed:uint = 0;\n\t\tpublic var rndFactorPosition:FlxPoint = new FlxPoint;\n\t\t\n\t\t/**\n\t\t * A reference to the Bullet that was fired\n\t\t */\n\t\tpublic var currentBullet:Bullet;\n\t\t\n\t\t//\tCallbacks\n\t\tpublic var onPreFireCallback:Function;\n\t\tpublic var onFireCallback:Function;\n\t\tpublic var onPostFireCallback:Function;\n\t\t\n\t\t//\tSounds\n\t\tpublic var onPreFireSound:FlxSound;\n\t\tpublic var onFireSound:FlxSound;\n\t\tpublic var onPostFireSound:FlxSound;\n\t\t\n\t\t//\tQuick firing direction angle constants\n\t\tpublic static const BULLET_UP:int = -90;\n\t\tpublic static const BULLET_DOWN:int = 90;\n\t\tpublic static const BULLET_LEFT:int = 180;\n\t\tpublic static const BULLET_RIGHT:int = 0;\n\t\tpublic static const BULLET_NORTH_EAST:int = -45;\n\t\tpublic static const BULLET_NORTH_WEST:int = -135;\n\t\tpublic static const BULLET_SOUTH_EAST:int = 45;\n\t\tpublic static const BULLET_SOUTH_WEST:int = 135;\n\t\t\n\t\t/**\n\t\t * Keeps a tally of how many bullets have been fired by this weapon\n\t\t */\n\t\tpublic var bulletsFired:uint = 0;\n\t\t\n\t\t//\tTODO :)\n\t\tprivate var currentMagazine:uint;\n\t\t//private var currentBullet:uint;\n\t\tprivate var magazineCount:uint;\n\t\tprivate var bulletsPerMagazine:uint;\n\t\tprivate var magazineSwapDelay:uint;\n\t\tprivate var magazineSwapCallback:Function;\n\t\tprivate var magazineSwapSound:FlxSound;\n\t\t\n\t\tprivate static const FIRE:uint = 0;\n\t\tprivate static const FIRE_AT_MOUSE:uint = 1;\n\t\tprivate static const FIRE_AT_POSITION:uint = 2;\n\t\tprivate static const FIRE_AT_TARGET:uint = 3;\n\t\tprivate static const FIRE_FROM_ANGLE:uint = 4;\n\t\tprivate static const FIRE_FROM_PARENT_ANGLE:uint = 5;\n\t\t\n\t\t/**\n\t\t * Creates the FlxWeapon class which will fire your bullets.<br>\n\t\t * You should call one of the makeBullet functions to visually create the bullets.<br>\n\t\t * Then either use setDirection with fire() or one of the fireAt functions to launch them.\n\t\t * \n\t\t * @param\tname\t\tThe name of your weapon (i.e. \"lazer\" or \"shotgun\"). For your internal reference really, but could be displayed in-game.\n\t\t * @param\tparentRef\tIf this weapon belongs to a parent sprite, specify it here (bullets will fire from the sprites x/y vars as defined below).\n\t\t * @param\txVariable\tThe x axis variable of the parent to use when firing. Typically \"x\", but could be \"screenX\" or any public getter that exposes the x coordinate.\n\t\t * @param\tyVariable\tThe y axis variable of the parent to use when firing. Typically \"y\", but could be \"screenY\" or any public getter that exposes the y coordinate.\n\t\t */\n\t\tpublic function FlxWeapon(name:String, parentRef:* = null, xVariable:String = \"x\", yVariable:String = \"y\")\n\t\t{\n\t\t\tthis.name = name;\n\t\t\t\n\t\t\tbounds = new FlxRect(0, 0, FlxG.width, FlxG.height);\n\t\t\t\n\t\t\tpositionOffset = new FlxPoint;\n\t\t\t\n\t\t\tvelocity = new FlxPoint;\n\t\t\t\n\t\t\tif (parentRef)\n\t\t\t{\n\t\t\t\tsetParent(parentRef, xVariable, yVariable);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Makes a pixel bullet sprite (rather than an image). You can set the width/height and color of the bullet.\n\t\t * \n\t\t * @param\tquantity\tHow many bullets do you need to make? This value should be high enough to cover all bullets you need on-screen *at once* plus probably a few extra spare!\n\t\t * @param\twidth\t\tThe width (in pixels) of the bullets\n\t\t * @param\theight\t\tThe height (in pixels) of the bullets\n\t\t * @param\tcolor\t\tThe color of the bullets. Must be given in 0xAARRGGBB format\n\t\t * @param\toffsetX\t\tWhen the bullet is fired if you need to offset it on the x axis, for example to line it up with the \"nose\" of a space ship, set the amount here (positive or negative)\n\t\t * @param\toffsetY\t\tWhen the bullet is fired if you need to offset it on the y axis, for example to line it up with the \"nose\" of a space ship, set the amount here (positive or negative)\n\t\t */\n\t\tpublic function makePixelBullet(quantity:uint, width:int = 2, height:int = 2, color:uint = 0xffffffff, offsetX:int = 0, offsetY:int = 0):void\n\t\t{\n\t\t\tgroup = new FlxGroup(quantity);\n\t\t\t\n\t\t\tfor (var b:uint = 0; b < quantity; b++)\n\t\t\t{\n\t\t\t\tvar tempBullet:Bullet = new Bullet(this, b);\n\t\t\t\t\n\t\t\t\ttempBullet.makeGraphic(width, height, color);\n\t\t\t\t\n\t\t\t\tgroup.add(tempBullet);\n\t\t\t}\n\t\t\t\n\t\t\tpositionOffset.x = offsetX;\n\t\t\tpositionOffset.y = offsetY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Makes a bullet sprite from the given image. It will use the width/height of the image.\n\t\t * \n\t\t * @param\tquantity\t\tHow many bullets do you need to make? This value should be high enough to cover all bullets you need on-screen *at once* plus probably a few extra spare!\n\t\t * @param\timage\t\t\tThe image used to create the bullet from\n\t\t * @param\toffsetX\t\t\tWhen the bullet is fired if you need to offset it on the x axis, for example to line it up with the \"nose\" of a space ship, set the amount here (positive or negative)\n\t\t * @param\toffsetY\t\t\tWhen the bullet is fired if you need to offset it on the y axis, for example to line it up with the \"nose\" of a space ship, set the amount here (positive or negative)\n\t\t * @param\tautoRotate\t\tWhen true the bullet sprite will rotate to match the angle of the parent sprite. Call fireFromParentAngle or fromFromAngle to fire it using an angle as the velocity.\n\t\t * @param\tframe\t\t\tIf the image 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\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\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\tpublic function makeImageBullet(quantity:uint, image:Class, offsetX:int = 0, offsetY:int = 0, autoRotate:Boolean = false, rotations:uint = 16, frame:int = -1, antiAliasing:Boolean = false, autoBuffer:Boolean = false):void\n\t\t{\n\t\t\tgroup = new FlxGroup(quantity);\n\t\t\t\n\t\t\trotateToAngle = autoRotate;\n\t\t\t\n\t\t\tfor (var b:uint = 0; b < quantity; b++)\n\t\t\t{\n\t\t\t\tvar tempBullet:Bullet = new Bullet(this, b);\n\t\t\t\t\n\t\t\t\tif (autoRotate)\n\t\t\t\t{\n\t\t\t\t\ttempBullet.loadRotatedGraphic(image, rotations, frame, antiAliasing, autoBuffer);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\ttempBullet.loadGraphic(image);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tgroup.add(tempBullet);\n\t\t\t}\n\t\t\t\n\t\t\tpositionOffset.x = offsetX;\n\t\t\tpositionOffset.y = offsetY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Makes an animated bullet from the image and frame data given.\n\t\t * \n\t\t * @param\tquantity\t\tHow many bullets do you need to make? This value should be high enough to cover all bullets you need on-screen *at once* plus probably a few extra spare!\n\t\t * @param\timageSequence\tThe image used to created the animated bullet from\n\t\t * @param\tframeWidth\t\tThe width of each frame in the animation\n\t\t * @param\tframeHeight\t\tThe height of each frame in the animation\n\t\t * @param\tframes\t\t\tAn array of numbers indicating what frames to play in what order (e.g. 1, 2, 3)\n\t\t * @param\tframeRate\t\tThe speed in frames per second that the animation should play at (e.g. 40 fps)\n\t\t * @param\tlooped\t\t\tWhether or not the animation is looped or just plays once\n\t\t * @param\toffsetX\t\t\tWhen the bullet is fired if you need to offset it on the x axis, for example to line it up with the \"nose\" of a space ship, set the amount here (positive or negative)\n\t\t * @param\toffsetY\t\t\tWhen the bullet is fired if you need to offset it on the y axis, for example to line it up with the \"nose\" of a space ship, set the amount here (positive or negative)\n\t\t */\n\t\tpublic function makeAnimatedBullet(quantity:uint, imageSequence:Class, frameWidth:uint, frameHeight:uint, frames:Array, frameRate:uint, looped:Boolean, offsetX:int = 0, offsetY:int = 0):void\n\t\t{\n\t\t\tgroup = new FlxGroup(quantity);\n\t\t\t\n\t\t\tfor (var b:uint = 0; b < quantity; b++)\n\t\t\t{\n\t\t\t\tvar tempBullet:Bullet = new Bullet(this, b);\n\t\t\t\t\n\t\t\t\ttempBullet.loadGraphic(imageSequence, true, false, frameWidth, frameHeight);\n\t\t\t\t\n\t\t\t\ttempBullet.addAnimation(\"fire\", frames, frameRate, looped);\n\t\t\t\t\n\t\t\t\tgroup.add(tempBullet);\n\t\t\t}\n\t\t\t\n\t\t\tpositionOffset.x = offsetX;\n\t\t\tpositionOffset.y = offsetY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function that handles the actual firing of the bullets\n\t\t * \n\t\t * @param\tmethod\n\t\t * @param\tx\n\t\t * @param\ty\n\t\t * @param\ttarget\n\t\t * @return\ttrue if a bullet was fired or false if one wasn't available. The bullet last fired is stored in FlxWeapon.prevBullet\n\t\t */\n\t\tprivate function runFire(method:uint, x:int = 0, y:int = 0, target:FlxSprite = null, angle:int = 0):Boolean\n\t\t{\n\t\t\tif (fireRate > 0 && (getTimer() < nextFire))\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\tcurrentBullet = getFreeBullet();\n\t\t\t\n\t\t\tif (currentBullet == null)\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (onPreFireCallback is Function)\n\t\t\t{\n\t\t\t\tonPreFireCallback.apply();\n\t\t\t}\n\t\t\t\n\t\t\tif (onPreFireSound)\n\t\t\t{\n\t\t\t\tonPreFireSound.play();\n\t\t\t}\n\t\t\t\n\t\t\t//\tClear any velocity that may have been previously set from the pool\n\t\t\tcurrentBullet.velocity.x = 0;\n\t\t\tcurrentBullet.velocity.y = 0;\n\t\t\t\n\t\t\tlastFired = getTimer();\n\t\t\tnextFire = getTimer() + fireRate;\n\t\t\t\n\t\t\tvar launchX:int = positionOffset.x;\n\t\t\tvar launchY:int = positionOffset.y;\n\t\t\t\n\t\t\tif (fireFromParent)\n\t\t\t{\n\t\t\t\tlaunchX += parent[parentXVariable];\n\t\t\t\tlaunchY += parent[parentYVariable];\n\t\t\t}\n\t\t\telse if (fireFromPosition)\n\t\t\t{\n\t\t\t\tlaunchX += fireX;\n\t\t\t\tlaunchY += fireY;\n\t\t\t}\n\t\t\t\n\t\t\tif (directionFromParent)\n\t\t\t{\n\t\t\t\tvelocity = FlxVelocity.velocityFromFacing(parent, bulletSpeed);\n\t\t\t}\n\t\t\t\n\t\t\t//\tFaster (less CPU) to use this small if-else ladder than a switch statement\n\t\t\tif (method == FIRE)\n\t\t\t{\n\t\t\t\tcurrentBullet.fire(launchX, launchY, velocity.x, velocity.y);\n\t\t\t}\n\t\t\telse if (method == FIRE_AT_MOUSE)\n\t\t\t{\n\t\t\t\tcurrentBullet.fireAtMouse(launchX, launchY, bulletSpeed);\n\t\t\t}\n\t\t\telse if (method == FIRE_AT_POSITION)\n\t\t\t{\n\t\t\t\tcurrentBullet.fireAtPosition(launchX, launchY, x, y, bulletSpeed);\n\t\t\t}\n\t\t\telse if (method == FIRE_AT_TARGET)\n\t\t\t{\n\t\t\t\tcurrentBullet.fireAtTarget(launchX, launchY, target, bulletSpeed);\n\t\t\t}\n\t\t\telse if (method == FIRE_FROM_ANGLE)\n\t\t\t{\n\t\t\t\tcurrentBullet.fireFromAngle(launchX, launchY, angle, bulletSpeed);\n\t\t\t}\n\t\t\telse if (method == FIRE_FROM_PARENT_ANGLE)\n\t\t\t{\n\t\t\t\tcurrentBullet.fireFromAngle(launchX, launchY, parent.angle, bulletSpeed);\n\t\t\t}\n\t\t\t\n\t\t\tif (onPostFireCallback is Function)\n\t\t\t{\n\t\t\t\tonPostFireCallback.apply();\n\t\t\t}\n\t\t\t\n\t\t\tif (onPostFireSound)\n\t\t\t{\n\t\t\t\tonPostFireSound.play();\n\t\t\t}\n\t\t\t\n\t\t\tbulletsFired++;\n\t\t\t\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fires a bullet (if one is available). The bullet will be given the velocity defined in setBulletDirection and fired at the rate set in setFireRate.\n\t\t * \n\t\t * @return\ttrue if a bullet was fired or false if one wasn't available. A reference to the bullet fired is stored in FlxWeapon.currentBullet.\n\t\t */\n\t\tpublic function fire():Boolean\n\t\t{\n\t\t\treturn runFire(FIRE);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fires a bullet (if one is available) at the mouse coordinates, using the speed set in setBulletSpeed and the rate set in setFireRate.\n\t\t * \n\t\t * @return\ttrue if a bullet was fired or false if one wasn't available. A reference to the bullet fired is stored in FlxWeapon.currentBullet.\n\t\t */\n\t\tpublic function fireAtMouse():Boolean\n\t\t{\n\t\t\treturn runFire(FIRE_AT_MOUSE);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fires a bullet (if one is available) at the given x/y coordinates, using the speed set in setBulletSpeed and the rate set in setFireRate.\n\t\t * \n\t\t * @param\tx\tThe x coordinate (in game world pixels) to fire at\n\t\t * @param\ty\tThe y coordinate (in game world pixels) to fire at\n\t\t * @return\ttrue if a bullet was fired or false if one wasn't available. A reference to the bullet fired is stored in FlxWeapon.currentBullet.\n\t\t */\n\t\tpublic function fireAtPosition(x:int, y:int):Boolean\n\t\t{\n\t\t\treturn runFire(FIRE_AT_POSITION, x, y);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fires a bullet (if one is available) at the given targets x/y coordinates, using the speed set in setBulletSpeed and the rate set in setFireRate.\n\t\t * \n\t\t * @param\ttarget\tThe FlxSprite you wish to fire the bullet at\n\t\t * @return\ttrue if a bullet was fired or false if one wasn't available. A reference to the bullet fired is stored in FlxWeapon.currentBullet.\n\t\t */\n\t\tpublic function fireAtTarget(target:FlxSprite):Boolean\n\t\t{\n\t\t\treturn runFire(FIRE_AT_TARGET, 0, 0, target);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fires a bullet (if one is available) based on the given angle\n\t\t * \n\t\t * @param\tangle\tThe angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)\n\t\t * @return\ttrue if a bullet was fired or false if one wasn't available. A reference to the bullet fired is stored in FlxWeapon.currentBullet.\n\t\t */\n\t\tpublic function fireFromAngle(angle:int):Boolean\n\t\t{\n\t\t\treturn runFire(FIRE_FROM_ANGLE, 0, 0, null, angle);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Fires a bullet (if one is available) based on the angle of the Weapons parent\n\t\t * \n\t\t * @return\ttrue if a bullet was fired or false if one wasn't available. A reference to the bullet fired is stored in FlxWeapon.currentBullet.\n\t\t */\n\t\tpublic function fireFromParentAngle():Boolean\n\t\t{\n\t\t\treturn runFire(FIRE_FROM_PARENT_ANGLE);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Causes the Weapon to fire from the parents x/y value, as seen in Space Invaders and most shoot-em-ups.\n\t\t * \n\t\t * @param\tparentRef\t\tIf this weapon belongs to a parent sprite, specify it here (bullets will fire from the sprites x/y vars as defined below).\n\t\t * @param\txVariable\t\tThe x axis variable of the parent to use when firing. Typically \"x\", but could be \"screenX\" or any public getter that exposes the x coordinate.\n\t\t * @param\tyVariable\t\tThe y axis variable of the parent to use when firing. Typically \"y\", but could be \"screenY\" or any public getter that exposes the y coordinate.\n\t\t * @param\toffsetX\t\t\tWhen the bullet is fired if you need to offset it on the x axis, for example to line it up with the \"nose\" of a space ship, set the amount here (positive or negative)\n\t\t * @param\toffsetY\t\t\tWhen the bullet is fired if you need to offset it on the y axis, for example to line it up with the \"nose\" of a space ship, set the amount here (positive or negative)\n\t\t * @param\tuseDirection\tWhen fired the bullet direction is based on parent sprites facing value (up/down/left/right)\n\t\t */\n\t\tpublic function setParent(parentRef:*, xVariable:String, yVariable:String, offsetX:int = 0, offsetY:int = 0, useDirection:Boolean = false):void\n\t\t{\n\t\t\tif (parentRef)\n\t\t\t{\n\t\t\t\tfireFromParent = true;\n\t\t\t\t\n\t\t\t\tparent = parentRef;\n\t\t\t\t\n\t\t\t\tparentXVariable = xVariable;\n\t\t\t\tparentYVariable = yVariable;\n\t\t\t\n\t\t\t\tpositionOffset.x = offsetX;\n\t\t\t\tpositionOffset.y = offsetY;\n\t\t\t\t\n\t\t\t\tdirectionFromParent = useDirection;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * Causes the Weapon to fire from a fixed x/y position on the screen, like in the game Missile Command.<br>\n\t\t * If set this over-rides a call to setParent (which causes the Weapon to fire from the parents x/y position)\n\t\t * \n\t\t * @param\tx\tThe x coordinate (in game world pixels) to fire from\n\t\t * @param\ty\tThe y coordinate (in game world pixels) to fire from\n\t\t * @param\toffsetX\t\tWhen the bullet is fired if you need to offset it on the x axis, for example to line it up with the \"nose\" of a space ship, set the amount here (positive or negative)\n\t\t * @param\toffsetY\t\tWhen the bullet is fired if you need to offset it on the y axis, for example to line it up with the \"nose\" of a space ship, set the amount here (positive or negative)\n\t\t */\n\t\tpublic function setFiringPosition(x:int, y:int, offsetX:int = 0, offsetY:int = 0):void\n\t\t{\n\t\t\tfireFromPosition = true;\n\t\t\tfireX = x;\n\t\t\tfireY = y;\n\t\t\t\n\t\t\tpositionOffset.x = offsetX;\n\t\t\tpositionOffset.y = offsetY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The speed in pixels/sec (sq) that the bullet travels at when fired via fireAtMouse, fireAtPosition or fireAtTarget.\n\t\t * You can update this value in real-time, should you need to speed-up or slow-down your bullets (i.e. collecting a power-up)\n\t\t * \n\t\t * @param\tspeed\t\tThe speed it will move, in pixels per second (sq)\n\t\t */\n\t\tpublic function setBulletSpeed(speed:uint):void\n\t\t{\n\t\t\tbulletSpeed = speed;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The speed in pixels/sec (sq) that the bullet travels at when fired via fireAtMouse, fireAtPosition or fireAtTarget.\n\t\t * \n\t\t * @return\tThe speed the bullet moves at, in pixels per second (sq)\n\t\t */\n\t\tpublic function getBulletSpeed():uint\n\t\t{\n\t\t\treturn bulletSpeed;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets the firing rate of the Weapon. By default there is no rate, as it can be controlled by FlxControl.setFireButton.\n\t\t * However if you are firing using the mouse you may wish to set a firing rate.\n\t\t * \n\t\t * @param\trate\tThe delay in milliseconds (ms) between which each bullet is fired, set to zero to clear\n\t\t */\n\t\tpublic function setFireRate(rate:uint):void\n\t\t{\n\t\t\tfireRate = rate;\n\t\t}\n\t\t\n\t\t/**\n\t\t * When a bullet goes outside of this bounds it will be automatically killed, freeing it up for firing again.\n\t\t * TODO - Needs testing with a scrolling map (when not using single screen display)\n\t\t * \n\t\t * @param\tbounds\tAn FlxRect area. Inside this area the bullet should be considered alive, once outside it will be killed.\n\t\t */\n\t\tpublic function setBulletBounds(bounds:FlxRect):void\n\t\t{\n\t\t\tthis.bounds = bounds;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Set the direction the bullet will travel when fired.\n\t\t * You can use one of the consts such as BULLET_UP, BULLET_DOWN or BULLET_NORTH_EAST to set the angle easily.\n\t\t * Speed should be given in pixels/sec (sq) and is the speed at which the bullet travels when fired.\n\t\t * \n\t\t * @param\tangle\t\tThe angle of the bullet. In clockwise positive direction: Right = 0, Down = 90, Left = 180, Up = -90. You can use one of the consts such as BULLET_UP, etc\n\t\t * @param\tspeed\t\tThe speed it will move, in pixels per second (sq)\n\t\t */\n\t\tpublic function setBulletDirection(angle:int, speed:uint):void\n\t\t{\n\t\t\tvelocity = FlxVelocity.velocityFromAngle(angle, speed);\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets gravity on all currently created bullets<br>\n\t\t * This will update ALL bullets, even those currently \"in flight\", so be careful about when you call this!\n\t\t * \n\t\t * @param\txForce\tA positive value applies gravity dragging the bullet to the right. A negative value drags the bullet to the left. Zero disables horizontal gravity.\n\t\t * @param\tyforce\tA positive value applies gravity dragging the bullet down. A negative value drags the bullet up. Zero disables vertical gravity.\n\t\t */\n\t\tpublic function setBulletGravity(xForce:int, yForce:int):void\n\t\t{\n\t\t\tgroup.setAll(\"xGravity\", xForce);\n\t\t\tgroup.setAll(\"yGravity\", yForce);\n\t\t}\n\t\t\n\t\t/**\n\t\t * If you'd like your bullets to accelerate to their top speed rather than be launched already at it, then set the acceleration value here.\n\t\t * If you've previously set the acceleration then setting it to zero will cancel the effect.\n\t\t * This will update ALL bullets, even those currently \"in flight\", so be careful about when you call this!\n\t\t * \n\t\t * @param\txAcceleration\t\tAcceleration speed in pixels per second to apply to the sprites horizontal movement, set to zero to cancel. Negative values move left, positive move right.\n\t\t * @param\tyAcceleration\t\tAcceleration speed in pixels per second to apply to the sprites vertical movement, set to zero to cancel. Negative values move up, positive move down.\n\t\t * @param\txSpeedMax\t\t\tThe maximum speed in pixels per second in which the sprite can move horizontally\n\t\t * @param\tySpeedMax\t\t\tThe maximum speed in pixels per second in which the sprite can move vertically\n\t\t */\n\t\tpublic function setBulletAcceleration(xAcceleration:int, yAcceleration:int, xSpeedMax:int, ySpeedMax:int):void\n\t\t{\n\t\t\tif (xAcceleration == 0 && yAcceleration == 0)\n\t\t\t{\n\t\t\t\tgroup.setAll(\"accelerates\", false);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tgroup.setAll(\"accelerates\", true);\n\t\t\t\tgroup.setAll(\"xAcceleration\", xAcceleration);\n\t\t\t\tgroup.setAll(\"yAcceleration\", yAcceleration);\n\t\t\t\tgroup.setAll(\"maxVelocityX\", xSpeedMax);\n\t\t\t\tgroup.setAll(\"maxVelocityY\", ySpeedMax);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/**\n\t\t * When the bullet is fired from a parent (or fixed position) it will do so from their x/y coordinate.<br>\n\t\t * Often you need to align a bullet with the sprite, i.e. to make it look like it came out of the \"nose\" of a space ship.<br>\n\t\t * Use this offset x/y value to achieve that effect.\n\t\t * \n\t\t * @param\toffsetX\t\tThe x coordinate offset to add to the launch location (positive or negative)\n\t\t * @param\toffsetY\t\tThe y coordinate offset to add to the launch location (positive or negative)\n\t\t */\n\t\tpublic function setBulletOffset(offsetX:int, offsetY:int):void\n\t\t{\n\t\t\tpositionOffset.x = offsetX;\n\t\t\tpositionOffset.y = offsetY;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Give the bullet a random factor to its angle, speed, position or lifespan when fired. Can create a nice \"scatter gun\" effect.\n\t\t * \n\t\t * @param\trandomAngle\t\tThe +- value applied to the angle when fired. For example 20 means the bullet can fire up to 20 degrees under or over its angle when fired.\n\t\t * @param\trandomSpeed\t\tThe +- value applied to the bullet speed when fired. For example 10 means the bullet speed varies by +- 10px/sec\n\t\t * @param\trandomPosition\tThe +- values applied to the x/y coordinates the bullet is fired from.\n\t\t * @param\trandomLifeSpan\tThe +- values applied to the life span of the bullet.\n\t\t */\n\t\tpublic function setBulletRandomFactor(randomAngle:uint = 0, randomSpeed:uint = 0, randomPosition:FlxPoint = null, randomLifeSpan:uint = 0):void\n\t\t{\n\t\t\trndFactorAngle = randomAngle;\n\t\t\trndFactorSpeed = randomSpeed;\n\t\t\t\n\t\t\tif (randomPosition != null)\n\t\t\t{\n\t\t\t\trndFactorPosition = randomPosition;\n\t\t\t}\n\t\t\t\n\t\t\trndFactorLifeSpan = randomLifeSpan;\n\t\t}\n\t\t\n\t\t/**\n\t\t * If the bullet should have a fixed life span use this function to set it.\n\t\t * The bullet will be killed once it passes this lifespan (if still alive and in bounds)\n\t\t * \n\t\t * @param\tlifespan\tThe lifespan of the bullet in ms, calculated when the bullet is fired. Set to zero to disable bullet lifespan.\n\t\t */\n\t\tpublic function setBulletLifeSpan(lifespan:int):void\n\t\t{\n\t\t\tbulletLifeSpan = lifespan;\n\t\t}\n\t\t\n\t\t/**\n\t\t * The elasticity of the fired bullet controls how much it rebounds off collision surfaces.\n\t\t * \n\t\t * @param\telasticity\tThe elasticity of the bullet between 0 and 1 (0 being no rebound, 1 being 100% force rebound). Set to zero to disable.\n\t\t */\n\t\tpublic function setBulletElasticity(elasticity:Number):void\n\t\t{\n\t\t\tbulletElasticity = elasticity;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Internal function that returns the next available bullet from the pool (if any)\n\t\t * \n\t\t * @return\tA bullet\n\t\t */\n\t\tprivate function getFreeBullet():Bullet\n\t\t{\n\t\t\tvar result:Bullet = null;\n\t\t\t\n\t\t\tif (group == null || group.length == 0)\n\t\t\t{\n\t\t\t\tthrow new Error(\"Weapon.as cannot fire a bullet until one has been created via a call to makePixelBullet or makeImageBullet\");\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t\n\t\t\tfor each (var bullet:Bullet in group.members)\n\t\t\t{\n\t\t\t\tif (bullet.exists == false)\n\t\t\t\t{\n\t\t\t\t\tresult = bullet;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets a pre-fire callback function and sound. These are played immediately before the bullet is fired.\n\t\t * \n\t\t * @param\tcallback\tThe function to call\n\t\t * @param\tsound\t\tAn FlxSound to play\n\t\t */\n\t\tpublic function setPreFireCallback(callback:Function = null, sound:FlxSound = null):void\n\t\t{\n\t\t\tonPreFireCallback = callback;\n\t\t\tonPreFireSound = sound;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets a fire callback function and sound. These are played immediately as the bullet is fired.\n\t\t * \n\t\t * @param\tcallback\tThe function to call\n\t\t * @param\tsound\t\tAn FlxSound to play\n\t\t */\n\t\tpublic function setFireCallback(callback:Function = null, sound:FlxSound = null):void\n\t\t{\n\t\t\tonFireCallback = callback;\n\t\t\tonFireSound = sound;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Sets a post-fire callback function and sound. These are played immediately after the bullet is fired.\n\t\t * \n\t\t * @param\tcallback\tThe function to call\n\t\t * @param\tsound\t\tAn FlxSound to play\n\t\t */\n\t\tpublic function setPostFireCallback(callback:Function = null, sound:FlxSound = null):void\n\t\t{\n\t\t\tonPostFireCallback = callback;\n\t\t\tonPostFireSound = sound;\n\t\t}\n\t\t\n\t\t// TODO\n\t\tpublic function TODOcreateBulletPattern(pattern:Array):void\n\t\t{\n\t\t\t//\tLaunches this many bullets\n\t\t}\n\t\t\n\t\t\n\t\tpublic function update():void\n\t\t{\n\t\t\t// ???\n\t\t}\n\t\t\n\t}\n\n}"
  },
  {
    "path": "src/org/flixel/plugin/photonstorm/PNGEncoder.as",
    "content": "/*\n  Copyright (c) 2008, Adobe Systems Incorporated\n  All rights reserved.\n\n  Redistribution and use in source and binary forms, with or without \n  modification, are permitted provided that the following conditions are\n  met:\n\n  * Redistributions of source code must retain the above copyright notice, \n    this list of conditions and the following disclaimer.\n  \n  * Redistributions in binary form must reproduce the above copyright\n    notice, this list of conditions and the following disclaimer in the \n    documentation and/or other materials provided with the distribution.\n  \n  * Neither the name of Adobe Systems Incorporated nor the names of its \n    contributors may be used to endorse or promote products derived from \n    this software without specific prior written permission.\n\n  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\n  IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\n  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR \n  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\npackage org.flixel.plugin.photonstorm\n{\n\timport flash.geom.*;\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.utils.ByteArray;\n\n\t/**\n\t * Class that converts BitmapData into a valid PNG\n\t */\t\n\tpublic class PNGEncoder\n\t{\n\t\t/**\n\t\t * Created a PNG image from the specified BitmapData\n\t\t *\n\t\t * @param image The BitmapData that will be converted into the PNG format.\n\t\t * @return a ByteArray representing the PNG encoded image data.\n\t\t * @langversion ActionScript 3.0\n\t\t * @playerversion Flash 9.0\n\t\t * @tiptext\n\t\t */\t\t\t\n\t    public static function encode(img:BitmapData):ByteArray {\n\t        // Create output byte array\n\t        var png:ByteArray = new ByteArray();\n\t        // Write PNG signature\n\t        png.writeUnsignedInt(0x89504e47);\n\t        png.writeUnsignedInt(0x0D0A1A0A);\n\t        // Build IHDR chunk\n\t        var IHDR:ByteArray = new ByteArray();\n\t        IHDR.writeInt(img.width);\n\t        IHDR.writeInt(img.height);\n\t        IHDR.writeUnsignedInt(0x08060000); // 32bit RGBA\n\t        IHDR.writeByte(0);\n\t        writeChunk(png,0x49484452,IHDR);\n\t        // Build IDAT chunk\n\t        var IDAT:ByteArray= new ByteArray();\n\t        for(var i:int=0;i < img.height;i++) {\n\t            // no filter\n\t            IDAT.writeByte(0);\n\t            var p:uint;\n\t            var j:int;\n\t            if ( !img.transparent ) {\n\t                for(j=0;j < img.width;j++) {\n\t                    p = img.getPixel(j,i);\n\t                    IDAT.writeUnsignedInt(\n\t                        uint(((p&0xFFFFFF) << 8)|0xFF));\n\t                }\n\t            } else {\n\t                for(j=0;j < img.width;j++) {\n\t                    p = img.getPixel32(j,i);\n\t                    IDAT.writeUnsignedInt(\n\t                        uint(((p&0xFFFFFF) << 8)|\n\t                        (p>>>24)));\n\t                }\n\t            }\n\t        }\n\t        IDAT.compress();\n\t        writeChunk(png,0x49444154,IDAT);\n\t        // Build IEND chunk\n\t        writeChunk(png,0x49454E44,null);\n\t        // return PNG\n\t        return png;\n\t    }\n\t\n\t    private static var crcTable:Array;\n\t    private static var crcTableComputed:Boolean = false;\n\t\n\t    private static function writeChunk(png:ByteArray, \n\t            type:uint, data:ByteArray):void {\n\t        if (!crcTableComputed) {\n\t            crcTableComputed = true;\n\t            crcTable = [];\n\t            var c:uint;\n\t            for (var n:uint = 0; n < 256; n++) {\n\t                c = n;\n\t                for (var k:uint = 0; k < 8; k++) {\n\t                    if (c & 1) {\n\t                        c = uint(uint(0xedb88320) ^ \n\t                            uint(c >>> 1));\n\t                    } else {\n\t                        c = uint(c >>> 1);\n\t                    }\n\t                }\n\t                crcTable[n] = c;\n\t            }\n\t        }\n\t        var len:uint = 0;\n\t        if (data != null) {\n\t            len = data.length;\n\t        }\n\t        png.writeUnsignedInt(len);\n\t        var p:uint = png.position;\n\t        png.writeUnsignedInt(type);\n\t        if ( data != null ) {\n\t            png.writeBytes(data);\n\t        }\n\t        var e:uint = png.position;\n\t        png.position = p;\n\t        c = 0xffffffff;\n\t        for (var i:int = 0; i < (e-p); i++) {\n\t            c = uint(crcTable[\n\t                (c ^ png.readUnsignedByte()) & \n\t                uint(0xff)] ^ uint(c >>> 8));\n\t        }\n\t        c = uint(c^uint(0xffffffff));\n\t        png.position = e;\n\t        png.writeUnsignedInt(c);\n\t    }\n\t}\n}"
  }
]