Flash - concatenating variables

ryanmm

Member
Messages
38
Reaction score
0
Points
6
Can't figure this one out...



...this works
Code:
on(release)
{
   var TempMusicName1 = "slammal";
   currentSong++;
   VarVar = "TempMusicName";
   VarVar += currentSong.toString();
   PlayVar = this[VarVar];
   trace(PlayVar); //result slammal
}




...this doesn't
PHP:
//PHP file "GetSongNames.php"
<?PHP echo 'Name0=slammal&Name1=whatever'; ?>

Code:
// actionscript 2
 
 
// frame action to load variables
myVars = new LoadVars(); 
myVars.load("GetSongNames.php"); 
 
 
// button action 
on(release)
{
   currentSong++;
   VarVar = "myVars.Name";
   VarVar += currentSong.toString();
   PlayVar = this[VarVar];
   trace(PlayVar); //result undefined????
}

My only idea is that it doesn't like the "." in "myVars.Name" ???
How can I get around this?
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Try:

Code:
on(release)
{
   currentSong++;
   VarVar = "Name";
   VarVar += currentSong.toString();
   key = myVars[ VarVar ];
   PlayVar = this[key];
   trace(PlayVar); //result undefined????
}
 

ryanmm

Member
Messages
38
Reaction score
0
Points
6
Nope. Still not working. Comes back as undefined.

Try:

Code:
on(release)
{
   currentSong++;
   VarVar = "Name";
   VarVar += currentSong.toString();
   key = myVars[ VarVar ];
   PlayVar = this[key];
   trace(PlayVar); //result undefined????
}
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Code:
on(release)
{
   currentSong++;
   VarVar = "Name";
   VarVar += currentSong.toString();
   trace(VarVar); //result undefined????
   key = myVars[ VarVar ];
   trace(key); //result undefined????
   PlayVar = this[key];
   trace(PlayVar); //result undefined????
}

then check the earlier lines ...
 

ryanmm

Member
Messages
38
Reaction score
0
Points
6
Everything traced out and checked.

problem is with this line:

key = myVars[ VarVar ];

key comes back as undefined
 
Top