I found a way to not overwritten my last value, it’s working fine but want to make cleaner, more dynamic.
Is there a better way to make it?
here’s my current code:
private function handleMarkers(event:CustomEventCenter):void
{
// Get the complete xml List of data info from custom dispatcher
var xmlListData = event._name.xmlList;
var counter:uint = 0;
var tabResult:Array = new Array();
for each (var item:XML in xmlListData)
{
if (counter < xmlListData.length())
{
// Search to find the type '01' to the correct index position
if (item.@type.indexOf('01') == 0)
{
// Return the right info
var pointID = item.@type;
var name = item.name;
counter++;
createMarkers(pointID, name);
} else if(item.@type.indexOf('05') == 0) {
var pointID2 = item.@type;
var name2 = item.name;
counter++;
createMarkers(pointID2, name2);
} else if(item.@type.indexOf('06') == 0) {
var pointID3 = item.@type;
var name3 = item.name;
counter++;
createMarkers(pointID3, name3);
}
}
}
// Defined positions for button
var xPos = 20;
var yPos = 20;
var space:uint = 40;
// Create buttons
for (var i=0;i<3;i++) {
pointID = new PointID();
pointID.index = i;
pointID.x = xPos;
pointID.y = yPos;
xPos += i*20 + space;
pointID.buttonMode = true;
switch(pointID.index) {
case 0:
pointID.name = String(pointID);
break;
case 1:
pointID.name = String(pointID2);
break;
case 2:
pointID.name = String(pointID3);
break;
}
addChild(pointID);
pointRepere.addEventListener(MouseEvent.CLICK, handlePointClicked);
}
}