| Package | vegas.ui |
| Class | public class KeyInspector |
| Inheritance | KeyInspector Object |
Example :
package examples
{
import vegas.ui.KeyInspector;
import flash.display.Sprite;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Point;
import flash.ui.Keyboard;
[SWF(width="980", height="720", frameRate="24", backgroundColor="#666666")]
public class KeyInspectorExample extends Sprite
{
public function KeyInspectorExample()
{
////////
ball = new Sprite() ;
ball.graphics.beginFill( 0xFF0000 ) ;
ball.graphics.drawCircle(0, 0, 24) ;
ball.x = 50 ;
ball.y = 50 ;
addChild( ball ) ;
////////
key = new KeyInspector( stage );
////////
stage.scaleMode = StageScaleMode.NO_SCALE ;
stage.addEventListener( Event.ENTER_FRAME, enterFrame );
}
protected var ball:Sprite ;
protected var key:KeyInspector ;
public var speed:Point = new Point(10,10) ;
protected function enterFrame( e:Event ):void
{
if ( key.isDown( Keyboard.LEFT ) )
{
ball.x -= speed.x ;
}
if ( key.isDown( Keyboard.RIGHT ) )
{
ball.x += speed.x ;
}
if ( key.isDown( Keyboard.UP ) )
{
ball.y -= speed.y ;
}
if ( key.isDown( Keyboard.DOWN ) )
{
ball.y += speed.y ;
}
}
}
}
| Property | Defined By | ||
|---|---|---|---|
| target : InteractiveObject
The interactive display object reference on which to listen for keyboard events. | KeyInspector | ||
| Method | Defined By | ||
|---|---|---|---|
KeyInspector(display:InteractiveObject)
Creates a new KeyInspector instance. | KeyInspector | ||
clear():void
Clear the inspector key code buffering. | KeyInspector | ||
isDown(keyCode:uint):Boolean
To test whether a key is down. | KeyInspector | ||
isUp(keyCode:uint):Boolean
Tests whether a key is up. | KeyInspector | ||
| target | property |
target:InteractiveObjectThe interactive display object reference on which to listen for keyboard events.
public function get target():InteractiveObject public function set target(value:InteractiveObject):void| KeyInspector | () | Constructor |
public function KeyInspector(display:InteractiveObject)Creates a new KeyInspector instance.
Parametersdisplay:InteractiveObject — An interactive display object on which to listen for keyboard events.
To catch all key events, this should be a reference to the stage.
|
| clear | () | method |
public function clear():voidClear the inspector key code buffering.
| isDown | () | method |
public function isDown(keyCode:uint):BooleanTo test whether a key is down.
Parameters
keyCode:uint — code for the key to test.
|
Boolean — true if the key is down, false otherwise.
|
See also
| isUp | () | method |
public function isUp(keyCode:uint):BooleanTests whether a key is up.
Parameters
keyCode:uint — code for the key to test.
|
Boolean — true if the key is up, false otherwise.
|
See also