EinReaper 0 Report post Posted October 22, 2008 (edited) Hello!I have a list component in a fla. When I click a button, I add items to the list. (using list.addItem )The problem is that every time I add new items I want to refresh the list; this means that I want to delete all items that are in the list and leave only the new ones.Is there anyway to do this using only one function?(I know that I can use list.removeItem , but that would mean I have to delete every item in the list one by one). Edited October 22, 2008 by EinReaper (see edit history) Share this post Link to post Share on other sites
galexcd 0 Report post Posted October 22, 2008 You can use the removeAll() method to remove all items in a list. Here is more information on the method. Share this post Link to post Share on other sites
EinReaper 0 Report post Posted October 23, 2008 (edited) Thank you.removeAll() does indeed do the trick.But now I have another problem: when I select a field from the list what's the variable that holds the data for this field? Any field has a label (the thing you see) and a data (the variable underneath).I've tried list.data (where list is the instance name for my list), but this returns 'undefined'.I have a similar situation for a ComboBox; if I use combobox.text it returns the label for the field I selected, but I don't know how to access the data. Edited October 23, 2008 by EinReaper (see edit history) Share this post Link to post Share on other sites
galexcd 0 Report post Posted October 24, 2008 Thank you.removeAll() does indeed do the trick.But now I have another problem: when I select a field from the list what's the variable that holds the data for this field? Any field has a label (the thing you see) and a data (the variable underneath).I've tried list.data (where list is the instance name for my list), but this returns 'undefined'.I have a similar situation for a ComboBox; if I use combobox.text it returns the label for the field I selected, but I don't know how to access the data. i haven't mettled with the list component for some time but if I recall correctly list.data returns an array. Have you tried list.data[0]? Share this post Link to post Share on other sites
EinReaper 0 Report post Posted October 27, 2008 (edited) I haven't tried that because I'm looking for a function that returns data for a selected item, not an item located at position i.I have found something that might help: list.selectedItem.data . The problem is that this returns the correct value for list.selectedItem.label , but it returns 'undefined' for list.selectedItem.data.I'm not sure what I'm doing wrong...Later Edit: as it turns out list.selectedItem.data was the proper function to use. The problem was that I wasn't inserting data correctly into the items. Edited October 27, 2008 by EinReaper (see edit history) Share this post Link to post Share on other sites
Nabb 0 Report post Posted October 27, 2008 (edited) How are you using the addItem function call? There are two ways to use it, the first is list.addItem("label","data"); The second is list.addItem({label:"label", data:"data"}); Both should work to all you to retrieve the data using list.selectedItem.data. There is another method to add a label to the list but as far as I know, it doesn't allow you to store data with it. (list.label.push("label"), but list.data.push("data") fails) Note that you can store data in an array elsewhere if desired and push to it seperately to calling addItem (or define a function which does both ), and retrieve the data from the array by using array[list.selectedIndex].. ...okay I see you've fixed your error (saw the update when using preview post), but I'll leave this post here to inform anyone who might later need this! Edited October 27, 2008 by Nabb (see edit history) Share this post Link to post Share on other sites
EinReaper 0 Report post Posted October 27, 2008 Well, I was using the first method: list.addItem("label","data") , but for some reason it didn't work. The second method works just fine: list.addItem({label:"label", data:"data"}) Share this post Link to post Share on other sites
sarankarthi 0 Report post Posted May 28, 2009 (edited) hey therei need the vb.net code details to read the particular line of text document from the local computer.. please anybody could help me...________Zen Edited May 28, 2009 by sarankarthi (see edit history) Share this post Link to post Share on other sites