A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Reloading new xml file into xml object

  1. #1
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875

    Reloading new xml file into xml object

    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
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    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.
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    Member
    Join Date
    Jan 2006
    Posts
    33
    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
    Attached Files Attached Files

  4. #4
    Member
    Join Date
    Jan 2006
    Posts
    33
    bump

    Please anyone? I am in desperate need to get this working. Your help is very much appreciated, thank you.

  5. #5
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    whoa thats a post i made in 2005!!
    i'll have a look at your file...(later this evening, at work right now)
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  6. #6
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    I was interested in this as I knew it couldnt be that hard to do. and walla it wasnt. not rocket science or anything...
    Last edited by slinky2000; 09-01-2009 at 11:18 AM.

  7. #7
    Member
    Join Date
    Jan 2006
    Posts
    33
    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!

  8. #8
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    yea thats all I did prob not the best coding practive the way I did it but its works a treat

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