PDA

View Full Version : Travelling Sales Person in Flash



Blackspirit
March 30th, 2005, 10:29 PM
Hello,

I'm doing an assignment at school that requires the use of plain formatted text files.

I can get them into flash fine, but I can't get the text split and put into an array properly.

Eg.
" 1 5000"
"10 5000"

Theres a space infront the the 1 is in first example, so that will be array[0]. But I want array[0]=1

When I try to split it by " ", and then remove any blanks in my array, it really goes crazy when there is two spaces, or three. Coupled that with flash bringing in the newline character, my codes getting a bit crazy, and very slow.

Is there any easy way to split text files into an array?

drosa10
March 30th, 2005, 10:33 PM
try this. In your txt. Put
array1=whatever
&array2=dogpoo
&array3=banana
.....


In Your code, put
loadVariablesNum("text.txt",0)

myArray=newArray(array1,array2,array3)

that should work.

Blackspirit
March 30th, 2005, 10:38 PM
Are yes, I should have stated the text file can't be changed. And its in a special format ie

1 1209
2 3048
3 3039

Thats it. Theres no variables in the text file. I used the onData method, which gets the basic input string passed to it.