Chapter 15. Service Monitor Framework

For desktop applications, you often need the ability to detect the status of network connectivity and monitor its changes. Some applications require a constant Internet connection, while others, called occasionally connected applications, can work offline as well as online by caching the offline content. Adobe AIR can detect network connectivity changes, thereby enabling you to plan the behavior of the application based on its status.

Including the Service Monitor Framework in an Application (JavaScript)

Problem

You want to use the service monitor framework with JavaScript to detect the status of network connectivity.

Solution

Import the service monitor framework into the AIR application.

Discussion

The service monitor framework is a separate framework from the standard AIR framework. To be able to use the service monitor framework, you need to import the servicemonitor.swf file into your HTML and JavaScript application. You can find this file in the AIR SDK’s frameworks folder. Copy servicemonitor.swf into the directory of your AIR project.

To import the file, use the script tag. The tag’s type attribute specifies the scripting language of the element’s contents and overrides the default scripting language. Set the type attribute to the application/x-shockwave-flash value, as shown here:

<script type="application/x-shockwave-flash"
src="frameworks/servicemonitor.swf"></script>

In the previous line of code, the servicemonitor.swf file resides in the frameworks ...

Get Adobe AIR 1.5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.