I want to execute ActionScript function from HTML and return value back to HTML. But function in flash require addEventListener. So I have no idea how can I return value, because main-function finishes faster then EventListener-function. Obviously event-functions have no ability to return something besides void, but maybe there are some tricks?
Share
Assuming that you don’t need to have the return value back immediately for the javascript to work, you could poll the flash until it is ready, and then read the return value.
In the flash, execute() sets a “ready” boolean to false (which can be read from javascript by isReady()) and then starts the asynchronous operation. Once it’s completed, the flash stores the return value which can be read from javascript by getReturnValue() and finally changes the ready boolean to true.
This assumes that you don’t need to call parallell execute commands. In that case you could give each execution an id, and send in that to execute(), isReady() and getReturnValue() and have the flash handle parallell requests by separating the internal asynchronous calls by id.