Flash AS3:
Does anyone know how to load items one at a time instead of loading in loop at a normal process using AS3? I'm having problem with overwritten value.
I couldn't make that work, it's always overwritten the last value.I tried to use the dictionary and though it will help to resolve my problem...
I want to be able for EACH button when I clicked it displays the visibility of my markers.
private function handleMarkers(event:CustomEventCenter):void
{
// Get items info from custom dispatcher
var nom = event._name.nom;
...
var tabMarkerID:Array = new Array();
// Defined positions for button
var xPos = 20;
var yPos = 0;
// Store the right markerID into each index separated
if (event._name.markerID == '01') {
tabMarkerID[0] = event._name.markerID;
} else if (event._name.markerID == '05') {
tabMarkerID[1] = event._name.markerID;
}
// Create a dictionary
var dict:Dictionary = new Dictionary();
// Create arrondissement objects for 14 available markers
var arrond1:Object = new Object();
var arrond2:Object = new Object();
dict[arrond1] = tabMarkerID[0];
dict[arrond2] = tabMarkerID[1];
for (var i=0;i<2;i++)
{
pointRepere = new PointRepere();
for (var item:Object in dict)
{
if (dict[item] != undefined) {
pointRepere.name = String(dict[item]); // here the issue
pointRepere.x = xPos;
pointRepere.y = yPos;
yPos += i*20 + 40;
pointRepere.buttonMode = true;
addChild(pointRepere);
createMarkers(dict[item], nom);
pointRepere.addEventListener(MouseEvent.CLICK, handlePointClicked);
}
}
}
}
private function handlePointClicked(event:MouseEvent):void
{
trace("Name: "+event.target.name);
displayMarkerType(event.target.name);
}
private function displayMarkerType(id:String):void
{
for (var i=0; i< _marker.tabArrondMarker[id].markers.length; i++)
{
var marker:Marker = _marker.tabArrondMarker[id].markers[i];
(!marker.visible) ? marker.visible = true : marker.visible = false;
}
}