First, don't use URLLoader, HTTPService is easier.

 

Second, you *can't* use the result in the same function in which you
invoke send(), you must do that work in the handler function.

 

Third, use the AsyncToken. You can assign a identifier to each query
when you send it, and use that identifier in a switch statement in a
handler function to determine how to handle the result.  Or you can
directly assign a handler function to the AsyncToken.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Sudha Hariharan
Sent: Monday, December 18, 2006 1:50 AM
To: [email protected]
Subject: [flexcoders] multiple HTTP Requests

 

hi,

I am rather new to flex and this is one of my amateur attempts at
building RIAs. My application at present includes a tree menu, items of
which when dropped onto a canvas opens up window components. Each window
sends a http request that gets the appropriate data onto the display of
the window. 
when i include multiple http requests at a given time, the data relevent
to the most recent request is only being displayed. How do I display
data from other http requests simulatenously?
a portion of my code is here
<mx:HTTPService id="userRequest" url="http://localhost/mydoc.php "
useProxy="false" method="POST" result="sHandler(event)">
      <mx:request xmlns="">
      </mx:request>
   </mx:HTTPService>
     <mx:HTTPService id="userRequest1" url="http://localhost/mydoc1.php
" useProxy="false" method="POST" result="sHandler(event)">
      <mx:request xmlns="">
      </mx:request>
   </mx:HTTPService>

  public function onDragDrop(event:DragEvent):void{

        var myWindow:ResizableTitleWindow = new ResizableTitleWindow();
        var myTextArea:Text = new Text();
        var ds:DragSource = event.dragSource ;
        if( !ds.hasFormat("treeItems") ) return; // no useful data
            var items:Array = ds.dataForFormat("treeItems") as Array;
        for(var i:Number=0; i < items.length; i++) {
            var item:XML = XML(items[i]);
        if( [EMAIL PROTECTED] == "ms"){

            userRequest.send();
    myTextArea.text= userRequest.lastResult.slk;

}
else if([EMAIL PROTECTED] == "hr"){
userRequest1.send();
myTextArea.text = userRequest1.lastResult.slk;
}
}
myWindow.label = "New Window";
myWindow.x = xvalue;
myWindow.y = yvalue;
myWindow.addChild(myTextArea);
home1.addChild (myWindow);
}
public function sHandler(event:ResultEvent):void
            {
                
                myTextArea.text = event.result.slk ;

            }    

A friend of mine suggested to your URLLoader instead of
HTTPRequest...how do I go about with that?..Please help me

Thanks in Advance,
Sudha Hariharan. 

 Send free SMS to your Friends on Mobile from your Yahoo! Messenger.
Download Now! http://messenger.yahoo.com/download.php

 

Reply via email to