Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 442

Programming actionscript 3.0
Table of Contents

Advertisement

statusText.text = "Unable to set conversion mode.\n" + error.message;
}
}
The previous code first creates a text field, which is used to display a status message to the
user. Next, if the IME is installed, the code enables the IME and sets the conversion mode to
Korean. If the user's computer does not have a Korean IME installed, an error is thrown by
Flash Player and is caught by the
message in the previously created text field.
Disabling the IME for certain text fields
In some cases, you may want to disable the user's IME while they type characters. For
example, if you had a text field that only accepts numeric input, you may not want the IME
to come up and slow down data entry.
The following example demonstrates how you can listen for the
FocusEvent.FOCUS_OUT
var phoneTxt:TextField = new TextField();
var nameTxt:TextField = new TextField();
phoneTxt.type = TextFieldType.INPUT;
phoneTxt.addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
phoneTxt.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
phoneTxt.restrict = "0-9";
phoneTxt.width = 100;
phoneTxt.height = 18;
phoneTxt.background = true;
phoneTxt.border = true;
addChild(phoneTxt);
nameField.type = TextFieldType.INPUT;
nameField.x = 120;
nameField.width = 100;
nameField.height = 18;
nameField.background = true;
nameField.border = true;
addChild(nameField);
function focusInHandler(event:FocusEvent):void
{
if (Capabilities.hasIME)
{
IME.enabled = false;
}
}
function focusOutHandler(event:FocusEvent):void
442
Client System Environment
block. The
try..catch
events and disable the user's IME accordingly:
block displays the error
try..catch
FocusEvent.FOCUS_IN
and

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents