`

flash cookie的制作和使用例子详解 三

 
阅读更多
前面的两篇博客介绍的是怎么用页面来操作flash cookie,还要放在容器里运行,这篇做一个简单的仅仅使用flash就可以读写flash cookie的例子

先看flash中的代码,当然这次要在flash中定义一些button 显示,输入等控件,看页面就知道定义了哪些控件,再看代码就知道这些控件被命名成什么



先看flash中的代码
var myCookie:Cookie= new Cookie();
setFCButton.addEventListener(MouseEvent.CLICK,setFC)
function setFC(evt: Event){
	var obj:Object = new Object();
	obj.userName=userNameInput.text
	obj.sex=sexInput.text;
	myCookie.put("userInfo",obj);
	
}
getFCButton.addEventListener(MouseEvent.CLICK,getFC)
function getFC(evt: Event):void{
	fcDisplay.text = "userName:"+myCookie.get("userInfo").userName;
	fcDisplay.text = fcDisplay.text + "    sex:"+myCookie.get("userInfo").sex;
}


上面调用 var myCookie:Cookie= new Cookie(); cookie这个类和前面两篇用的是一模一样的

其实有了上面的东西就可以在adobe flash cs5里测试运行了。或着打开生成的swf也是一样的,再就是先前面一样,嵌入到html中用浏览器打开

html代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN" xml:lang="zh-CN">
	<head>
		<title>testFC</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<style type="text/css" media="screen">
		html, body { height:100%; background-color: #ffffff;}
		body { margin:0; padding:0; overflow:hidden; }
		#flashContent { width:100%; height:100%; }
		</style>

	</head>
	
	<body>

		
		<div id="flashContent">
			 <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="500" height="500" id="testFC" title="testFC" align="middle">
			 <param name="allowScriptAccess" value="always" />
			 <param name="movie" value="testFC.swf">
			 <param name="quality" value="high">
			 <param name="wmode" value="transparent" />
			 <embed src="testFC.swf" name="testFC" quality="high" allowScriptAccess="always"  swLiveConnect="true" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  width="500" height="500"></embed>
			</object>
	</div>
	</body>
</html>


  • 大小: 7.9 KB
0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics