Flash Actionscript常用的几个代码,可以直接操作打印机、调用Outlook、调用JS代码、设置网页为首页等。
1、flash调用打印机
//库里一个mc,连接符为aa,舞台上一个按钮,名字为print_btn
this.createEmptyMovieClip("creat_mc", 999);
creat_mc.attachMovie("aa", "aa_mc", 1000, {_x:200, _y:200});
print_btn.onPress = function()
{
var printJobrintJob = new PrintJob();
var isStartPrint:Boolean = printJob.start();
if (isStartPrint)
{
printJob.addPage(_root, {printAsBitmap:true});
printJob.send();
}
delete printJob;
};
//提示,打印那桢停哪桢,PrintJob类其他方法就不写了,按f1自己看吧。
yyjcw.Com
////////////////////////////////////////////
2、调用outlook,我的电脑,回收站等
//先在舞台上建个叫aa_btn的按钮 网页教学网
_root.aa_btn.onPress = function()
{
getURL("
mailto:tslxg@hotmail.com");
//调用outlook必须放到服务器上使用,本地无效
yyjcw.Com
//链接[我的电脑].swf放桌面上有效,以下一样
getURL("[url=file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D]file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D[/url]}");
//链接[我的文档]
//getURL("[url=file:///::{450D8FBA-AD25-11D0-98A8-0800361B1103]file:///::{450D8FBA-AD25-11D0-98A8-0800361B1103[/url]}");
//链接[网上邻居]
//getURL("[url=file:///::{208D2C60-3AEA-1069-A2D7-08002B30309D]file:///::{208D2C60-3AEA-1069-A2D7-08002B30309D[/url]}")
//链接[控制面版]
//getURL("[url=file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}/::{21EC2020-3AEA-1069-A2DD-08002B30309D]file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}/::{21EC2020-3AEA-1069-A2DD-08002B30309D[/url]}");
//链接[回收站]
//getURL("[url=file:///::{645FF040-5081-101B-9F08-00AA002F954E]file:///::{645FF040-5081-101B-9F08-00AA002F954E[/url]}");
};
3、flash调用js函数
//就举个例子,其他的自己试吧,大括号内写成一行,放网页上,本地无效,网页中的高,宽要全改为100% yyjcw.Com
aa_btn.onPress = function()
{
getURL("javascript:NewWindow=window.open('http://www.yyjcw.com/flash/index.html','newWin','width=660,height=480,left=0,top=0,toolbar=No,
location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus(); void(0);");
};
////////////////////////////////////////////
4、设为首页:
on (release) {
getURL(";void document.links.setHomePage('http://www.yyjcw.com/')", "_self", "OST");
}
注意要将网页中的flash的ID号命名为"links"
加入收藏夹:
on (release) {
getURL(" window.external.AddFavorite(
http://www.yyjcw.com,'网页');", "_self", "OST");
} Webjx.Com