flashactionscript-3labeltracetilelist

retrieve the label value from a TileList (Flash CS5 AS3)


I have a TileList, that i loaded with a PHP script that gives back an dinamically generated xml so i can load the TileList with the images and labels it needs.

Now, i want to click on an item of the TileList an retrieve its Label so i can send it to another PHP script that uses the string of the Label to do a search query so i can load latitud and longitude to a map to where that item is located.

i have been trying to trace it, but its a no go.

var path:String = "http://localhost/entretenimiento.php";
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, onLoadComplete);
xmlLoader.load(new URLRequest(path));       

function onLoadComplete(e:Event):void {
    System.disposeXML(xmlData);
    var xmlData:XML = new XML(e.target.data);
    //trace(xmlData);

    for (var i:int=0; i<xmlData.e_nombre.length(); i++)
    {
        myTileList.addItem({label:xmlData.e_nombre[i], source:xmlData.e_imagen[i]});
        //trace(xmlData.e_nombre[i]);
    }

    var display;
    myTileList.addEventListener(Event.CHANGE, listListener);
    myTileList.selectedIndex = 0;

    function listListener(event:Event):void {
    display.source = myTileList.selectedItem.label;
    trace(display.source);
    trace("working");

    }

}

I need help, i dont know how to retrieve the label from item clicked on the TileList.

Im using Flash CS5.


Solution

  • Ok, well...

    this was simple, after a nap i just sat down and tried this and it gave me what i wanted.

    var path:String = "http://localhost/entretenimiento.php";
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.addEventListener(Event.COMPLETE, onLoadComplete);
    xmlLoader.load(new URLRequest(path));       
    
    function onLoadComplete(e:Event):void {
      System.disposeXML(xmlData);
      var xmlData:XML = new XML(e.target.data);
      //trace(xmlData);
    
      for (var i:int=0; i<xmlData.e_nombre.length(); i++)
      {
          myTileList.addItem({label:xmlData.e_nombre[i], source:xmlData.e_imagen[i]});
          //trace(xmlData.e_nombre[i]);
      }
    
      myTileList.addEventListener(Event.CHANGE, listListener);
      myTileList.selectedIndex = 0;
    
      function listListener(event:Event):void {
    
      trace(myTileList.selectedItem.label);
    
      }
    
    }