Question about position.x
I run a demo code,it extends Sprite,like follows:
public class Vehicle extends Sprite{
protected var _position:Vector2D;
public function Vehicle(){
_position = new Vector2D();
draw();
}
protected function draw():void{
graphics.clear();
graphics.lineStyle(0);
graphics.moveTo(10, 0);
graphics.lineTo(-10, 5);
graphics.lineTo(-10, -5);
graphics.lineTo(10, 0);
}
public function update():void{
_position = _position.add(_velocity);
x = position.x;
y = position.y;
}
}
I don't understand following code,because I only define _position and don't define position variable,why I can use position.x?
x = position.x;
y = position.y;
Any idea will be appreciated!