Playing with this:
http://community.stencyl.com/index.php/topic,8665.0.htmland some AS3 code from here:
http://thierryzoghbi.co.uk/blog/2009/03/capturing-text-input-as3/I've got the ability to input text that works with foreign keyboards, including Cyrillic characters, etc.
This is AWESOME for me, as it allows me to capture and render to screen non-latin characters, which has been an issue for some time in an EU project I am involved with. Not only does this allow characters outside the usual SW a-z, 0-9 plus some punctuation, it allows user configurable colours for text, background, style, etc, which is a God(dess) send for Children with Dyslexia for whom my games are being developed.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html has information on how to change background and border colours, etc,
Place the following in a script for a scene inside a code block in the When Created block:
import flash.text.*;
//Creating the textfield object and naming it "myTextField"
var myTextField:TextField = new TextField();
//Here we add the new textfield instance to the stage with addchild()
FlxG.stage.addChild(myTextField);
//Here we define some properties for our text field, starting with giving it some text to contain.
//A width, x and y coordinates.
myTextField.type = TextFieldType.INPUT;
myTextField.width = 250;
myTextField.x = 25;
myTextField.y = 25;
myTextField.background = true;
//Here are some great properties to define, first one is to make sure the text is not selectable, then adding a border.
myTextField.selectable = true;
myTextField.border = true;
// If you WANT to restrict input characters, here's how to do it!
//myTextField.restrict = '1234567890,. QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm';
//myTextField.restrict = '1234567890'; woudl be for numbers only for example.
//myTextField.multiline = true; // Causes RETURN characters (i.e. newlines) to be inserted into the text if the cursor is mid text
// myTextField.wordWrap = true; // Causes the auto size below not to work if enabled.
//This last property for our textfield is to make it autosize with the text, aligning to the left.
myTextField.autoSize = TextFieldAutoSize.LEFT;
//This is the section for our text styling, first we create a TextFormat instance naming it myFormat
var myFormat:TextFormat = new TextFormat();
//Giving the format a hex decimal color code
myFormat.color = 0xAA0000;
//Adding some bigger text size
myFormat.size = 24;
//Last text style is to make it italic.
myFormat.italic = true;
//Now the most important thing for the textformat, we need to add it to the myTextField with setTextFormat.
myTextField.defaultTextFormat = myFormat;
myTextField.text = "some text here!";
var OutputBox:TextField = new TextField();
OutputBox.background = false;
OutputBox.x = 25;
OutputBox.y = 200;
OutputBox.selectable = false;
OutputBox.border = false;
//This last property for our textfield is to make it autosize with the text, aligning to the left.
OutputBox.autoSize = TextFieldAutoSize.LEFT;
FlxG.stage.addChild(OutputBox);
//Use OutputBox.text = "blah"; for standard text printing or OutputBox.htmlText for HTML formatted text. Note I cannot get the font colour to work :-(
OutputBox.htmlText = "<P ALIGN='LEFT'><FONT FACE='Ariel' SIZE='36' COLOR='00FF00' LETTERSPACING='0' KERNING='0'><b>Lorem ipsum dolor sit amet.</b></FONT></P>";
Then add a Keyboard event with the following inside a code block:
var str:String = myTextField.text;
OutputBox.text = str;
//myTextField.text = "Start again!"
and set the event to When enter IS released. It might be possible to use an AS3 event handler, but this seemed a better way to integrate into SW.