【问题标题】:How can I get and set the selected radio button in external HTML content through actionscript?如何通过 actionscript 在外部 HTML 内容中获取和设置选定的单选按钮?
【发布时间】:2013-09-22 20:19:47
【问题描述】:

我是 flash 和 as3 的新手。

我在 Flash 中通过 mx:html 使用外部 html 文件。

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

<mx:HTML id="myHTML"/>

这个 myHTML.htm 文件中有 3 个单选按钮。

有没有办法通过actionscript获取和设置选中的单选按钮?

我正在开发一个 AIR 应用程序。据我所知,ExternalAPI 不起作用。实际上我想使用多个带有单选按钮的测验问题的 HTML 文件。

【问题讨论】:

    标签: javascript html actionscript-3 flash air


    【解决方案1】:

    由于缺乏 MXML 经验及其应用,有些犹豫要不要回答,我会研究 AS3 的 ExternalInterface http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html 及其在 Flex 中的使用 http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_4.html

    【讨论】:

    • 其实我正在开发一个 AIR 应用程序。据我所知,ExternalAPI 不起作用。实际上我想使用带有单选按钮的测验问题的多个 HTML 文件。
    【解决方案2】:

    没有人告诉我这个简单的代码:

    在 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);
    }
    

    在 HTML 文件中

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

    【讨论】:

      猜你喜欢
      • 2011-11-13
      • 1970-01-01
      • 1970-01-01
      • 2014-04-16
      • 2011-07-28
      • 1970-01-01
      • 1970-01-01
      • 2015-01-28
      • 1970-01-01
      相关资源
      最近更新 更多