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??
...
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);
}
...
private function handlePointClicked(event:MouseEvent):void
{
trace('test: '+event.target.name) // Display last index item clicked
displayPointsType(event.target.name);
}
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;
}
}