Guest User

Untitled

a guest
Oct 30th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import flash.display.MovieClip;
  4.     import flash.display.Sprite;
  5.     import flash.events.Event;
  6.     import flash.events.KeyboardEvent;
  7.     import flash.text.TextField;
  8.     import flash.text.TextFieldType;
  9.  
  10.     /**
  11.      * ...
  12.      * @author Richman Stewart
  13.      */
  14.    
  15.     public class Main extends Sprite{
  16.        
  17.         private var DebugBox:MovieClip = new MovieClip();
  18.         private var ShowDebugBox:Boolean = false;
  19.         private var OutputText:TextField = new TextField();
  20.         private var InputText:TextField = new TextField();
  21.        
  22.         public function Main():void {
  23.             stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyIsDown);
  24.         }
  25.        
  26.         private function CreateDebugBox():void{
  27.             DebugBox.graphics.lineStyle(1, 0x000000);
  28.             DebugBox.graphics.beginFill(0x00FF00, .4);
  29.            
  30.             DebugBox.graphics.lineTo(800, 0);
  31.             DebugBox.graphics.lineTo(800, 200);
  32.             DebugBox.graphics.lineTo(0, 200);
  33.             DebugBox.graphics.lineTo(0, 0);
  34.            
  35.             DebugBox.graphics.beginFill(0x000000, .2);
  36.            
  37.             DebugBox.graphics.lineTo(800, 0);
  38.             DebugBox.graphics.lineTo(800, 200);
  39.             DebugBox.graphics.lineTo(0, 200);
  40.             DebugBox.graphics.lineTo(0, 0);
  41.            
  42.             stage.addChild(DebugBox);
  43.         }
  44.        
  45.         private function KeyIsDown(ev:KeyboardEvent):void {
  46.             if (ev.keyCode == 192) {
  47.                 if (ShowDebugBox) {
  48.                     HideDebugBox();
  49.                     ShowDebugBox = false;
  50.                     stage.focus = null;
  51.                     InputText.text = "";
  52.                 }else{
  53.                     RunDebugBox();
  54.                     ShowDebugBox = true;
  55.                     stage.focus = InputText;
  56.                     InputText.text = "";
  57.                 }
  58.             }
  59.            
  60.             if (ev.keyCode == 13) {
  61.                 RunCommand(InputText.text);
  62.                 InputText.text = "";
  63.             }
  64.         }
  65.        
  66.         private function RunCommand(Command:String):void {
  67.             var CommandFound:Boolean = false;
  68.            
  69.             switch(Command){
  70.                 case "LogGuest":
  71.                 DebugMessage("Logged in with Guest");
  72.                 CommandFound = true;
  73.                 break;
  74.                 case "Suicide":
  75.                 DebugMessage("You commited suicide");
  76.                 CommandFound = true;
  77.                 break;
  78.             }
  79.            
  80.             if (!CommandFound) {
  81.                 DebugMessage(InputText.text + " is not a command");
  82.             }
  83.         }
  84.        
  85.         private function HideDebugBox():void{
  86.             stage.removeChild(DebugBox);
  87.             stage.removeChild(OutputText);
  88.             stage.removeChild(InputText);
  89.             InputText.text = "";
  90.             DebugBox.graphics.clear();
  91.         }
  92.        
  93.         private function RunDebugBox():void{
  94.             CreateDebugBox();
  95.             CreateOutputBox();
  96.             CreateInputBox();
  97.         }
  98.        
  99.         private function CreateOutputBox():void{
  100.             OutputText.width = 650;
  101.             OutputText.height = 120;
  102.            
  103.             OutputText.x = 50;
  104.             OutputText.y = 20;
  105.            
  106.             OutputText.border = true;
  107.            
  108.             stage.addChild(OutputText);
  109.         }
  110.        
  111.         private function CreateInputBox():void{
  112.             InputText.width = 650;
  113.             InputText.height = 25;
  114.            
  115.             InputText.x = 50;
  116.             InputText.y = 150;
  117.            
  118.             InputText.border = true;
  119.             InputText.type = TextFieldType.INPUT;
  120.            
  121.             stage.addChild(InputText);
  122.         }
  123.        
  124.         private function DebugMessage(Message:Object):void {
  125.             var NewDate:Date = new Date();
  126.            
  127.             var Hours:int = NewDate.getHours();
  128.             var Minutes:String = String(NewDate.getMinutes());
  129.             var Seconds:String = String(NewDate.getSeconds());
  130.             var AmPm:String = "Am";
  131.            
  132.             if (Hours > 12) {
  133.                 Hours = Hours - 12;
  134.                 AmPm = "Pm";
  135.             }
  136.            
  137.             if (int(Minutes) < 10) {
  138.                 Minutes = "0" + Minutes;
  139.             }
  140.            
  141.             if (int(Seconds) < 10) {
  142.                 Seconds = "0" + Seconds;
  143.             }
  144.            
  145.             OutputText.appendText(String(Message) + "   -  " + Hours + ":" + Minutes + ":" + Seconds + " " + AmPm + "\n");
  146.            
  147.             OutputText.scrollV = 999;
  148.         }
  149.     }
  150.  
  151. }
Add Comment
Please, Sign In to add comment