|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
专业性的服务。有的ASP商提供垂直型的应用服务,针对某一特定行业提供应用服务。cookieWrittenby:GünterHoffellner
Translatedby:BernhardSpuida
Firstpublished:9/8/2000
SettingorreadingcookiesinFlashmaybenecessaryforexampletoextendthepersonalizationofaweb
sitetotheFlashfile.
Flashdoesnotsupportdirectsettingandreadingofcookies.Thus,youeitherhavetotaketheoften
publisheddetourofusingJavaScriptoryoujustuseASPscriptstosetandreadcookies.Thishasamong
otherthingstheadvantagethatFlashcanaccesscookiesevenwhenJavaScriptisdisabled.
TheFlashFile
InthefollowingtheFlashfilewhichcanreadandsetcookiesattheclientisdescribed.Thefilecalls
theASPScriptstestCookies.asp,setCookies.aspandgetCookies.asptogainaccesstothebrowserscookies
viaASP.
TheFlashfiletestsforthepermissiontosetclientsidecookiesandallowsenteringdatathatistobe
storedinacookie.Thefilealsoreadsthecookiecontentanddisplaysitonscreen.
Therearetwofilesinthedownload:one.flainEnglish,andasecondoneinGerman.Thecompiled.swfis
availableinGermanonly.
TheUserInterface
Theuserinterfaceisdividedintothreepartswhicharedescribedinthefollowingsections.
Figure1:UserinterfaceinFlash
Step1:
TheuserclickstheSTARTTESTbuttontotriggerthetestontheservertodeterminewhetherthebrowser
ofthepagevisitoracceptscookies.Thestatusmessageindicateswhetherthebrowseracceptscookiesor
not.
Step2:
Inthecaseofcookiesbeingaccepted,theFlashmovierunsontothesecondpartandwaitsfordatatobe
savedinacookie.WithaclickontheSENDDATAbutton,thedataistransmittedtotheserver.
Step3:
Inthelastpart,theserverpassesthecookiedatabacktotheFlashfilewheretheyarewrittenintothe
textfields.
TheScriptsoftheFlashFile
ThegraphicpartoftheFlashfileisbuiltaccordingtostandardprocedureandisnotdescribedindetail
forthisreason.
ThelayerwiththenameSourcecodeisimportant,asthiscontainsthesourcecodeoftheFlashfile.We
willgointothedetailsofthisnow.
Figure2:TimelineinFlash
//Frame1
SetVariable:"cookies"="false"
stop
Thevariablecookiesisinitialisedwiththestringfalse.falseisusedastheserverdoesnot
returnthebooleanvaluestrueandfalse,butastringwiththevalueof"true"or"false".Flashwaits
forthebuttonclickforstartingthecookietest.
//Frame2,Labelstep1
LoadVariables("/testcookies.asp",0)
Thefiletestcookies.aspiscalledandreturnstrueorfalse(Cookiesaccepted-Cookiesnot
accepted).
//Frame10
If(cookieseq"true")
SetVariable:"cookietest"="Cookiescanbeset"
Stop
Else
SetVariable:"cookietest"="Cookiesnotallowed.Pleaseenable."
GotoandStop("nocookies")
EndIf
InFrame10adifferentmessageisdisplayedinthestatusfielddependingontheresultofthecookie
test.
Ifcookiesarenotaccepted,Flashjumpstothelabelnocookies,stopsthereandwillnotacceptany
inputbutanothercookietest.Intheif-conditioncookieseq"true"issetinquotesastheserverdoes
notreallyreturnthebooleanvaluesoftrueorfalse,butastringwhichisimmediatelytestedassuch.
Alsonotethatthestringcomparisonrequireseqinsteadof=.
ThestopcommandforcesFlashtowaitforaclickeventoftheSENDDATAbutton.Sendingthecookie
datatotheserverhappensasfollows:
//Frame11,Labelstep2
LoadVariables("/setcookies.asp?cookiename="&name&"&"&
"cookiemail="&email&"&"&"cookietelephone="&telephone,0)
Inthisscript,aquerystringcontainingtheuserentriesissenttothefilesetcookies.asp.Forthe
compositionofthequerystring,refertothearticleDataExchangebetweenASPandFlash(Germanonly).
//Frame19,Labelstep3
LoadVariables("/getcookies.asp",0)
ThedatareadfromacookiebyASPisloadedintotheFlashfile.
//Frame28
Stop
The</p>写软件都是想的时间比写的时间要长的.如果反过来了就得看看是什么原因了.另外大家可以回去问问公司里的小MM.(一般企业里,跟你们交付软件接触得最多的是她们) |
|