ActionScript - List component in flash

Discussion in 'Programming' started by Dollar, Feb 4, 2008.

  1. #1
    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/"} ); 
    PHP:
    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.
    PHP:
    So something in the actionscript is undefined. How to fix this actionscript?
     
    Dollar, Feb 4, 2008 IP
  2. wassim

    wassim Well-Known Member

    Messages:
    322
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    110
    #2
    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/"});
     
    wassim, Feb 5, 2008 IP
  3. Dollar

    Dollar Active Member

    Messages:
    2,598
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    90
    #3
    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/"});
    
    PHP:
     
    Dollar, Feb 5, 2008 IP