PDA

View Full Version : using addItem in a for loop


daveMcNally
01-23-2003, 11:20 AM
hi

i'm trying to populate a combo box list from within a for loop using the addItem method. the data is coming from a sharedobject called data.Saved. i can see the data in the object using trace but the combo will not populate. the Saved object contains and array which contains the previously enterd data.

onClipEvent (load) {
// get data from the object Files
Files = SharedObject.getLocal("Files");
save = Files.data.numberSaved;
trace(save+" "+Files.data.Saved);
for (i=1; i<=save; i++) {
inpu = Files.data.Saved[i];
SaveBox.addItem(inpu);
}
}

farafiro
01-23-2003, 12:35 PM
I think u the save in the for should be save.length

daveMcNally
01-23-2003, 01:05 PM
the save is an integer value loaded in the object from another part of the code. it tells me how many times the save button has been pressed

farafiro
01-23-2003, 01:10 PM
oops, sorry.
but what is the "numberSaved"?

daveMcNally
01-23-2003, 01:26 PM
this code lives on a button which is used to load text from and input text box to the combobox

FileSave is an array that contains all the file names entered
save is a counter that incs every time the button is pressed

this data is loaded into the sharedObject using the following code....
Files = SharedObject.getLocal("Files");
Files.data.Saved = FileSave;
Files.data.numberSaved = save;

when i quit then restart the movie i can recover the data from the shared objects using....

Files = SharedObject.getLocal("Files");
save = Files.data.numberSaved;
for (i=1; i<=save; i++) {
inpu = Files.data.Saved[i];
trace(inpu);
SaveBox.addItem(inpu);
}

where Files is the name of the object numberSaved is the inteder value of save and Saved contains the array of file names entered

incidently...the addItem method works fine on the button but not in the MC where this code is placed....

daveMcNally
01-23-2003, 02:03 PM
i've sussed it

basic pathing error doh....

SaveBox.addItem(inpu)

should have been..

_root.SaveBox.addItem(inpu)

thanks for the help though...