View Full Version : How to mix Flash and DHTML Laszlo apps
Getting started with OL4... we want to have our main app compiled in Flash but with some Laszlo DHTML Windows floating in front (so that we can use the cool new <html> version)... Provided the flash has wmode="transparent" this should work. Anyone have any ideas for communication between the two? Can the two Laszlo apps running in the same browser share canvas attributes or something like that?
Thanks
Zvi
If you compile your SWF as Flash 8 .. you can use ExternalInterface via Flash API .. to get two way communications SWF <--> DHTML (js).
Prior to ExternalInterface in Flash 8, it was a bit tricky using Javascript Integration Kit.
Of course, you can also pass FlashVars to SWF .. but I'm assuming that you do not want to reload your SWF to pass vars?
Thanks, yes we are looking to pass variable at run time. Actually we have Laszlo Flash to native DHTML communication working - my question was more whether OL4 DHTML Laszlo has some sort of API to help communication with the Flash.
I don't know if OL4 has any special callback API to communicate with Flash .. I mix DHTML from other sources, not OL4.
But since OL4 is only DHTML + JS after all (nothing new here!) you can callback to an SWF internal function using ExternalInterface callback (from JS).
__________________________________________________ __________
p.s.
Instead of ExternalInterface you can navigate the DOM from the DHTML page .. e.g.
// get our flash movie object
var myFlashMovie;
function init() {
if (document.getElementById) {
myFlashMovie = document.getElementById("alpha");
myFlashMovie2 = document.getElementById("beta"); // reference for another movie
}
}
where "alpha" and "beta" are ID's of two Flash movies .. then navigate to canvas attributes.
But unlike ExternalInterface this does not invoke a call to a function .. it only sets vars or attributes (which you might use as constraints).
The documentation seems to suggest that a Laszlo app (both DHTML and Flash) share Canvas attributes with the HTML page - is that right? Does that imply that two Laszlo apps (e.g. one DHTML and one Flash) embedded in the same page will share canvas attributes with each other?!
I'm kind of confused about this - thanks for any help
I can't answer that question .. since, for now, I'm deferring use of "mixed" OL4 + OL3.
I'm approaching this from another angle. Using OL3 + third party DHTML.
p.s.
you should read [ this recent thread (http://forum.openlaszlo.org/showthread.php?t=8835) ] with example of ExternalInterface usage.
Getting started with OL4... we want to have our main app compiled in Flash but with some Laszlo DHTML Windows floating in front (so that we can use the cool new <html> version)... Provided the flash has wmode="transparent" this should work. Anyone have any ideas for communication between the two? Can the two Laszlo apps running in the same browser share canvas attributes or something like that?
Thanks
Zvi
Hi Zvi,
I owe you and the community a blog post about the exciting new Flash/Browser Javascript communications bridge in 4.0. In the mean time, here's a rundown. To communicate from Browser Javascript to Flash, you can use Lz.callMethod() and/or Lz.get/SetCanvasAttribute(), documented here:
http://labs.openlaszlo.org/lps-4.0.0pre-nightly/docs/reference/Lz.html
To communicate from Flash to Browser Javascript, use LzBrowser.callJS():
/**
* Runs a Javascript method in the browser, optionally returning the result
*
* @param String js: Browser javascript method name to execute
* @param Function callback: Optionall callback function to get the return value of the javascript call
* @param Optional arguments to call
*/
LzBrowser.callJS = function (js, callback)
Of course, since a DHTML laszlo application is browser native, it can call Lz.* to get to Flash apps, and Browser Javascript can use canvas.xxx directly.
You can see a working example of all this at /examples/musicdhtml/ in your 4.0 download, or here:
http://labs.openlaszlo.org/lps-4.0.0pre-nightly/examples/musicdhtml/
Let me know how it goes!
Regards,
Max Carlson
OpenLaszlo.org
jsundman
03-27-2007, 09:21 AM
is here:
http://labs.openlaszlo.org/legals-nightly/docs/guide/browser-integration.html
I do expect to revise this based on your feedback.
Thanks,
jrs
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.