Monday, March 13, 2006

OpenLaszlo talks to the browser Javascript engine

Communication between the Flash player and the browser Javascript engine is easier than I thought when using OpenLaszlo. Here's some sample code:

<canvas>
<button>
<method event="onclick">
var js = "var el = document.getElementById(\"hello\"); el.innerHTML = \"Hello World!\"";
LzBrowser.loadJS(js);
</method>
</button>
</canvas>

As usual for SOLO deployment, compile this into a swf and embed it in an html page. In the body of the html, include the tag <div id="hello"/>. Open the html page in your browser, and click the button. VoilĂ , we see the "Hello World!" text appear in the browser, below the button. This is so cool, I will now proceed to do a happy dance!

0 Comments:

Post a Comment

<< Home