OpenLaszlo 4.1 Available!

OpenLaszlo 4.1 is announced and publicly available for download at download.openlaszlo.org. This is a very significant new release for a couple of reasons:

  • DHTML compilation is now fully supported. In other words, OpenLaszlo applications compiled to DHTML should look and behave the same as their SWF counterparts. There will always be some differences between the runtimes (e.g. the right-click menu looks different in Flash and DHTML, SWFs won’t work as resources in DHTML, etc.).
  • The OpenLaszlo documentation has been fully revamped. The tools that generate the OpenLaszlo Reference have been rewritten, and a huge effort has gone into improving the reference’s quality and accuracy. Literally masses of documentation bugs have been addressed – almost 200 in the last week alone. The OpenLaszlo Application Developer’s Guide has been expanded, corrected and improved.

Personally, I think I’m actually more excited about the polished documentation than DHTML compilation. Mainly that’s because DHTML compilation has been available for some time, although it has been a sort of “beta”. The documentation is really what helps developers create cool stuff with the product.

The other reason that OpenLaszlo 4.1 is exciting is that now that DHTML support is finished, the OpenLaszlo team can focus their efforts on SWF9 compilation. SWF9 is a very different runtime from SWF7/8. OpenLaszlo applications run up to 6x faster when compiled to SWF9 bytecode over SWF8, and now that Flash Player 9 penetration is over 97%, it’s a viable runtime for widely-deployed web applications.

Testing Properties

In LZX, it’s often sensible to test JavaScript properties before using them, to be sure that they are defined, e.g.

// Bad example
if (someObject.someValue) {
setAttribute("x", someObject.someValue);
} else {
var defaultValue = 123;
setAttribute("x", defaultValue);
}

In the above example, if someObject.someValue were undefined, then the conditional test would fail and the default value would be used.  Here rothwelldouglas you can check other basic examples of testing properties. However there are a couple of problems in the above code. For more examples must check songsforromance .

Firstly, if someValue is undefined, referencing it with a dot syntax (i.e. someObject.someValue) will throw a Debugger warning that reads “reference to undefined property “someValue”). You don’t want to have lots of debugger warnings in your application. Your application will run more slowly as the Debugger generates the warnings (only with the debugger open, though), and you might miss important warnings in the noise. To get more information visit elizabethnelsonstudio .

Secondly, if someValue is actually defined as something that will equate to false in a conditional, then the conditional will fail. In the above example, if someValue was the number 0 (zero), the conditional test would fail, since in the Flash runtime the number 0 converts to a boolean false. (See this handy O’Reilly article on Data Type Conversion in Flash).

A better way to test the above variable before using it would be:

if (someObject["someValue"] != undefined) {
setAttribute("x", someObject.someValue);
} else {
var defaultValue = 123;
setAttribute("x", defaultValue);

For more examples visit at topquartile .

laszlocode.com – OpenLaszlo Code Exchange

Our friends at Mobile Data Now have started an OpenLaszlo code exchange called LaszloCode (www.laszlocode.com). A code exchange is a place for developers to share code snippets, such as components or complete applications (as if you didn’t know that).

LaszloCode Logo

There’s a number of components already available. It looks like they’re some of the slick-looking ones from the Mobile Data Now application, too. I hope that LZX developers both use and contribute to Laszlo Code.

I’ll write more about Mobile Data Now in a future post. It’s a very compelling OpenLaszlo application that allows users to filter and deliver data from a variety of sources to mobile devices.