0

I have an HTML button that I need to dynamically assign to an AS3 variable when clicked (in order to load an .mp3). I am using externalInterface.call to collect javascript variables - I am just unsure how to change these dynamically when a button is clicked.

Can anybody help me learn with some sample code?

Thanks!

2 Answers 2

2

You can use ExternalInterface.addCallback to add a method to your *.swf that can be called from javascript code.

ExternalInterface.addCallback("testMethod", function(message:String) { trace(message) });

And in javascript:

document.getElementById('swf').testMethod('Hello!');
Sign up to request clarification or add additional context in comments.

Comments

0

ExternalInterface is one way, and @Andrey M has already provided some good tips on this approach.

However, if you're just passing values from HTML -> AS, consider using FlashVars, which are a more appropriate approach.

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.