O'Reilly logo

Adobe AIR 1.5 Cookbook by Koen De Weggheleire, Koen DeWeggheleire, Marco Casario, David Tucker, Rich Tretola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required