modifier un AS pour charger un xml
Bonjour à tous, j'essaye depuis quelques heures de modifier un actionscript sans y arriver. J'ai deux scripts différents qui chargent des fichiers xml différents, avec une structure différente. J'aimerais modifier un des AS afin qu'ils puissent charger le xml de l'autre fichier.
Quelqu'un pourrait m'aider?
je veux utiliser ce AS
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| system.useCodepage = true;
//FLASH FRAMER NAVIGATION MENU 1
//www.flashframer.com
//Store Button Position
var yPosition:Number = 300;
var xPosition:Number = 38;
//Declare New XML Object
var myXML:XML = new XML();
//Set Flash to ignore the XML file's white space
myXML.ignoreWhite = true;
//Declare new Array to store the links from the XML file
var images:Array = new Array();
//Declare new Array to store the names from the XML file
var names:Array = new Array();
//Declare new Array to store the dates from the XML file
var dates:Array = new Array();
//Set XML onLoad function
myXML.onLoad = function() {
//Set varible to store the XML childNodes
//This allows you to get the number of buttons in the XML file.
//You'll use this tell flash how many times to loop the for loop.
var linkname:Array = this.firstChild.childNodes;
//Set a for loop
for (i=0; i<linkname.length; i++) {
//Push the button name into the names Array
names.push(linkname[i].attributes.NAME);
dates.push(linkname[i].attributes.DATE);
//Push the button link into the links Array
images.push(linkname[i].attributes.IMAGE);
//Attach the button Movie Clip from the libray give it an instance name and place it on the next highest level
_root.attachMovie("buttonE","btn"+i,_root.getNextHighestDepth());
//Set the y position of the buttons
_root["btn"+i]._y = yPosition;
_root["btn"+i]._x = xPosition;
//Increace the varible yPosition 15 pixel each time the loop runs to place each button under each other
yPosition = yPosition+34;
//Place the button name from names Array into the blackTxt text box
_root["btn"+(i)].blackTxt.Txt.text = (names[i]);
//Place the button name from names Array into the whiteTxt text box
_root["btn"+(i)].whiteTxt.Txt.text = (dates[i]);
//Assign the btnOver function to the button onRollOver state.
_root["btn"+(i)].onRollOver = btnOver;
//Assign the btnOut function to the button onRollOut state.
_root["btn"+(i)].onRollOut = btnOut;
//Assign the btnRelease function to the button onRelease state.
_root["btn"+(i)].onRelease = btnRelease;
}
};
//Load the XML file
myXML.load("links.xml");
//Button Over function
function btnOver() {
//This referse to the current button the mouse is over
//Go To And Play frame 2 of the current button the mouse is over
this.gotoAndPlay(2);
}
//Button Out function
function btnOut() {
//Go To And Play frame 16 of the current button the mouse rolls out from
this.gotoAndPlay(16);
}
//Button Release function
function btnRelease() {
//Set a varible named currentBtn equal to the instance name of the current button the mouse clicked on
var currentBtn:String = this._name;
//Set a varible named currentIndex equal to the varible currentBtn and the characters between 3rd letter and 5th of that string.
//This will return a number between 0 and the total number of buttons
var currentIndex:String = currentBtn.substring(3, 5);
//Get the URL from the links Array
//Use the currentIndex varible as the index number
//getURL(links[currentIndex]);
//loadMovie(images[currentIndex], "_root.flyer.place");
_root.FlyerVar = images[currentIndex];
_root.content.gotoAndPlay("unload");
_root.flyer.gotoAndPlay("fin");
}
stop();
//FLASH FRAMER NAVIGATION MENU 1
//www.flashframer.com |
avec ce XML
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<info>
<name>DJ - MixTape</name>
</info>
<structure>
<input name="nom" type="input" validation="max(100)" label="Nom:"/>
<input name="lien" type="input" validation="max(250)" label="Lien:"/>
</structure>
<content>
<item>
<labelID>mixtape1</labelID>
<nom>nom Mix1</nom>
<lien>http://www.mix1.com</lien>
</item>
<item>
<labelID>mixtape2</labelID>
<nom>nom du Mix2</nom>
<lien>http://www.mix2.com</lien>
</item>
<item>
<labelID>mixtape3</labelID>
<nom>nom Mix3</nom>
<lien>http://www.mix3.com</lien>
</item>
</content>
</root> |
Mon ancien AS est le suivant et il n'est pas très pratique
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| // The first step is to activate the XML object
headlineXML = new XML();
headlineXML.ignoreWhite = true;
/*
With the XML Object now active you must now load an XML foramtted document.
Any DTD or XLS formatting will be ignored.
*/
headlineXML.onLoad = myLoad;
headlineXML.load("dj_mixtape.xml");
// Before proceeding to far into the program, make sure the XML document has loaded
// Extract information from the XML file
function myLoad(ok) {
if (ok == true) {
Publish(this.firstChild);
}
}
function Publish(HeadlineXMLNode) {
if (HeadlineXMLNode.lastChild.nodeName.toUpperCase() == "CONTENT") {
content = "";
item = HeadlineXMLNode.lastChild.firstChild;
while (item != null) {
if (item.nodeName.toUpperCase() == "ITEM") {
labelID = "";
nom = "";
lien = "";
element = item.firstChild;
while (element != null) {
if (element.nodeName.toUpperCase() == "LABELID") {
labelID = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "NOM") {
nom = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "LIEN") {
lien = element.firstChild.nodeValue;
}
element = element.nextSibling;
}
content += "<font size='14' color='#FFFFFF'><a href='"+LIEN+"' target='_blank'>"+NOM+"</a></font><br><br>";
txt.htmltext=content;
}
item = item.nextSibling;
}
}
} |
Je ne veux pas changer la structure du XML car il sera généré par un PHP