Loans - Mortgages - Articles - Remortgages - Mortgages

PDA

View Full Version : ActionScript - List component in flash


Dollar
Feb 4th 2008, 7:52 am
Anyone here help me with this?
I've already tried actionscript.org and the boneheads there don't reply. In fact I think the logged in members are not even real on that forum....

I want to create a list component with a links in them.

This is what I have. The list component's Instance name is "list"

var listener:Object = new Object();
listener.change = function(event) {
trace("You selected: "+event.target.selectedItem.label);
getURL(event.target.selectedItem.link);
}
list.addEventListener("change",listener);
list.addItem("somesite.com",{label:currentTerm,link:"http://www.somesite.com/"} );

Okay when I click on it, the trace pops up saying "somesite.com"
and my browser says.

Firefox can't find the file at /C|/DOCUME~1/COMPAQ~1/LOCALS~1/Temp/undefined.

So something in the actionscript is undefined. How to fix this actionscript?

wassim
Feb 5th 2008, 1:09 pm
Hi,
You have an issue in your code, I wont waste your time and mine explaining it, here is the correct way of doing this:

var listener:Object = new Object();
listener.change = function(evt) {
trace("You selected: "+evt.target.selectedItem.link);
getURL(evt.target.selectedItem.link);
};
list.addEventListener("change",listener);
list.addItem({label:"somesite.com", link:"http://www.somesite.com/"});

Dollar
Feb 5th 2008, 1:36 pm
Thanks but Someone else on another forum came up with this and it works in the same way.

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

list.addItem({label:"thesite.com",data:"http://www.thesite.com/"});