View Full Version : listBox bug or what?

04-07-2003, 07:13 PM
Well, folks... I have a default listBox named msg_queue.
and I made this:

keyboard = {};

keyboard.onKeyDown = function(){
var temp;
temp = String.fromCharCode((random(25)+65));
temp += String.fromCharCode((random(25)+65));



This code will add a random two character Item to my
msg_queue listBox, everytime a key is pressed.
I made this just for testing my application.

and so, I added one button named bt_erase the code for it is:

bt_erase.onRelease = function(){
var actual_index = msg_queue.getSelectedIndex();

As I press any key, it will add one Item,
and as I select any item and click to erase,
it will remove the selected item from the listbox.

This thing works fine.

but if I add some 5 items (for example), revome them all,
and try to add another item, my application stops running,
like it was running an infinite loop. flash says:

"A script in this movie is causing Flash Player to run slowly.
If it continues to run, you computer may become unresponsive.
Do you want to abort the script?"

Iīve already fixed the problem, but this doesnīt make sense.

why the heck it isnīt working?



04-07-2003, 07:24 PM
I think whats happening is when there are no items left and the button is clicked, it is hanging on trying to get the selected index and removing the selected item. Instead add a check for number of items.

function eraseItem(){
if(msg_queue.getLength() > 0) {
var actual_index = msg_queue.getSelectedIndex();

04-07-2003, 08:12 PM
Yeah, sure...

I though that way too...

but Iīve changed the keyPress for addItem
to a button onRelease event.

And that works fine.

Thatīs why Iīm very curious about this thing.

I havenīt changed any script on my add/remove functions.

I have just changed the way I enter data...

The fla is attached