Hi im try to reload a new xml file into an xml object when a button is pressed. However it does not seem to be working...it loads the first file "dictionary.xml" successfully, but when i try to reload another xml file "dictionaryMedium.xml" into the XML object when the button is pressed it does not load..in fact when after pressing the button only the trace statement trace(url) shows correctly. It doesnt even go into the onLoad function as trace("failure loading") does not even show... any help wouls be appreciated..thanks a lot
Code:
var dictionary_xml:XML = new XML();
initializeXML("dictionary.xml");
function initializeXML(url:String):Void{
trace(url);
dictionary_xml.ignoreWhite=true;
dictionary_xml.load(url);
dictionary_xml.onLoad = function(bSuccess:Boolean):Void{
if(bSuccess){
trace("success");
trace(dictionary_xml);
}else{
trace("failure loading");
}
}//end onLoad
}//end initializeXML
myButton_btn.onRelease = function():Void{
delete dictionary_xml;
var dictionary_xml:XML = new XML();
initializeXML("dictionaryMedium.xml");
}//end onRelease
oops its ok i think i see the error ( defining the new XML object within the function) anyway ill check it out.. yeah so now basically i will define a _global.dictionary_xml object... is there a more efficient way of doing what im trying to achieve? am i correct in writing delete dictionary_xml etc?
Last edited by silentweed; 05-17-2005 at 08:15 PM.
Hello, I have the same problem. I have searched all over for similar posts with a complete explanation on how to achieve this. I am trying to load a new XML file in place of the first XML file which was loaded at start.
Example: "file1.xml" is loaded at start which generates a menu, onPress of a button "file2.xml" is loaded and regenrates the menu replacing the old one.
I have attached the FLA which currently only loads "file1.xml". The button is already setup on stage. I have tried what was posted above but I cant seem to figure it out. Please take a look. Thanks
Wow, hah... I tried something similar but it didnt work out for me. I noticed you added a function around the main code allowing the 'file' to be defined. Excellent, thanks a million! Thx Slinky2000 & Silentweed!