Hey guys, kinda a nooby question with a for loop....
I have 4 objects that I all want to have their own velocities.
I have a bunch of variables (each one has a different value):
PHP Code:
public var vx1:Number;
public var vx2:Number;
public var vx3:Number;
public var vx4:Number;
Rather than having a function for each object to say:
PHP Code:
function1 { this.x = vx1}
function2 { this.x = vx2}
function3 { this.x = vx3}
function4 { this.x = vx4}
I'd like to have a for loop to have my objects x position to += vx(1 through 4):
PHP Code:
for (var i:Number=0; i<5; i++)
{
this.x += (vx+[i]);
}
So I tried the above with a combination of " " around different parts of (vx+[i]) but I realized that turning any of it into a string means 'this.x' cannot read it because x has to be a number not a string.
So how can I make this.x = vx1 then vx2 and so on with a for loop?
Thanks