PDA

View Full Version : [As3] Variable name from another variable


Broly
12-26-2006, 11:24 AM
Hi all,
I'm new in this forum :)
I've a problem in the Actionscript 3 Flash 9 Alpha.

I'm trying to give to a variable a name taken from another variable, for example

a = "pippo"
this[a] = 10
trace(pippo)

and this

b=1
this["pippo"+b] = 10
trace(pippo1)

works in Actionscript 2...but it doesn't work in Actionscript 3.
I tried in many ways but it doesn't work :(

Any help will be appreciated :)

Thanks!

TheCanadian
12-26-2006, 12:56 PM
var a = "pippo"
this[a] = 10
trace(this.pippo)



var b=1
this["pippo"+b] = 10
trace(this.pippo1)

Broly
12-26-2006, 01:05 PM
ActionScript Code:
var a = "pippo"
this[a] = 10
trace(this.pippo)



var b=1
this["pippo"+b] = 10
trace(this.pippo1)





Oh My God...

After your post, I made two considerations/conclusions.

1) I need holidays
2) I've to kill myself

Now I go to make my choice between two options...

Thanks The Canadian...and excuse for the stupid question :look:

TheCanadian
12-26-2006, 01:09 PM
:lol: No problem.