Packagecitrus.core
Classpublic class Console
InheritanceConsole Inheritance flash.display.Sprite

You can use the console to perform any type of command at your game's runtime. Press the key that opens it, then type a command into the console, then press enter. If your command is recognized, the command's handler function will fire.

You can create your own console commands by using the addCommand method.

When the console is open, it does not disable game input. You can manually toggle game input by listening for the onShowConsole and onHideConsole Signals.

When the console is open, you can press the up key to step backwards through your executed command history, even after you've closed your SWF. Pressing the down key will step forward through your history. Use this to quickly access commonly executed commands.

Each command follows this pattern: commandName param1 param2 param3.... First, you call the command name that you want to execute, then you pass any parameters into the command. For instance, you can set the jumpHeight property on a Hero object using the following command: "set myHero jumpHeight 20". That command finds an object named "myHero" and sets its jumpHeight property to 20.

Make sure and see the addCommand definition to learn how to add your own console commands.



Public Properties
 PropertyDefined By
  enabled : Boolean
Determines whether the console can be used.
Console
  onHideConsole : Signal
[read-only] Gets dispatched when the console is hidden.
Console
  onShowConsole : Signal
[read-only] Gets dispatched when the console is shown.
Console
  openKey : uint = 9
Default is tab key.
Console
Public Methods
 MethodDefined By
  
Console(openKey:int = 9)
Creates the instance of the console.
Console
  
addCommand(name:String, func:Function):void
Adds a command to the console.
Console
  
addCommandToHistory(command:String):void
Console
  
Console
  
Can be called to clear the command history.
Console
  
destroy():void
Console
  
Console
  
Console
  
Console
  
Console
  
Console
  
Console
Property Detail
enabledproperty
enabled:Boolean

Determines whether the console can be used. Set this property to false before releasing your final game.


Implementation
    public function get enabled():Boolean
    public function set enabled(value:Boolean):void
onHideConsoleproperty 
onHideConsole:Signal  [read-only]

Gets dispatched when the console is hidden. Handler accepts 0 params.


Implementation
    public function get onHideConsole():Signal
onShowConsoleproperty 
onShowConsole:Signal  [read-only]

Gets dispatched when the console is shown. Handler accepts 0 params.


Implementation
    public function get onShowConsole():Signal
openKeyproperty 
public var openKey:uint = 9

Default is tab key.

Constructor Detail
Console()Constructor
public function Console(openKey:int = 9)

Creates the instance of the console. This is a display object, so it is also added to the stage.

Parameters
openKey:int (default = 9)
Method Detail
addCommand()method
public function addCommand(name:String, func:Function):void

Adds a command to the console. Use this method to create your own commands. The name parameter is the word that you must type into the console to fire the command handler. The func parameter is the function that will fire when the console command is executed.

Your command handler should accept the parameters that are expected to be passed into the command. All of them should be typed as a String. As an example, this is a valid handler definition for the "set" command.

private function handleSetPropertyCommand(objectName:String, propertyName:String, propertyValue:String):void

You can then create logic for your command using the arguments.

Parameters

name:String — The word you want to use to execute your command in the console.
 
func:Function — The handler function that will get called when the command is executed. This function should accept the commands parameters as arguments.

addCommandToHistory()method 
public function addCommandToHistory(command:String):void

Parameters

command:String

clearConsole()method 
public function clearConsole():void

clearStoredHistory()method 
public function clearStoredHistory():void

Can be called to clear the command history.

destroy()method 
public function destroy():void

getCurrentCommand()method 
public function getCurrentCommand():String

Returns
String
getNextHistoryCommand()method 
public function getNextHistoryCommand():String

Returns
String
getPreviousHistoryCommand()method 
public function getPreviousHistoryCommand():String

Returns
String
hideConsole()method 
public function hideConsole():void

showConsole()method 
public function showConsole():void

toggleConsole()method 
public function toggleConsole():void