Okay, so I’ve been working on this news textbox, so what would be more reasonible than using XML?
I want the text to be loaded into a textbox (instance name: “infoText”)
When i publish the file, my textbox says: “undefined”
This is my AS:
function loadXML(loaded) {
if (loaded) {
xmlNode = this;
nyhed = [];
for (i=0; i<total; i++) {
nyhed* = xmlNode.childNodes*.nodeValue;
}
firstNyhed();
} else {
content = "Kunne ikke hente nyheden...";
}
}
nyhedsXML = new XML();
nyhedsXML.ignoreWhite = true;
nyhedsXML.onLoad = loadXML;
nyhedsXML.load("nyhed.xml");
//////////////////////////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevNyhed();
} else if (Key.getCode() == Key.RIGHT) {
nextNyhed();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevNyhed();
};
next_btn.onRelease = function() {
nextNyhed();
};
/////////////////////////////////////
p = 0;
function nextNyhed() {
if (p<(total-1)) {
p++;
}
infoText.text = nyhed*;
}
function prevNyhed() {
if (p>0) {
p--;
}
infoText.text = nyhed*;
}
function firstNyhed() {
infoText.text = nyhed[0];
}
This is my XML files content:
<?xml version="1.0" encoding="utf-8"?>
<nyheder>
<nyhed>I dag blev brixtofte anholdt saadan noget crap</nyhed>
<nyhed>lad os nu teste</nyhed>
<nyhed>tester</nyhed>
<nyhed>og tester stadig</nyhed>
<nyhed>sidste test</nyhed>
</nyheder>