# How to assign the correct items of each mc?

**URL:** <https://forum.kirupa.com/t/how-to-assign-the-correct-items-of-each-mc/300054>\
**Category:** Uncategorized\
**Created:** [November 15, 2009, 3:06pm UTC](https://forum.kirupa.com/t/how-to-assign-the-correct-items-of-each-mc/300054 "2009-11-15T15:06:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![qpixo](https://avatars.discourse-cdn.com/v4/letter/q/c4cdca/32.png) [@qpixo](https://forum.kirupa.com/u/qpixo)\
**Post date:** [November 15, 2009, 3:06pm UTC](https://forum.kirupa.com/t/how-to-assign-the-correct-items-of-each-mc/300054/1 "2009-11-15T15:06:38Z")

</div>

I have 2 buttons and tried to assign each of them a group of points to display on stage using visible. I have no issue to do the xml parsing but when I click on each of buttons It’s ONLY show up the last index items of the xml that I parsed.

What I want to do is to assign each of my 2 or more buttons a different group of points.

EX: button\_mc1 -\> load point ID in tabPoints which is 2 points  
button\_mc2 -\> load point ID in tabPoints which is 5 points

Current problem is:  
button\_mc1 -\> load point ID in tabPoints which is 5 points  
button\_mc2 -\> load point ID in tabPoints which is 5 points

Does anyone know a way to resolve that??

```auto

...
var count:int = 0;
var point:PointMC;

// Here I create 2 points and want to assign each of them the correct pointID so every 
// time when I click, it will load the CORRECT groups of points defined.
for (var i=0;i<2;i++)
{
         point_mc = new PointMC();
         point_mc.name = pointID; // get ID on XML file
         point_mc.index = count++;
                
         point_mc.x = xPos;
         point_mc.y = yPos;
         yPos += i*20 + 40;
         point_mc.buttonMode = true;
                
         addChild(point_mc);
                
         trace("PtName: "+point_mc.name); // Always return last index item 
            
         point_mc.addEventListener(MouseEvent.CLICK, handlePointClicked);
}

```

```auto

...
private function handlePointClicked(event:MouseEvent):void
{
            trace('test: '+event.target.name) // Display last index item clicked
            displayPointsType(event.target.name);
}

```

```auto

private function displayMarkerType(id:String):void
{
   for (var i=0; i< pointMC.tabPoint[id].points.length; i++)
   {
      var point:Marker = pointMC.tabPoint[id].points*;
      (!point.visible) ? point.visible = true : point.visible = false;    
    }
}

```
