title: Flex 3: removing items from an array collection when the user clicks a button and reflecting that in a repeater
body: <p>I have an arrayCollection with the following structure:</p>
  
  <pre><code>projectErrorsAC
      0
          project1number
          project2number
          position1number
          position2number
          project1name
          project2name
          student
      1
          ...
  </code></pre>
  
  <p>the AC is defined as follows:</p>
  
  <pre><code>[Bindable] private var projectErrorsAC:ArrayCollection = new ArrayCollection;
  </code></pre>
  
  <p>I'm using this AC in a repeater to display each error.  After each error is shown, I've placed an "Accept" and "Deny" button.  Once the user clicks either one of these buttons, I'd like to call a function that removes the particular error from the AC.  Here's what I have so far:</p>
  
  <p>Repeater:</p>
  
  <pre><code>&lt;mx:Repeater id="projRP" width="100%" dataProvider="{projectErrorsAC}"&gt;
  &lt;mx:HBox&gt;
      &lt;mx:Text id="projmsg" text="{projRP.currentItem.student} is working on the following projects on the same day: {projRP.currentItem.proj1name} and {projRP.currentItem.proj2name}." /&gt;
      &lt;mx:Text id="allow" text="Allow" color="#ff0000" selectable="false" 
          click="acceptProjConflict(projRP.currentItem);" 
          mouseOver="parentApplication.switchCursor(true);" 
          mouseOut="parentApplication.switchCursor(false);" /&gt;
      &lt;mx:Text text=" |" /&gt;
      &lt;mx:Text id="decline" text="Decline" color="#ff0000" selectable="false" click="declineProjConflict(projRP.currentItem);" mouseOver="parentApplication.switchCursor(true);" mouseOut="parentApplication.switchCursor(false);" /&gt;
  &lt;/mx:HBox&gt;
  &lt;/mx:Repeater&gt;
  </code></pre>
  
  <p>and here's the function I'm calling in the "click" part:</p>
  
  <pre><code>public function acceptProjConflict(conflict:Object):void
  {
  for (var i:int = 0; i &lt; projectErrorsAC.length; i++)
  {
      if (projectErrorsAC.getItemAt(i) == conflict)
          projectErrorsAC.removeItemAt(i);
  }               
  }
  </code></pre>
  
  <p>for some reason, this isn't working... </p>
  
  <p><strong>* EDIT *</strong></p>
  
  <p>SUCCESS!</p>
  
  <p>I had to create a module to put inside the repeater - the repeater now looks like this:</p>
  
  <pre><code>&lt;mx:Repeater id="projRP" width="100%" dataProvider="{projectErrorsAC}"&gt;
      &lt;conflict:showErrors id="projErrors" thisObject="{projRP.currentItem}" isProject="true"/&gt;
  &lt;/mx:Repeater&gt;
  </code></pre>
  
  <p>and my module looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();"&gt;
          &lt;mx:Script&gt;
              &lt;![CDATA[
                  public var isProject:Boolean;
                  public var thisObject:Object;
                  [Bindable] public var displayString:String = new String;
  
                  private function init():void
                  {
                      if (isProject)
                      {
                          displayString = thisObject.student + " is working on the following projects on the same day: " + thisObject.proj1name + " and " + thisObject.proj2name + ".";
                      }
                  }
              ]]&gt;
          &lt;/mx:Script&gt;
  
      &lt;mx:Canvas width="750"&gt;
          &lt;mx:HBox&gt;
              &lt;mx:Text id="projmsg" text="{displayString}" /&gt;
              &lt;mx:Text id="allow" text="Allow" color="#ff0000" selectable="false" click="parentDocument.acceptProjConflict(thisObject)" mouseOver="parentApplication.switchCursor(true);" mouseOut="parentApplication.switchCursor(false);" /&gt;
              &lt;mx:Text text=" |" /&gt;
              &lt;mx:Text id="decline" text="Decline" color="#ff0000" selectable="false" click="parentDocument.declineProjConflict(thisObject);" mouseOver="parentApplication.switchCursor(true);" mouseOut="parentApplication.switchCursor(false);" /&gt;
          &lt;/mx:HBox&gt;
      &lt;/mx:Canvas&gt;
  &lt;/mx:Module&gt;
  </code></pre>