Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to assign the loaded txt/xml file's array to variables?
    primarykey
    data
    text
    <p>I use following flash actionscript code, got from online, to load the "Loading.txt" file:</p> <pre><code>var myTextLoader:URLLoader = new URLLoader(); myTextLoader.addEventListener(Event.COMPLETE, onLoaded); function onLoaded(e:Event):void { var myArrayOfLines:Array = e.target.data.split(/\n/,","); } myTextLoader.load(new URLRequest("Loading.txt")); </code></pre> <p>In "Loading.txt", the data of object in a row is (Dim1 Dim2 Dim3 OX OY OZ) is: 60,12,9,-50,-50,50 84,12,9, 50, 50,50</p> <p>Then I use onLoaded[i-1][j-1], in a loop to get the data in row i and column j of the array, but I got some error message. Can somebody help me on this? I am totally new to actionscript. The loop I used is like var ArrayRows:int=2 // how to automatically get the number of rows of the txt file? </p> <pre><code>for(iObj=0;iObj&lt;ArrayRows;iObj++){ Dim1 = ObjDimArray[iObj][0] Dim2 = ObjDimArray[iObj][1] Dim3 = ObjDimArray[iObj][2] OX = ObjOriginArray[iObj][3] OY = ObjOriginArray[iObj][4] OZ = ObjOriginArray[iObj][5] } </code></pre> <p>Also, seems most people recommend using xml and I compiled an xml file "Loading.xml" for above "Loading.txt" as below</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;All&gt; &lt;Equipment Num="1"&gt; &lt;Manufacturer&gt;HW&lt;/Manufacturer&gt; &lt;Length&gt;60&lt;/Length&gt; &lt;Width&gt;12&lt;/Width&gt; &lt;Thickness&gt;9&lt;/Thickness&gt; &lt;OriginX&gt;-50&lt;/OriginX&gt; &lt;OriginY&gt;-50&lt;/OriginY&gt; &lt;OriginZ&gt; 50&lt;/OriginZ&gt; &lt;/Equipment&gt; &lt;Equipment Num="2"&gt; &lt;Manufacturer&gt;HW&lt;/Manufacturer&gt; &lt;Length&gt;84&lt;/Length&gt; &lt;Width&gt;12&lt;/Width&gt; &lt;Thickness&gt;9&lt;/Thickness&gt; &lt;OriginX&gt;50&lt;/OriginX&gt; &lt;OriginY&gt;50&lt;/OriginY&gt; &lt;OriginZ&gt;50&lt;/OriginZ&gt; &lt;/Equipment&gt; &lt;/All&gt; I used following code to load the "Loading.xml". I would like to use a loop to read all values and assign to a variable. Can anybody teach me how to do that? var myXML:XML = new XML(); var XML_URL:String = "Loading.xml"; var myXMLURL:URLRequest = new URLRequest(XML_URL); var myLoader:URLLoader = new URLLoader(myXMLURL); myLoader.addEventListener("complete", xmlLoaded); function xmlLoaded(event:Event):void { myXML = XML(myLoader.data); trace("Data loaded."); } </code></pre> <p>Thanks...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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