I want to make some function, with returning loading object. Something like:
var myVar:String;
myVar = MyFuncs.GetResponse("http://www....");
And GetResponse function must return some string value, for example json-like text. I try.. But cant understend.
public function GetResponse(url:String):String{
var request:URLRequest = new URLRequest(url);
var loader:URLLoader = new URLLoader();
loader.load(request);
return loader.data
}
But data is not loaded yet, when I return the value. I understand, I need to add listener, when loader is complete:
loader.addEventListener(Event.COMPLETE, Complete);
But cant understand, how can I return the loaded value, when the loading is complete. Because it will be a another function..
Please, help, if someone know, how :)
Sorry for my English, please.