Accordian Help/maybe use a dataset?

Hi all.

I have an Accordian component with 2 children hard coded in, I dynamically load create children into these accodians children to have a 2 level accordian. I also have need to destry the children via a delete button on each individual one. Everything works fine, until, I destroy a child.

After destroying a child and trying to add the next child another child is removed and I then get a gap in between items (I do loop through the accordian and use the Move method to ensure each child is in the correct position)

I can’t figure this one out. Anyone got any ideas?

My code is as follows:

[FONT=Courier New]function AddToTearOffs(WinID,SName,CName){[/FONT]
[FONT=Courier New] var child_obj:Object = _root.GadgetBar.myTearOffs.myTearOffsAcc.getChildAt(0);[/FONT]
[FONT=Courier New] var curSubjects:Number = child_obj.numChildren;[/FONT]
[FONT=Courier New] var Present:Boolean = false;[/FONT]
[FONT=Courier New] trace(curSubjects);[/FONT]
[FONT=Courier New]  for (i=0; i<curSubjects; i++) {[/FONT]
[FONT=Courier New]     child_obj.getChildAt(i).move(0,i*20);[/FONT]
[FONT=Courier New]     if (child_obj.getChildAt(i).ButtonText.Text.text == CName){[/FONT]
[FONT=Courier New]        Present = true;[/FONT]
[FONT=Courier New]     }[/FONT]
[FONT=Courier New]            };[/FONT]
[FONT=Courier New] if (Present == false){[/FONT]
[FONT=Courier New] var TearOffItem:Object = child_obj.createChild("TearOffItem", ["SubjectLbl"+WinID], {_x:0, _y:curSubjects*20});[/FONT]
[FONT=Courier New] TearOffItem.ButtonText.Text.text = CName;[/FONT]
[FONT=Courier New] TearOffItem.DeleteTearOff.onRelease = function(){[/FONT]
[FONT=Courier New]    var child_obj:Object = _root.GadgetBar.myTearOffs.myTearOffsAcc.getChildAt(0);[/FONT]
[FONT=Courier New]    var curSubjects:Number = child_obj.numChildren;[/FONT]
[FONT=Courier New]     for (i=0; i<curSubjects; i++) {[/FONT]
[FONT=Courier New]        if (child_obj.getChildAt(i).ButtonText.Text.text == CName){[/FONT]
[FONT=Courier New]           child_obj.destroyChildAt(i);[/FONT]
[FONT=Courier New]          updateAfterEvent();[/FONT]
[FONT=Courier New]       }[/FONT]
[FONT=Courier New]    var WindowX:Tween = new Tween(child_obj.getChildAt(i), "_y", Strong.easeInOut, child_obj.getChildAt(i)._y, i*20, .5, true);                              [/FONT]
[FONT=Courier New]    child_obj.getChildAt(i).move(0,i*20);[/FONT]
[FONT=Courier New]       };      [/FONT]
[FONT=Courier New] }      [/FONT]
[FONT=Courier New] }[/FONT]
[FONT=Courier New]}[/FONT]

I have considered trying to use a dataset to manage this and firing the dataset into a SharedObject. But, I can’t seem to cretae the Dataset in flash? Is it possible to create and use a dataset entirely in flash without being loaded from an external source?

My code so far is a as follows:

function CreateDS(WinID,SName,CName){
var my_ds:DataSet;
// Load Existing Dataset
try {
} catch(e:DataSetError) {
    trace("Unable to load shared object."); 
// Apend Dataset with new Item
//my_ds.createItem({WinID:WinID, SName:SName, CName:CName});
my_ds.addItem(my_ds.createItem({WinID:"A", SName:"B", CName:"C"}));
// Save New Dataset
try {
} catch(e:DataSetError) {
    trace("Unable to create shared object"); 

I appriciate this is a long post with many questions, but, any help gretaly appriciated!

Thanks, TonyL