Posted by Sankar.G | Posted in AS3 | Posted on 5:13 PM
var isKeyOne:Boolean = false;
var isKeyTwo:Boolean = false
stage.addEventListener(Event.ENTER_FRAME, checkTrue);
function checkTrue(event:Event):void
{
if(isKeyOne)
{
test.x--;
}
if(isKeyTwo)
{
test.y--;
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, makeTrue);
stage.addEventListener(KeyboardEvent.KEY_UP, makeFalse);
function makeTrue(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.LEFT)
{
isKeyOne = true;
}
if(event.keyCode == Keyboard.UP)
{
isKeyTwo = true;
}
}
function makeFalse(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.LEFT)
{
isKeyOne = false;
}
if(event.keyCode == Keyboard.UP)
{
isKeyTwo = false;
}
}
Create one MovieClip and Name it as test and Put this Script for Multiple Keyboard Handling
var isKeyTwo:Boolean = false
stage.addEventListener(Event.ENTER_FRAME, checkTrue);
function checkTrue(event:Event):void
{
if(isKeyOne)
{
test.x--;
}
if(isKeyTwo)
{
test.y--;
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, makeTrue);
stage.addEventListener(KeyboardEvent.KEY_UP, makeFalse);
function makeTrue(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.LEFT)
{
isKeyOne = true;
}
if(event.keyCode == Keyboard.UP)
{
isKeyTwo = true;
}
}
function makeFalse(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.LEFT)
{
isKeyOne = false;
}
if(event.keyCode == Keyboard.UP)
{
isKeyTwo = false;
}
}
Create one MovieClip and Name it as test and Put this Script for Multiple Keyboard Handling
how to play audio from the library with multiple keyboard? for example a keyboard and s simultaneously.
Hi Tommy,
You need to play same kind of 2 sounds from library again, Depend upon the keyboard (a) & (s)?