DrEvil wrote: > > I'm creating script objects and adding them to the actorlist, what all > do I need to do to ensure their destruction when I don't need them > anymore? As in clearing each out of memory and taking them off the list > when they are destroyed? Thanks > > Jeremy
Simply by setting the actorList = [] all the objects in the actorlist will be destroyed, along with all references to objects stored in properties of them, if any. You don't need to take each object off the list to get it destroyed. If you do, then you need to destroy the new reference you have created, so there's no advantage: For example: obj5 = (the actorList).[5] the actorList = [] obj5 still lives here, so you have to set obj5 = void (or 0) in order to destroy it. If you want to destroy a particular object in the actorList and keep the others, things may become a little more tricky if you don't want to compact the actorList every time you destroy an object. If you have four objects in the actorList they will be called one at a time through the stepFrame method of each of them: 1, 2, 3, 4. Then, if you set (the actorList).[2] = void no error will be issued since the object 2 hasn't any more a method stepFrame to be called and the sequence of calls will be 1, 3, 4. But if one of the remaining objects attempts to access a property of a destroyed one, you get a "property not found" error: on mCalculateDistance me ij = indexOfMeInActorList + 1 repeat with j = maxObjects down to ij o = the actorList[j] xox = x - o.x yoy = y - o.y distance = sqrt(xox * xox + yoy * yoy) end repeat .... end When this code is in execution for the object 1, an error is issued for j=2 since o = the actorList[j], is not an object and doesn't have a prop x cause it was destroyed. Circumstances may suggest the best use of actorList. HTH, Franco FC Programming Consultant http://www.chnexus.com/main.htm mailto:[EMAIL PROTECTED] [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]