织梦视频教程:求救~~~在Flash中如何实现设为首页和加入收藏夹?

来源:百度文库 编辑:中科新闻网 时间:2024/04/27 23:53:28
我技术上现在遇到麻烦了,不知道如何在FLASH里实现设为首页和加为收藏夹,网上能到找到相应的方法,但是经过试验不好使,哪为高手给指点一下~~~~下面是网上提供的相应的代码。。。多谢了~~~

一种方法是通过按钮的getURL实现,只要在按钮上加入相应的ActionScript脚本即可。脚本如下:
设为首页

on (release) { getURL("javascript :void(document.links[0].style.behavior=''''''''url(#default#homepage)'''''''');void document.links[0].setHomePage(''''''''http://您的网站地址/'''''''');", "_self", "POST"); }
加入收藏夹

on (release) { getURL("javascript :void window.external.AddFavorite(''''''''http://您的网站地址'''''''',''''''''网站名称'''''''');", "_self", "POST"); }
第二种方法是通过用fscommand的方法,比上面一个要复杂一些。首先在Flash的按钮上添加ActionScript脚本代码
设为首页

on (release) { fscommand("setHomePage", "http://您的网站地址"); }
加入收藏夹

on (release) { fscommand("addFavorite", "http://网站地址|网站名称"); }
在发布Flash动画时选上HTML,在Template下拉菜单中选择Flash with fscommand,发布出html页面接着要对发布出来的HTML页面进行修改,在HTML代码中找到这么一段
// Handle all the the FSCommand messages in a Flash movie function sethomepage_DoFSCommand(command, args) { }
这一段修改成// Handle all the the FSCommand messages in a Flash movie function sethomepage_DoFSCommand(command, args) { var sethomepageObj = InternetExplorer ? sethomepage : document.sethomepage; if (command == "setHomePage") { document.links[0].style.behavior = "url(#default#homepage)"; document.links[0].setHomePage(args); } else if (command == "addFavorite") { args = args.split("|"); window.external.AddFavorite(args[0], args[1]);

用这个。我已经用过了,可以用。

加入收藏夹:
on (release)
{
getURL("javascript:void window.external.AddFavorite(\'http://www.chenz.com/\',\'中国产品资源网\');", "_self", "POST");
}

设为首页:
on (release) {
getURL("javascript:void(document.links[0].style.behavior='url(#default#homepage)');void document.links[0].setHomePage('http://www.chenz.com');")
}

第一个方法是行的,但你露了最后一步:
在网页html文件的body标签后加入代码:

代码:
<A HREF=javascript:></A>

~~~