I have made a bit more progress with the text editor. I have a browse button in the application to open an existing text file for editing. I have the dialog open up, and limit the user to only open *.txt documents, then have the application open a file stream and read its contents. For binary data, this is done using
var stream = new air.FileStream();
stream.open( file, air.FileMode.READ );
stream.readBytes( header, 0, 0 );
stream.close();
However I need to read flat ASCII files, not binary files, and this is handled differently in javascript and AIR. I am still searching for a good reference book that outlines the AIRAliases script as well as the AIR document object model (DOM).
Monday, March 24, 2008
Sunday, March 16, 2008
Save File As Prompt
I have a basic model working that allows me to write to a and save the file to the document with a specified name "note.txt" (using the AIR air.File.desktopDirectory.resolvePath()).
This functionality is a start, but it is too limited. I want to be able to save a file to a user-specified location, using a user specified name. I am still in search of a good reference for some built-in AIR DOM and methods.
I have come a cross the method browseForOpen(), which I can use later to open an existing note. Unfortunately, my guess of browseForSave() to save a file is not working...
I will continue searching for a more thorough AIR reference online.
This functionality is a start, but it is too limited. I want to be able to save a file to a user-specified location, using a user specified name. I am still in search of a good reference for some built-in AIR DOM and methods.
I have come a cross the method browseForOpen(), which I can use later to open an existing note. Unfortunately, my guess of browseForSave() to save a file is not working...
I will continue searching for a more thorough AIR reference online.
Monday, March 10, 2008
Working with the File System
After completing my image resizing and database applications, I am working on creating a simple AIR application that manipulates/creates a file on the local machine. The application will allow a user to browse for an existing file, make edits to the file, and save it to specified directory (essentially a simplified text editor, similar to notepad). I have begun work on the application, with the basic GUI set up and the basic logic working, but I will need to figure out what AIR file methods are available to both read and write from files/filestreams, as well as how to allow the user to browse his system's file system.
I may end up building on this application to use the AIR default menus.
I may end up building on this application to use the AIR default menus.
Thursday, March 6, 2008
SQLite + AJAX
After playing with the AIR SQLite Admin (mentioned in the previous post), I created a simple database using the following SQL:
I also downloaded this large collection of samples for AIR 3 Beta
I began playing with the CRUD example, which is a simplified version of what I wanted to complete for my project. In the example, a simpler database is used, using only two columns (id and name). I wanted to make my own contact management system, so after about an hour's work, I had a fully working example, using four fields (id, first name, last name, and email). This project helped me better learn how to connect to the SQLite DB from AIR, as well as furthered my understanding of basic AJAX, particularly how to use the javascript methods createElement, and appendChild. The adaptation of the CRUD example provided proved to be a bit more difficult, as it was a bit oversimplified, and adding database columns requires a great deal of modification to the example. Below is a screen shot of my project using the more robust database.

After completing the SQLite/AJAX example, I went on to work on the image scaler. Originally, the scaler used a fixed scale ration (25%). I modified the example to use user input to scale the image appropriately, as well as return a success message on completion. The application appears as the following:

For my next project, I hope to use a Map API such as GoogleMaps or Yahoo Maps Beta
I also will be sure to post more blog updates as I do these projects- I have a tendency to play with AIR for 20 minutes at a time, and not post what I have learned until I have completed the projects. Instead, I will keep my blog up to date as to my progress.
CREATE TABLE contact (
id INTEGER primary key autoincrement,
fname TEXT,
lname TEXT,
email TEXT
);
I also downloaded this large collection of samples for AIR 3 Beta
I began playing with the CRUD example, which is a simplified version of what I wanted to complete for my project. In the example, a simpler database is used, using only two columns (id and name). I wanted to make my own contact management system, so after about an hour's work, I had a fully working example, using four fields (id, first name, last name, and email). This project helped me better learn how to connect to the SQLite DB from AIR, as well as furthered my understanding of basic AJAX, particularly how to use the javascript methods createElement, and appendChild. The adaptation of the CRUD example provided proved to be a bit more difficult, as it was a bit oversimplified, and adding database columns requires a great deal of modification to the example. Below is a screen shot of my project using the more robust database.

After completing the SQLite/AJAX example, I went on to work on the image scaler. Originally, the scaler used a fixed scale ration (25%). I modified the example to use user input to scale the image appropriately, as well as return a success message on completion. The application appears as the following:

For my next project, I hope to use a Map API such as GoogleMaps or Yahoo Maps Beta
I also will be sure to post more blog updates as I do these projects- I have a tendency to play with AIR for 20 minutes at a time, and not post what I have learned until I have completed the projects. Instead, I will keep my blog up to date as to my progress.
Sunday, February 24, 2008
Nifty Air Functions
So after reading through the AIR Ajax Tutorial, I decided to play around a bit with AIR and its asynchronis abilities. I created a small application that simply tells the user the status of the network connection by checking an RSS feed from macromedia's site. Below are two screen shots of the small application (note the highlighted sections):
And when the network connection is disabled....
I've also started to play with SQLite and AIR. After some struggle to determine how to execute queries from AIR, and looking at this tutorial, I ended up looking elsewhere for a simple way to manipulate data in the SQLite database. I found an Air-based SQLite Admin Application and have been familiarizing myself with SQLite syntax, which is not too different from any other SQL langauge. I plan on writing my next small application to modify and update data in a local SQLite database. Thus far I have a small table created called 'Contacts,' and I plan on using this table for my test application.
Until then, I will continue poking around different AIR tutorials and web blogs to see what other things are possible.
And when the network connection is disabled....I've also started to play with SQLite and AIR. After some struggle to determine how to execute queries from AIR, and looking at this tutorial, I ended up looking elsewhere for a simple way to manipulate data in the SQLite database. I found an Air-based SQLite Admin Application and have been familiarizing myself with SQLite syntax, which is not too different from any other SQL langauge. I plan on writing my next small application to modify and update data in a local SQLite database. Thus far I have a small table created called 'Contacts,' and I plan on using this table for my test application.
Until then, I will continue poking around different AIR tutorials and web blogs to see what other things are possible.
Thursday, February 21, 2008
On my Way
I've begun the tutorial Introducing Adobe AIR for Ajax developers to look into how to incorporate AJAX and dynamic content into Adobe Air.
I've also begun poking through the code of the Credit Union Management Game and looked into the logic. The code is a little archaic, very much unlike traditional languages I am used to, but I think that I should be able to figure out some of the logic by simply poking around and looking up GWBasic syntax. Thankfully, the code is well commented, so that may make things a bit easier.
I hope to finish the AJAX tutorial this weekend and include some screen shots.
I've also begun poking through the code of the Credit Union Management Game and looked into the logic. The code is a little archaic, very much unlike traditional languages I am used to, but I think that I should be able to figure out some of the logic by simply poking around and looking up GWBasic syntax. Thankfully, the code is well commented, so that may make things a bit easier.
I hope to finish the AJAX tutorial this weekend and include some screen shots.
Wednesday, February 6, 2008
Development Begins
After reading the first chapter of the O'Reilly Adobe Integrated Runtime (AIR) for Javascript Developers, I have a greater understanding of the advantages of using AIR for application development, particularly as opposed to using a standard internet browser. While the book goes into detail the specific advantages over traditional browser-based web applications, the main advantages are outlined below:
This appears to be a problem with the XML descriptor file. I changed the runtime version from "http://ns.adobe.com/air/application/1.0.M4" to "http://ns.adobe.com/air/application/1.0.M6".
This solved the first problem, but then the ADL began to complain about other tags in the XML file, which led me to believe that the XML notation must have changed with the newest version of Air. I found this tutorial, and began basing my XML descriptor file on the given example.
After correcting the XML, the ADL stopped generating errors. The application would run, but for some reason the GUI would not load, and the application would simply hang with the following prompt "init function called" is a return statement from the HTML file, so we know that the application is running, but for whatever reason, the AIR GUI is not loading.

Unfortunately, the AIR/AJAX tutorial does not go into detail in how to utilize the ADL and ADT binaries to test/build the application.
After some tweaking and trouble shooting, I realized why my GUI for my application was not coming up... it helps to set the visibility of the application to true in the XML descriptor file.
<visible>true </visible>
And Voila:

I have successfully created my first HTML AIR application, with only a few bumps and dents along the way!
- AIR was specifically designed for applications, unlike browsers, originally designed to serve simple HTML pages
- Better control flow of applications. (ie no Back Button that can cause state loss, or control flow exceptions)
- Integration with the Desktop, including greater interaction between web applications and desktop applications
- The ability to utilize the application when an internet connection is unavailable
- No need for platform-specific code, particularly with Javascript, AJAX, and CSS
- No need for application developers to have to learn new languages
This appears to be a problem with the XML descriptor file. I changed the runtime version from "http://ns.adobe.com/air/application/1.0.M4" to "http://ns.adobe.com/air/application/1.0.M6".This solved the first problem, but then the ADL began to complain about other tags in the XML file, which led me to believe that the XML notation must have changed with the newest version of Air. I found this tutorial, and began basing my XML descriptor file on the given example.
After correcting the XML, the ADL stopped generating errors. The application would run, but for some reason the GUI would not load, and the application would simply hang with the following prompt "init function called" is a return statement from the HTML file, so we know that the application is running, but for whatever reason, the AIR GUI is not loading.

Unfortunately, the AIR/AJAX tutorial does not go into detail in how to utilize the ADL and ADT binaries to test/build the application.
After some tweaking and trouble shooting, I realized why my GUI for my application was not coming up... it helps to set the visibility of the application to true in the XML descriptor file.
<visible>true </visible>
And Voila:

I have successfully created my first HTML AIR application, with only a few bumps and dents along the way!
Subscribe to:
Posts (Atom)
