Object | +-System.IME public class IME extends Object 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:
Availability: ActionScript 1.0; Flash Player 8 Property summary
Properties inherited from class Object
Event summary
Method summary
Methods inherited from class Object
addListener (IME.addListener method)public static addListener(listener:Object) : Void Registers an object to receive notification when an IME event handler is invoked by the onIMEComposition event. Availability: ActionScript 1.0; Flash Player 8 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); } } ALPHANUMERIC_FULL (IME.ALPHANUMERIC_FULL property)public static ALPHANUMERIC_FULL : String A string with the value "ALPHANUMERIC_FULL" for use with setConversionMode() and getConversionMode(). This constant is used with all IMEs. Availability: ActionScript 1.0; Flash Player 8 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 setConversionMode (IME.setConversionMode method), getConversionMode (IME.getConversionMode method), hasIME (capabilities.hasIME property) ALPHANUMERIC_HALF (IME.ALPHANUMERIC_HALF property)public static ALPHANUMERIC_HALF : String A string with the value "ALPHANUMERIC_HALF" for use with setConversionMode() and getConversionMode(). This constant is used with all IMEs. Availability: ActionScript 1.0; Flash Player 8 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 setConversionMode (IME.setConversionMode method), getConversionMode (IME.getConversionMode method) CHINESE (IME.CHINESE property)public static CHINESE : String A string with the value "CHINESE" for use with setConversionMode() and getConversionMode(). This constant is used with simplified and traditional Chinese IMEs. Availability: ActionScript 1.0; Flash Player 8 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 setConversionMode (IME.setConversionMode method), getConversionMode (IME.getConversionMode method) doConversion (IME.doConversion method)public static doConversion() : Boolean Instructs the IME to select the first candidate for the current composition string. Availability: ActionScript 1.0; Flash Player 8 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 (IME.getConversionMode method)public static getConversionMode() : String Indicates the conversion mode of the current IME. Availability: ActionScript 1.0; Flash Player 8 Returns String - The conversion mode. Possible values are IME mode string constants that indicate the conversion mode:
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 ALPHANUMERIC_FULL (IME.ALPHANUMERIC_FULL property), ALPHANUMERIC_HALF (IME.ALPHANUMERIC_HALF property), CHINESE (IME.CHINESE property), JAPANESE_HIRAGANA (IME.JAPANESE_HIRAGANA property), JAPANESE_KATAKANA_FULL (IME.JAPANESE_KATAKANA_FULL property), JAPANESE_KATAKANA_HALF (IME.JAPANESE_KATAKANA_HALF property), KOREAN (IME.KOREAN property), UNKNOWN (IME.UNKNOWN property) getEnabled (IME.getEnabled method)public static getEnabled() : Boolean Indicates whether the system IME is enabled. An enabled IME performs multibyte input; a disabled IME performs alphanumeric input. Availability: ActionScript 1.0; Flash Player 8 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); } JAPANESE_HIRAGANA (IME.JAPANESE_HIRAGANA property)public static JAPANESE_HIRAGANA : String A string with the value "JAPANESE_HIRAGANA" for use with setConversionMode() and getConversionMode(). This constant is used with Japanese IMEs. Availability: ActionScript 1.0; Flash Player 8 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 setConversionMode (IME.setConversionMode method), getConversionMode (IME.getConversionMode method) JAPANESE_KATAKANA_FULL (IME.JAPANESE_KATAKANA_FULL property)public static JAPANESE_KATAKANA_FULL : String A string with the value "JAPANESE_KATAKANA_FULL" for use with setConversionMode() and getConversionMode(). This constant is used with Japanese IMEs. Availability: ActionScript 1.0; Flash Player 8 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 setConversionMode (IME.setConversionMode method), getConversionMode (IME.getConversionMode method) JAPANESE_KATAKANA_HALF (IME.JAPANESE_KATAKANA_HALF property)public static JAPANESE_KATAKANA_HALF : String A string with the value "JAPANESE_KATAKANA_HALF" for use with setConversionMode() and getConversionMode(). This constant is used with Japanese IMEs. Availability: ActionScript 1.0; Flash Player 8 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 setConversionMode (IME.setConversionMode method), getConversionMode (IME.getConversionMode method) KOREAN (IME.KOREAN property)public static KOREAN : String A string with the value "KOREAN" for use with setConversionMode() and getConversionMode(). This constant is used with Korean IMEs. Availability: ActionScript 1.0; Flash Player 8 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); race(System.IME.getConversionMode()); } See also setConversionMode (IME.setConversionMode method), getConversionMode (IME.getConversionMode method) onIMEComposition (IME.onIMEComposition event listener)onIMEComposition = function([readingString:String]) {} 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. Availability: ActionScript 1.0; Flash Player 8 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 (IME.addListener method), setCompositionString (IME.setCompositionString method) removeListener (IME.removeListener method)public static removeListener(listener:Object) : Boolean Removes a listener object that was previously registered to an IME instance with IME.addListener(). Availability: ActionScript 1.0; Flash Player 8 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 (IME.setCompositionString method)public static setCompositionString(composition:String) : Boolean 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. Availability: ActionScript 1.0; Flash Player 8 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 (IME.setConversionMode method)public static setConversionMode(mode:String) : Boolean Sets the conversion mode of the current IME. Availability: ActionScript 1.0; Flash Player 8 Parameters mode:String - The conversion mode. Possible values are the IME mode string constants:
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 ALPHANUMERIC_FULL (IME.ALPHANUMERIC_FULL property), ALPHANUMERIC_HALF (IME.ALPHANUMERIC_HALF property), CHINESE (IME.CHINESE property), JAPANESE_HIRAGANA (IME.JAPANESE_HIRAGANA property), JAPANESE_KATAKANA_FULL (IME.JAPANESE_KATAKANA_FULL property), JAPANESE_KATAKANA_HALF (IME.JAPANESE_KATAKANA_HALF property), KOREAN (IME.KOREAN property) setEnabled (IME.setEnabled method)public static setEnabled(enabled:Boolean) : Boolean Enables or disables the system IME. An enabled IME performs multibyte input; a disabled IME performs alphanumeric input. Availability: ActionScript 1.0; Flash Player 8 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); } UNKNOWN (IME.UNKNOWN property)public static UNKNOWN : String A string with the value "UNKNOWN" for use with getConversionMode(). This constant is used with all IMEs. Availability: ActionScript 1.0; Flash Player 8 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 getConversionMode (IME.getConversionMode method) |