13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Keyboard input<br />

var inputTxt:TextField;<br />

var outputTxt:TextField;<br />

inputTxt = new TextField();<br />

inputTxt.type = TextFieldType.INPUT;<br />

inputTxt.width = 200;<br />

inputTxt.height = 18;<br />

inputTxt.border = true;<br />

inputTxt.background = true;<br />

addChild(inputTxt);<br />

outputTxt = new TextField();<br />

outputTxt.autoSize = TextFieldAutoSize.LEFT;<br />

outputTxt.y = 20;<br />

addChild(outputTxt);<br />

if (Capabilities.hasIME)<br />

{<br />

IME.<strong>en</strong>abled = true;<br />

try<br />

{<br />

IME.conversionMode = IMEConversionMode.JAPANESE_HIRAGANA;<br />

}<br />

catch (error:Error)<br />

{<br />

outputTxt.text = "Unable to change IME.";<br />

}<br />

System.ime.addEv<strong>en</strong>tList<strong>en</strong>er(IMEEv<strong>en</strong>t.IME_COMPOSITION, imeCompositionHandler);<br />

}<br />

else<br />

{<br />

outputTxt.text = "Please install IME and try again.";<br />

}<br />

function imeCompositionHandler(ev<strong>en</strong>t:IMEEv<strong>en</strong>t):void<br />

{<br />

outputTxt.text = "you typed: " + ev<strong>en</strong>t.text;<br />

}<br />

The previous code creates two text fields and adds them to the display list. The first text field, inputTxt, is an input<br />

text field that allows the user to <strong>en</strong>ter Japanese text. The second text field, outputTxt, is a dynamic text field that<br />

displays error messages to the user, or echoes the Japanese string that the user types into the inputTxt text field.<br />

Virtual keyboards<br />

Flash Player 10.2 and later, AIR 2.6 and later<br />

Mobile devices, such as phones and tablets, oft<strong>en</strong> provide a virtual, software keyboard instead of a physical one. The<br />

classes in the Flash API let you:<br />

Detect wh<strong>en</strong> the virtual keyboard is raised and wh<strong>en</strong> it closes.<br />

Prev<strong>en</strong>t the keyboard from raising.<br />

Determine the area of the stage obscured by the virtual keyboard.<br />

Last updated 6/6/2012<br />

566

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!