Mscape Help


How To: Allow the user to enter text, such as their name

As part of your mediascape you may wish to have the player enter in text data, for instance if you want to refer to the player by name they'll need to type their name in. If you have tried to achieve this you will have had problems as mscape player blocks the standard Windows Mobile on-screen keyboard meaning that there is currently no built-in way of entering text.

This tutorial presents an alternative on-screen keyboard implementation that uses Adobe Flash, and allows you to download sample files so you should be able to get going pretty quickly.

This implementation was based on an open source on-screen keyboard . The original version was designed for kiosk systems using a large screen so it has been customized it to fit a standard Windows Mobile device in portrait mode (240x320).

I have created a demo Flash system that uses the new component for you, as well as a demo mediascape that uses it.

entername.jpg
The on-screen keyboard

download Download sample files

tip This sample is designed for mediascapes that already have an Adobe Flash interface, and as such is probably most useful for those with Adobe Flash authoring experience.

Contents of the download

onscreenkeyboard2.fla The FLA file that builds the onscreen keyboard component. You only need to open this if you want to customize the look-and-feel of the keyboard (see the OnScreenKeyboard MovieClip within this FLA)

onscreenkeyboard2.swf The swf for the keyboard component. This must be included in your mediascape
UseInFlashDemoHost.fla A demo Flash app that hosts the keyboard. This is a simple flash movie that demonstrates how to pop up the keyboard at a particular point in the movie, and get the return value. Click the S shape to pop up the keyboard.
UseInFlashDemoHost.swf The swf for the hosting app demo. This is used in the demo mediascape.
KeyboardTester.as Source file for keyboard. You shouldn't need to change this.
StandardKey.as Source file for keyboard. This can be used to customize the text that appears on the space shift del ok buttons.
OnScreenKeyboard.as Source file for keyboard. You shouldn't need to change this.

Inside the UseInFlashDemoHost flash file there are two important parts of the code..

When the S is clicked..

on(press)
{
_global.TextEntry_Title = "Enter your name";
mcTextEntry.loadMovie(_global.swfDirectory + "onscreenkeyboard2.swf");
}

mcTextEntry is a movieclip defined on the stage that is used to define the location of the keyboard (0,0). _global.TextEntry is used to set the title that appers at the top of the keyboard screen ('Enter your name').

When the user clicks OK, the function TextEntry? _Complete is run on the main timeline (at _root) Here's the definition..

function TextEntry_Complete(text)
{
unloadMovie(mcTextEntry); // get rid of the keyboard
trace(text); // print the text entered out to the log
}

Example Mediascape

The example mediascape included in the package is called keyboardTest and simply plays the UseInFlashDemoHost flash movie. Note that the onscreenkeyboard2 swf file is also included - this is essential.

The way that the mediascape knows what text was entered is via the OnFSCommand event. Important: It's actually the UseInFlashDemoHost swf that will fire the OnFSCommand NOT the onscreenkeyboard2 swf.

Here's the contents of the OnFSCommand event for UseInFlashDemoHost..

if (Command == "TextEntry")
{
  Logger.Log("User entered " + Parameters[0]);
  UserName.Value = Parameters[0];  // save the text that was typed into the variable called UserName.
}

mscapecontents.png
contents of the example mediascape

If you run this on your mobile device, then clicking the S will open the on-screen keyboard. Type your message and click OK to hide the keyboard. The text you have types will be output to the log file. To view the log on mscape player

On mscape tester the log is visible at the bottom of the screen.

Using the on-screen keyboard for mediascapes without an existing Adobe Flash interface

The example mediascape demonstrates how to use the on-screen keyboard when you already have an existing Adobe Flash interface. If this is not the case, here's how to build a mediascape that uses the component..

onscreenkeyboard2.Play();

if (Command == "TextEntry")
{
  Logger.Log("User entered " + Parameters[0]);
  UserName.Value = Parameters[0]; 
}


Comments

This article is new, please leave comments if something is wrong or unclear.

-- BenClayton? - 02 May 2008

 

Ready to
get started?

Download Mscape Suite Version 2.1 | 10.5 MB

Download Mscape Beta

Experimental Beta Version 2.5 | 10.5 MB

Ask the Mscape Community

Forums