Search code examples
javascripthtmlactionscript-3flashair

How can I get and set the selected radio button in external HTML content through actionscript?


I am new in flash and as3.

I am using an external html file through mx:html in Flash.

<fx:Script>
...
myHTML.location = "../assets/myHTML.htm";
...
</fx:Script>

<mx:HTML id="myHTML"/>

There are 3 radio buttons in this myHTML.htm file.

Is there any way to get and set the selected radio button through actionscript?

I am developing an AIR application. And as far as I come to know that the ExternalAPI will not work. Actually I want to use multiple HTML files of quiz question with radio buttons.


Solution

  • Nobody tell me this simple code:

    In Flex/Actionscript:

    function initial():void
    {
    html.addEventListener(Event.HTML_DOM_INITIALIZE,loaded);
    }
    
    function loaded(e:Event):void
    {
    html.htmlLoader.window.getOption = getOption;
    }
    
    function setvalue():void
    {
    html.htmlLoader.window.selectradio(radioButtonID);
    }
    
    function getOption(value:String):void
    {
    trace(value);
    }
    

    in HTML file

    <SCRIPT LANGUAGE="JavaScript">
    function selectradio(selectvalue)
    {
    document.getElementById(selectvalue).checked = true;
    }
    </SCRIPT>
    
    <INPUT ID="a" TYPE="radio" NAME="op" onClick="getOption('a')"