Javascript来通过ExternalInterface的闪光 [英] Javascript to flash via ExternalInterface

查看:115
本文介绍了Javascript来通过ExternalInterface的闪光的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,如果有人可以看看我的code。我试图从JavaScript传递一个虚拟变量来动作3具有以下code:

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:
    <对象的classid =CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000
         ID =music_playerWIDTH =500HEIGHT =375
         codeBase类=htt​​p://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab>
         < PARAM NAME =电影值=music_player.swf/>
         < PARAM NAME =质量值=高/>
         < PARAM NAME =BGCOLOR值=#869ca7/>
         < PARAM NAME =allowScriptAccess的值=总是/>
         <嵌入SRC =music_player.swf品质=高BGCOLOR =#869ca7
             WIDTH =500HEIGHT =375NAME =music_playerALIGN =中间
             玩=真正的循环=假品质=高的allowScriptAccess =总是
             TYPE =应用程序/ x-冲击波闪光
             PLUGINSPAGE =htt​​p://www.macromedia.com/go/getflashplayer>
         < /嵌入>
     < /对象>

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

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

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

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

有谁看到一个错误?

Does anyone see a mistake?

推荐答案

你提的问题是非常混乱。我想,你在这里做了两个错误。

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

从JavaScript你要调用的ActionScript函数叫做jsAlert,但该功能在Actionscript中公开为getNextTrack。我想应该是:

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

二,凡在ActionScript中定义函数,你忽略了,对ExternalInterface.addCallback实际上有三个参数。

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

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

这篇关于Javascript来通过ExternalInterface的闪光的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆