<p>I have an array of objects that when another object hits one of them, the object will be removed. I have removed it from the stage using removeChild() and removed from the array using splice(), but somehow the object is still calling some of its functions which is causing errors. How do I completely get rid of an object? There are no event listeners tied to it either.</p>

[{'answer_id': 69552, 'author': 'mikechambers', 'author_id': 10232, 'author_profile': 'https://Stackoverflow.com/users/10232', 'pm_score': 1, 'selected': False, 'text': '<p>It sounds like you may be running into a garbage collection issue with the flash player.</p>\n\n<p>A new API has been added to Flash Player 10 that should address this:</p>\n\n<p>unloadAndStop()</p>\n\n<p>Grant Skinner has more info on this on his blog:\n<a href="http://www.gskinner.com/blog/archives/2008/07/unloadandstop_i.html" rel="nofollow noreferrer">http://www.gskinner.com/blog/archives/2008/07/unloadandstop_i.html</a></p>\n\n<p>You can grab a beta of Flash Player 10 at:</p>\n\n<p><a href="http://labs.adobe.com/technologies/flashplayer10/" rel="nofollow noreferrer">http://labs.adobe.com/technologies/flashplayer10/</a></p>\n\n<p>mike chambers</p>\n\n<p>mesh@adobe.com</p>\n'}, {'answer_id': 70019, 'author': 'grapefrukt', 'author_id': 914, 'author_profile': 'https://Stackoverflow.com/users/914', 'pm_score': 0, 'selected': False, 'text': '<p>Is the object in question a MovieClip, and does it have a timeline playing?\nIf so you will need to stop it before removing. \nAlso keep in mind that storing a reference to the object in any way (although most commonly in an Event listener) will keep it from getting garbage collected. This includes any references to functions or child objects.</p>\n'}, {'answer_id': 71963, 'author': 'Iain', 'author_id': 11911, 'author_profile': 'https://Stackoverflow.com/users/11911', 'pm_score': 0, 'selected': False, 'text': '<p>For a function to be called, by definition there must be either a listener or setTimeOut somewhere, or the timeline must be playing. Make sure you remove all listeners and all references to the object. What kind of object is it?</p>\n\n<p>The output window or debugger should show you the stack of function calls that led to the unwanted call. If you paste the error output into your question then we will be able to give you a more accurate answer.</p>\n'}, {'answer_id': 73941, 'author': 'hasseg', 'author_id': 4111, 'author_profile': 'https://Stackoverflow.com/users/4111', 'pm_score': 0, 'selected': False, 'text': '<p>Also remember to stop and remove any related Timers when disposing of the removed objects: <a href="http://www.bit-101.com/blog/?p=1169" rel="nofollow noreferrer">BIT-101: Running timers are not garbage collected. Ever.</a></p>\n'}, {'answer_id': 75679, 'author': 'Theo', 'author_id': 1109, 'author_profile': 'https://Stackoverflow.com/users/1109', 'pm_score': 2, 'selected': False, 'text': "<p>You need to make sure that the display object you're removing:</p>\n\n<ul>\n<li>has no listeners registered on the stage, e.g. you need to call <code>stage.removeEventListener(...)</code> for any corresponding <code>stage.addEventListener(...)</code></li>\n<li>doesn't have a listener for the <code>Event.ENTER_FRAME</code> event</li>\n<li>doesn't listen for events on any timers</li>\n<li>isn't called by a timer set up with <code>setInterval</code> anywhere</li>\n<li>etc. basically anything having to do with timers, the stage, it's parent, loaders and the time line can cause objects to linger and not be removed</li>\n</ul>\n\n<p>So when you have removed the object with <code>removeChild</code> and removed it from the array you kept it in, also call its <code>stop</code> method to make sure it's not playing its timeline. It may also be a good thing to have a method on that object called something like <code>halt</code>, <code>cleanup</code> or <code>finalize</code> that unregisters any listeners, stops timers, timeouts, intervals, etc., clears references (i.e. sets the variables to <code>null</code>) to it's parent, the stage or any object that isn't going away too.</p>\n"}, {'answer_id': 77769, 'author': 'matt lohkamp', 'author_id': 14026, 'author_profile': 'https://Stackoverflow.com/users/14026', 'pm_score': 0, 'selected': False, 'text': "<p>I would look at Event.ENTER_FRAME and TimerEvent.TIMER listeners, make sure they're nullified before you remove the object.</p>\n"}, {'answer_id': 117162, 'author': 'Brian Hodge', 'author_id': 20628, 'author_profile': 'https://Stackoverflow.com/users/20628', 'pm_score': 1, 'selected': False, 'text': '<p>To completely get rid of an object in AS3 you must set its value to null.  Garbage collection will have no problems removing it because there are no references to it.  Also if can be helpful to use "weak references" with event listeners.  When creating an event listener it typically is the event type and the function to be fired.  </p>\n\n<pre><code>addEventListener(SomeEvent.EVENT_HAPPEND, onEventHappend);\n</code></pre>\n\n<p>below I will illustrate the same, but with a weak reference.</p>\n\n<pre><code>addEventListener(SomeEvent.EVENT_HAPPEND, onEventHappend, false, 0, true);\n</code></pre>\n\n<p>We know what the first two parameters are so lets begin with the third.  The third parameter dictates whether the event fires the onEventHappened function during the capture phase (true) or the bubbling phase (false which is also the default).  The only reason I am mentioning this parameter is that it is required prior to setting the weak reference parameter.  The fourth parameter is priority and dictates which events have priority when both listening on the same object and same phase of the event flow.  The fifth parameter sets the weak reference to true or false, for this case we will use true which is helpful for garbage collection. </p>\n'}]
['https://Stackoverflow.com/questions/69016', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']