在设计asp和 Flash通信过程中,读取数据有个问题,需要点击按钮两次才能显示数据,具体的文件如下city.fla,有名为BTnlink的button,button的动作为 on (press) {
setProperty(_root.mvCity,_alpha,100); _root.mvCity.gotoAndPlay(2);
} 有名为mvcity的movieclip,包括了四个动态文本框分别为txtCityName、txtCityPerson、txtCityKind、txtCityMemo,mvcity的第一帧关键帧代码stop();,第二帧代码: function OpenAsp(url) { var URL = "City.asp?key=" + url; this.loadVariables(URL, "POST" ; this.txtCityName = this.CityName; this.txtCityPerson = this.CityPerson; this.txtCityKind = this.CityKind; this.txtCityMemo = this.CityMemo; }
OpenAsp(_root.url);
stop();
主场景第一帧空白关键帧动作代码: var url; url=""; ,第二帧放上了button和move clip动作为 setProperty(_root.mvCity,_alpha,0); _root.url = "Am"; stop();
asp文件为city.asp,代码如下 <%
str = "CityName=北京&CityPerson=200&CityKind=ShouDu&CityMemo=Hello,World,this City is" & key Response.Write str %>
建议用loadVars对象来与ASP通讯……详情搜索HANDMADE的贴子…… 用loadVariables从ASP后台载入数据时……应该要加一个random的参数……这样才能起到刷新的作用……“post”方式应该也存在这个问题(未做实验研究)…… 比如: this.loadVariables("City.asp?key="+url+"&random="+random(99999), "POST");
原因是当GET方式发送的变量未改变时……会从IE缓存里读取缓存的信息…… 打开IE缓存看一下就明白了……缓存的纪录是以GET方式的URL为名保存的…… 对了……刚才没发现……你loadVariables()之后立即进行赋值了……而那时候数据并没有载入完成……所以问题是出在这里了……帮你改一下:
function OpenAsp(url) { var this.CityName=null; var URL = "City.asp?key=" + url; this.loadVariables(URL, "POST"; this.onEnterFrame=function(){ if(this.CityName !=null){ this.txtCityName = this.CityName; this.txtCityPerson = this.CityPerson; this.txtCityKind = this.CityKind; this.txtCityMemo = this.CityMemo; delete this.onEnterFrame; }; }; }
(出处:http://www.hackhome.com)
|