Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1

60 | Chapter 3: Working with JavaScript and HTML Within AIR


TIP
This technique works only with ActionScript 3 libraries.

Let’s look at an example. Included in the Adobe AIR SDK is
a SWF that contains the ActionScript 3 Adobe AIR service
connectivity API. While this example won’t show how to use
that API, it will show how to access those APIs from within
JavaScript.


TIP
An example of how to use the Service Connectivity API is
provided in the cookbook section of Chapter 4.

In order for the example to work, you must copy the
frameworks/servicemonitor.swffile from the AIR SDK to your
application directory.


Any classes and APIs available within the compiled SWF will
be made available via thewindow.runtimeproperty. The API
we want to reference is in a class namedServiceMonitorin
theair.net package.


Here’s the code:


<script src="servicemonitor.swf"></script>

<script>
function onAppLoad( )
{
var monitor = new runtime.air.net.ServiceMonitor();
}
</script>

This is a very simple example that shows how to load com-
piled ActionScript libraries, and then access them from Java-
Script. In this case, we include theservicemonitor.swffile via
the HTML script tag. This file contains the compiled Action-
Script 3 APIs for theair.net.ServiceMonitor class.

Free download pdf