The id Attribute in 4.1

One subtle thing that has changed in OpenLaszlo 4.1 is that you can no longer specify the id attribute when instantiating objects from script.

When instantiating a class from script, you can specify a dictionary of initial properties as the second argument to the constructor:

var v = new lz.view(canvas, {width: 300, height: 300, bgcolor: 0xff0000}); // 4.1

Prior to OpenLaszlo 4.1, the constructor shown above would have been LzView() instead of lz.view(). Also, prior to 4.1, you could have specified the id attribute in addition to the width, height, and bgcolor attributes, and then referenced your newly-created view by that id later in the application. e.g.

var v = new LzView(canvas, {id: "myNewView", width: 300, height: 300, bgcolor: 0xff0000}); // 4.0.12

Since the SWF9 does not allow global variables to be created on-the-fly, OpenLaszlo 4.1 will no longer allow you to do this either. For better or for worse.

2 thoughts on “The id Attribute in 4.1

  1. “Since the SWF9 does not allow global variables to be created on-the-fly,” … thanks for highlighting this Antun!

    I suppose for debugging you should be able to say canvas.myNewView = v on the next line for easy access in the debugger, righ?

Leave a Reply

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