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">
...
</method>

… with:
<handler name="onevent">
...
</handler>

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:
<script>
new LzDelegate(canvas, "myMethod", ds, "ondata");
</script>

<method name="myMethod">
...
</method>

… you should define your method as shown below:

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

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: