PDA

View Full Version : variable problems


tme
04-08-2003, 11:44 PM
i want to save a list of words from an external text file into an array, but when i trace my array after loading the external text file, the output window just says undefined.

i don't know how i should do it
:(

any help would be so much appreciated

Billy T
04-08-2003, 11:55 PM
using MX? post the code you have so far...

tme
04-09-2003, 12:07 AM
this is probably embarressingly incorrect...

frame 1 actionscript:

first i wrote this:

var GroupA;
loadVariables("data.txt");
trace(GroupA);

then i tried this:

GroupA = new Array();
loadVariables("data.txt");
trace(GroupA);

tme
04-09-2003, 12:08 AM
oh yeah, and i'm using MX

Billy T
04-09-2003, 12:21 AM
nah you are processing the text before it has loaded

myVars=new LoadVars();
myVars.onLoad=function(ok){
if(ok){
GroupA=this.theText.split("|");
}else{
trace("****!!!");
}
}
myVars.load("data.txt");


your text file should look something like

&theText=val1|val2|val3

cheers

tme
04-09-2003, 12:41 AM
thanks a whole bunch billy t!

:p

Billy T
04-09-2003, 02:08 AM
no worries