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

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

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

[img]http://dl2.iteye.com/upload/attachment/0084/9022/2f793baa-a940-359d-839c-66a9d6347889.png[/img]

先看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>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值