1

I have a case where I have a "drop-down box" in an HTML webpage with some JQuery calculations, looks something like this:

<select style="width: 190px;" class="calc" name="os2" id="os2" type="text">
<option value="Front" data-whatever="2">Front </option>
<option value="Front and Back" data-whatever="2.9">Front and Back </option>
</select>

What I'm trying to do is have this Flash ActionScript 3 Application (embedded on the same HTML page) grab a variable from the drop-down box. Now, using FlashVars is fine, except it doesn't account for when the selection is changed (obviously), but...

Is there a way to reload the variable into Flash real-time when the user changes the drop-down box selection?

Any light on this would be terrific, thanks a lot!

Aaron
  • 531
  • 3
  • 8
  • 22
  • ExternalInterface is the way to go. To add to Marty's answer: You'll want to expose a method from Flash to JS using `ExternalInterface.addCallback()`. In JS, you'll want to listen for changes to the combo-box item; when one is detected, call the exposed function of your Flash object to tell it what the new value is. – Cameron Feb 27 '12 at 21:49

1 Answers1

1

You can use ExternalInterface to communicate between Flash and JavaScript.

This article seems to cover exactly what you want to do:
Bi-Directional Actionscript/Javascript Communication in AS3

Bi-directional Actionscript/Javascript communication is something that has been out for a while, but some Flash designers/developers still are saying, "I didn't know you could do that."

Well you can! And with just a little bit of code.

Community
  • 1
  • 1
Marty
  • 39,033
  • 19
  • 93
  • 162