Question

very simple question that I cannot find an answer to:

private const LEFT_HOUSE_2_X:Number = 445;
private const LEFT_HOUSE_2_Y:Number = 145;
private const LEFT_HOUSE_2_WIDTH:Number = 45;
private const LEFT_HOUSE_2_HEIGHT:Number = 35;

How can I use access the constant above if I am using an iterator: e.g.

var i:uint = 2;

LEFT_HOUSE_{ i }_X ?

Also to be done with a variable.

Was it helpful?

Solution

using square brackets you can read a const or variable with variable name

this["LEFT_HOUSE_"+i+"_X"]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top