从 TileList 检索标签值 (Flash CS5 AS3)

发布于 2024-12-08 17:51:32 字数 1109 浏览 0 评论 0原文

我有一个 TileList,我加载了一个 PHP 脚本,该脚本返回动态生成的 xml,以便我可以加载 TileList 及其所需的图像和标签。

现在,我想单击 TileList 的一个项目并检索其标签,以便我可以将其发送到另一个 PHP 脚本,该脚本使用标签的字符串进行搜索查询,以便我可以将纬度和经度加载到地图上项目位于。

我一直试图追踪它,但没有成功。

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");

    }

}

我需要帮助,我不知道如何从 TileList 上单击的项目中检索标签。

我正在使用 Flash CS5。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

虚拟世界 2024-12-15 17:51:32
// this should live somewhere in your code:
var path:String = "http://localhost/entretenimiento.php";
var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.addEventListener(Event.COMPLETE, onComplete);
    xmlLoader.load( new URLRequest( path ));

private function onComplete(e:Event):void
{
    // XML works just fine as a data provider, you don't need the loop.
    myTileList.dataProvider = new DataProvider(new XML(e.target.data));
    // You can assign which properties of the xml the list uses.
    myTileList.sourceField = "e_imagen";
    myTileList.labelField = "e_nombre"; 
    // I'm assuming that the goal is to have the user select an item, 
    //     so we'll register to listen for a click.
    myTileList.addEventListener( MouseEvent.CLICK, listListener );
}

private function listListener(e:Event):void
{
    /* 
    Because we're listening for a click, and the listener is registered to the list
    make sure that what we've clicked is an item (a CellRenderer) and not the
    background or something.
    */

    if ( getDefinitionByName(getQualifiedClassName(e.target)) == CellRenderer )
    {
        // You can call your other web service from here.
        // The "target" is a CellRenderer, and its data is an XML node.
        trace(e.target.data.label);
    }
}
// this should live somewhere in your code:
var path:String = "http://localhost/entretenimiento.php";
var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.addEventListener(Event.COMPLETE, onComplete);
    xmlLoader.load( new URLRequest( path ));

private function onComplete(e:Event):void
{
    // XML works just fine as a data provider, you don't need the loop.
    myTileList.dataProvider = new DataProvider(new XML(e.target.data));
    // You can assign which properties of the xml the list uses.
    myTileList.sourceField = "e_imagen";
    myTileList.labelField = "e_nombre"; 
    // I'm assuming that the goal is to have the user select an item, 
    //     so we'll register to listen for a click.
    myTileList.addEventListener( MouseEvent.CLICK, listListener );
}

private function listListener(e:Event):void
{
    /* 
    Because we're listening for a click, and the listener is registered to the list
    make sure that what we've clicked is an item (a CellRenderer) and not the
    background or something.
    */

    if ( getDefinitionByName(getQualifiedClassName(e.target)) == CellRenderer )
    {
        // You can call your other web service from here.
        // The "target" is a CellRenderer, and its data is an XML node.
        trace(e.target.data.label);
    }
}
探春 2024-12-15 17:51:32

好吧,嗯……

这很简单,午睡后我只是坐下来尝试一下,它给了我我想要的东西。

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);

  }

}

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);

  }

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文