O'Reilly logo

Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime by Rich Tretola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A.11. Add History Window

The last step in this Appendix is to utilize the data stored in the SQLite database. To use the data, we will create a simple history window showing the last 10 results of the weather service for the zip code that is currently being used. We will also need to add some methods to the DataManager class to retrieve the history data. The data will be returned as a SQLResult object and then cast as an ArrayCollection and set into the DataModel's historyData property, which is bound to a DataGrid in the History.mxml Window component. Here are the steps needed to add the history window.

Add a new SQLStatement to the DataManager class.

private var selectHistorySQL:SQLStatement;

Add import statements to the DataManager class.

import flash.data.SQLResult;
import com.everythingflex.shared.model.DataModel;
import mx.collections.ArrayCollection;

Create an instance of the DataModel within the DataManager class to hold the results of the selectHistorySQL statement:

private var model:DataModel = DataModel.getInstance();

Next, add the getHistory() function to the DataManager class.

public function getHistory(zipCode:String):void{ var sqlText:String = "SELECT MAX(TEMPERATURE) AS HIGH, " + "ZIPCODE, WEATHERDATETIMESTAMP " + "FROM CALLS " + "WHERE ZIPCODE = :zipCode " + "GROUP BY WEATHERDATETIMESTAMP " + "ORDER BY ID DESC " + "LIMIT 10 "; selectHistorySQL = new SQLStatement(); selectHistorySQL.sqlConnection = conn; selectHistorySQL.addEventListener(SQLEvent.RESULT,getHistoryResult); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required