suppose we defined some variables outside of the function like this:
var a:String ;
Then we call some php code to load the query and get results from the database as XML format like these:
function processSearch():void
{
var phpVars:URLVariables = new URLVariables();
var phpFileRequest:URLRequest = new URLRequest("p_search.php");
phpFileRequest.method = URLRequestMethod.POST;
phpFileRequest.data = phpVars;
var phpLoader:URLLoader = new URLLoader();
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpLoader.addEventListener(Event.COMPLETE, showResult);
phpLoader.load(phpFileRequest);
}
function showResult(event:Event):void
{
var p_info:XML;
p_info = new XML(event.target.data.systemResult);
a=p.information[0] //assign value here
}
processSearch();
trace(a)
the confusing part arises here as we can't get this assigned value a outside the scope of this showResult function. We can only race the value inside this function and I'm struggled to find a way to pass data outside this function for further usage.