Flash里如何在FF与IE8下也能调用到HTML里的JS函数?

李睿_Lee 2010-08-03 11:09:25
我要实现点击Flash里的一个按钮或者链接,然后调用页面的JS函数。
网上说ExternalInterface适用性广一点,所以我用以下方法:

import flash.external.ExternalInterface;//导入 ExternalInterface 类

然后调用ExternalInterface.call("JS函数名");

可是在Maxthon里成功了,在IE8和FF下无反应。备注:我AS版本是2.0
请教解决方案。
...全文
267 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
c1421 2012-06-16
  • 打赏
  • 举报
回复
学习到了,有用,谢谢
[Quote=引用 9 楼 的回复:]

找到原因了,原来不是在同个级别的,数据调用是用this._parent.link
初次接触Flash与AS。
[/Quote]
李睿_Lee 2010-08-06
  • 打赏
  • 举报
回复
都没人回。
换个问题好了,懒得再发帖了

我要做一个动态的新闻列表,读取数据到数组里后,用下面的这这个函数生成列表,在调试过程中,发现一个奇怪的问题
mc.descTxt.htmlText = array[0][i].shortdesc+array[0][i].link;这个结果里的链接数据是正确的,所有的mc.link的值却都是数组里的最后一个值。不知道为什么。
function createNewsList(total, array)
{
var movieclip = newsList.news.newMc;
var i = 0;
while (i < total)
{
var depth = movieclip._parent.getNextHighestDepth();
movieclip.duplicateMovieClip("new"+i,depth);
var mc = eval("newsList.news.new" + i);
mc._x = -360;
mc.id = i;
var titleVar = "<b>" + array[0][i].date + " - " + array[0][i].title + "</b>";
mc.titleTxt.htmlText = titleVar;
mc.descTxt.htmlText = array[0][i].shortdesc+array[0][i].link;
var delay = 100 * i;
setTimeout(setClipPos,delay,i,mc);
if (array[0][i].link != undefined)
{
mc.link = array[0][i].link;
mc.bg.onPress = function ()
{
_root.showPop("产品介绍",mc.link);
//getURL(mc.link, "_blank");
};
mc.bg.onRollOver = function ()
{
this.up = true;
this.play();
};
mc.bg.onRollOut = mc.bg.onReleaseOutside = function ()
{
this.up = false;
this.play();
};
} // end if
++i;
} // end while
arrangeArticles(movieclip, total);
}

showPop是我写的另一个函数,用这个函数调用网页里的一个js脚本函数
CunningBoy 2010-08-06
  • 打赏
  • 举报
回复
来接分,CSDN里面开发flash的很少
李睿_Lee 2010-08-06
  • 打赏
  • 举报
回复
找到原因了,原来不是在同个级别的,数据调用是用this._parent.link
初次接触Flash与AS。
CunningBoy 2010-08-06
  • 打赏
  • 举报
回复
function createNewsList(total, array){
var movieclip = newsList.news.newMc;
var i = 0;
var mc;
var titleVar;
var delay;
while (i < total){
var depth = movieclip._parent.getNextHighestDepth();
movieclip.duplicateMovieClip("new"+i,depth);
mc = eval("newsList.news.new" + i);
mc._x = -360;
mc.id = i;
titleVar = "<b>" + array[0][i].date + " - " + array[0][i].title + "</b>";
mc.titleTxt.htmlText = titleVar;
mc.descTxt.htmlText = array[0][i].shortdesc+array[0][i].link;
delay = 100 * i;
setTimeout(setClipPos,delay,i,mc);
if (array[0][i].link != undefined){
mc.link = array[0][i].link;
mc.bg.onPress = function (){
_root.showPop("产品介绍",mc.link);
//getURL(mc.link, "_blank");
};
mc.bg.onRollOver = function (){
this.up = true;
this.play();
};
mc.bg.onRollOut = mc.bg.onReleaseOutside = function (){
this.up = false;
this.play();
};
} // end if
++i;
} // end while
arrangeArticles(movieclip, total);
}
diffmaker 2010-08-04
  • 打赏
  • 举报
回复
最近比较忙
李睿_Lee 2010-08-04
  • 打赏
  • 举报
回复
这里人气太不旺了。
散分了,都没人来。
followheartying 2010-08-04
  • 打赏
  • 举报
回复
关注一下!
李睿_Lee 2010-08-03
  • 打赏
  • 举报
回复
找到问题的所在了,原来要挂在站点下才行,看来可能是IE8和FireFox的安全性引起的。

2,278

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计/Flash/Silverlight 开发 Flash流媒体开发
社区管理员
  • Flash流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧