Writing an OpenLaszlo AIR Application

A while back, I wrote about using OpenLaszlo to write Adobe AIR applications. A number of people asked me for step-by-step instructions. It’s taken me a while to get around to writing these, and I’m happy to post this finally.

The instructions below explain what to install, where I installed it, and the steps I took to create a chromeless AIR application. A chromeless AIR app is one that doesn’t have the operating system’s standard window around the embedded SWF. It’s trickier to create a chromeless app, than a windowed app. You can drag the application, and close it from within OpenLaszlo.

I use Windows XP and Cygwin, so the build script won’t work on Mac/Linux machines right away. It’s intended to serve as a guide.

Download the OpenLaszlo AIR Application Source and Installer.

OpenLaszlo Air Screenshot

Setup

  1. Download and install the Adobe AIR runtime, for your platform. You’ll need this to run your application. I used Adobe AIR Beta 3.
  2. Download and install the appropriate OpenLaszlo distribution for your platform. I used OpenLaszlo 4.0.9.1. If you’re new to OpenLaszlo, the Windows/Mac/Linux distributions include Apache Tomcat and OpenLaszlo. Install to the default directory. If you’re on Windows, you may need to download and install the Java SDK (i.e. the JDK) first (if you don’t have it already). You can get that from Sun’s website. Look for J2SE JDK 6.
  3. Download and unzip the Adobe Flex SDK. You’ll need this to act as a bridge between OpenLaszlo and the AIR runtime. I got Flex 3 SDK Beta , and extracted it to a new folder called C:\Program Files\flex3sdk_b3_121207.
  4. Download and unzip Adobe AIR SDK. I got AIR Beta 3, and extracted it to C:\Program Files\air_b3_win_sdk_121207.

Development

  1. Copy the OpenLaszlo source code/build script to (say) the my-apps directory. Check the paths set in build.sh – you may need to update them.
  2. Copy the Flex source code to the appropriate place in your Flex install directory. See the paths in build.sh as a guide.
  3. Copy the AIR source code to the appropriate place in your AIR install directory. See the paths in build.sh as a guide.
  4. To do a quick test, cd to your OpenLaszlo directory and run:
    ./build.sh -test
    That will compile your application and launch it (without installing). If all goes well, you’ll be facing your first OpenLaszlo AIR application.
  5. To build the installer, run:
    ./build.sh
    The .air installer will be build in the AIR source directory.

Installation

If you just want to test out the application, double-click the OpenLaszloAir.air file to install it.

The Snapfish Flex, er… OpenLaszlo Application

I’ve known that Snapfish have been using OpenLaszlo for some time. Their logo is displayed on Laszlo’s corporate site as an adopter, and the app is listed on the OpenLaszlo Applications page of the wiki. That’s why I was surprised to discover that Snapfish is listed on the Flex Showcase (an Adobe website). For a moment, I thought that perhaps Snapfish had replace the OpenLaszlo one with a Flex one. But no, the OpenLaszlo application is still there (you need to log in, then click “Play Slideshow” on any album, and int will launch). I couldn’t find a Flex app on the Snapfish site.

The funny thing is: the screenshot of the Snapfish application that’s on the Flex Showcase is actually of the OpenLaszlo app! You can even see the gray OpenLaszlo slider component at the top-right:

Flex Showcase Screenshot

Tell Those Pesky Script-Running-Slowly Errors Where to Go

Anyone who has done any OpenLaszlo (or Flash-related) development has inevitably come across those dreaded Script-Running-Slowly errors. They’re caused by the application taking too long to process a piece of script. e.g. An infinite (or very long) loop, creating too many views at once or a large number of chained constraints.

No more issues.

Happily, there’s now a cure. As of Flash 7 (which is the minimum supported Flash runtime in OpenLaszlo 4.0+), the criteria for triggering these errors are configurable. Hopefully this feature will make it into the OpenLaszlo platform, but for now, you can use the Windows
SWF ScriptLimits Injector (SWFSLI) program to tweak these criteria.

  1. Download the SWFSLI program from: http://www.buraks.com/swfsli/
  2. Compile your OpenLaszlo application SOLO using proxied=”false” in the canvas.
  3. Run SWFSLI against the newly-compiled SWF:
    swfsli myapp.lzx.lzr\=swf7.swf /r65535 /t300 /b

That’s it. SWFSLI will adjust the settings in your original SWF file, and make a backup copy. To deploy, you’ll need a wrapper page. Note that this won’t make your application run faster; it’ll only loosen Flash’s criteria for throwing the Script-Running-Slowly error.

I created two examples (before.swf and after.swf). Both of these run 10,000,000 iterations and then print that they’re done. On my laptop, before.swf consistenly throws the error, after.swf never does: