Paul Robertson's words, punctuated

Thoughts on development, user-centered design, code, etc. by Paul Robertson

AIR 1.5 encrypted SQLite database – how to use it, best practices, and new projects

Over a year ago I described a potential area of concern for using a SQLite database with an AIR application – because all apps use the same database engine, any AIR app can read any other app’s database (as long as it can find the database file).

As you may have heard among all the news that’s coming out from MAX right now, Adobe AIR 1.5 has just been released. Most of the features of AIR 1.5 are features that were introduced with Flash Player 10. However, one new feature in AIR 1.5 that helps address the easy-to-read database issue is AIR 1.5’s new support for AES encrypted databases.

I’ve had the interesting and at times complex job of writing the documentation for this new feature. The bulk of the new documentation is in a new section ”Using encryption with SQL databases” in the SQL database chapter of the manual “Developing Adobe AIR Applications”.

It’s pretty straightforward to use an encrypted database. You have to create the database as an encrypted db. To create or open it, you call the SQLConnection class’s open() or openAsync() methods, just as you normally do, and there’s a new parameter where you provide a 16-byte ByteArray encryption key for the database. That’s all there is to it.

The SQLConnection class also has a new reencrypt() method, that you use to change the encryption key of an already encrypted database.

If you want to see some code examples, check out the documentation listed above, or see these quick start articles on the Adobe developer center:

There are a couple of parts of the new documentation that I think are particularly interesting (although I’m obviously biased since I wrote it all):

  • Considerations for using encryption with a database talks about some of the various reasons you may want to use an encrypted database, and some of the differences in how you might architect your application to account for the desired level of security and privacy.
  • Example: Generating and using an encryption key goes into great depth into one technique for creating an encryption key for your database. You have to provide a ByteArray encryption key to encrypt your database. How you come up with that encryption key can have a big impact on the actual security of your app data.

    This was definitely the most involved example I’ve written for the documentation. the techniques it uses were specified to me by security engineers at Adobe. The documentation goes into lots of detail describing how these techniques are used and why. Both the code and the text went through a series of reviews by engineers and security experts.

    I ended up writing the example as a simple UI, plus a class that anyone can just pull into their own app (rather than having to pull apart the example and turn it into something you can use. I’m also excited to share that Mike Chambers and Christian Cantrell decided that this “encryption key generator” class is useful enough that it’s now included in the open-source ActionScript 3.0 core library (as3corelib) project.

Now that AIR 1.5 is out the door, I’ve updated my AIR database admin tool to support encrypted databases (when you try to open an encrypted database it prompts you for an encryption key, which you enter as a Base-64 string). I already mentioned that I wrote the encryption key generator class that’s now in as3corelib. I’ve also got at least one more new encrypted database-related open-source project that I’m about to release…but I’ll wait until the MAX “firehose” dies down a bit before I write more about that one. =)

Video and other updates from 360|Flex AIR SQL Optimization

I just learned today that the video from my 360|Flex presentation “AIR SQLite: An optimization conversation” has been added to the set of available 360|Flex videos. You can view the video on Ted Patrick’s blog or in the 360|Flex channel in Adobe Media Player.

Also, I learned that David Deraedt has released another AIR SQLite admin tool called “Lita” that looks promising. You can read about Lita or download Lita from David’s site.

And, for the sake of archives and history and what-not, I did go back and update my original post containing the slides and links for the presentation, with new links to the video and to information about Lita.

Flash Player 10/Flash CS4 documentation now available

(or, “why I haven’t written anything new here in a looong time”)

Like so many people, my work goes in cycles (from “busy” to “crazy” to “desperate crunch”). If you’re someone who follows this site (if in fact there is anybody who does), you may have figured out that any time I go for a long time without posting, it means I’m near the end of a project (and consequently, that new documentation is coming soon).

Well, that time has arrived. With the public announcement of Adobe Creative Suite 4, we’re doing something different in terms of the schedule for releasing documentation. This time the documentation has been released ahead of time, before the product actually ships. (Primarily for the sake of search engine indexing – but hey, let’s not complain.)

Of course, a draft version of the Flash Player 10 language reference has been around for a while now, but if you haven’t had a chance to take a look (or if you want to know how things turned out in their final form), you can now view the final Flash CS4 (including ActionScript for Flash Player 10) documentation. Also, this includes several significant additions to the content in Programming ActionScript 3.0, so if you prefer to learn by reading about a topic rather than by piecing things together from the reference, then you’ll find this content useful.

Here are a few top-level links to get you started:

Just for fun, here is the new content that I wrote:

And here are some of the other new topics that I think are the most interesting:

So, what’s next for me? (Thanks for asking!) Since finishing the final versions of the Flash CS4 documentation, I’ve been working on some “quick start” articles around the new features. Those articles will appear in the Flash developer center soon – probably when Flash CS4 actually ships. (I’ve done one on the Vector class and one on the new FileReference functionality for accessing local files without a server round trip. Other colleagues have done cool things with dynamically generating audio and Pixel Bender – so I think it’ll definitely be worth a look.) Along with that, I’m working on new features for the next version of Adobe AIR. I also have a few side projects that I’ve been trying to make progress on as I can sneak in a minute here and there.

360|Flex slides for “AIR SQLite: An optimization conversation”

Updates (Oct. 30, 2008): The video of my presentation has been posted, so I added a link to it at the bottom of this post. Also, I just learned about another AIR-based SQLite admin tool which looks interesting, so I added it to the list of resources even though it’s obviously not discussed in the presentation.

As I mentioned briefly before, this week I presented at the 360|Flex San Jose (August 2008) conference. My presentation was titled “Adobe AIR SQLite: An optimization conversation.” As I mentioned in the presentation, the term “optimization” could mean a few different things – for example, optimization meaning improving performance, or optimization meaning improving developer productivity. While my presentation focused mostly on the first type of optimization, I included suggestions for tools, libraries, and strategies that fall in the “developer productivity” type of optimization as well.

Anyway, as always I’m happy to make my presentation materials available. Here are the slides (with some notes) from my presentation:

“Adobe AIR SQLite: An optimization conversation” slides (PDF in .zip - 504kb)

I don’t really have any specific code examples, apart from what’s in the slides, so there’s no “source code” download. However, I did link to a lot of external tools and resources (including a few of my own). To save you the trouble of digging into the PDF, here are the links:

Tools

Application architecture/patterns/libraries

Finally, as you may have heard, Adobe sponsored the recording of every presentation at 360|Flex, and they’re all going to be made available free of charge via a channel in Adobe Media Player. They’re rolling them out in phases, and mine isn’t available yet. When it is, I’ll update this post with the video as well. Update: the video is now available on Ted Patrick’s blog as well as in Adobe Media Player.

In the mean time, 360|Flex was full of awesome presentations. I wasn’t able to get to all the ones I wanted to see, due to conflicts and me trying to finish up preparation for my presentation. So I’m going to be spending some time watching many of those videos as well. If you’d like to see the videos, Ted Patrick has posted instructions on his blog:

How to view 360|Flex San Jose 8/08 session videos in Adobe Media Player

Randy Pausch’s “Last Lecture”

This has been around a lot (I even saw it mentioned in my local newspaper) so it’s probably not news to anyone, but I wanted to save this link so I can find it again.

This is definitely an amazing, thought-provoking look at leading a rich and fulfilling life, from someone who knew he didn’t have long to live and yet still showed more energy and excitement for life than just about anyone:

Dr. Randy Pausch, Carnegie Mellon CS professor, Dead at 47 (TechCrunch)

The interview I don’t remember

Wow. I go on vacation and come back to find that I someone has been impersonating me. How did I discover this horrible fact? The 360 Flex folks posted an interview with me, but I sure don’t remember meeting up with them. What’s more, the alleged interview takes place in a Starbucks, and I don’t ever remember going into a Starbucks before. (At least my imposter did his homework enough to know that I don’t drink coffee.)

Okay, so I did know that they interviewed me (although in my memory it didn’t happen at Starbucks), and those are in fact my answers to their questions. (I actually wish they had reformatted them a bit. I think they are a bit tough to understand as they appear in the post but I didn’t realize the context in which the answers would be presented.) In any case it’s quite a silly read, and the other speaker interviews they’ve posted are even funnier. Poor Tom sure puts up with a lot of heckling from John.

Although I’ve never been to 360 Flex before, I’ve always wanted to go. I was fortunate enough to get chosen as a speaker – hopefully my presentation will turn out well enough that they’ll let me come back again =). And I definitely meant it when I said that there are so many presentations I’m looking forward to, that there was no way I could limit my list to just two!

Oh, and I suppose I should make two small corrections. One, I haven’t actually started working on my slides/presentation content for 360 Flex yet (oops!). Two, as of now I’m not planning to include any stick figures in my presentation. That’s not to say I never have, however =)

P.S. I know the issue of identity theft is a real one, and a very serious one. In fact a couple of weeks ago I thought I might had been a victim of identity theft (expected bills and checks were missing from my mail) and it was very disturbing. So please don’t take my joke about someone impersonating me as a sign that I don’t think identity theft is a real, serious issue!

Slides and files for “AIR, Windows, Menus, and the System Tray”

As I’ve mentioned before, a couple of weeks ago at the Webmaniacs conference I presented a session titled “Adobe AIR: Windows, Menus, and the System Tray” (and I also presented the same material in a partially different form over the course of two SilvaFUG meetings. The presentation covers those three aspects of Adobe AIR, specifically using Flex components when they’re available. The coverage is pretty thorough in the broad sense, plus it talks about many of the issues you might run into working with these aspects of AIR.

In all those presentations I promised to make my slides and code available. For those of you who attended my presentations these are a long time coming; for those who attended my session at Webmaniacs/Flexmaniacs, these are also somewhat overdue.

In any case, after deadlines, conference, and illness, here are the slides and files for my Webmaniacs session “Adobe AIR: Windows, Menus, and the System Tray” (and my two SilvaFUG presentations that were based on that session):

The .zip file contains three files and a folder:

  • Webmaniacs 2008 Slides for presentation.pdf: PDF “notes pages” printout of my presentation – each page contains one slide plus any notes that I added.
  • Exercises.pdf: Since this is a “hands-on” presentation I created this document that contains step-by-step instructions for all the exercises. Using this plus the files below you should be able to work through all the exercises for the session.
  • Code Snippets for exercises.txt: While all the code listings for the exercises are available in the PDF, a few of them are really long. In any case, if you’d rather copy and paste instead of type as you work through the exercises you can get the code from this file.
  • Exercises_workspace_start/: A Flex Builder workspace with the “starting state” of some of the exercises for the session. Most of the exercises just start from a blank screen or continue a previous exercise, but for a few I set up the UI ahead of time to save time, and those files are in this folder.

Enjoy! As always, please leave comments and feedback.

New ActionScript unit testing framework

Back in November 2005 (yes, 2.5 years ago!) I wrote an article about how data types and type checking work in ActionScript. ActionScript is different than many languages, in that the ActionScript compiler can be used for compile-time type checking (or not), and at runtime it is a strongly typed language, but it also has features of dynamically typed languages. This allows for some flexibility but also means that you have to be careful about testing your code (because the compiler won’t always catch everything).

My conclusion (not original by any means) was that unit testing is an important tool for ActionScript developers. I’ve tried a couple of ActionScript unit testing frameworks (ASUnit and FlexUnit). And finally getting to the point of this post, I was interested to learn today that the crew at Digital Primates is releasing an open source unit testing framework for Flex, known as “dpunit”.

(via Jesse Warden via Twitter)

Adobe opens door for creating alternative SWF players

Adobe just announced a new project called the Open Screen Project. There’s a lot going on with the project, so I won’t try to summarize all the different points and partners. If you read through the material, you’ll see that a lot of it talks about opening the door for improving access and presentation/experience for mobiles and other devices (the page describes it as “driving consistent rich Internet experiences across televisions, personal computers, mobile devices, and consumer electronics”).

In one sense, it’s a big bunch of companies partnering with Adobe to make it so that interactive content can be accessed on mobile phones (using Flash Player and eventually Adobe AIR, surprise, surprise). And the content isn’t supposed to be just available, but fully available, using the full capabilities of Flash Player. What? Full Flash Player running on a mobile device? Nobody’s ever complained about that, right? =)

But this isn’t just an announcement of a partnership to think about what may come someday in the future. As part of all of this, Adobe is doing some concrete things today. There are a few things that Adobe’s releasing/changing. The most notable of these to me is that Adobe’s changing the license restrictions on the SWF format (as well as FLV and to allow it to be used not only for creating authoring tools, but players as well. From the FAQ page (emphasis mine):

Publication of an unrestricted SWF file format has long been requested by the Adobe Flash developer community. The longstanding publication of the SWF specification has fostered a vibrant ecosystem of companies and developers who create experiences with Adobe Flash technology and by removing the SWF licensing restrictions we are allowing that growing ecosystem to use the file format for any purpose, including the ability to playback SWF content.

As you may know, for years Adobe (and Macromedia before them) published the SWF format specification, allowing other companies to create tools that generate SWF files. That’s why there are all those “build Flash for free online” sites and packages that hosting companies offer. That’s why Nicholas Cannasse was able to create the awesome MTASC ActionScript 2.0 compiler back when the only way to compile ActionScript was through the Flash authoring tool. Heck, even Adobe used to try to compete with Flash authoring with their LiveMotion product. (Try being the operative word. After all, Macromedia wasn’t dumb. They’d develop Flash version X and Flash Player version X simultaneously, release them both, and only then – a few months later, really – publish the SWF spec. At that point competitors could start working on a competing authoring tool. For people who were targeting a very different market that was okay, but for anyone trying to go head-to-head with Flash? No chance.)

Anyway, the license allowed all of that without any royalties or anything. However, there was a big restriction on the license – if you ever looked at the SWF spec, you could not create an alternative SWF player (i.e. a Flash Player competitor). There’s a compelling reason for this – even though the player has always been free for desktop computers and hence not a direct source of revenue, Macromedia knew that it’s greatest strength was in its “write once, run anywhere” capability. Every web designer knows how horrible it is to try and design a page to look even mostly similar in all browsers – let alone exactly the same. By restricting the creation of alternative SWF players, there is much less chance of alternative “mostly but not completely” compliant players showing up on users’ computers.

Of course, that’s in the past now. As of today the license restriction has been removed, and anyone who wants to can look at the SWF spec and, if they choose, use that knowledge to create an alternative SWF player. (Gnash team I’m looking at you!) In my opinion, for those groups this is the next best thing to Flash Player itself being open-sourced (and maybe better, since that would put them out of a project). While this does have exactly the negative potential I mentioned above, it’s a big deal for device manufacturers. If they bet their future on Flash Player, they don’t want to be stuck if Adobe goes out of business or decides to throw away Flash to focus more on their PostScript printer driver business =) It’s a risk, and I’m crossing my fingers that we don’t get splintered Flash Players all over the place. As others have said, there are some benefits that hopefully outweigh the risks. Fortunately, Flash is a pretty big brand, and Adobe’s definitely not releasing their trademarks on Flash, Flash Player, etc. So anyone who makes an alternative SWF player will not be able to call it Flash anything. (Unless Adobe decides to create a certification program for alternative players or something like that – something which I didn’t see mentioned at all in the project pages.)

For Flash/Flex/AIR developers, honestly I don’t think this project opens any doors immediately, but I think it does have a lot of promise for the future. Currently, it’s pretty hard to create Flash content for a mobile device. You basically have to create a separate version for every device. Many of the devices have Flash Player burned on the ROM, so that player can never be upgraded. If you want to target one of those devices you’re stuck on Flash 4 (tell target lives forever!) When a new version of Flash Lite is released, it takes months before it is added to devices and those devices get into stores and users’ hands.

So a lot of this is about Adobe and other companies working together to make it so that you can use the same code, targeting a player with the same capabilities, no matter whether you’re creating content for a PC or a mobile device. For example, part of the plan is to create a set of “device porting layer APIs for Adobe Flash Player.” In the words of the FAQ, these are “device-specific abstractions of Adobe Flash Player that enable it to work on different operating systems and devices.” Another notable part of the plan is to make it so that the player can be updated just like it can on a PC. Goodness knows I often wish I could update the Flash Player on my Wii!

Plus, the fact that Adobe’s no longer restricting who can create SWF players, and no longer charging royalties to device manufacturers who include Flash Player in their devices, means it will be cheaper, easier, and safer for companies to include Flash Player on their devices, meaning a larger market for content.

Anyway, I was pretty surprised by all of this, and happy for the potential future growth that this could lead to. Adobe’s once again making a big bet, and the payoff will be great for all of us if it works out.