Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading vars via php -- help PLEASE! 1

Status
Not open for further replies.

tkinter

Technical User
Jul 31, 2002
24
0
0
US
Ok, I'm going to include a lot of information in this.

Here is the contents of my live.txt file:
ind0=1&name0=n/a&team0=n/a&hp0=0&ap0=0&x0=0&y0=0&ind1=2&name1=n/a&team1=n/a&hp1=0&ap1=0&x1=0&y1=0&ind2=3&name2=n/a&team2=n/a&hp2=0&ap2=0&x2=0&y2=0&ind3=4&name3=kPxSouLJa02&team3=TERRORIST&hp3=100&ap3=0&x3=-915&y3=1208&ind4=5&name4=n/a&team4=n/a&hp4=0&ap4=0&x4=0&y4=0&ind5=6&name5=n/a&team5=n/a&hp5=0&ap5=0&x5=0&y5=0&ind6=7&name6=n/a&team6=n/a&hp6=0&ap6=0&x6=0&y6=0&ind7=8&name7=n/a&team7=n/a&hp7=0&ap7=0&x7=0&y7=0&ind8=9&name8=n/a&team8=n/a&hp8=0&ap8=0&x8=0&y8=0&ind9=10&name9=n/a&team9=n/a&hp9=0&ap9=0&x9=0&y9=0&ind10=11&name10=n/a&team10=n/a&hp10=0&ap10=0&x10=0&y10=0&ind11=12&name11=n/a&team11=n/a&hp11=0&ap11=0&x11=0&y11=0&ind12=13&name12=n/a&team12=n/a&hp12=0&ap12=0&x12=0&y12=0&ind13=14&name13=n/a&team13=n/a&hp13=0&ap13=0&x13=0&y13=0&ind14=15&name14=n/a&team14=n/a&hp14=0&ap14=0&x14=0&y14=0&ind15=16&name15=n/a&team15=n/a&hp15=0&ap15=0&x15=0&y15=0&ind16=17&name16=n/a&team16=n/a&hp16=0&ap16=0&x16=0&y16=0&ind17=18&name17=n/a&team17=n/a&hp17=0&ap17=0&x17=0&y17=0&ind18=19&name18=n/a&team18=n/a&hp18=0&ap18=0&x18=0&y18=0&ind19=20&name19=n/a&team19=n/a&hp19=0&ap19=0&x19=0&y19=0&ind20=21&name20=n/a&team20=n/a&hp20=0&ap20=0&x20=0&y20=0&ind21=22&name21=n/a&team21=n/a&hp21=0&ap21=0&x21=0&y21=0&ind22=23&name22=n/a&team22=n/a&hp22=0&ap22=0&x22=0&y22=0&ind23=24&name23=n/a&team23=n/a&hp23=0&ap23=0&x23=0&y23=0&ind24=25&name24=n/a&team24=n/a&hp24=0&ap24=0&x24=0&y24=0&ind25=26&name25=n/a&team25=n/a&hp25=0&ap25=0&x25=0&y25=0&ind26=27&name26=n/a&team26=n/a&hp26=0&ap26=0&x26=0&y26=0&ind27=28&name27=n/a&team27=n/a&hp27=0&ap27=0&x27=0&y27=0&ind28=29&name28=n/a&team28=n/a&hp28=0&ap28=0&x28=0&y28=0&ind29=30&name29=n/a&team29=n/a&hp29=0&ap29=0&x29=0&y29=0&ind30=31&name30=n/a&team30=n/a&hp30=0&ap30=0&x30=0&y30=0&ind31=32&name31=n/a&team31=n/a&hp31=0&ap31=0&x31=0&y31=0&cant=32

Now, I have this code, in a frame in my flash movie:

//Create the LoadVars object and load data into it
new ind[33]
new name[33]
new team[33]
new hp[33]
new ap[33]
new x[33]
new y[33]

myData = new LoadVars();
myData.load("live.txt");
myData.onLoad = function(succes){

for(var i=0; i<33; i++){
ind = myData([&quot;ind&quot; + i]);
name = myData([&quot;name&quot; + i]);
team = myData([&quot;team&quot; + i]);
hp = myData([&quot;hp&quot; + i]);
ap = myData([&quot;ap&quot; + i]);
x = myData([&quot;x&quot; + i]);
y = myData([&quot;y&quot; + i]);
trace(name)
}
}
stop()

Now, my questions
Why doesn't this work?...lol

at the end I'm doing a trace(name) and every one of those variables I'm setting keeps coming up 'undefined'

How can I get these variables from the .txt file and put them into these arrays?...what am I doing wrong?
 
I'm not too familiar with array stuff, but the following does work for me...

ind = new Array();
name = new Array();
team = new Array();
hp = new Array();
ap = new Array();
x = new Array();
y = new Array();

myData = new LoadVars();
myData.load(&quot;live.txt&quot;);
myData.onLoad = function(succes){
for(var i=0; i<33; i++){
ind = this[&quot;ind&quot;+i];
name = this[&quot;name&quot;+i];
team = this[&quot;team&quot;+i];
hp = this[&quot;hp&quot;+i];
ap = this[&quot;ap&quot;+i];
x = this[&quot;x&quot;+i];
y = this[&quot;y&quot;+i];
// A few traces to check...
trace(&quot;ind&quot;+3+&quot;: &quot;+ind[3]);
trace(&quot;name&quot;+3+&quot;: &quot;+name[3]);
trace(&quot;team&quot;+3+&quot;: &quot;+team[3]);
trace(&quot;hp&quot;+3+&quot;: &quot;+hp[3]);
}
};

stop();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top