Topic: Howto use virtual keyboard in Actionscript

I try to use the virtual keyboard from the example widgets (http://wiki.chumby.com/mediawiki/index. … le_Widgets) with Flashdevelop. I added the .swf as Library Asset, and when I compile

var keyboard:MovieClip;
keyboard = _root.attachMovie("src.keyboard.swf", "keyboard", _root.getNextHighestDepth());

I see the virtual keyboard, can type something, and see the result in the keyboard's Textfield.
But how do I listen for the final ENTER-key, and how then do I get the textstring ?

Any help/example code would be welcome.

Re: Howto use virtual keyboard in Actionscript

When the user hits the enter key, it will call the "accept" function, so you can do:

keyboard.accept = function(s:String) {
    trace('user entered '+s);
}

You can also use "keyboard.getText()" to retrieve the text.

Re: Howto use virtual keyboard in Actionscript

Thanks for your fast reply. I think I make a AS2-rookie-mistake here ??

class Main {
  public static function main():Void { 
    var keyboard:MovieClip = _root.attachMovie("keyboard.swf", "keyboard", _root.getNextHighestDepth());
    keyboard.accept = function(s:String) {
            trace("user entered "+s);
        }
    trace("trace works");
    }
}

This outputs "trace works", shows the keyboard, allows me to type, but never shows "user entered". AS/Flash is veeery strange. I have no clue. Help, please !

4 (edited by occasional 2010-01-28 04:45:12)

Re: Howto use virtual keyboard in Actionscript

Phhhht! I finally found the solution. Just in case anyone else is interested, this worked for me:

class Main {
  public static function main():Void { 
    var keyboard:MovieClip = _root.attachMovie("keyboard.swf", "keyboard", _root.getNextHighestDepth());
    keyboard.instance1.accept = function(s:String) {
            trace("user entered "+s);
    }
  }
}

On to the next frontier!

Re: Howto use virtual keyboard in Actionscript

Updated the wiki with this useful knowledge!

Re: Howto use virtual keyboard in Actionscript

Hold on! Things are more complicated: Having added and removed a few MovieClips, I found that it's not always "instance1". I figured out how to get the correct "instance"-number, but that looks ugly:

  var keyboard:MovieClip = _root.attachMovie("keyboard.swf", "keyboard", _root.getNextHighestDepth());
  for (var prop in keyboard) {
    var k:Object = eval("keyboard." + prop);
    k.accept = function(s:String) {
        trace("user entered " + s);
        keyboard.removeMovieClip();  // removes the Virtual Keyboard from Screen
    }
  }

The for-loop is processed only once, setting prop to "instanceX" and thus k to keyboard.instanceX.

Re: Howto use virtual keyboard in Actionscript

Can some one post the code for Flash CS4 (AS3) ?
Ive done the followings:
Moved all the keyboard files into my source folder.
Drag and drom the keyboard.swf into the library, made it a movieClip, and selected "export for ActionScript" then set its class name to keyboard.
Then I've added this code:

 var mykeyboard:MovieClip =  new keyboard;
 addChild(mykeyboard);

The problem is that the keyboard appears empty on the stage.

Any help?

Re: Howto use virtual keyboard in Actionscript

Hello,
Can you tell me where I can find an example dealing with chumby virtual keyboard ?
I'm new to chumby, actionscript an flashdevelop, and when I try to use the virtual keyboard, nothing is displayed.
I inserted the keyboard.swf into my project, but I must miss something...
Thanks in advance for your help.

9 (edited by Ratzfatz 2010-08-07 09:14:01)

Re: Howto use virtual keyboard in Actionscript

I'm using Chumby Inc.s virtual keyboard for the SearchTube-Widget (developed with FlashDevelop).
-Copy the keyboard.swf into the "assets"-folder of your projects (create one if there's not yet one), then start flashdevelop and open your project
-In the Project Manager sidebar (Menu/view/Project Manager) open the "assets"-folder
-Right-click on the "keyboard.swf" and enable "Add to Library"

From your sourcecode, invoke it as described above .

The first parameter for attachMovie() might be different: right-click again on keyboard.swf, chose "options" and look at the "Auto-generate ID for attachMovie()" in the "Advanced"-tab. If you put the keyboard.swf into the assets-folder, the ID is "assets.keyboard.swf", so you have to write

keyboard = _root.attachMovie("assets.keyboard.swf", "keyboard", _root.getNextHighestDepth);

Good luck!

10 (edited by moxbox 2010-12-07 13:24:25)

Re: Howto use virtual keyboard in Actionscript

I am also trying to get the VirtualKeyboard example to work.

?Could someone please tell me where the "keyboard.swf" file is located?

I see that Duane uploaded "VirtualKeyboard.tgz", however that is the AS source and not the .swf file.

I'm a flash newbie - could someone please send a link to the .swf file?
(or explain to the rest of us how to make one from "VirtualKeyboard.tgz"?)

thanks,
mox

Re: Howto use virtual keyboard in Actionscript

moxbox wrote:

I am also trying to get the VirtualKeyboard example to work.

?Could someone please tell me where the "keyboard.swf" file is located?

I see that Duane uploaded "VirtualKeyboard.tgz", however that is the AS source and not the .swf file.

I'm a flash newbie - could someone please send a link to the .swf file?
(or explain to the rest of us how to make one from "VirtualKeyboard.tgz"?)

thanks,
mox

Please see the wiki post regarding this. The VirtualKeyboard.tgz file contains keyboard.swf. You'll need to unzip/unpack the .tgz file. I used WinRAR to do this

Re: Howto use virtual keyboard in Actionscript

Ah, I discovered the problem.
If you do a right click -> "save target as" the browser will truncate the VirtualKeyboard.tgz file,
and just leave you with the sources. When I did a :

wget http://files.chumby.com/widgetexamples/ … yboard.tgz

then I was able to get everything, and it included the "keyboard.swf".

Thank you for your fast response - it is very appreciated.

best regards,
moxbox

Re: Howto use virtual keyboard in Actionscript

O.K., another newbie here.  I tried putting the files in my project, but when I go to compile and test, I get dozens of lines like:

Building Wiki
Compiling resources
Warning : package VirtualKeyboard not found
Warning : The MovieClip keyboardMedSpaceButton needs the class com.chumby.keyboard.KeyboardKey which was not compiled :
Please force compilation of this class by adding it to the commandline.
Warning : The MovieClip keyboardSmallGrayButton needs the class com.chumby.keyboard.KeyboardKey which was not compiled :
Please force compilation of this class by adding it to the commandline.
Warning : The MovieClip keyboardReturnButton needs the class com.chumby.keyboard.KeyboardKey which was not compiled :
Please force compilation of this class by adding it to the commandline.

What am I doing wrong?  Thanks!