title: how to display multiple model data with a single view--mvc
body: <p>I created a VectorModel(store vector data like start and end point) and VectorView(to display vector) classes.</p>
  
  <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>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 &lt; _v2.m)
      {//display v1
            displayVector(_v1);
      }else if(_v1.m &gt; _v2.m)
      {//display v2
           displayVector(_v2);
      }
  }
  
  private function displayVector(v:VectorModel):void
  {
       var vView:VectorView = new VectorView(v);
       addChild(vView);
  }
  </code></pre>
  
  <p>the result display two line(vector) between each circle and mouse position</p>
  
  <p>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.(how to get around this?)</p>
  
  <pre><code>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 &lt; _v2.m)
      {//display v1
          displayVector("v1");
      }else if(_v1.m &gt; _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);
          }
     }
  }
  </code></pre>
  
  <p>is there better way to do it?
  thank you for your time and for your help ;)</p>