我的事件处理程序出了问题。我试图使用URLRequest从数据库加载一些数据。但它陷入了无限循环。有关为什么它会循环的任何建议,即使在加载了所有数据之后呢?
结果被推入数组。
代码:
public function Listingdetailinfo()
{
somedata = SearchVectorTest.lists;
SrSend = new URLRequest("http://testurl/requestimage.php");
SrSend.method = URLRequestMethod.POST;
Arvariables = new URLVariables ;
SrSend.data = Arvariables;
SaLoader = new URLLoader();
SaLoader.dataFormat = URLLoaderDataFormat.TEXT;
Arvariables.data1 = somedata[0];
SaLoader.load(SrSend);
SaLoader.addEventListener(Event.COMPLETE,Asandler);
function searchVOs( pic:String )
{
this.pic = pic;
}
function Asandler(event:Event):void
{
trace(event.target.data);
// retrieve data from php call
var resultString:String = event.target.data;
trace(event.target.data);
// parse result string as json object and cast it to array
var resultArray:Array = JSON.parse(resultString) as Array;
var len:int = resultArray.length;
trace(resultString);
// create vector of SearchVO
var searchVOs:Array = new Array();
// get the length of the result set
var i:int;
for (i=0; i<len; i++)
{
searchVOs[i] = new Listingdetailinfo();
searchVOs[i].pic = resultArray[i].pic;
myArray.push(searchVOs[i].pic);
}
}
}
答案 0 :(得分:0)
我假设您的代码代表了Listingdetailinfo类的构造函数。你&#34;无限循环的原因&#34;是你在
中创建这个类的新实例searchVOs[i] = new Listingdetailinfo();