Overview:  We have a page with heavy JavaScript and AJAX.  Through
various forms of magic, we generate this data set which we need to
ship off to a Flex object on the page.  That Flex object graphs the
data, and allows the user to torture it.  The result is a modified
version of the data that needs to get back out to the JavaScript. 
Someone else ("G") is developing the Flex object, and I'm doing the
JavaScript/HTML/Java Servlets.

The problem we're having is that when I call the function that G
exports from his flex, many times it's not "ready yet".  The results
are that I either get an error "Error calling method on NPObject!", or
an error saying that it doesn't have the method I called.  

Sometimes I get the first error just trying to instantiate the Flex
object.  When that happens, retrying does not help at all.  I can
retry forever, and it won't work until I reload the page and try
again.  Maybe.

So I wrote this function that waits a half a second before calling
itself recursively (using JavaScript's setTimeout() function) before
trying to instantiate the Flex object, then it goes into a loop, using
setTimeout() to sleep between retries.  The problem with doing it this
way is that asynchronous calls can't return a value, because they're
running in a different thread.

So.  Is there a way to know for sure that the Flex object is fully
loaded and ready for duty?  Can the Flex object tell me somehow?

Also, Google finds tons of people asking what "Error calling method on
NPObject!" means, but no good answers.  Can someone tell me what that
is, and if there's a way of getting a more accurate error message?

Thanks.


Reply via email to