A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Timing issue when using onLoad and XML

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    528

    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.

  2. #2
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    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!
    As ever,
    Vinayak Kadam

  3. #3
    Banned
    Join Date
    Mar 2009
    Posts
    153

    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center