English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

eg. var myName="john", and I want a variable called john. In PHP I'd do $$firstVarName. Thanks!

2007-02-18 04:17:51 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

In actionscript you do it with square brackets.

for example:

var myNewVariable:String = "variableName";
this[myNewVariable] = "hello";

trace(this[myNewVariable]);
trace(this.variableName);

so in your case it would be:

var myName:String = "john";
this[myName] = "top bloke";

trace(this.john);

(should return "top bloke")

Make sense?

2007-02-18 06:43:39 · answer #1 · answered by gromitski 5 · 0 0

Here it goes:

var myName = "vinayak";
set(myName, "12345");

// now you can work with the dynamic variable
trace(vinayak);

// output would be : 12345

2007-02-18 06:26:29 · answer #2 · answered by vin 2 · 0 0

fedest.com, questions and answers