{"id":80,"date":"2008-07-02T17:24:12","date_gmt":"2008-07-03T01:24:12","guid":{"rendered":"http:\/\/www.antunkarlovac.com\/blog\/?p=80"},"modified":"2021-04-29T04:46:22","modified_gmt":"2021-04-29T12:46:22","slug":"migrating-lzx-code-to-openlaszlo-41","status":"publish","type":"post","link":"https:\/\/www.antunkarlovac.com\/blog\/2008\/07\/02\/migrating-lzx-code-to-openlaszlo-41\/","title":{"rendered":"Migrating LZX Code to OpenLaszlo 4.1"},"content":{"rendered":"<p>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&#8217;d post here as a reference.<\/p>\n<p><strong>Don&#8217;t use &lt;method event=&#8221;&#8221;&gt; Syntax<\/strong><\/p>\n<p>The &lt;handler name=&#8221;&#8221;&gt;syntax was introduced to replace the &lt;method event=&#8221;&#8221;&gt; 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:<br \/>\n<code><br \/>\n&lt;method event=\"onevent\"&gt;<br \/>\n...<br \/>\n&lt;\/method&gt;<\/code><\/p>\n<p>&#8230; with:<br \/>\n<code><br \/>\n&lt;handler name=\"onevent\"&gt;<br \/>\n...<br \/>\n&lt;\/handler&gt;<\/code><\/p>\n<p><strong>Delegate Method Arguments<\/strong><\/p>\n<p>Any method you call with a delegate must now have a defined argument. This is in preparation for future compatibility with SWF9. Check these out <a href=\"http:\/\/colabioclipanama2019.com\">colabioclipanama2019<\/a>. In short, if you write:<br \/>\n<code><br \/>\n&lt;script&gt;<br \/>\nnew LzDelegate(canvas, \"myMethod\", ds, \"ondata\");<br \/>\n&lt;\/script&gt;<\/code><\/p>\n<p><code>&lt;method name=\"myMethod\"&gt;<br \/>\n...<br \/>\n&lt;\/method&gt;<\/code><\/p>\n<p>&#8230; you should define your method as shown below:<\/p>\n<p><code>&lt;method name=\"myMethod\" args=\"arg\"&gt;<br \/>\n...<br \/>\n&lt;\/method&gt;<\/code><\/p>\n<p><strong>The New &#8220;lz&#8221; Namespace<\/strong><\/p>\n<p>In OpenLaszlo 4.0.x, there was a <strong>global<\/strong> object that contained references to classes, colors and global tokens. In OpenLaszlo 4.1, there is now an <strong>lz<\/strong> object that replaces this for class definitions. Here\u2019s\u00a0<span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;salbreux-pesage&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:268476,&quot;5&quot;:{&quot;1&quot;:[{&quot;1&quot;:2,&quot;2&quot;:0,&quot;5&quot;:{&quot;1&quot;:2,&quot;2&quot;:0}},{&quot;1&quot;:0,&quot;2&quot;:0,&quot;3&quot;:3},{&quot;1&quot;:1,&quot;2&quot;:0,&quot;4&quot;:1}]},&quot;6&quot;:{&quot;1&quot;:[{&quot;1&quot;:2,&quot;2&quot;:0,&quot;5&quot;:{&quot;1&quot;:2,&quot;2&quot;:0}},{&quot;1&quot;:0,&quot;2&quot;:0,&quot;3&quot;:3},{&quot;1&quot;:1,&quot;2&quot;:0,&quot;4&quot;:1}]},&quot;7&quot;:{&quot;1&quot;:[{&quot;1&quot;:2,&quot;2&quot;:0,&quot;5&quot;:{&quot;1&quot;:2,&quot;2&quot;:0}},{&quot;1&quot;:0,&quot;2&quot;:0,&quot;3&quot;:3},{&quot;1&quot;:1,&quot;2&quot;:0,&quot;4&quot;:1}]},&quot;8&quot;:{&quot;1&quot;:[{&quot;1&quot;:2,&quot;2&quot;:0,&quot;5&quot;:{&quot;1&quot;:2,&quot;2&quot;:0}},{&quot;1&quot;:0,&quot;2&quot;:0,&quot;3&quot;:3},{&quot;1&quot;:1,&quot;2&quot;:0,&quot;4&quot;:1}]},&quot;10&quot;:2,&quot;14&quot;:{&quot;1&quot;:2,&quot;2&quot;:3700253},&quot;15&quot;:&quot;Arial&quot;,&quot;21&quot;:1}\" data-sheets-hyperlink=\"http:\/\/salbreux-pesage.com\/\" data-sheets-hyperlinkruns=\"[null,0,&quot;http:\/\/salbreux-pesage.com\/&quot;]\"><a class=\"in-cell-link\" href=\"http:\/\/salbreux-pesage.com\/\" target=\"_blank\">salbreux-pesage<\/a><\/span> an example for you to better understanding.It creates a virtual namespace. So if you need to procedurally instantiate an OpenLaszlo window, instead of writing:<\/p>\n<p><code>new window(canvas, {width:300, height:300});<\/code><\/p>\n<p>&#8230; you now write:<\/p>\n<p><code>new lz.window(canvas, {width:300, height:300});<\/code><\/p>\n<p>If you need to paramaterize the name of a class, you used to write:<\/p>\n<p><code>var classname = \"window\";<br \/>\nnew global[classname](canvas, {width:300, height:300});<\/code><\/p>\n<p>&#8230; instead, now you would write:<\/p>\n<p><code>var classname = \"window\";<br \/>\nnew lz[classname](canvas, {width:300, height:300})<\/code>;<\/p>\n<p>Those are the main issues I ran into. Otherwise code written for OpenLaszlo 4.0.12 seems to run fine on 4.1.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>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&#8217;d post here as a reference. Don&#8217;t use &lt;method event=&#8221;&#8221;&gt; Syntax The &lt;handler name=&#8221;&#8221;&gt;syntax was introduced to replace the &lt;method event=&#8221;&#8221;&gt; syntax some time ago. With 4.1, I found that the &hellip; <a href=\"https:\/\/www.antunkarlovac.com\/blog\/2008\/07\/02\/migrating-lzx-code-to-openlaszlo-41\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Migrating LZX Code to OpenLaszlo 4.1<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/80"}],"collection":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/comments?post=80"}],"version-history":[{"count":3,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":402,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/80\/revisions\/402"}],"wp:attachment":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/categories?post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/tags?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}