Johnny G Junior's NoteBook Treasures: February 2010

Monday, February 15, 2010

Loading XML and Making sense of it.





Using the XML template above, i wrote a code to just TEST the results from the XML Document.

 ///// FLASH CODE testing images.xml doc  
   
 var xmlData:XML = new XML(); ///// Create New Variable called xmlData  
 xmlData.load("images.xml"); //// load xml file  
 xmlData.ignoreWhite = true; /// ignore them white spaces  
   
 xmlData.onLoad = function(Success){ //// on load do this function  
 if (Success) {  
 xmlNode = this.firstChild;  
 Value1 = xmlNode.childNodes[0].attributes.value1; //// call the 1st Child's attribute called value 1  
 Value2 = xmlNode.childNodes[0].attributes.value2; //// call the 1st Child's attribute called value 2  
 Name = xmlNode.childNodes[0].firstChild; /// call child nodes first child.  
   
 trace (Name); /// show value of Name  
 trace (Value1); //// show value of Value1  
 trace (Value2); ///// show value of Value2  
   
 } else {  
 trace ("This file did not load");  
 } //// close if/else statement  
   
 } /// close function block  
   






and if you are looking for some kind of image to load. you will need it to load in a movieClip. For example:

 container.loadMovie(Value1,1);   
   
 /// container being the movieclips instance name  
 /// loadMovie(Value1... Value1 being the variable carrying the location of the image from the xml document  
   
 /// loadMovie(Value1,1); 1 being the Level (NOT LAYER) it should be on.