To make the ActionScript
classes of your application available in JavaScript, you can assign
the loaded HTML content to the application domain containing the class
definitions. The application domain of the JavaScript execution
context can be set with the
runtimeApplicationDomain
property
of the HTMLLoader object. To set the application domain to the primary
application domain, for example, set
runtimeApplicationDomain
to
ApplicationDomain.currentDomain
,
as shown in the following code:
html.runtimeApplicationDomain = ApplicationDomain.currentDomain;
Once
the
runtimeApplicationDomain
property is set, the
JavaScript context shares class definitions with the assigned domain.
To create an instance of a custom class in JavaScript, reference
the class definition through the
window.runtime
property
and use the
new
operator:
var customClassObject = new window.runtime.CustomClass();
The
HTML content must be from a compatible security domain. If the HTML
content is from a different security domain than that of the application
domain you assign, the page uses a default application domain instead.
For example, if you load a remote page from the Internet, you could
not assign ApplicationDomain.currentDomain as the application domain of
the page.