31.07.2013 Views

Building Adobe AIR Applications

Building Adobe AIR Applications

Building Adobe AIR Applications

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BUILDING ADOBE <strong>AIR</strong> APPLICATIONS<br />

<strong>AIR</strong>.SWF in-browser API<br />

4 Select the options you want, and then click the Install button.<br />

5 When the installation is complete, click Finish.<br />

Modify the badge.swf file<br />

The Flex SDK and <strong>AIR</strong> SDK provides the source files for the badge.swf file. These files are included in the<br />

samples/badge folder of the SDK:<br />

Source files Description<br />

badge.fla The source Flash file used to compile the badge.swf file. The badge.fla file compiles into a SWF 9 file (which can<br />

be loaded in Flash Player).<br />

<strong>AIR</strong>Badge.as An ActionScript 3.0 class that defines the base class used in the basdge.fla file.<br />

You can use Flash Professional to redesign the visual interface of the badge.fla file.<br />

The <strong>AIR</strong>Badge() constructor function, defined in the <strong>AIR</strong>Badge class, loads the air.swf file hosted at<br />

http://airdownload.adobe.com/air/browserapi/air.swf. The air.swf file includes code for using the seamless install<br />

feature.<br />

The onInit() method (in the <strong>AIR</strong>Badge class) is invoked when the air.swf file is loaded successfully:<br />

private function onInit(e:Event):void {<br />

_air = e.target.content;<br />

switch (_air.getStatus()) {<br />

case "installed" :<br />

root.statusMessage.text = "";<br />

break;<br />

case "available" :<br />

if (_appName && _appName.length > 0) {<br />

root.statusMessage.htmlText = "In order to run " + _appName +<br />

", this installer will also set up <strong>Adobe</strong>® <strong>AIR</strong>®.";<br />

} else {<br />

root.statusMessage.htmlText = "In order to run this application, "<br />

+ "this installer will also set up <strong>Adobe</strong>® <strong>AIR</strong>®.";<br />

}<br />

break;<br />

case "unavailable" :<br />

root.statusMessage.htmlText = "<strong>Adobe</strong>® <strong>AIR</strong>® is not available for your system.";<br />

root.buttonBg_mc.enabled = false;<br />

break;<br />

}<br />

}<br />

The code sets the global _air variable to the main class of the loaded air.swf file. This class includes the following<br />

public methods, which the badge.swf file accesses to call seamless install functionality:<br />

Last updated 7/8/2013<br />

238

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!