all groups > flash actionscript > february 2008 >
You're in the

flash actionscript

group:

Clearing ListBox Items Out


Clearing ListBox Items Out lingowizard
2/12/2004 10:39:20 PM
flash actionscript:
I am using the Listbox component that ships with Flash MX and have 2 radio
buttons that toggle the list of items in the listbox - 2 different sets of
items. The problem is that when you click the radio buttons it just adds the
particular array of items to the existing list, so it it keeps getting longer
and longer

[b]I've tried:[/b
myListBox.removeAl

and this..

function supplierChoice1()
_root.company_List.removeAll
companyLength_old = _root.company_List.length
cindex = 0
while(cindex < companyLength_old)
_root.company_List.removeItemAt(cindex)
cindex++
}
companyLength = _root.companyNames1.length
cindex = 0
while(cindex < companyLength)
_root.company_List.addItemAt(cindex, _root.companyNames1[cindex],
_root.companyProducts1[cindex])
cindex++


trace("supplier")
updateAfterEvent()



This is the change handler for the radio button of the first company list.
"company.List" is the listBox component name

Is there a way to just reset the whole component to it's initial state? or
empty its contents? Thanks

Re: Clearing ListBox Items Out lingowizard
2/13/2004 4:34:21 PM
I came across that I need to put the myListBox.removeAll in a different frame -
but that doesn't work. I know I am making a simple mistake. So if anyone knows
how to clear the items in the supplied component listbox out so I can refill it
with a different list of items please help. I also made separate frames to be
called by the change handler for the radio buttons - which work. Then I made a
function to removeAll the items from the list box

...but that doesn't work. Why wouldn't [b]removeAll[/b] work
Re: Clearing ListBox Items Out lingowizard
2/13/2004 5:58:04 PM
I'd like to thank myself for coming to the rescue. I am a great help to myself.

I figured it out. Problem solved. Ignore any further babbling I may post.
Perhaps the act of mere posting the question jiggled some glial cells in my
brain and helped. To bad I won't tell what the solution is since no one
bothered with a reply - any one doing a search and reading this I am really,
very truly sorry.

Did you read this far,...I said ignore further babbling above. Perhaps that
was the solution. Actually reading what I was scripting! Ha! to all of you who
are experiencing high blood pressure right now

Re: Clearing ListBox Items Out Jack
2/13/2004 10:49:19 PM

"lingowizard" babbled .. To bad I won't tell what the solution is since no
one bothered with a reply

What a wanka, king-size even :((

Twit Filter ON :)

RE: Clearing ListBox Items Out Natacha
2/19/2008 6:37:37 PM
To everyone looking for a solution for this, (no thanks to the unhelpful twit) calling invalidateList() works for me:

videoList.dataProvider = new DataProvider(listArr);
videoList.invalidateList();

(invalidateList redraws the list - you don't need to remove any element in the list if you reset it's item using a new dataprovider)

From http://www.developmentnow.com/g/69_2004_2_0_0_336076/Clearing-ListBox-Items-Out.htm

Posted via DevelopmentNow.com Groups
AddThis Social Bookmark Button