Simple HTML Based Apollo Example

Most of the docs and examples for the Apollo alpha are Flex / ActionScript focused (next beta will be more focused on HTML / JavaScript). However, you can build Apollo applications using just HTML and JavaScript.

Here is a simple example that shows how to build an HTML / JavaScript Apollo application, and how to access Apollo APIs from JavaScript. The application shows how to launch a file browser from the application, and access information about the selected file (you could then easily read in the contents of the file).


Note, that we are working on making it a little easier to access the Apollo apis from JavaScript.application.xml[code]HTMLFileExampleMike Chambersfileexample.html[/code]fileexample.html[code]
[/code]fileexample.js[code]var apollo = window.runtime;//called when page has loadedfunction onLoad(){//set initial size of app windowwindow.resizeTo(400,300);}//called when button is pressed to select a filefunction onFileClick(){//this will trace out the string to the command lineapollo.trace(“hello”);//get a reference to the desktopvar f = apollo.flash.filesystem.File.desktopDirectory;//listen for the select eventf.addEventListener(apollo.flash.events.Event.SELECT, onFileSelect);//open the browse dialogf.browse();}//called when user selects a filefunction onFileSelect(e){//print the path of the selected fileoutput.value = e.target.url;}[/code]You can test this by using ADL (included in the Apollo SDK) from the command line like so:[code]adl application.xml[/code]You can download the code from here.Post any questions in the comments.