456 Working with Text and Strings
3. Select Control > Test Movie to test the document.
A message appears in the Output panel stating whether you have an IME installed and
currently active.
You can also use the IME class to enable and disable the IME in Flash at runtime. The
following example requires that you have an IME installed on your system. For more
information on installing an IME on your specific platform, see the following links:
■ www.microsoft.com/globaldev/default.mspx
■ http://developer.apple.com/documentation/
■ http://java.sun.com
You can enable and disable an IME while the SWF file plays, as shown in the following
example.
To enable and disable an input method editor at runtime:
1. Create a new Flash document and save it as ime2.fla.
2. Create two button symbol instances on the Stage and give them the instance names
enable_btn and disable_btn.
3. Add the following ActionScript to Frame 1 of the main Timeline:
checkIME();
var my_fmt:TextFormat = new TextFormat();
my_fmt.font = "_sans";
this.createTextField("ime_txt", 10, 100, 10, 320, 240);
ime_txt.border = true;
ime_txt.multiline = true;
ime_txt.setNewTextFormat(my_fmt);
ime_txt.type = "input";
ime_txt.wordWrap = true;
enable_btn.onRelease = function() {
System.IME.setEnabled(true);
};
disable_btn.onRelease = function() {
System.IME.setEnabled(false);
};
function checkIME():Boolean {
if (System.capabilities.hasIME) {
if (System.IME.getEnabled()) {
trace("You have an IME installed and enabled.");
return true;
} else {
trace("You have an IME installed but not enabled.");