f*******w 发帖数: 407 | 1 我是刚接触actionscript没到一个星期的新手,请版上的高手指教:
I use following flash actionscript code, got from online, to load the "
Loading.txt" file:
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"));
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
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?
for(iObj=0;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]
}
Also, seems most people recommend using xml and I compiled an xml file "
Loading.xml" for above "Loading.txt" as below
HW
60
12
9
-50
-50
50
HW
84
12
9
50
50
50
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.");
}
Please help - how to assign the loaded txt/xml file's array to variables?
I use following flash actionscript code, got from online, to load the "
Loading.txt" file:
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"));
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
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?
for(iObj=0;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]
}
Also, seems most people recommend using xml and I compiled an xml file "
Loading.xml" for above "Loading.txt" as below
HW
60
12
9
-50
-50
50
HW
84
12
9
50
50
50
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.");
}
非常感谢! |
|