Packagevegas.ui
Classpublic dynamic class CheatCode
InheritanceCheatCode Inheritance flash.events.EventDispatcher
Implements Lockable

Creates a command ( or keywords, or cheat codes ) to type on the keyboard. This command can be notify with a simple callback or a classic Event.

View the examples



Public Properties
 PropertyDefined By
  delay : Number
Indicates the amount of time to wait before reseting the keyboard input.
CheatCode
  keys : Array
Determinates the Array representation of all key codes to validate the cheat code.
CheatCode
  stage : Stage
Indicates the Stage reference of the application.
CheatCode
Public Methods
 MethodDefined By
  
CheatCode(keys:Array = null, stage:Stage = null, delay:uint = 1000)
Creates a new CheatCode instance.
CheatCode
  
createFromString(code:String, stage:Stage = null, delay:uint = 1000):CheatCode
[static] Generates a cheat code object with a specific String expression.
CheatCode
  
isLocked():Boolean
Returns true if the object is locked.
CheatCode
  
lock():void
Locks the object.
CheatCode
  
unlock():void
Unlocks the object.
CheatCode
Property Detail
delayproperty
delay:Number

Indicates the amount of time to wait before reseting the keyboard input.


Implementation
    public function get delay():Number
    public function set delay(value:Number):void
keysproperty 
keys:Array

Determinates the Array representation of all key codes to validate the cheat code.


Implementation
    public function get keys():Array
    public function set keys(value:Array):void
stageproperty 
stage:Stage

Indicates the Stage reference of the application. This property must be defines to handle the keyboard events.


Implementation
    public function get stage():Stage
    public function set stage(value:Stage):void
Constructor Detail
CheatCode()Constructor
public function CheatCode(keys:Array = null, stage:Stage = null, delay:uint = 1000)

Creates a new CheatCode instance.

Parameters
keys:Array (default = null) — The Array representation of all key codes to validate the cheat code.
 
stage:Stage (default = null) — a Stage reference to handle the keyboard events (This property must be defines to handle the keyboard events).
 
delay:uint (default = 1000) — the amount of time to wait before reseting the keyboard input (default 1000 ms).
Method Detail
createFromString()method
public static function createFromString(code:String, stage:Stage = null, delay:uint = 1000):CheatCode

Generates a cheat code object with a specific String expression.

Example :

         import vegas.ui.CheatCode;
         
         var cheat:CheatCode = CheatCode.createFromString( "hello" , stage ) ;
         
         cheat.onSelect = function():void
         {
             trace( "hello world !" );
         }
         

Parameters

code:String
 
stage:Stage (default = null)
 
delay:uint (default = 1000)

Returns
CheatCode
isLocked()method 
public function isLocked():Boolean

Returns true if the object is locked.

Returns
Booleantrue if the object is locked.
lock()method 
public function lock():void

Locks the object.

unlock()method 
public function unlock():void

Unlocks the object.

Examples
Creates cheat codes in your applications.
     
     import vegas.ui.CheatCode;
     
     ///////// konami code ( UP | UP | DOWN | DOWN | LEFT | RIGHT | LEFT | RIGHT | B | A ).
     
     var selectKonami:Function = function( e:Event ):void
     {
         trace( "hello konami code !" );
     }
     
     var konami:Array = [ 38 , 38 , 40 , 40 , 37 , 39 , 37 , 39 , 66 , 65 ] ;
          var cheat1:CheatCode = new CheatCode( stage , konami ) ;
          cheat1.addEventListener( Event.SELECT , selectKonami ) ;
     
     ///////// custom code based String expression ("hello").
     
     var selectHelloWorld:Function = function():void
     {
         trace( "hello world !" );
     }
     
     var cheat2:CheatCode = CheatCode.createFromString( "hello" , stage ) ;
     
     cheat2.onSelect = selectHelloWorld ; // use basic callback method