I created a VectorModel(store vector data like start and end point) and VectorView(to display vector) classes.

I wanted to create two circle(c1 and c2) and display a vector between each circle and mouse position(v1 and v2), then display the smallest vector only.(if mouse get closer to c1 display v1 only, if its closer to c2, display v2 only).
v1 and v2 are two VectorModel instance.

I want to know if its possible to create a single VectorView Instance and pass it a VectorModel parameter each time.
that's how i tried to do that:

private function enterFrame(e:Event):void
{
//update v1 and v2
_v1.update(_c1.x, _c1.y, mouseX, mouseY);
_v2.update(_c2.x, _c2.y, mouseX, mouseY);

if (_v1.m < _v2.m)
{//display v1
displayVector(_v1);
}else if(_v1.m > _v2.m)
{//display v2
displayVector(_v2);
}
}

private function displayVector(v:VectorModel):void
{
var vView:VectorView = new VectorView(v);
addChild(vView);
}


the result display two line(vector) between each circle and mouse position


I tried to solve this issue by creating a VectorView for each VectorModel and it worked despite thise error:
Error #1009: Cannot access a property or method of a null object reference.

private function enterFrame(e:Event):void
{
//update v1 and v2
_v1.update(_c1.x, _c1.y, mouseX, mouseY);
_v2.update(_c2.x, _c2.y, mouseX, mouseY);

if (_v1.m < _v2.m)
{//display v1
displayVector("v1");
}else if(_v1.m > _v2.m)
{//display v2
displayVector("v2");
}
}

private function displayVector(v:String):void
{
if (v=="v1")
{
addChild(_v1View);
if (_v2View.parent!=null)
{
removeChild(_v2View);
}

}else if(v=="v2")
{
addChild(_v2View);
if (_v1View.parent!=null)
{
removeChild(_v1View);
}
}
}

thank you for your time and for your help