[RESOLVED] xml in html (php)
Hi,
I have used xml in flash and figured out how accessing the button names work. This is the code I used:
Quote:
Originally Posted by
Nightwalker83
I figured out the solution!
Code:
var req: URLRequest = new URLRequest("menuDef.xml");
var loader:URLLoader = new URLLoader(req);
var i:int
var myXML:XML = new XML();
loader.load(req);
loader.addEventListener(Event.COMPLETE,dataLoaded);
//Button code
function dataLoaded (event: Event){
myXML = new XML(loader.data);
for (i = 0; i < 5; i++){
var j:int = i+ 1;
/**3 is the line in the
xml the labels start from. (i) starts counting from the 4th line until the end
specified above.**/
this["btnMenu"+ j].btText.text = myXML.child(3).child(i);
}
}
If the items in your xml file are more or less than "5" change the number to suit.
Now! My question is how would I access the xml data via html code and use it to display the button name flash or html?
At the moment I am using this code within each flash button:
Code:
var req: URLRequest = new URLRequest("../xml/menuDef.xml"); //Remove the "/" before the folder name for the splash page.
var loader:URLLoader = new URLLoader(req);
var i:int
var myXML:XML = new XML();
this.addEventListener(MouseEvent.CLICK,callurl);
loader.load(req);
loader.addEventListener(Event.COMPLETE,dataLoaded);
//Button code
function dataLoaded (event: Event){
myXML = new XML(loader.data);
for (i = 0; i < 1; i++){
var j:int = i+ 1;
/**3 is the line in the
xml the labels start from. (i) starts counting from the 4th line until the end
specified above.**/
this["btn"+ j].btText.text = myXML.child(3).child(i);
}
}
However, I doubt that is wise pragmatically since I repeat the code in every button. In flash I could just put all the button code such as above in the main page that would be it. Is this possible to via html?
Thanks,
Nightwalker