PDA

View Full Version : Adding getURL's to a List component


mspieg
12-06-2005, 07:34 PM
Hi,
I have a List Component which is being populated with the following script:

rightList.addItem({label:currentTerm,link:"link1"});

I would like to set it up so that when you click on one of the list items, it would launch a GetURL:"javascript". How can I pass the URL's to the List Item?

thanks!

Paerez
12-06-2005, 08:04 PM
use an event listener for "change" (when a list item is clicked, and it isn't already clicked). The url will be in event.target.selectedItem.link, because you added it to "link" in your initObj.

var listener:Object = new Object();
listener.change = function(event) {
trace("You selected: "+event.target.selectedItem.label);
getURL(event.target.selectedItem.link);
}
rightList.addEventListener("change",listener);

mspieg
12-08-2005, 06:55 PM
use an event listener for "change" (when a list item is clicked, and it isn't already clicked). The url will be in event.target.selectedItem.link, because you added it to "link" in your initObj.


Will this still work if you dont use initObj, if the list component is just placed on the stage?

thanks,

Paerez
12-09-2005, 04:01 PM
I was calling:

{label:currentTerm,link:"link1"}

that your initObj. It is an object you created on the fly to pass into the addItem method and it had initializing variables. And yes, it will work if you place it on the stage.