开发者

Linking flash to OOP javascript using ExternalInterface?

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

Example:

Flash -

Extern开发者_开发百科alInterface.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???


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜