Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.display.MovieClip;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.events.KeyboardEvent;
- import flash.text.TextField;
- import flash.text.TextFieldType;
- /**
- * ...
- * @author Richman Stewart
- */
- public class Main extends Sprite{
- private var DebugBox:MovieClip = new MovieClip();
- private var ShowDebugBox:Boolean = false;
- private var OutputText:TextField = new TextField();
- private var InputText:TextField = new TextField();
- public function Main():void {
- stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyIsDown);
- }
- private function CreateDebugBox():void{
- DebugBox.graphics.lineStyle(1, 0x000000);
- DebugBox.graphics.beginFill(0x00FF00, .4);
- DebugBox.graphics.lineTo(800, 0);
- DebugBox.graphics.lineTo(800, 200);
- DebugBox.graphics.lineTo(0, 200);
- DebugBox.graphics.lineTo(0, 0);
- DebugBox.graphics.beginFill(0x000000, .2);
- DebugBox.graphics.lineTo(800, 0);
- DebugBox.graphics.lineTo(800, 200);
- DebugBox.graphics.lineTo(0, 200);
- DebugBox.graphics.lineTo(0, 0);
- stage.addChild(DebugBox);
- }
- private function KeyIsDown(ev:KeyboardEvent):void {
- if (ev.keyCode == 192) {
- if (ShowDebugBox) {
- HideDebugBox();
- ShowDebugBox = false;
- stage.focus = null;
- InputText.text = "";
- }else{
- RunDebugBox();
- ShowDebugBox = true;
- stage.focus = InputText;
- InputText.text = "";
- }
- }
- if (ev.keyCode == 13) {
- RunCommand(InputText.text);
- InputText.text = "";
- }
- }
- private function RunCommand(Command:String):void {
- var CommandFound:Boolean = false;
- switch(Command){
- case "LogGuest":
- DebugMessage("Logged in with Guest");
- CommandFound = true;
- break;
- case "Suicide":
- DebugMessage("You commited suicide");
- CommandFound = true;
- break;
- }
- if (!CommandFound) {
- DebugMessage(InputText.text + " is not a command");
- }
- }
- private function HideDebugBox():void{
- stage.removeChild(DebugBox);
- stage.removeChild(OutputText);
- stage.removeChild(InputText);
- InputText.text = "";
- DebugBox.graphics.clear();
- }
- private function RunDebugBox():void{
- CreateDebugBox();
- CreateOutputBox();
- CreateInputBox();
- }
- private function CreateOutputBox():void{
- OutputText.width = 650;
- OutputText.height = 120;
- OutputText.x = 50;
- OutputText.y = 20;
- OutputText.border = true;
- stage.addChild(OutputText);
- }
- private function CreateInputBox():void{
- InputText.width = 650;
- InputText.height = 25;
- InputText.x = 50;
- InputText.y = 150;
- InputText.border = true;
- InputText.type = TextFieldType.INPUT;
- stage.addChild(InputText);
- }
- private function DebugMessage(Message:Object):void {
- var NewDate:Date = new Date();
- var Hours:int = NewDate.getHours();
- var Minutes:String = String(NewDate.getMinutes());
- var Seconds:String = String(NewDate.getSeconds());
- var AmPm:String = "Am";
- if (Hours > 12) {
- Hours = Hours - 12;
- AmPm = "Pm";
- }
- if (int(Minutes) < 10) {
- Minutes = "0" + Minutes;
- }
- if (int(Seconds) < 10) {
- Seconds = "0" + Seconds;
- }
- OutputText.appendText(String(Message) + " - " + Hours + ":" + Minutes + ":" + Seconds + " " + AmPm + "\n");
- OutputText.scrollV = 999;
- }
- }
- }
Add Comment
Please, Sign In to add comment