Flash保存游戏链接的快捷方式到桌面

Flash AS3创建桌面快捷方式
本文介绍了一种使用ActionScript 3 (AS3) 在桌面创建URL快捷方式的方法。通过构造特定格式的字符串并利用FileReference API保存为 .url 文件实现。此技术适用于需要在用户桌面上提供快速访问入口的应用场景。
 1 /** 
 2          * 桌面保存快捷方式
 3          */
 4         public static function addDesktopUrl(strTitle:String, strUrl:String, onFinish:Function = null,onError:Function = null):void
 5         {
 6             try
 7             {
 8                 var kSaveFile:FileReference = new FileReference();                
 9                 var strFileContent:String = "[InternetShortcut]" + "\n";
10                 strFileContent +=  "URL=" + strUrl+"\n";
11                 strFileContent +=  "IconFile=" +"\n";
12                 strFileContent +=  "IconIndex=0" +"\n";
13                 if(onFinish!=null){
14                     kSaveFile.addEventListener(Event.COMPLETE, onFinish);    
15                 }
16                 if(onError!=null){
17                     kSaveFile.addEventListener(IOErrorEvent.IO_ERROR, onError);
18                 }
19                 kSaveFile.save(strFileContent, strTitle + ".url");                
20             }
21             catch (e:Error) 
22             {
23             }
24         }

 这里用了一个字符串来动态的生成桌面快捷方式

 如果把一个桌面快捷方式拖到文本框中,可以看到,这个快捷方式是可以用文本框打开的。打开后看到的内容就是类似上面的字符串生成的格式。

 

转载于:https://www.cnblogs.com/hisiqi/archive/2013/01/21/2869750.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值