Migrating LZX Code to OpenLaszlo 4.1

I was recently porting some LZX code in OpenLaszlo Training materials from 4.0.12 to 4.1, and stumbled upon a few issues, which I thought I’d post here as a reference.

Don’t use <method event=””> Syntax

The <handler name=””>syntax was introduced to replace the <method event=””> syntax some time ago. With 4.1, I found that the compiler/debugger could get confused if you continued to use the old syntax in some cases. Sometimes the error messages were not useful. In short, replace:

<method event="onevent">

… with:

<handler name="onevent">

Delegate Method Arguments

Any method you call with a delegate must now have a defined argument. This is in preparation for future compatibility with SWF9. In short, if you write:

new LzDelegate(canvas, "myMethod", ds, "ondata");

<method name="myMethod">

… you should define your method as shown below:

<method name="myMethod" args="arg">

The New “lz” Namespace

In OpenLaszlo 4.0.x, there was a global object that contained references to classes, colors and global tokens. In OpenLaszlo 4.1, there is now an lz object that replaces this for class definitions. It creates a virtual namespace. So if you need to procedurally instantiate an OpenLaszlo window, instead of writing:

new window(canvas, {width:300, height:300});

… you now write:

new lz.window(canvas, {width:300, height:300});

If you need to paramaterize the name of a class, you used to write:

var classname = "window";
new global[classname](canvas, {width:300, height:300});

… instead, now you would write:

var classname = "window";
new lz[classname](canvas, {width:300, height:300})

Those are the main issues I ran into. Otherwise code written for OpenLaszlo 4.0.12 seems to run fine on 4.1.

2 responses to “Migrating LZX Code to OpenLaszlo 4.1

  1. Robert Yeager (of http://www.qrowd.com and http://www.cooqy.com) has posted a great list of 4.0.12 – 4.1 migration tips on the OpenLaszlo forums:


    … and some of this information has been added to the Runtime Differences page on the wiki:


  2. Pingback: Recent URLs tagged Openlaszlo - Urlrecorder

Leave a Reply

Your email address will not be published. Required fields are marked *