Hi!
I am trying to load the output of a php-file into some flash variables and then fill some textfields with those variables. But it seems like even though i have a completehandler it tries to fill the textfields before i get all the data. Could someone please take a look at my code and see if there is anything wrong?
function loadQuestion(){
var request:URLRequest = new URLRequest("the url to my php script");
request.method = URLRequestMethod.GET;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(request);
function completeHandler(evt:Event) {
question = evt.target.data.question;
answer = evt.target.data.answer;
qfield.text = question;
afield.text = answer;
}
}
loadQuestion();
Is it wrong of me to have the completeHandler inside the loadQuestion function? And is it wrong of me to assume that because i put the data in the textfields in the completeHandler it should w8 until its finished loading?
All help much appreciated!