flash网站计数器 基于sharedObject
今天有人问到了怎么只用flex前端来计算用户访问本页的次数!!
其实这不难想 ,我们需要利用类似 cookie的东西
flash 里就是 SharedObject
下面就是利用SharedObject来确定用户访问本网站的次数
多次刷新页面进行测试demo :
http://56589.5c5c.info/swf/sharedObject.html
直接复制到你的 flash里测试:
/*注: sharedObject文件保存在
C:\Documents and Settings\Administrator\Application Data\Macromedia\Flash Player\#SharedObjects\您的计算机名\
*/
import flash.net.SharedObject;
import flash.text.TextField;
//显示文本
var showText:TextField= new TextField();
addChild(showText);
showText.x=200;
showText.y=150;
var so:SharedObject = SharedObject.getLocal("flashCookie","/",false);
if(!so.data.times){ //如果times未设置,则进行设置
so.data.times=1;//设置次数
}
else{
++so.data.times;
}
so.flush();
showText.htmlText="<bold>您已访问本页"+"<strong>"+so.data.times+"</strong>"+"次</bold>";
相关文档:
flashbuilder中可以建立flex工程与actionscript工程.
flex工程内可以使用mxml是完成设计工作.
actionscript工程建立时默认只有:
playerglobal.swc
flex.swc
utilities.sec
playerglobal.swc
这几个类库.没有framework.swc,就无法使用Button等控件了.
解决方案是 actionscript工程中加入framework.swc.
路径是 x:/A ......
用SWFObject,将swf文件嵌入网页后,在IE浏览器中首次浏览正常,刷新后,stageWidth就为0了,swf中基于stageWidth定位的元素,就会错乱。
转自(ljhzzyx 2009-09-24 14:44:20)
首先区分一下stage的stageWidth和width属性。stage.stageWidth是flash player的宽度,stage.width是指stage里content的宽度,如果这个舞台(sta ......
本来想用flash的as2调用html+javascript的方法取得本地路径,但项目催得紧,没有时间研究基本不会的html了。只好使用熟悉的vc,捣鼓了一整天,凑合出一个解决方法来。不罗嗦了,见正文。
======================flash端的as2脚本如下:
//call Open file dialog
//fscommand("exec", "deleteFile.exe ......
原理;用flash把书签相关信息写入剪贴板,用VC的程序读剪切板内容,写入硬盘。当flash读书签时,直接读取txt文件。写入或删除操作,用vc的程序。
=======================flash端:
按键设计: add | bookmark | del
限制:每本txt电子书只有一个书签。
src:
button add:
on(release){
//add
System.setClipboard ......