lines = new SegmentSet();
_view.scene.addChild(lines);
var line:LineSegment = new LineSegment(new Vector3D(0,0,0),new Vector3D(100,0,0),0x8cb1d6,0x8cb1d6,2);
var line1:LineSegment = new LineSegment(new Vector3D(100,0,0),new Vector3D(0,0,0),0x8cb1d6,0x8cb1d6,2);
lines.addSegment(line);
lines.addSegment(line1);
lines.removeSegment(line1);
The FlashPlayer shows Error that out of index.
I tracked the removeSegment method of SegmentSet Class
public function removeSegment( segment:Segment ):void {
//to do, add support curve indices/offset
var index:uint;
for( var i:uint = 0; i < _segments.length; ++i ) {
if( _segments[i] == segment ) {
_segments.splice( i, 1 );
removeSegmentByIndex( segment.index );
_lineCount--;
} else {
_segments[i].index = index;
index += 6;
}
}
_vertexBufferDirty = true;
_indexBufferDirty = true;
}
After I add a new code between _segments.splice(i, 1); and remove(segment.index); then ,it works…
_segments.splice(i, 1);
segment.index = index;
remove(segment.index);