Javascript 通过ExternalInterface 来刷新

发布于 2024-07-23 04:38:13 字数 1451 浏览 1 评论 0 原文

我想知道是否有人可以查看我的代码。 我正在尝试使用以下代码将虚拟变量从 javascript 传递到 actionscript 3:

HTML:
id =“music_player”宽度=“500”高度=“375”
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">




<嵌入src =“music_player.swf”质量=“高”bgcolor =“#869ca7”
宽度=“500”高度=“375”名称=“music_player”对齐=“中间”
播放=“真”循环=“假”质量=“高”allowScriptAccess=“总是”
类型=“应用程序/x-shockwave-flash”
pluginspage="http://www.macromedia.com/go/getflashplayer">

JavaScript:
var nextTrackLocation = "dummyString";
getFlashMovie("music_player").jsAlert(nextTrackLocation);

function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];  }  

和动作脚本:
ExternalInterface.addCallback("getNextTrack", jsAlert);

function jsAlert(mess){
ExternalInterface.call("alert", mess);
}

有人看到错误吗?

I'm wondering if someone could look over my code. I'm trying to pass a dummy variable from javascript to actionscript 3 with the following code:

HTML:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="music_player" width="500" height="375"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
<param name="movie" value="music_player.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#869ca7" />
<param name="allowScriptAccess" value="always" />
<embed src="music_player.swf" quality="high" bgcolor="#869ca7"
width="500" height="375" name="music_player" align="middle"
play="true" loop="false" quality="high" allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>

Javascript:
var nextTrackLocation = "dummyString";
getFlashMovie("music_player").jsAlert(nextTrackLocation);

function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];  }  

and the actionscript:
ExternalInterface.addCallback("getNextTrack", jsAlert);

function jsAlert(mess){
ExternalInterface.call("alert", mess);
}

Does anyone see a mistake?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潦草背影 2024-07-30 04:38:14

你的问题很令人困惑。 我认为你在这里犯了两个错误。

从 Javascript 中,您尝试调用 Actionscript 中名为“jsAlert”的函数,但该函数在 Actionscript 中公开为“getNextTrack”。 我认为应该是:

getFlashMovie("music_player").getNextTrack(nextTrackLocation);

其次,在 Actionscript 中定义函数的地方,您忽略了ExternalInterface.addCallback 实际上需要三个参数。

ExternalInterface.addCallback("getNextTrack", null, jsAlert);

Your question is very confusing. I think you are making two mistakes here.

From Javascript you're trying to call a function in Actionscript called "jsAlert" but the function is in Actionscript exposed as "getNextTrack". I think it should be:

getFlashMovie("music_player").getNextTrack(nextTrackLocation);

Second, where you define the function in Actionscript you overlooked that the ExternalInterface.addCallback actually takes three parameters.

ExternalInterface.addCallback("getNextTrack", null, jsAlert);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文