Adding an Array property to a prototype
I need to add an array to every visible object that can be created as well as a few functions that interact with the array. I thought I had it but it turns out the array is a shared array between all objects that are created. When I try to create the array in the create constructor, the functions that interact with it all start to report that "this.arrayname is null or does not exist". This sounded simple when I started but I am just not getting past this little thing. This is what I had done that almost worked:
If I created a new object and did obj.addToArray("some item"), then I got obj.myArray.length = 1. But if I create a new object, say obj2, and immediately test it's array length, I get obj2.myArray.length=1 and I obviously want it to be 0.
Any pointers would be helpfull. I assume I am going at this at the wrong level, someone will know.
Thanks
Active.System.HTML.prototype.myArray = new Array();
Active.System.HTML.prototype.addToArray = function(newItem){ this.myArray.push(newItem);}
Active.System.HTML.prototype.removefromArray = function(removeItem) { delete this.myArray[this.myArray.ondexOf(removeItem)]
If I created a new object and did obj.addToArray("some item"), then I got obj.myArray.length = 1. But if I create a new object, say obj2, and immediately test it's array length, I get obj2.myArray.length=1 and I obviously want it to be 0.
Any pointers would be helpfull. I assume I am going at this at the wrong level, someone will know.
Thanks
Jim Hunter
August 11,