PDA

View Full Version : loading an array from a text file


spyny
10-09-2003, 01:48 PM
I've posted a nu thread with the wrong word.
The right word is array.

I want to load different arrays in a flash website using .txt files.

Is it possible to do that like loadVars...?

merci beaucoup!

webguy
10-09-2003, 01:53 PM
You can use the split() function to split any value in your loadVars object at a deliminator. People usually use the pipe ( | ) as a deliminator as it is rarely used in information.

Learn how to use split() on a string and you will find your answer.

webG

spyny
10-10-2003, 04:26 AM
Do you think this (the split method) is still practical if i need to have image files names inside the arrays like


["myImage.jpg", "myImage2.jpg",...]


What about the """""" ?

hehe

JEBoothjr
10-10-2003, 09:46 AM
You'll have to use pipes in your text file, it won't work if you use the brackets (to way flash reads an array). You'll have to bring in the list and then create the array. Like webguy said, I'd use pipes. For example in your text file:

mylist=image1.jpg|image2.jpg|image3.jpg

then after it's loaded in Flash, use split.


myArray=myList.split("|");
trace(myArray[0])
trace(myArray[1])
trace(myArray[2])

spyny
10-10-2003, 04:03 PM
what is the practical difference between the two?

spyny
10-11-2003, 11:22 AM
ok, once i have the data in my Array, can i type :

loadMovie(myArray[0], "thatMC");


or

"myArray[0]"

i hope it doesn't become a string then.

spyny
10-11-2003, 12:05 PM
Do i necessarily have to place

trace("myVar");

on a MC in order to get the variable that is loaded from a txt file?

if i put it on the stage, i get "undefined"...

Then, i also have to place

myVar.split("|")

on a MC, right?

I read in a tutorial that the variable takes some time to load.

ahem

CyanBlue
10-12-2003, 05:41 PM
Howdy, spyny... ;)

Are you still having problem with it???

If you do, you might want to show us your code so that people can help you better... ;)

annexion
10-12-2003, 09:20 PM
Hey webguy, I couldn't resist:

"deliminator" should be delimiter. It made me think of Schwarzenegger when I saw it.:p

CyanBlue
10-12-2003, 09:25 PM
Originally posted by annexion
Hey webguy, I couldn't resist:

"deliminator" should be delimiter. It made me think of Schwarzenegger when I saw it.:p :D :D :D

So...
_root.of.all.evil == somewhere.in.CA???

:D :D :D

webguy
10-13-2003, 10:45 AM
Next new blockbuster:

"Deliminator 2"
"Rise of the Pipes"

:D