【问题标题】:Can't Call Flash AS3 Function From JavaScript无法从 JavaScript 调用 Flash AS3 函数
【发布时间】:2014-09-21 23:57:41
【问题描述】:

我非常困惑,我花了一整天的时间来做一些应该很容易的事情。我只想从 JavaScript 调用 Flash 函数 - 就是这样。

动作脚本代码:

import flash.display.Loader;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
import flash.external.ExternalInterface;
import flash.net.FileReference;             
import flash.events.IOErrorEvent;
import flash.events.Event;
import flash.system.Security;

Security.allowDomain("*");
ExternalInterface.addCallback("test", test);

function test()
{
    ExternalInterface.call("alert", "Doesn't Work");
}

JavaScript/HTML

    <h1>Test</h1>
    <script>
        function getFlashMovie(movieName) {
            var isIE = navigator.appName.indexOf("Microsoft") != -1;
            return (isIE) ? window[movieName] : document[movieName];
        }
        function poc() {
            getFlashMovie( "Test" ).test();
        }
    </script>
    <button onclick="poc()">Click Me!</button>

这不起作用,对象'Test'不存在函数'test'

我想我会在这里问作为最后的努力。这是我的现场示例: http://itsclassified.info/flash/Test.html

【问题讨论】:

  • 使用document.getElementById("Test") 获取对对象的引用。

标签: javascript actionscript-3 flash


【解决方案1】:

这是给定页面http://itsclassified.info/flash/Test.html的一些js代码

<object type="application/x-shockwave-flash" data="Test.swf" name="POC" width="1" height="1">
                <param name="movie" value="Test.swf" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="#ffffff" />
                <param name="play" value="true" />
                <param name="loop" value="true" />
                <param name="wmode" value="window" />
                <param name="scale" value="showall" />
                <param name="menu" value="true" />
                <param name="devicefont" value="false" />
                <param name="salign" value="" />
                <param name="allowScriptAccess" value="always" />
            <!--<![endif]-->
                <a href="http://www.adobe.com/go/getflash">
                    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                </a>
            <!--[if !IE]>-->
            </object>
            <!--<![endif]-->

尝试改变

name="POC"

name="Test"

我已经在 chrome 和 IE11 中测试过,它可以工作。

【讨论】:

    猜你喜欢
    • 2015-08-22
    • 2013-03-20
    • 2013-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-26
    • 2012-01-19
    相关资源
    最近更新 更多