|
Flash 8 ActionScript 2.0 Language Reference
|
|
SystemClass IME
Object
public class IME
extends Object
Player version: | Flash Player 8 |
The IME class lets you directly manipulate the operating system's input method editor (IME) in the Flash Player application that is running on a client computer. You can determine whether an IME is installed, whether or not the IME is enabled, and which IME is enabled. You can disable or enable the IME in the Flash Player application, and you can perform other limited functions, depending on the operating system. Input method editors let users type non-ASCII text characters in Asian languages such as Chinese, Japanese, and Korean. For more information on IMEs, see the operating system documentation for the platform for which you are developing applications. Some additional resources for information about input methods are listed here:
The following table shows the platform coverage of this class:
Capability | Windows | Macintosh OSX | Macintosh Classic | Linux/Solaris XIM |
Determine whether the IME is installed
System.capabilities.hasIME | Yes | Yes | Yes | Yes |
Set IME on or off
System.IME.setEnabled() | Yes | Yes | Yes | Yes |
Find out whether IME is on or off
System.IME.getEnabled() | Yes | Yes | Yes | Yes |
Set IME conversion mode
System.IME.setConversionMode() | Yes | Yes ** | No | Yes |
Get IME conversion mode
System.IME.getConversionMode() | Yes | Yes ** | No | Yes |
Send IME the string to be converted
System.IME.setCompositionString() | Yes * | No | No | Yes |
Get from IME the original string before conversion
System.IME.addListener() listener.onIMEComposition() System.IME.removeListener() | Yes * | No | No | Yes |
Send request to convert to IME
System.IME.doConversion() | Yes * | No | No | Yes |
* Not all Windows IMEs support all of these operations. So far the only IME that supports them all is the Japanese IME. Every IME differs in its support of the OS calls.
** On Macintosh these methods are supported only for Japanese, and they are not supported for third-party IMEs.
static | ALPHANUMERIC_FULL : String
A string with the value "ALPHANUMERIC_FULL" for use with setConversionMode() and getConversionMode() . |
static | ALPHANUMERIC_HALF : String
A string with the value "ALPHANUMERIC_HALF" for use with setConversionMode() and getConversionMode() . |
static | CHINESE : String
A string with the value "CHINESE" for use with setConversionMode() and getConversionMode() . |
static | JAPANESE_HIRAGANA : String
A string with the value "JAPANESE_HIRAGANA" for use with setConversionMode() and getConversionMode() . |
static | JAPANESE_KATAKANA_FULL : String
A string with the value "JAPANESE_KATAKANA_FULL" for use with setConversionMode() and getConversionMode() . |
static | JAPANESE_KATAKANA_HALF : String
A string with the value "JAPANESE_KATAKANA_HALF" for use with setConversionMode() and getConversionMode() . |
static | KOREAN : String
A string with the value "KOREAN" for use with setConversionMode() and getConversionMode() . |
static | UNKNOWN : String
A string with the value "UNKNOWN" for use with getConversionMode() . |
ALPHANUMERIC_FULL Constant
public static ALPHANUMERIC_FULL : String
Player version: | Flash Player 8 |
A string with the value "ALPHANUMERIC_FULL"
for use with setConversionMode()
and getConversionMode()
. This constant is used with all IMEs.
Example
The following example sets the IME to ALPHANUMERIC_FULL
if the system has an Input Method Editor (IME) installed (System.capabilities.hasIME
).
if(System.capabilities.hasIME) {
trace(System.IME.getConversionMode());
System.IME.setConversionMode(System.IME.ALPHANUMERIC_FULL);
trace(System.IME.getConversionMode());
}
See also
ALPHANUMERIC_HALF Constant
public static ALPHANUMERIC_HALF : String
Player version: | Flash Player 8 |
A string with the value "ALPHANUMERIC_HALF"
for use with setConversionMode()
and getConversionMode()
. This constant is used with all IMEs.
Example
The following example sets the IME to ALPHANUMERIC_HALF
if the system has an Input Method Editor (IME) installed (System.capabilities.hasIME
).
if(System.capabilities.hasIME) {
trace(System.IME.getConversionMode());
System.IME.setConversionMode(System.IME.ALPHANUMERIC_HALF);
trace(System.IME.getConversionMode());
}
See also
CHINESE Constant
public static CHINESE : String
Player version: | Flash Player 8 |
A string with the value "CHINESE"
for use with setConversionMode()
and getConversionMode()
. This constant is used with simplified and traditional Chinese IMEs.
Example
The following example sets the IME to CHINESE
if the system has an Input Method Editor (IME) installed (System.capabilities.hasIME
).
if(System.capabilities.hasIME) {
trace(System.IME.getConversionMode());
System.IME.setConversionMode(System.IME.CHINESE);
trace(System.IME.getConversionMode());
}
See also
JAPANESE_HIRAGANA Constant
public static JAPANESE_HIRAGANA : String
Player version: | Flash Player 8 |
A string with the value "JAPANESE_HIRAGANA"
for use with setConversionMode()
and getConversionMode()
. This constant is used with Japanese IMEs.
Example
The following example sets the IME to JAPANESE_HIRAGANA
if the system has an Input Method Editor (IME) installed (System.capabilities.hasIME
).
if(System.capabilities.hasIME) {
trace(System.IME.getConversionMode());
System.IME.setConversionMode(System.IME.JAPANESE_HIRAGANA);
trace(System.IME.getConversionMode());
}
See also
JAPANESE_KATAKANA_FULL Constant
public static JAPANESE_KATAKANA_FULL : String
Player version: | Flash Player 8 |
A string with the value "JAPANESE_KATAKANA_FULL"
for use with setConversionMode()
and getConversionMode()
. This constant is used with Japanese IMEs.
Example
The following example sets the IME to JAPANESE_KATAKANA_FULL
if the system has an Input Method Editor (IME) installed (System.capabilities.hasIME
).
if(System.capabilities.hasIME) {
trace(System.IME.getConversionMode());
System.IME.setConversionMode(System.IME.JAPANESE_KATAKANA_FULL);
trace(System.IME.getConversionMode());
}
See also
JAPANESE_KATAKANA_HALF Constant
public static JAPANESE_KATAKANA_HALF : String
Player version: | Flash Player 8 |
A string with the value "JAPANESE_KATAKANA_HALF"
for use with setConversionMode()
and getConversionMode()
. This constant is used with Japanese IMEs.
Example
The following example sets the IME to JAPANESE_KATAKANA_HALF
if the system has an Input Method Editor (IME) installed (System.capabilities.hasIME
).
if(System.capabilities.hasIME) {
trace(System.IME.getConversionMode());
System.IME.setConversionMode(System.IME.JAPANESE_KATAKANA_HALF);
trace(System.IME.getConversionMode());
}
See also
KOREAN Constant
public static KOREAN : String
Player version: | Flash Player 8 |
A string with the value "KOREAN"
for use with setConversionMode()
and getConversionMode()
. This constant is used with Korean IMEs.
Example
The following example sets the IME to KOREAN
if the system has an Input Method Editor (IME) installed (System.capabilities.hasIME
).
if(System.capabilities.hasIME) {
trace(System.IME.getConversionMode());
System.IME.setConversionMode(System.IME.KOREAN);
trace(System.IME.getConversionMode());
}
See also
UNKNOWN Constant
public static UNKNOWN : String
Player version: | Flash Player 8 |
A string with the value "UNKNOWN"
for use with getConversionMode()
. This constant is used with all IMEs.
Example
The following example sets the IME to UNKNOWN
if the system has an Input Method Editor (IME) installed (System.capabilities.hasIME
).
if(System.capabilities.hasIME) {
trace(System.IME.getConversionMode());
System.IME.setConversionMode(System.IME.UNKNOWN);
trace(System.IME.getConversionMode());
}
See also
onIMEComposition Event Listener
public onIMEComposition = function([readingString:String]) {}
Player version: | Flash Player 8 |
Notified when the IME composition string is being set. To use this listener, you must create a listener object. You can then define a function for this listener and use IME.addListener()
to register the listener with the IME object, as in the following code:
var someListener:Object = new Object();
someListener.onIMEComposition = function () {
// statements
}
System.IME.addListener(someListener);
Listeners enable different pieces of code to cooperate because multiple listeners can receive notification about a single event.
Parameters
| readingString:String [optional] — The original text typed into the IME before the user started picking candidates. |
Example
The following example shows how to add a listener object with the callback method onIMEComposition()
to System.IME
, which outputs notification when a user sets the composition string by clicking in the text field.
var IMEListener:Object = new Object();
IMEListener.onIMEComposition = function(str:String) {
trace(">> onIMEComposition: " + str);
}
System.IME.addListener(IMEListener);
trace(System.IME.length);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.createTextField("txt", this.getNextHighestDepth(), 0, 0, 0, 0);
mc.txt.border = true;
mc.txt.background = true;
mc.txt.autoSize = "left";
mc.txt.text = "Click this text to add a listener.";
mc.onPress = function() {
if(System.capabilities.hasIME) {
Selection.setFocus(mc.txt);
System.IME.setCompositionString(mc.txt.text);
}
}
See also
addListener Method
public static addListener(listener:Object) : Void
Player version: | Flash Player 8 |
Registers an object to receive notification when an IME event handler is invoked by the onIMEComposition
event.
Parameters
| listener:Object — An object, with an onIMEComposition (readingString) method, that listens for a callback notification from the IME event handlers. The reading string passed to this method is in the composition mode of the IME. For example, if the user enters text in Hiragana and then selects a Kanji candidate, the reading string is the original Hiragana. |
Example
The following example shows how to add a listener object to System.IME
that outputs notification when a user sets the composition string by clicking in the text field.
var IMEListener:Object = new Object();
IMEListener.onIMEComposition = function(str:String) {
trace(">> onIMEComposition: " + str);
}
System.IME.addListener(IMEListener);
trace(System.IME.length);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.createTextField("txt", this.getNextHighestDepth(), 0, 0, 0, 0);
mc.txt.border = true;
mc.txt.background = true;
mc.txt.autoSize = "left";
mc.txt.text = "Click this text to add a listener.";
mc.onPress = function() {
if(System.capabilities.hasIME) {
Selection.setFocus(mc.txt);
System.IME.setCompositionString(mc.txt.text);
}
}
doConversion Method
public static doConversion() : Boolean
Player version: | Flash Player 8 |
Instructs the IME to select the first candidate for the current composition string.
Returns
| Boolean —
Returns true if the call is successful; otherwise false .
|
Example
The following example shows how to select the first candidate for the IME composition string. If the user's system has IME, clicking in the text field selects the candidate.
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.createTextField("txt", this.getNextHighestDepth(), 0, 0, 0, 0);
mc.txt.border = true;
mc.txt.background = true;
mc.txt.autoSize = "left";
mc.txt.text = "Set this text as the composition string and convert it.";
mc.onPress = function() {
if(System.capabilities.hasIME) {
Selection.setFocus(mc.txt);
System.IME.setCompositionString(mc.txt.text);
trace(System.IME.doConversion());
}
}
getConversionMode Method
public static getConversionMode() : String
Player version: | Flash Player 8 |
Indicates the conversion mode of the current IME.
Returns
| String —
The conversion mode. Possible values are IME mode string constants that indicate the conversion mode: ALPHANUMERIC_FULL ALPHANUMERIC_HALF CHINESE JAPANESE_HIRAGANA JAPANESE_KATAKANA_FULL JAPANESE_KATAKANA_HALF KOREAN UNKNOWN
|
Example
The following example gets the IME if the system has an Input Method Editor (IME) installed ( System.capabilities.hasIME
).
var mode:String = System.IME.UNKNOWN;
if(System.capabilities.hasIME) {
mode = System.IME.getConversionMode();
}
trace(mode);
See also
getEnabled Method
public static getEnabled() : Boolean
Player version: | Flash Player 8 |
Indicates whether the system IME is enabled. An enabled IME performs multibyte input; a disabled IME performs alphanumeric input.
Returns
| Boolean —
Returns true if the system IME is enabled, false if it is disabled.
|
Example
The following example checks to see whether IME is enabled by calling the isEnabled()
method.
if(System.capabilities.hasIME) {
var isImeEnabled:Boolean = System.IME.getEnabled();
trace(isImeEnabled);
}
removeListener Method
public static removeListener(listener:Object) : Boolean
Player version: | Flash Player 8 |
Removes a listener object that was previously registered to an IME
instance with IME.addListener()
.
Parameters
| listener:Object — The object that no longer receives callback notification from the IME event handlers. |
Returns
| Boolean —
Returns true if the listener object is removed; otherwise false .
|
Example
The following example shows how to remove a listener object from System.IME
when a user sets the composition string by clicking in the text field.
var IMEListener:Object = new Object();
IMEListener.onIMEComposition = function(str:String) {
trace(">> onIMEComposition: " + str);
System.IME.removeListener(this);
trace(System.IME.length); // 0
}
System.IME.addListener(IMEListener);
trace(System.IME.length); // 1
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.createTextField("txt", this.getNextHighestDepth(), 0, 0, 0, 0);
mc.txt.border = true;
mc.txt.background = true;
mc.txt.autoSize = "left";
mc.txt.text = "Click this text to add and remove a listener.";
mc.onPress = function() {
if(System.capabilities.hasIME) {
Selection.setFocus(mc.txt);
System.IME.setCompositionString(mc.txt.text);
}
}
setCompositionString Method
public static setCompositionString(composition:String) : Boolean
Player version: | Flash Player 8 |
Sets the IME composition string. When this string is set, the user can select IME candidates before committing the result to the text field that currently has focus.
Parameters
| composition:String — The string to send to the IME. |
Returns
| Boolean —
If the IME composition string is successfully set, returns true . This method fails and returns false if no text field has focus.
|
Example
The following example shows how to set the IME composition string. If the user's system has IME, clicking in the text field shows the IME options.
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.createTextField("txt", this.getNextHighestDepth(), 0, 0, 0, 0);
mc.txt.border = true;
mc.txt.background = true;
mc.txt.autoSize = "left";
mc.txt.text = "Set this text as the composition string.";
mc.onPress = function() {
if(System.capabilities.hasIME) {
Selection.setFocus(mc.txt);
trace(System.IME.setCompositionString(mc.txt.text));
}
}
setConversionMode Method
public static setConversionMode(mode:String) : Boolean
Player version: | Flash Player 8 |
Sets the conversion mode of the current IME.
Parameters
| mode:String — The conversion mode. Possible values are the IME mode string constants: ALPHANUMERIC_FULL ALPHANUMERIC_HALF CHINESE JAPANESE_HIRAGANA JAPANESE_KATAKANA_FULL JAPANESE_KATAKANA_HALF KOREAN |
Returns
| Boolean —
Returns true if the conversion mode was successfully set; otherwise false .
|
Example
The following example gets the IME if the system has an Input Method Editor (IME) installed ( System.capabilities.hasIME
) and sets the variable mode
to that value.
var mode:String = System.IME.UNKNOWN;
if(System.capabilities.hasIME) {
mode = System.IME.getConversionMode();
}
System.IME.setConversionMode(mode);
trace(System.IME.getConversionMode());
See also
setEnabled Method
public static setEnabled(enabled:Boolean) : Boolean
Player version: | Flash Player 8 |
Enables or disables the system IME. An enabled IME performs multibyte input; a disabled IME performs alphanumeric input.
Parameters
| enabled:Boolean — Set to true to enable the system IME, false to disable it. |
Returns
| Boolean —
If the attempt to enable the system IME is successful, returns true ; otherwise false .
|
Example
The following example checks to see whether IME is enabled by calling the isEnabled()
method and then changes its enabled state to the opposite by calling the setEnabled()
method.
if(System.capabilities.hasIME) {
var isImeEnabled:Boolean = System.IME.getEnabled();
trace(isImeEnabled);
if(isImeEnabled) {
System.IME.setEnabled(false);
}
else {
System.IME.setEnabled(true);
}
var isImeEnabled:Boolean = System.IME.getEnabled();
trace(isImeEnabled);
}
Copyright © 2005 Macromedia Inc. All rights reserved.
Tue Sep 13 2005, 16:15 PDT