all groups > flash data integration > february 2006 >
You're in the

flash data integration

group:

Concatenating variables onto a LoadVars


Concatenating variables onto a LoadVars italoCalvino
2/9/2006 12:00:00 AM
flash data integration: I have a (for i=0;i<num;i++) loop and it tries to concatenate the variable "i"
onto the end of a loadVars variable, called "firstName". I'm doing this so
that it will match the "firstname".i variable that is being passed from a php
program.

I have tried using: +i, .concat(i), .toString(i) and none of them are working.

Does anyone know how to do this?


Re: Concatenating variables onto a LoadVars ekameleon
2/9/2006 12:00:00 AM
Hello :)

read the documentation ;) (F1 in flash)

you can use + opérator (is easy ;))

var myObject = {} ;
var max = 15 ;
for (var i = 0 ; i<15 ; i++) {
myObject["firstName"+i] = i ;
trace(i + " : " + myObject["firstName"+i]) ;
}

trace(myObject.firstName2) ;
trace(myObject["firstName3"] ;

All in Actionscript is Object :)

bye.

hitaloCalvino a écrit :
[quoted text, click to view]
Re: Concatenating variables onto a LoadVars italoCalvino
2/9/2006 12:00:00 AM
Thank you so much for the advice, but I still couldn't get it to work. In case
you have the patience, I've attached the code that isn't returning the
variables "firstName1" "lastName1""memory1". I'd really appreciate your help.

var sendData:LoadVars = new LoadVars;
var loadData:LoadVars = new LoadVars;

sendData.subject = "josephineBeach";

sendData.sendAndLoad("sendMemories.php", loadData, "POST");

loadData.onLoad = function(success:Boolean){
num = number(loadData.n);

if(success)
{_root.dynamic_txt.text = num;

_root.movie_mc.subject_txt.text = loadData.subject;

for(i=0;i<num;i++)

y = -50 + (i*100);

firstName=;
lastName =;
memory =;

trace(firstNameNum);
trace(lastNameNum);
trace(memoryNum);

fullName = loadData.firstName + " " + loadData.lastName;
memory = loadData.memory;

_root.movie_mc.createTextField("fullName_txt",
movie_mc.getNextHighestDepth(), -200, y, 100, 50);
_root.movie_mc.fullName_txt.text = fullName;


_root.movie_mc.createTextField("memory_txt", movie_mc.getNextHighestDepth(),
0, y, 300, 50);
_root.movie_mc.memory_txt.text = memory;
}

else
{dynamic_txt.text = "sorry";}

}

Re: Concatenating variables onto a LoadVars italoCalvino
2/9/2006 3:35:38 PM
:D

I figured it out.

AddThis Social Bookmark Button