I have to call a javacript function that returns some data(which I want) in a callback function. Now currently I am transferring back this data to flex by calling it from javascript.
But I want the flex to somehow wait for the javascript function to get data. How can I do that?
Code looks something like:
This is my flex call to javascript :
function delegateComputaionToJavascript(uncomputedData){
externalInterface.call('myJavascriptFunctionThatReturnsCallback', uncomputedData);
}
function computationCompleteHandler(computedData){
//goes ahead to process further
//like saving this data to DB in a server call
}
My javascript function that returns data:
function myJavascriptFunctionThatReturnsCallback(uncomputedData){
var SomeDataComputator= SomeDataComputator();
SomeDataComputator.computeData(uncomputedData, function (computedData){
// call the flex again from here
myFlashObject.computationCompleteHandler(computedData);
})
}
What I want is that delegateComputaionToJavascript function in flex should not only call the javascript but wait for myJavascriptFunctionThatReturnsCallback to finish execution so that I can make a server call in delegateComputaionToJavascript itself.
Cant say anything about flex since I've never worked with it closely, but in pure as3 you can get the return value from javascript as follows:
Any concrete solution will strongly depend on your existing code.