-
Timing issue when using onLoad and XML
I am loading an XML file and when I run a trace inside the onLoad event the results show. When I put the same trace outside that event, the trace returns undefined because it runs before the XML is Loaded.
I don't know how to assign the results of the XML to a variable being used outside the XML unless I call that through another event.
For example. I want to preload some images if the user has been to the movie before. I call XML which has the image array. But I can't tap into that array because my function is outside the XML Load event and my function is not tied to an event.
Hope that made sense.
-
Senior Member
Can you check and use the 'onData' event handler instead of 'onLoad'... I am not sure about this, but you can check from the Flash documentation!
-
Initialise your array outside 'onLoad' handler
Code:
var xmlArray=new Array();
var myxml=new XML();
myxml.onLoad=function(success){
if(success){
xmlArray.push(your_node_value); // or whatever
}
}
myxml.load("xmlfile.xml");
trace(xmlArray); // should work
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|