Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

Listener Objects and XML List Components

I was given some code here that allowed me to populate a list component with my XML.  That thread and code is here:

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_21314467.html

Now, I'm trying to understand how my listener can know how to associate the item that was clicked on in the list with a different item in my xml. Here is my listener object:

var nodes:Array = _root.songList.firstChild.childNodes;

for(var i:Number = 0; i < nodes.length; i++){
      var children:Array = nodes[i].childNodes;
      _root.song_list.addItem(children[0].firstChild.nodeValue, children);
}
      var listener:Object = new Object();
      listener.change = function(evt:Object):Void
{
      var data:Object = evt._root.song_list.selectedItem.data;
};
_root.song_list.addEventListener("change", listener);

It's watching change to the list componet with the instance name of song_list.  The code I have works, I'm just trying to understand it so I can implement it in a slightly different way elsewhere.  I need to understand how the listener know which node was selected so I can access other associated data for that node (if I'm saying that correctly).
0
Aspirin99
Asked:
Aspirin99
1 Solution
 
BuffonCommented:
you get in you function as parameter "evt:Object", this event object contains properties (properties that contain information about the event) for example:
evt.target      <<----         a reference to the component instance broadcasting the event


so in this case, instead of:
evt._root.song_list.selectedItem.data
you can write:
evt.target.data


evt.target is a cell you update and it has properties like data and label.
0
 
Aspirin99Author Commented:
I'm just not making the connection. I'll study some more and see if I can ask the question better.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now