Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 438

Programming actionscript 3.0
Table of Contents

Advertisement

The main application file is application1.swf. It contains Loader objects that load content
from other SWF files. In this scenario, the current domain is Application domain 1. Usage A,
usage B, and usage C illustrate different techniques for setting the appropriate application
domain for each SWF file in an application.
Usage A
: Partition the child SWF file by creating a child of the system domain. In the
diagram, application domain 2 is created as a child of the system domain.The
application2.swf file is loaded in application domain 2, and its class definitions are thus
partitioned from the classes defined in application1.swf.
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:
request.url = "application2.swf";
request.applicationDomain = new ApplicationDomain();
Usage B:
Add 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
application's 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 an remote
shared library (RSL). Use this technique to load RSLs by a preloader before the application
starts.
The following code sets an application domain to the current domain:
request.url = "module1.swf";
request.applicationDomain = ApplicationDomain.currentDomain;
Usage C:
Use the parent's 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.
438
Client System Environment

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents