×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    21

    XML.Load timeout in flash lite 2.x

    Hi.

    I'm using XML to display a latest news feed on my mobile app. I use the example here:
    http://wiki.forum.nokia.com/index.ph...arse_XML_files

    Everything works great, but if (for example) my web server is not responding (say the web server is down) the xml.load must poll the web server for about 20 seconds or more trying to connect, delaying my app from loading. I'd like it to try to load the xml file for 5 seconds and if it doesnt get a response from the web server then carry on loading the app.

    I've looked into adding a timeout using these methods:
    http://www.gskinner.com/blog/archive...timate_as.html
    and Loadvars onHTTPStatus

    but none are supported in flash lite 2.x. Can anybody suggest another approach please?
    Thanks for any help.

  2. #2
    Registered User
    Join Date
    Apr 2008
    Location
    India / Singapore
    Posts
    549

    Re: XML.Load timeout in flash lite 2.x

    You can simply create a setInterval for 5 seconds, after you attempt to load the external XML.
    When the timer event fires, check if XML.data = null, if so you can conclude that webserver is down.
    Twitter - manikantan_k
    Just in --

  3. #3
    Registered User
    Join Date
    Jun 2010
    Posts
    21

    Re: XML.Load timeout in flash lite 2.x

    Ahhh, ok. Interesting. Thanks. I've just knocked this code up, but can't test it right now. I hope it's what you mean, and I'll see if it works later:

    Code:
    stop();
    
    // create a new XML object
    var myPhoneXML = new XML(); 
    //Text nodes that contain only white space are discarded
    myPhoneXML.ignoreWhite = true; // define the onload handler
    myPhoneXML.onLoad = function(success) 
    {	
    if (success) {		
    	//do something
    } else {		
    	//do something else
    }}; 
    
    // load the XML file into the myPhoneXML object
    myPhoneXML.load("http://www.website.com/whatever.xml");
    
    setInterval(
    myPhoneXML.onData = function(src){
    	if (src == undefined) {
    		this.onLoad(false);
    		//did not load ok
    	} else {
    		this.parseXML(src);
    		this.loaded = true;
    		this.onLoad(true);
    		//loaded ok - call onload
    	}
    }
    ,5000);

  4. #4
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    100

    Re: XML.Load timeout in flash lite 2.x

    Not exactly.
    Don't put any onData handler in the interval function. Just check the property.
    onData handler is invoked when the XML is completely loaded.

  5. #5
    Registered User
    Join Date
    Jun 2010
    Posts
    21

    Re: XML.Load timeout in flash lite 2.x

    Which property are you both referring to? If i try:

    setInterval(
    function(){
    if (xml.data == null) {
    trace("null")
    }else
    {
    trace("not null")
    }
    }, 1000 );

    i get "There is no property with the name 'data'"??

  6. #6
    Registered User
    Join Date
    Jun 2010
    Posts
    21

    Re: XML.Load timeout in flash lite 2.x

    hmmm....i have a feeling that you guys are talking about using shared objects......

  7. #7
    Registered User
    Join Date
    Jun 2010
    Posts
    21

    Re: XML.Load timeout in flash lite 2.x

    OK, i guess effectively i could just use a couple of booleans as opposed to checking the data of a shared object like below, right? I think it would work in principle. But this brings me on to my next question.

    xml.load gets called.
    A prompt appears on the mobile saying "Connect to network?" or similar

    Is there any way to wait for a user selection here? Because using setInterval like below just carries on after 5 seconds even if the user hasn't made a selection?

    Thanks.

    Code:
    stop();
    
    var blnLoaded : blnLoaded = false;
    
    // create a new XML object
    var myPhoneXML = new XML(); 
    //Text nodes that contain only white space are discarded
    myPhoneXML.ignoreWhite = true; // define the onload handler
    myPhoneXML.onLoad = function(success) 
    {	
    if (success) {		
    	blnLoaded = true;
    } else {		
    	blnLoaded = false;
    
    }}; 
    // load the XML file into the myPhoneXML object
    myPhoneXML.load("http://www.website.com/whatever.xml");
    
    setInterval(
    function(){
    if blnLoaded == false
    {
        //continue instead of waiting
    }
    }
    ,5000);

  8. #8
    Registered User
    Join Date
    Jun 2010
    Posts
    21

    Re: XML.Load timeout in flash lite 2.x

    I'm wondering if setting the 'script time limit' to 5 seconds under Publish Settings would be better than using SetInterval.....anybody used this? Thanks...

  9. #9
    Regular Contributor
    Join Date
    Dec 2007
    Posts
    63

    Re: XML.Load timeout in flash lite 2.x

    Please set a variable parameter after url... So, you can get updated data.

    Even you can also use YQL to easy load query data.
    Regards,

    Ravindra Suthar

Similar Threads

  1. Flash Lite 3.1 Unable to load data dilemma
    By terstepki in forum [Archived] Flash Lite on Nokia Devices
    Replies: 8
    Last Post: 2010-04-08, 07:44
  2. How to load local XML file in Flash Lite that is embedded in a WRT Widget?
    By kvirtanen in forum [Archived] Flash Lite on Nokia Devices
    Replies: 3
    Last Post: 2010-04-06, 10:14
  3. Dynamic Video Stream/Load in Flash Lite 1.1
    By supriyaakg in forum [Archived] Flash Lite on Nokia Devices
    Replies: 1
    Last Post: 2010-03-24, 17:42
  4. Dynamic Video Stream/Load in Flash Lite 1.1
    By supriyaakg in forum [Closed] Publishing to Nokia Store
    Replies: 0
    Last Post: 2010-03-24, 05:04
  5. Loading XML into Flash Lite
    By Noeff2002 in forum [Archived] Flash Lite on Nokia Devices
    Replies: 1
    Last Post: 2009-11-03, 14:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×