Cover | Table of Contents
Internet applications are all about reach. The promise of the web is one of content and applications anywhere, regardless of the platform or device. Rich clients must embrace and support all popular desktop operating systems, as well as the broadest range of emerging device platforms such as smart phones, PDAs, set-top boxes, game consoles, and Internet appliances.
Internet applications are all about reach. The promise of the web is one of content and applications anywhere, regardless of the platform or device. Rich clients must embrace and support all popular desktop operating systems, as well as the broadest range of emerging device platforms such as smart phones, PDAs, set-top boxes, game consoles, and Internet appliances.
<User>/Applications directory (where <User> is your system user account name).ADL | This is used to launch and test an AIR application without having to first install it. |
ADT | This is used to package an AIR application for distribution. |
;<SDK_Path>/bin
adt<?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://ns.adobe.com/air/application/1.0.M4" appId="com.oreilly.AIRHelloWorld" version="1.0"> <name>AIRHelloWorld</name> <title>AIRHelloWorld Installer</title> <description>Simple Hello World Example using HTML</description> <copyright></copyright> <rootContent systemChrome="standard" transparent="false" visible="true"> ApolloHelloWorld.html</rootContent> </application>
adl AIRHelloWorld.xml
rootContent value.AIRHelloWorld.html and AIRHelloWorld.xml files are in the same directory. adl –package AIRFILENAME FILESTOINCLUDE
adt -package AIRHelloWorld.air AIRHelloWorld.xml
AIRHelloWorld.html
window.runtime property. This will be discussed in more detail later. myWindow = window.open("Window.html", "myWindow",
"height=400,width=400");
window.runtime = window.opener.runtime;
Dialog | Supported in Beta |
|---|---|
alert | yes |
confirm | yes |
prompt | no |
window.runtime property. The runtime property is at the root of the runtime environment, and all APIs are relative to this root.trace() you reference it directly from the runtime property, like so: window.runtime.trace("foo");
totalMemory Flash Player property that is in the flash.system.System class. To call this API from JavaScript:var mem = window.runtime.flash.system.System.totalMemory;
NativeWindow instance that represents the main application window is not directly accessible from inside the main HTML DOM. Using AIR APIs, an application can traverse outside of the HTML control, out to the Stage, and get a reference to its NativeWindow instance. Once a reference to the native window has been obtained, the appropriate methods can be called to trigger the operating-system specific event (or vice versa). In the case of being able to minimize the window, the application can use NativeWindow.minimize() and NativeWindow.close() in the case of closing:window.htmlControl.stage.window.minimize( ); window.htmlControl.stage.window.close( );
NativeWindow.close() event does not necessarily terminate the application. If only one application window is available, the application will terminate. If there are multiple windows, they will close until only one window remains. Closing the last window terminates the application.<?xml version="1.0" encoding="utf-8" ?> <application xmlns="http://ns.adobe.com/air/application/1.0.M4" appId="com.adobe.demo.html.CustomChrome" version="1.0 Beta"> <name>Custom Chrome</name> <title>Custom Chrome</title> <rootContent visible="true" transparent="true" systemChrome="none" width="206" height="206"> custom.html </rootContent> </application>
NativeWindow instance that represents the main application window is not directly accessible from inside the main HTML DOM. Using AIR APIs, an application can traverse outside of the HTML control, out to the Stage, and get a reference to its NativeWindow instance. Once a reference to the native window has been obtained, the appropriate methods can be called to trigger the operating-system specific event (or vice versa). In the case of being able to minimize the window, the application can use NativeWindow.minimize() and NativeWindow.close() in the case of closing:window.htmlControl.stage.window.minimize( ); window.htmlControl.stage.window.close( );
NativeWindow.close() event does not necessarily terminate the application. If only one application window is available, the application will terminate. If there are multiple windows, they will close until only one window remains. Closing the last window terminates the application.<?xml version="1.0" encoding="utf-8" ?> <application xmlns="http://ns.adobe.com/air/application/1.0.M4" appId="com.adobe.demo.html.CustomChrome" version="1.0 Beta"> <name>Custom Chrome</name> <title>Custom Chrome</title> <rootContent visible="true" transparent="true" systemChrome="none" width="206" height="206"> custom.html </rootContent> </application>
<html>
<head>
<title>Custom Window Controls</title>
<style>
body {
background-image: url( 'custom-chrome.gif' );
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
}
#closer {
position: absolute;
width: 70px;
left: 68px;
top: 105px;
}
#minimize {
position: absolute;
width: 70px;
left: 68px;
top: 75px;
}
textarea {
position: absolute;
left: 8px;
right: 8px;
bottom: 8px;
top: 36px;
border-color: #B3B3B3;
}
#title {
position: absolute;
font-weight: bold;
color: #FFFFFF;
}
</style>
<script type="text/javascript" src="AIRAliases.js"></
script>
<script>
function doClose( )
{
window.htmlControl.stage.window.close( );
}
function doLoad( )
{
document.getElementById( "minimize" ).
addEventListener( "click", doMinimize );
document.getElementById( "closer" ).addEventListener(
"click", doClose );
}
function doMinimize( )
{
window.htmlControl.stage.window.minimize( );
}
</script>
</head>
<body onload="doLoad( )">
<input id="minimize" type="button" value="Minimize" />
<input id="closer" type="button" value="Close" />
</body>
</html>
window.open() method.window.open() method invokes a new window similar to the way it would when used in the browser. Content that gets loaded into the new window can come from a local file, or URL endpoint. Similar to windows created using JavaScript in the browser, there is finite control over the window itself. The window properties that can be controlled are width, height, scrollbars, and resizable.var login = window.open( "login.html", "login", "width = 300, height = 200" );
window.opener property that is commonly used in JavaScript to refer from a new window to the parent (creating) window can also be used. <html>
<head>
<title>Basic Window</title>
<script type="text/javascript" src="AIRAliases.js">
</script>
<script>
function doLoad( )
{
document.getElementById( "btnLogin" ).
addEventListener( "click", doLogin );
}
function doLogin( )
{
var login = window.open( "Login.html", null,
"width = 270, height = 150" );
}
</script>
</head>
<body onload="doLoad( )">
<input id="btnLogin" type="button" value="Login" />
</body>
</html>
Login.html
<html>
<head>
<title>Login</title>
</head>
<body>
<table>
<tr>
<td>Email:</td>
<td><input name="email" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="password" /></td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="button" value="Sign In" />
</td>
</tr>
</table>
</body>
</html>
File and FileStream classes that are part of AIR.File class. The File class also contains static properties that point to common locations on the operating system. These locations include the desktop directory, user directory and documents directory:var file = air.File.applicationStorageDirectory.resolve( "myFile.txt" );
File.resolve() creates a reference to a file named myFile.txt located in the application storage directory. Once a reference has been established, it can be used in file IO operations. Note that this doesn't actually create the file at this point.FileStream class. The FileStream class does not take any arguments in its constructor:var stream = ne