So I'm running into the problem where you cannot make recursive FAB>JS>FAB
calls, an exception is thrown by the FAB. Here's an example:
[ActionScript code]
public function myFirstMethod(myCallback:Function)
{
doSomething();
myCallback();
}
public function mySecondMethod()
{
doSomethingElse();
}
[Javascript code]
function start()
{
myFabObject.myFirstMethod(myOtherJavascriptFunction);
}
function myOtherJavascriptFunction()
{
myFabObject.mySecondMethod(); // this line fails
}
The only workaround I've found for this is to queue the javascript callback up
on another thread (or whatever Flash has) with setTimeout, like so:
public function myFirstMethod(myCallback:Function)
{
doSomething();
flash.utils.setTimeout(myCallback, 1, myArgs);
}
This allows myFirstMethod to complete without directly calling back into
javascript, so it breaks the chain of recursion. But it's obviously ugly &
kludgey, so I was hoping someone out there had a better solution. Any ideas?