Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3 & XML - How do I construct xml data in as3?
    primarykey
    data
    text
    <p>I am playing around with saving .xml files from data in my game. I know how to convert an xml object to a <code>ByteArray</code> and write that to a <code>FileReference</code>. What I need to know now is how to go from an empty xml object (using <code>var xml:XML = new XML()</code>) to a fully populated xml object.</p> <p>Can someone show me what functions to use to add nodes and values? Specifically I need to know how to make several of the same type of node. Here's a sample of what the final xml should look like:</p> <pre><code>&lt;data&gt; &lt;player&gt; &lt;money&gt;15831&lt;/money&gt; &lt;shipType&gt;1&lt;/shipType&gt; &lt;ship&gt; &lt;fuelCur&gt;450&lt;/fuelCur&gt; &lt;energyCur&gt;160&lt;/energyCur&gt; &lt;shieldCur&gt;100&lt;/shieldCur&gt; &lt;armorCur&gt;40&lt;/armorCur&gt; &lt;structCur&gt;15&lt;/structCur&gt; &lt;/ship&gt; &lt;/player&gt; &lt;currentSystem&gt;3&lt;/currentSystem&gt; &lt;currentPlanet&gt;3&lt;/currentPlanet&gt; &lt;date&gt; &lt;year&gt;2012&lt;/year&gt; &lt;month&gt;10&lt;/month&gt; &lt;day&gt;15&lt;/day&gt; &lt;/date&gt; &lt;missionFlag&gt;true&lt;/missionFlag&gt; &lt;planet id="0"&gt; &lt;population&gt;0&lt;/population&gt; &lt;/planet&gt; &lt;planet id="1"&gt; &lt;population&gt;29827632&lt;/population&gt; &lt;/planet&gt; &lt;planet id="2"&gt; &lt;population&gt;0&lt;/population&gt; &lt;/planet&gt; &lt;/data&gt; </code></pre> <p>It might be useful to know how to remove and how to alter nodes and values, too.</p> <p>Also, do I need to import something from the flash library to do this with XML? I'm using FlashDevelop, but when I type <code>xml.</code>, FlashDevelop doesn't bring up suggestions like it normally does.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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