PDA

View Full Version : Loading Multiple Vars Into One Textbox



Digitalosophy
September 29th, 2003, 04:41 PM
Hey i am having trouble loading multiple variables into a multline textbox. I am using asp which will output a recordset into flash. For testing purposes var0 should equal three names in my array. Flash is only reading 1. How do I set flash up to read that whole array(3 variables in one textbox)? I know Flash won't output var1 or var2 because I don't have those textfields with those variable names.

Here's what var0 outputs

http://www.delusionalfx.com/exp/flash_asp/register/test.asp

Here's my Flash code



loadVariablesNum("http://www.delusionalfx.com/exp/flash_asp/register/test.asp",0,"GET");


I have one flash multiline textbox with a variable name var0

Here's what flash reads

http://www.delusionalfx.com/exp/flash_asp/register/users.html

I figured that this was more of a flash problem so I posted it here.

Thanks in advance

lostinbeta
September 30th, 2003, 12:52 AM
giving the textbox the variable name of var0 basically just makes it display the value of the variable var0. Since var1 and var2 are not var0 they do not get displayed.

You can give it another variable name and use something like newVarName = var0+", "+var1+", "+var2 which in the future can be simplified with a for loop. Or you can use an instance name and it would be instanceName.text = whatever. Or you can use loadVars() to load in the variables and do what you want with them.

claudio
September 30th, 2003, 12:58 AM
myTextField.html = true;
loadText = new LoadVars();
loadText.onLoad = function(success) {
if (success) {
var my_array = this.var0.split('|');//split the content of txt file into an array
for (var i = 0; i<my_array.length; i++) {
myTextField.htmlText += my_array[i]+"\n";
}
} else {
myTextField.text = "Error loading contents!";
}
};
loadText.load("textfile.txt");
//your texrfile should look like this:
//var0=variable1|variable2|variable3&

Digitalosophy
September 30th, 2003, 04:35 PM
hey guys, thanks for your repies. however i was unsuccessful in both methods. let me explain

Lostinbeta:



newVarName = var0;
trace(newvarName);


undefined. i have no clue as to why but that's the output i get. i was scratching my head last night trying to get it work. i'd love an explanation why that doesn't work. i guess because var0 is being loaded from an external source?

Claudio:

Your method didn't work as well. i hope this doesn't seem like a noob question but... will your method only work with txt files? i am loading info from an asp page

anyway this is becing a neccessity for me to get through. i have attached my fla. maybe you guys can take a look.

and lost maybe you can explain why yor method doesn't work, seems to me like it should.

anyway, thanks again!

lostinbeta
September 30th, 2003, 04:52 PM
I noticed at the end of your output you have "i=3", is it safe to assume you can use this to get how many variables there will be (or rather how many names there will be)?

If so, then you can use this to get the output....

myTextField.html = true;
loadText = new LoadVars();
loadText.onLoad = function(success) {
if (success) {
for (var j = 0; j<this.i; j++) {
myTextField.htmlText += this["var"+j]+"\n";
}
} else {
myTextField.htmlText = "Error loading contents!";
}
};
loadText.load("http://www.delusionalfx.com/exp/register/test.asp");

Digitalosophy
September 30th, 2003, 05:30 PM
well good call, i edited my asp script a bit and was able to load all vars into my textbox by simply using


loadVariablesNum("http://www.delusionalfx.com/exp/flash_asp/register/test.asp",0,"GET");


As of right now my textbox displays
Davevar=Chrisvar=Hide

So i'm on the right track, now I just have to figure out how to get the "var' out of my output. Which to my knowledge is because of my asp script. See I have a loop that outputs var=whatever. becuase I need to target the var varaible in flash.

So.. this does work, thank you. now maybe i guess i should recontruct my asp code a bit or maybe im loading the values into flash incorrectly. i'm going to have to do some research on this.

Thank yall very much !