views:

39

answers:

1

Hey all,

I'm looking to call a flash method from a method in javascript and recieve a result:

Example:

Flash -

ExternalInterface.addCallback("getProgress", getProgress) // Javascript to flash

public function getProgress():void {
   ExternalInterface.call("getProgress", progress); // Send progress back to javascript from flash

}

Javascript -

Object.prototype = {
...

getProgress : function() {
   $("#movie").getProgress();
   return progress;
}

...
}

Anyone have any idea how to hook all this up???

+1  A: 

Are you trying to pass the value of progress from flash to javascript or javascript to flash? From the wording of the question it seems that you want to call a flash method from javascript and receive a return value. But then why are you calling ExternalInterface.call from flash's getProgress method and returning progress from the javascript method?

change the flash part to:

ExternalInterface.addCallback("getProgress", getProgress)
public function getProgress():void 
{
    return progress;
}

And call

alert(window["moviename"].getProgress());    //IE

alert(document["moviename"].getProgress());  //Firefox

Checkout ExternalInterface example in livedocs.

Amarghosh
Thanks for responding. I managed to solve this problem exactly as you suggested. I didn't realize the flash function called from addCallback could return a value!
Matt