This content has been marked as final. Show 5 replies
That's normal behaviour.
You cannot have a function return the value of a loadVars load like that. Flash doesn't wait for loading to happen before executing further code. So return resultString will probably return undefined.
If you really want to put it inside a function you could do it like this I guess:
What I want to do is running a for loop and loading data each time. This cannot be done in such a stage. Is there an event fired, when the data finished loading, a status change?
Where can I have a look at the LoadVariables class?
A for loop doesn't really make sense. It needs to be event based.
If you want to repeatedly load data from the same php script you would use LoadVars also. The onLoad event handler gives you the values after each load - they are only available after it has run and you should only consider making another request to the same script sometime after this point. You can do something with the values and then use setTimeout to trigger the next load request if you want a polling behaviour. You could use a variable to count the number of loads and do something other than the setTimeout if you wanted it to repeat only a set number of times.
Thanks a lot for your help. I think setTimeout / setInterval combined with the test function you mentioned in the last post will solve my problem. I am going to try that out. Will post the results.
No problems. setTimeout is the one you really want. You only want to trigger a delayed call once after each onLoad "event". If you use setInterval it could end up running more than once before a subsequent onLoad occurs - so your 'loop' is just onLoad establishing a setTimeout for the next load request... it will keep doing that unless you you tell it to stop and there's no risk of the requests piling up in between.