我想知道是否有人可以查看我的代码。 我正在尝试使用以下代码将虚拟变量从 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?
发布评论
评论(1)
你的问题很令人困惑。 我认为你在这里犯了两个错误。
从 Javascript 中,您尝试调用 Actionscript 中名为“jsAlert”的函数,但该函数在 Actionscript 中公开为“getNextTrack”。 我认为应该是:
其次,在 Actionscript 中定义函数的地方,您忽略了ExternalInterface.addCallback 实际上需要三个参数。
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:
Second, where you define the function in Actionscript you overlooked that the ExternalInterface.addCallback actually takes three parameters.