Skip to main content
Apr 18, 2006 8:21 PM UTC
Answered

Understanding onLoad (XML)

I have the code below.
When I watch the process in the Debug window, I realize that the "traiterXML" function is done after all the code is processed. I think i don't grasp the way codes are treated. Is there an event i should call, or watch, making it sure the code after the ".load" call is run after the XML treatment has been done?
This topic is closed to new replies. Start a new post to keep the conversation going.
Peter LorentCorrect answer
Inspiring
Apr 18, 2006 8:41 PM UTC
The XML-object works like this:
When you instruct it to load a file it gets the file, parses it and then fires an event 'onLoad'. If you define an onLoad handler for the object, it will execute the statements.
But in the meantime, all other code on the frame will be executed too. So, all your code that depends on the XML-object must be in the onLoad-handler or, like shyaway suggested, you place the code on the second frame and instruct the playhead to go to that frame in the onLoad handler. Or you place all code in functions and call the functions from the onLoad handler.

4 replies

Apr 18, 2006 8:48 PM UTC
Thank you LuigiL.
Translate
Peter LorentCorrect answer
Inspiring
Apr 18, 2006 8:41 PM UTC
The XML-object works like this:
When you instruct it to load a file it gets the file, parses it and then fires an event 'onLoad'. If you define an onLoad handler for the object, it will execute the statements.
But in the meantime, all other code on the frame will be executed too. So, all your code that depends on the XML-object must be in the onLoad-handler or, like shyaway suggested, you place the code on the second frame and instruct the playhead to go to that frame in the onLoad handler. Or you place all code in functions and call the functions from the onLoad handler.
Translate
Apr 18, 2006 8:40 PM UTC
Thanks!
Translate
Participating Frequently
Apr 18, 2006 8:25 PM UTC
it's best to preload your xml before tampering with it.
in frame 1, in your onLoad code... function(success){
if(success){
gotoAndStop(2);
}else{
gotoAndStop(error_frame);

that should force your xml to load before going to frame 2.
Translate