View Full Version : List and delete SO items.
TonyL
09-13-2006, 03:06 PM
:confused: :confused: :confused:
Is it actually possible to remove single items from a SO array?
I have a user-defined list of URLs which are stored as an array in a SO. When the user access the movie this SO populates a Combo box. This part is fine, works well and I am happy with it.
What I want to do now is load this SO into a list where the user can remove a single url, then update the SO to reflect the change... But, if I access the SO manually and remove an element, the whole list is deleted. Is it actually possible to do this?
I would post code etc, but, I haven't coded anything as yet, because, on the face of it, it appears impossible to remove a single element from the array inside the SO???
Thanks in advance.
mcmcom
09-13-2006, 04:01 PM
i think the only way around it is to re-collect the whole SO, put it in flash as an array, then let the user delete one item. Delete the Entire SO and re-write the new array (minus one item) back into the SO (overwriting the whole SO) the only difference to the user is one item removed from it. Wether you kill the entire SO or not is irrelavant because you have the entire collection in flash by the time you need it anyways.
hth,
mcm
TonyL
09-13-2006, 04:06 PM
Just sitting here thinking about it and thats pretty much the page I was on. recreating the SO everytime...
Can this be done from a Combo box? Load the array into combo box items then remove as appropriate and rewrite the SO?
mcmcom
09-13-2006, 04:18 PM
ya totally,
how are you getting the items from the SO TO the combobox, just do the reverse of that.
Create an array
Populate the array from the combobox
Overwrite the SO with that array.
only diff to the user will be one less item in the SO.
hth,
mcm
TonyL
09-13-2006, 05:23 PM
Ok, I'm pretty much there now. Any idea how to get the item count for the ComboBox.
Basically what I am doing is a for loop:
for (var i = 0;var i=0; i<_root.ComboBox.items.Count; i++)
newSite = new Object();
newSite.site = _root.ComboBox.selectedItem.data;
newSite.siteurl = _root.ComboBox.selectedItem.label;
//...
dataArray.push(newFeed);
}
but _root.ComboBox.items.Count returns undefined...?
TonyL
09-13-2006, 05:31 PM
Thats cool. fixed it. _root.ComboBox.length
TonyL
09-14-2006, 09:30 AM
Almost there now...
I can't seem to get the remaining values in an array correct. I have looped through the items in the combobox and the code is creating a correct length array, but, every element of the array is populated by the values in the 0 index...? Code below:
_root.ComboBox.removeItemAt(_root.ComboBox.selecte dIndex);
_root.ComboBox.selectedIndex = 0;
_root.local_data.clear();
var dataArray = new Array();
newFeed = new Object();
for (var i=0; i<_root.ComboBox.length; i++) {
newFeed.site = _root.ComboBox.getItemAt(i).data;
newFeed.siteurl = _root.ComboBox.getItemAt(i).label;
dataArray.push(newFeed);
}
_root.local_data.data.myList = dataArray;
_root.local_data.flush();
Anybody got any ideas? Thanks in advance.
TonyL
09-14-2006, 02:18 PM
Fixed it!
For those of you interested. updated code below:
var dataArray = new Array();
newFeed = new Object();
for (var i=0; i<_root.ComboBox.length; i++) {
newFeed[i] = new Object();
newFeed[i].site = _root.ComboBox.getItemAt(i).data;
newFeed[i].siteurl = _root.ComboBox.getItemAt(i).label;
trace(i);
trace(newFeed[i].site);
trace(newFeed[i].siteurl);
dataArray.push(newFeed[i]);
}
trace(dataArray);
// add array to FeedList Object
_root.local_data.data.myList = dataArray;
_root.local_data.flush()
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.