开发者

Call an ActionScript function from Javascript

I want to call an Action Script function from javascript. But also I need the ActionScript function to return a value to the javascript call.

This is what I want to accomplish开发者_运维百科.

 /* JS CODE */

 var str = getStringFromFlash();
 alert(str);

getStringFromFlash should be a function defined in ActionScript that can return a value.


On the Flash side:

ExternalInterface.addCallback("getValue", getValue);

Where getValue() is the function that returns the string.

Then on the JavaScript side:

var flashObject = document.getElementById("myFlashObject");
var str = flashObject.getValue();
alert(str);

See API documentation for the ExternalInterface class for a more complete example.


ExternalInterface.addCallback()

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜