如何在Flash中处理Cookies?

see7di 2006-04-23 07:58:14
今天搞了一个FLASH的留言本,但是不知道如何用它来处理ASP的COOKIES,请指教。
...全文
136 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
see7di 2006-04-23
  • 打赏
  • 举报
回复
谢谢
jamila8 2006-04-23
  • 打赏
  • 举报
回复
顶一下.
youzi520 2006-04-23
  • 打赏
  • 举报
回复
学习,MARK..
www_7di_net 2006-04-23
  • 打赏
  • 举报
回复
以下是ASP访问FLASH的详解
<%

Class SWFDump

Private header
Private RECTdata
Private nBits
Private mversion
Private mfilelen
Private mxMin
Private mxMax
Private myMin
Private myMax
Private mheigt
Private mwidth
Private mframerate
Private mframecount

Private Sub Class_Initialize()

End Sub

Private Sub Class_Terminate()

End Sub


Private Function ReadHeader (filename)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(filename, ForReading)
ReadHeader = f.Read(21)
End Function

Private Function ToBin(inNumber, OutLenStr )
Dim binary
binary = ""
do while inNumber >= 1
binary = binary & inNumber mod 2
inNumber = inNumber \ 2
loop
binary = binary & String(OutLenStr - len(binary), "0")
ToBin = StrReverse(binary)
End Function

Private Function Bin2Decimal(inBin)
Dim counter
Dim temp
Dim Value
inBin = StrReverse(inBin)
temp = 0
For counter = 1 to Len(inBin)
If counter = 1 then
Value = 1
Else
Value = Value * 2
End If
temp = temp + mid(inBin, counter ,1) * Value
Next
Bin2Decimal = temp
End Function

Public Function SWFDump(fileName)

header = ReadHeader (fileName)
mversion = asc(mid(header,4,1))
mfilelen = asc(mid(header,5,1))
mfilelen = mfilelen + asc(mid(header,6,1)) * 256
mfilelen = mfilelen + asc(mid(header,7,1)) * 256 * 256
mfilelen = mfilelen + asc(mid(header,8,1)) * 256 * 256 * 256

RECTdata = ToBin(asc(mid(header,9,1)),8)
RECTdata = RECTdata & ToBin(asc(mid(header,10,1)),8)
RECTdata = RECTdata & ToBin(asc(mid(header,11,1)),8)
RECTdata = RECTdata & ToBin(asc(mid(header,12,1)),8)
RECTdata = RECTdata & ToBin(asc(mid(header,13,1)),8)
RECTdata = RECTdata & ToBin(asc(mid(header,14,1)),8)
RECTdata = RECTdata & ToBin(asc(mid(header,15,1)),8)
RECTdata = RECTdata & ToBin(asc(mid(header,16,1)),8)
RECTdata = RECTdata & ToBin(asc(mid(header,17,1)),8)

nBits = Mid(RECTdata,1,5)
nBits = Bin2Decimal(nBits)

mxMin = Bin2Decimal(Mid(RECTdata,6,nBits))
mxMax = Bin2Decimal(Mid(RECTdata,6 + nBits * 1 ,nBits))
myMin = Bin2Decimal(Mid(RECTdata,6 + nBits * 2 ,nBits))
myMax = Bin2Decimal(Mid(RECTdata,6 + nBits * 3 ,nBits))

mheigt = (myMax - myMin) / 20
mwidth = (mxMax - mxMin) / 20

mframerate = asc(mid(header,18,1))

mframecount = asc(mid(header,19,1))
mframecount = mframecount + asc(mid(header,20,1)) * 256

End Function


Public Property Get Heigt()
Heigt = mheigt
End Property

Public Property Get Width()
Width = mwidth
End Property

Public Property Get Version()
Version = mversion
End Property

Public Property Get FileLen()
FileLen = mfilelen
End Property

Public Property Get xMin()
xMin = mxMin
End Property

Public Property Get xMax()
xMax = mxMax
End Property

Public Property Get yMin()
yMin = myMin
End Property

Public Property Get yMax()
yMax = myMax
End Property

Public Property Get Framerate()
Framerate = mframerate
End Property

Public Property Get Framecount()
Framecount = mframecount
End Property
End Class
%>

做成包含文件swfheaderdump.inc
调用:

<!-- #include file="swfheaderdump.inc" -->
<%
' Pass the SWF name in querystring this way
' swfdump.asp?swf=yourmovie.swf

set myObj = new swfdump
myObj.SWFDump (Server.MapPath(request("swf")))

Response.Write "Heigt (pixel) = " & myObj.Heigt & "<br>"
Response.Write "Width (pixel) = " & myObj.Width & "<br>"
Response.Write "Version = " & myObj.Version & "<br>"
Response.Write "FileLen (bytes) = " & myObj.FileLen & "<br>"
Response.Write "xMin (twips) = " & myObj.xMin & "<br>"
Response.Write "xMax (twips) = " & myObj.xMax & "<br>"
Response.Write "yMin (twips) = " & myObj.yMin & "<br>"
Response.Write "yMax (twips) = " & myObj.yMax & "<br>"
Response.Write "FrameRate = " & myObj.FrameRate & "<br>"
Response.Write "FrameCount = " & myObj.FrameCount & "<br>"
%>
www_7di_net 2006-04-23
  • 打赏
  • 举报
回复
testcookies.asp
' 检查浏览器是否接受 cookies
<%
strTest = Request.QueryString("CookieTest")
If UCase(strTest) <> Ucase("true") Then
Session("__FlashCookieTest") = True
' 第一次呼叫.设置session变量
' 用QueryString重定向
strURL = Request.ServerVariables("SCRIPT_NAME")
strQueryString = "?CookieTest=true"
Response.Redirect(strURL & strQueryString)
Response.End
Else
If Session("__FlashCookieTest") = True Then
' 已完成重定向.检查session变量是否包含值
strOut = "Cookies=true"
' Session变量包含值,因此浏览器接受cookies

Else
strOut = "Cookies=false"
' Session变量为空,浏览器决绝cookies
End If
End If
Response.Write(strOut)
' 输出到Flash
%>

在ASP中,使用 Response.Cookies 集合能够很容易设定cookies。Flash程序呼叫setcookies.asp,传送在Querystring中cookies(names and values)变量到ASP程序;接着,ASP从Querystring 集合读取所有的值,再由Response.Cookies送出对应的 cookies到浏览器去。看看这个文件的代码:
setcookies.asp
<%
For each item in Request.QueryString
Response.Cookies(item) = Request.Querystring(item)
Next
%>

当Flash程序呼叫getcookies.asp文件,会以URL编码文字传回所有的cookies的名称和值。这样,当Flash呼叫getcookies.asp时,cookies的值就会写入Flash同样名称的变数中,代码如下:
getcookies.asp
' 读取 Cookies
<%
For each cookie in Request.Cookies
strOut = strOut & Server.URLEncode(cookie) & "="
strOut = strOut & Server.URLEncode(Request.Cookies(cookie))
strOut = strOut & "&"
Next
Response.Write strOut
%>
sxsgssgs 2006-04-23
  • 打赏
  • 举报
回复
去flash版问问吧。
see7di 2006-04-23
  • 打赏
  • 举报
回复
可否提供以下程序代码?
baicha123 2006-04-23
  • 打赏
  • 举报
回复
用asp处理之后输出文本或者xml然后再通过flash读取

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧