Using in-memory databases in AIR

Jacob Wright
May 16th, 2008

Adobe Integrated Runtime (AIR) has support for creating and using SQLite databases through the use of the SQLConnection class in the flash.data package. Using this package you can store a database on a user's hard drive and even name it with any extension you'd like (registering your app with that extension will let you double click on your "database" file and open the app with that as a parameter, pretty slick).

One feature with the database package often overlooked is its ability to create and use in-memory databases. Using in-memory databases allows for faster read and write to the database and is perfect for operations such as building a code-completion lookup (someone going to rewrite Flex Builder in AIR? :), establishing a temporary search database of all the words in a list of documents that could be used for an autocomplete field, and any other situation where a database would be great to use but doesn't need to be kept around between application launches.

To create an in-memory database simply leave out the file parameter of the database connection.

var db:SQLConnection = new SQLConnection();
db.open(); // no file is passed in

Then you run your database setup script to create your tables and your good to go.

Why Open Source

Jacob Wright
April 3rd, 2008

I have to admit, it took me awhile to understand why anyone would want to open source their software. I understood perfectly well why I would want to use it, but as a developer who makes money from writing software I assumed you don't make money writing open source software, thus, you starve. I understand now how it works and will explain simply for both developers and business why open source software makes sense.

(more...)

Why is WordPress so easy to install, so painful to update?

Jacob Wright
March 14th, 2008

I don't think there is a better open-source blog engine on the market than WordPress, but why is it so painful to update it? You have to back up the database, download the files, copy over the config file, themes, uploads, and any other stuff you need to the new installation, and then rename the folders quickly so the new one fills the space of the old one.

Why can't we just get the files that have changed downloaded and the database updated by pressing a big blue "Update" button?

How to listen to Flash events that don’t bubble

Jacob Wright
March 3rd, 2008

I learned a little trick the other week and thought I'd share. Sometimes you might need to listen to a non-bubbling event "up the chain" somewhere, but of course, since it is not bubbling, that can be hard. The trick is that event events that don't have bubbling still have the capture phase, so if you flip that capture flag to true in the event listener then you can now listen to any events dispatched by any child views whether they are bubbling or not.

Example:

// listen for some event (this one is even custom) that does not bubble
// make sure to set true on capture
stage.addEventListener("customNonBubbling", myListener, true);

...

<mx:Button id="myButton" click="dispatchEvent(new Event('customNonBubbling'))"/>

Note: this only works on display objects as far as I know. Capture and bubbling don't apply to objects that are not on the display list.

Hacking the Flex SDK

Jacob Wright
March 3rd, 2008

The Flex SDK is finally fully open-source. So I thought I'd have a little fun and implement my own Binding classes to be used when using the [Bindable] metadata tag in an ActionScript 3 project.

The first thing I did of course was to checkout the Flex SDK from subversion. They've got instructions on doing all that in their wiki. The wiki also has some great instructions for downloading and installing ANT and the other things you'll need to build the SDK. Look further down on the previously linked to page in the section "Building and testing."

Once I had the project checked out I downloaded ANT per the Mac-specific instructions on the wiki. I the ran `source setup.sh` and then `ant -q main` just like they said and voila! I had built my own SDK. Of course, it was basically the same as the one already installed with Flex Builder.

I then started digging into the code and found in the sdk/modules/compiler/src/java/flex2/compiler/as3/binding/BindableProperty.vm template file that is used for the auto-generated binding code. I took out some of the imports, changed the [Bindable(event="propertyChange")] on line 62 to [Bindable(event="${entry.propertyName}Change")], and changed every place it had dispatchEvent(PropertyCha.... to dispatchEvent(new Event("${entry.propertyName}Change"). This will allow my binding class that just looks for {propertyName}"Change" event for binding instead of using the expensive describeType function.

Next, I compiled the whole SDK and had issues, because the Flex framework needs to use the old binding. SO DON'T DO THAT. After backtracking and fixing things up I changed to the sdk/modules/compiler/ directory and THEN ran `ant -q main`. Now my mxmlc will use the new binding template but the old framework SWCs weren't compiled wrong with it.

To check out the new generated classes compile your project using `mxmlc Main.as -keep`. That creates a folder called "generated" that has all those classes including your new bindable changes in it. Now in Flex Builder, you can add a your new SDK and compile your own projects. Haven't had time to actually test this out yet and I've gotta run, but let me know if you get it working.

AIR Project Tracker (timer, task-list)

Jacob Wright
January 12th, 2008

I wrote a project timer awhile ago. After I had done that (in Flash 8) I needed a task list that could be split up by client and project, so I combined the old time and a new task list into what I called creatively the Project Tracker. I've been using it since Apollo preview release. I just added a new feature for myself that rounds the times to the nearest half-hour or hour if desired (since that's how my company bills clients), and I thought that I'd share it. It allows you to keep track of time spent on tasks, project, and clients as well as let's you check off any of them when complete. You can also store notes about each of them.

It doesn't use any AIR specific features, just SharedObject, but I sure like to have it as a desktop application rather than in the browser. I always close browser versions on accident.

This application is provided as-is with no documentation, support, or guarantee of anything. Hope you find it useful. You can view Project Tracker in your web browser before you download it.

Update: Republished for the AIR 1.0 release and updated badge install.
Update 2: Found and fixed the problem reported in comments. Using a relative path in the badge installer for AIR apps results in some of the errors reported.



This application requires the following be installed:

  1. Adobe® AIR™ Runtime
  2. Project Tracker

Please click on each link in the order above to complete the installation process.

« Previous PageNext Page »