Multi touch keyboard in flash? 
Posted: 04 July 2009 01:31 PM   [ Ignore ]
Rank
Joined  2008-05-05
Total Posts:  72
New Member

Anyone know how I can simulate key pressed in flash? or is there a easier way to make an onscreen keyboard in AS3?

Profile
 
 
Posted: 04 July 2009 05:26 PM   [ Ignore ]   [ # 1 ]
Avatar
Rank
Joined  2008-08-05
Total Posts:  81
New Member

yes you can by doing that:

stage.focus = stage;
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);

stage.dispatchEvent( new KeyboardEvent( KeyboardEvent.KEY_DOWN, true, false, 0, Keyboard.ENTER ) );

function keyDownHandler( e:KeyboardEvent ):void
{
trace("enter pressed !” );
}

Good luck wink

 Signature 

Florian / CTO at So touch
http://www.so-touch.com

Profile
 
 
Posted: 05 July 2009 12:12 PM   [ Ignore ]   [ # 2 ]
Rank
Joined  2008-05-05
Total Posts:  72
New Member

thanks flo, but I’m looking for a way to build an on screen keyboard in flash so that it can work as a way for input.  For example when a key “enter” is pressed on the on screen keyboard a “enter” is simulated as if the “enter” key is pressed on a physical keyboard, this way a keyboard can work with multiple applications.

Profile
 
 
Posted: 05 July 2009 01:26 PM   [ Ignore ]   [ # 3 ]
Avatar
Rank
Joined  2008-08-05
Total Posts:  81
New Member

Yes I understand. And the only solution you have is the one I proposed.

As soon as the keyboard is in the display list, you can use h is variable “stage”.
You can dispatch from the stage, but also from any other EventDispatcher like Sprite or MovieClip are.

In a normal situation, you would register the KeyboardEvent on the stage, right?
So, your “virtual keyboard” instance can force the dispatchEvent when the corresponding key is pressed.
Juste replace “Keyboard.ENTER” by a variable.

 Signature 

Florian / CTO at So touch
http://www.so-touch.com

Profile
 
 
Posted: 05 July 2009 01:50 PM   [ Ignore ]   [ # 4 ]
RankRankRank
Joined  2007-12-05
Total Posts:  317
Sr. Member

There is already a virtual KeyboardObject in the AS3 multi-touch API that is downloadable from the SVN.
Greg

 Signature 

ElOpsis
ElOpsis Blog

Profile
 
 
Posted: 08 July 2009 04:34 AM   [ Ignore ]   [ # 5 ]
Rank
Joined  2008-05-05
Total Posts:  72
New Member

thanks

found it in
AS3\int\app\core\object

however when I try to use it with the following code

var ScreenKB:KeyboardObject;

ScreenKB = new KeyboardObject();
ScreenKB.x = 100;
ScreenKB.y = 100;
addChild(ScreenKB);

First I got the error of not able to embed Arial.ttf, so I copied Arial.ttf to the object fold, than the error no longer showed up, than I get these errors

1120: Access of undefined property noSelection.
1118: Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type flash.display:MovieClip.
1061: Call to a possibly undefined method getChildByName through a reference with static type flash.display:DisplayObject.
1119: Access of possibly undefined property relatedObject through a reference with static type flash.events:Event.

anyone know whats going on? I imported all the classes needed

Profile