[Laszlo-dev] suggested improvement for loadJS in SWF9 runtime
Max Carlson
max at openlaszlo.org
Tue Nov 10 02:39:43 PST 2009
Yes, sorry the comment at
http://svn.openlaszlo.org/openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/DojoExternalInterface.as
should mention that it's a wrapper for swf9 and higher.
Raju Bitter wrote:
> It calls DojoExternalInterface.call.apply(), which is a file from Dojo.
> Based on the comment in that file it's a wrapper around Flash8
> ExternalInterface, but I guess the comment is not up to date. Max?
>
> http://svn.openlaszlo.org/openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzBrowserKernel.lzs
>
>> /**
>> * Runs a Javascript method in the browser, returning the result
>> * @keywords flashspecific
>> */
>> static function callJS (...args) :* {
>> var js:String = args[0];// String js: Browser javascript to execute
>> var callback:* = args[1];
>> //DojoExternalInterface.call.apply(null, args);
>> if (LzBrowserKernel.jsready != true) {
>> LzBrowserKernel.__jslocked = true;
>> }
>> if (LzBrowserKernel.__jslocked == true) {
>> if (callback != false) {
>> var o:Array = [];
>> for (var i:int = 0; i < args.length; i++) {
>> o[i] = args[i];
>> }
>> LzBrowserKernel.__jscallq.push(o);
>> //Debug.write('queued', LzBrowserKernel.__jscallq.length, o);
>> }
>> return null;
>> }
>>
>> LzBrowserKernel.__jscallback = callback;
>>
>> args[1] = LzBrowserKernel.callJSReturn;
>>
>> //LzBrowserKernel.__jslocked = true;
>> //Debug.write('calling with args real', args);
>> DojoExternalInterface.call.apply(null, args);
>>
>> if (callback == false) {
>> LzBrowserKernel._dequeueJS();
>> }
>> return null;
>> }
>
> http://svn.openlaszlo.org/openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/DojoExternalInterface.as
>
>> function call(...args) :void {
>> var methodName:String = args[0];
>> var resultsCallback:Function = args[1];
>>
>> var parameters:Array = [];
>> for(var i:int = 0; i < args.length; i++){
>> if(i != 1){ // skip the callback
>> parameters.push(args[i]);
>> }
>> }
>>
>> // we might have any number of optional arguments, so we have to
>> // pass them in dynamically; strip out the results callback
>> //Debug.write('Calling', parameters);
>> var results:* = ExternalInterface.call.apply(null, parameters);
>>
>> // immediately give the results back, since ExternalInterface is
>> // synchronous
>> if(resultsCallback != null && typeof resultsCallback !=
>> "undefined"){
>> resultsCallback.call(null, results);
>> }
>> }
>
>
>
> On Nov 10, 2009, at 4:39 AM, Henry Minsky wrote:
>
>> Did you try the callJS method? I believe it uses the ExternalInterface
>> calls.
>>
>> On Mon, Nov 9, 2009 at 10:12 PM, Chris Kohlhardt <chrisk at gliffy.com>
>> wrote:
>> Hey there. It's been a while. :)
>>
>> We're migrating our massive laszlo application to SWF9. We do several
>> javascript calls in our app, and I was having issues calling
>> lz.Browser.loadJS() several times in a row. Basically, not all the
>> calls were making it through to the browser's javascript.
>>
>> Anyway, after much trial and error, I discovered that as3 has
>> ExternalInterface.call() for this purpose, and sure enough, using this
>> native call directly works.
>>
>> So.... not sure if this is the right place to suggest this, but you
>> might consider updating loadJS() in kernel/swf9/LzBrowserKernel.lzs
>> with ExternalInterface.call().
>>
>> -chris
>>
>>
>>
>> --
>> Henry Minsky
>> Software Architect
>> hminsky at laszlosystems.com
>>
>>
>
--
Regards,
Max Carlson
OpenLaszlo.org
More information about the Laszlo-dev
mailing list