|
There is usefull method of the Array object that you may find of use here.
Splice() allows you to splice a section of the array. The sintax
is arrayName.splice(startIndex,lengthToRemove,valuesToAdd).
If you use ButtonArray.splice(buttonToRemoveIndex,1) it will remove that element of the array for you. Doug Melvin wrote: Has anyone come up with a good way to deal wiuth arrays?I want to dynamically add and remove buttons from an array of buttons..How about a linked-list.. will this work alright in this environment?Or will a linked-list be too resource intensive?I don't want to have to cludge by array of buttons.. But for those wondering how I would go about doing that.. 1) the buttons themselves don't go into an array2) You maintain an array of handles to buttons..3) when you create a button, add it's handle(reference to the object) to the array of handles4) when you delete and object you FIRST remove it's handle.. var tmpArray = new Array();for (var i=0;i<Handles.length;i++){ if (Handles[i] !== TheHandle){ set tmpArray[tmpArray.length] = Handles[i]; }}delete Handles; //what's the correct way to kill an array?var Handles = new Array();for (var i=0;i<tmpArray.length;i++){ set Handles[Handles.length] = tmpArray[i]; }} Will this work? will deleteing the handles array cause us to loose the reference to the object?Or will the references saty true as they are actuall references to button ojects? Feedback please!! Doug Melvin --
|
- [Dynapi-Help] Array Manipulation Doug Melvin
- Re: [Dynapi-Help] Array Manipulation Scott Andrew LePera
- [Dynapi-Help] DynLayer.lyrobj? Michael Pemberton
- [Dynapi-Help] DynLayer.lyrobj? Theo Bebekis
