开发者

.lastresult property of my call responder

good morning stackoverflow.. I have a problem... i wanted to loop a service call so that it can dynamically populate my array..this is my sampple code

var i:Number = new Number();

            {
            for(i=0;i<facilityIDArray.length;i++){
            getEventsFromFacilityIDResult.token = currente开发者_开发技巧ventService.getEventsFromFacilityID(facilityIDArray.getItemAt(i));
            getEventsFromFacilityIDResult.addEventListener(ResultEvent.RESULT,toShowArray);
            }

then this is the function that is called by the service call

{ public function toShowArray(event:ResultEvent):void {

            var i:Number = new Number();
            var obj:Object = new Object();
            var tempArray:ArrayCollection = new ArrayCollection();
            tempArray = getEventsFromFacilityIDResult.lastResult;

            if(tempArray != null){
                for(i=0;i<tempArray.length;i++){
                obj = tempArray.getItemAt(i);
                obj.id = int(localIDArray.length -1);

                showArray.addItem(obj);
                }
            }
        }

}..

the main thing that is happening here is only the last call will be added to showArray the other calls are disregarded..can you please help me


You're adding multiple listeners to that one HTTPService object each time a result returns from a call to send on said HTTPService every one of those listeners will be called, so toShowArray will be called multiple times (each time for each separate request). Depending on where showArray is initialized it may be that you're re-instantiating it between the return calls. Put a breakpoint in the toShowArray method, how many times is it called (is showArray empty in each call, why?), this doesn't seem like a good method. Why doesn't the service just return the full set instead of making a bunch of separate requests and trying to handle each response out of order (since the calls are Asynch knowing which one will come back when is impossible, furthermore browsers and OSes restrict the number of open TCP/IP connections so in many cases you'll only have 2 concurrent requests open from the client). Also, when you paste code into stackoverflow, paste the full code then highlight all the code (use your mouse or keyboard to select it all) and hit the code button above the text area this will make it slightly easier to help you get to an answer. Explain what the parts are that you made up that aren't included in the code, IE getEventsFromFacilityIDResult I have to assume based on the listeners and the properties you reference on it what type of object it is.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜