ADOBE FLEX 3
Developer Guide
500
One use of this technique is to have an old application dynamically loading a newer version of the same application
without conflict. There is no conflict because although the same class names are used, they are partitioned into
different application domains.
The following code creates an application domain that is a child of the system domain, and starts loading a SWF
using that application domain:
var appDomainA:ApplicationDomain = new ApplicationDomain();
var contextA:LoaderContext = new LoaderContext(false, appDomainA);
var loaderA:Loader = new Loader();
loaderA.load(new URLRequest("application2.swf"), contextA);
Usage B: dd new class definitions to current class definitions. The application domain of module1.swf is set to the
current domain (Application domain 1). This lets you add to the applications current set of class definitions with
new class definitions. This could be used for a run-time shared library of the main application. The loaded SWF is
treated as a remote shared library (RSL). Use this technique to load RSLs by a preloader before the application starts.
The following code loads a SWF, setting its application domain to the current domain:
var appDomainB:ApplicationDomain = ApplicationDomain.currentDomain;
var contextB:LoaderContext = new LoaderContext(false, appDomainB);
var loaderB:Loader = new Loader();
loaderB.load(new URLRequest("module1.swf"), contextB);
Usage C: se the parents class definitions by creating a new child domain of the current domain. The application
domain of module3.swf is a child of the current domain, and the child uses the parent's versions of all classes. One
use of this technique might be a module of a multiple-screen rich Internet application (RIA), loaded as a child of the
main application, that uses the main application's types. If you can ensure that all classes are always updated to be
backward compatible, and that the loading application is always newer than the things it loads, the children will use
the parent versions. Having a new application domain also allows you to unload all the class definitions for garbage
collection, if you can ensure that you do not continue to have references to the child SWF.
This technique lets loaded modules share the loader's singleton objects and static class members.
The following code creates a new child domain of the current domain, and starts loading a SWF using that appli-
cation domain:
var appDomainC:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
var contextC:LoaderContext = new LoaderContext(false, appDomainC);
var loaderC:Loader = new Loader();
loaderC.load(new URLRequest("module3.swf"), contextC);
Using the IME class
The IME class lets you manipulate the operating systems IME within Flash Player or Adobe AIR.
Using ActionScript, you can determine the following:
If an IME is installed on the user's computer (Capabilities.hasIME)
If the IME is enabled or disabled on the users computer (IME.enabled)
The conversion mode the current IME is using (IME.conversionMode)

Get ADOBE® FLEX® 3: PROGRAMMING ACTIONSCRIPT™ 3.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.