I'm stuck thinking about the best way to go about setting a line segment's position, I have a class Line(length, angle, previous) being called from a class Polygon.. Right now I have:
public class Line extends Sprite {
public function Line(length:Number, angle:Number, previous:Line = null) {
if (previous != null) {
this.x = previous.end.x;
this.y = previous.end.y;
} else {
this.x = 0;
this.y = 0;
}
/**/
}
}
Now, is this the best practice or should I be doing:
Polygon.addLine(length:Number, angle:Number):void {
var previous = (_line.length == 0) ? null : _line[_line.length - 1]; // Array containing all Lines
var line:Line = new Line(length, angle, previous);
line.x = (_line.length == 0) ? 0 : previous.end.x;
line.y = (_line.length == 0) ? 0 : previous.end.y;
/**/
}
One thing to add, Line is only used by Polygon in this application.