Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1

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


In addition, the file-browsing dialog created via:


<input type="file" />

is not currently supported within the Beta.


Any dialogs not currently supported in the Beta, will be sup-
ported in the 1.0 release.


XMLHttpRequest and Ajax


TheXMLHttpRequestobject, which enables the use of Ajax
techniques for sending and loading data, is completely sup-
ported within AIR applications.


One advantage to developing Ajax applications within
Adobe AIR versus the browser, is that because you have a
consistent runtime to target across operating systems, you do
not have to worry about cross-browser, platform inconsisten-
cies in how the API is implemented.


The primary benefit of this is that you have to write only one
version of the code.


Here’s a simple example of anXMLHttpRequestobject call
within an AIR application that works regardless of which
operating system the application is running on:


<script type="text/javascript">
var xmlhttp;
function appLoad( )
{
//replace with URL to resource being loaded
var url = "http://www.mikechambers.com/blog/";
xmlhttp = new XMLHttpRequest( );
xmlhttp.open("GET", url,true);

xmlhttp.onreadystatechange=function( ){
if (xmlhttp.readyState==4)
{
runtime.trace(xmlhttp.responseText);
}
}
Free download pdf