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.

有帮助吗?

解决方案

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

this["LEFT_HOUSE_"+i+"_X"]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top