Problem with ExternalInterface in Flash / JavaScript and WRT

199 views Asked by At

I'm doing a WRT app that uses flash inside. The thing is i have to pass parameters to the swf via javascript. So i created a function in javascript like

function returnFunction() { return "test"; }

and in my SWF i have the following code:

import flash.external.ExternalInterface;

var result:Object = ExternalInterface.call("returnFunction");
versionTxt.text = "Returned: " + String(result);

So, this works fine when i run on my local machine(had to change some security on the flash player) and when i host it on a server. But i have to run it on a mobile phone, so i wrapped it in a WRT app, but when i test it, it returns like:

Returned: null

So i'm out of options here, is it a security problem? I guess i already saw something like this running in WRT so i'm quite sure it's possible, just don't know what i'm missing here :/

1

There are 1 answers

1
JoeyRobichaud On

Maybe you could set it up so that the javascript or WRT calls back with a value into a function that you've exposed via the ExternalInterface.

Flash:

import flash.external.*; 

//Add a function call that can be accessed from javascript
ExternalInterface.addCallback("operationComplete", operationComplete);

//invoke the javascript operation
function startExternalOperation(){
  ExternalInterface.call("operation");
}

//javascript invokes this function when it is done
function operationComplete(result:Object){
  //do something with results
}

JavaScript:

function operation() {
  var result;

  //do something and populate result

  document.getElementById("swfObject").operationComplete(result);
}

Nokia Reference