Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3 - XML change element value not working?
    text
    copied!<p>I'm currently making a high scores table, and one of the high score tables is for a spelling quiz.</p> <p>I have a local file called <code>highscores.xml</code>, which looks like this:</p> <pre><code>&lt;highscores&gt; &lt;spelling&gt; &lt;first&gt;0&lt;/first&gt; &lt;second&gt;0&lt;/second&gt; &lt;third&gt;0&lt;/third&gt; &lt;fourth&gt;0&lt;/fourth&gt; &lt;fifth&gt;0&lt;/fifth&gt; &lt;/spelling&gt; &lt;/highscores&gt; </code></pre> <p>and this is AS3 function that runs after I load the <code>highscores.xml</code> file:</p> <pre><code>function highScoresLoaded(e:Event) { highScoresXML = new XML(urlLoader.data); highScoresArray = new Array(); highScoresArray.push(highScoresXML.spelling.first); highScoresArray.push(highScoresXML.spelling.second); highScoresArray.push(highScoresXML.spelling.third); highScoresArray.push(highScoresXML.spelling.fourth); highScoresArray.push(highScoresXML.spelling.fifth); highScoresArray.push(points); highScoresArray = highScoresArray.sort(Array.DESCENDING); highScoresArray.pop(); firstScoreTXT.text = highScoresArray[0]; secondScoreTXT.text = highScoresArray[1]; thirdScoreTXT.text = highScoresArray[2]; fourthScoreTXT.text = highScoresArray[3]; fifthScoreTXT.text = highScoresArray[4]; highScoresXML.spelling.first = highScoresArray[0]; highScoresXML.spelling.second = highScoresArray[1]; highScoresXML.spelling.third = highScoresArray[2]; highScoresXML.spelling.fourth = highScoresArray[3]; highScoresXML.spelling.fifth = highScoresArray[4]; trace(highScoresXML); } </code></pre> <p>but the trace output at the end of a function goes like this(I've just scored 4250 on the quiz):</p> <pre><code>&lt;highscores&gt; &lt;spelling&gt; &lt;first&gt;4250&lt;/first&gt; &lt;second&gt;0&lt;/second&gt; &lt;third&gt;0&lt;/third&gt; &lt;first&gt;4250&lt;/first&gt; &lt;fifth&gt;0&lt;/fifth&gt; &lt;/spelling&gt; &lt;/highscores&gt; </code></pre> <p>When I delete this line it works fine:</p> <pre><code>highScoresXML.spelling.fourth = highScoresArray[3]; </code></pre> <p>I'm not that good at programming and can't seem to figure it out.</p> <p>Any help would be appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload