1

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.

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

Comments

1

ExternalInterface.addCallback()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.