Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In one of our Flash project we're using XML file for UI text content loading. The XML get reloaded after specific time interval to keep UI updated. This works fine for few time intervals. But after some random number of reloads, despite of XML loading, I'm unable to read one of the child element from the XML loaded.

Action Script Code:

JavaScript
function LoadCaptions(file : String) : void
{
	captions_LDR = new URLLoader();
	captions_LDR.addEventListener(Event.COMPLETE,CaptionLoadComplete,false,0,true);
	try
	{
		captions_LDR.load(new URLRequest(file));
	}
	catch (e : Error)
	{// --- retry ---
		trace("captions_LDR :  " + e);
		captions_LDR.load(new URLRequest(file));
	}
}

function CaptionLoadComplete(event : Event) : void
{
	captions_XML = new XML(captions_LDR.data);
   
       //Continue other XML loading.
	try{	voiceLOAD(system_PATH + base_PATH + voice_PATH + voice_FILE);
	}catch (e : Error){}
	
	try{	configDynamicLOAD(system_PATH + base_PATH + configDynamic_PATH + configDynamic_FILE);
	}catch (e : Error){}
}



If I print loaded XM it prints as : (trimmed to sample it).

HTML
<captions airportCode="HSV" airportName="Huntsville Intl-Carl T Jones Field">
 	<!-- START: -->
    <caption id="805E123F" unicodeFont="no" name="English"><!-- en -->
        <en>English</en>	
    </caption>
</captions>


But if I try to access the first caption element using code

JavaScript
captions_XML.child(0).children()


instead of content i.e. 'English', it returns blank.

What I have tried:

I have tried to reload the XML file if I'm not able to access the element value. But then also, XML gets loaded properly, it event prints the XML content but if I try to access the first child element value, it again give blank. So, the reloading logic gets stuck into deadlock loop.
Posted
Updated 5-May-16 1:25am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900