PDA

View Full Version : AS3 replacement for removeMovieClip



Aquilonian
April 25th, 2007, 11:13 AM
In AS2, if i have a movieClip c and a reference to it called b, if i remove c and trace b it will return null
Now, the As2 to 3 migration says that the replacement for removeMovieClip is removeChild, however this dont do the same thing, only removes it from a display list
So,if i want to delete all the references to the movieClip in memory, i think they way is to manually do it, however, for dynamic content sometimes i dont know what are the references for it
So, what is the best way to loop into a entire swf looking for references of my movieClip and making eachReference = null ?
I mean, i know how to do it to stuff in the main displayList, but if there is some reference out of any display list?
Does it make sense?Thanks

senocular
April 25th, 2007, 11:18 AM
removeChild removes it from the screen. Then, its no longer seen. This is mostly like removeMovieClip. Just like with AS2, references to objects will remain even if one reference was deleted. Additional references will keep the object in memory since they still point to the object. In AS2 movie clip references continued to exist as well. However, these were "soft" references that only referenced movie clips by a kind of "tag" and not their object value since movie clips in AS2 were so closely bound to timelines that when removed from timelines they could no longer function as an object. In AS3, you're dealing with normal object references for display objects and they will persist even when the object is removed from the display list just like with any other object and that object will continue to function normally, just not seen.

So if you want to get rid of the object completely, yes, you have to delete or null all references to it. Otherwise, to just remove it from the screen, you use removeChild. Its not the same as AS2 but things are different in AS3 and, really, its much more flexible this way.

Aquilonian
April 25th, 2007, 03:26 PM
So, how do i do this?I mean, for those who are not in any parent display list?
Is there any way to list those clips?

senocular
April 25th, 2007, 03:28 PM
you just have to keep track of them yourself.

Aquilonian
April 25th, 2007, 03:45 PM
So i think i will have to create a function to search on all the display list looking for references to the clip to be deleted , and delete everyone in the end, and also never remove any clip from any display list without use this function...
I mean, never let any clip out of any parent cos if i forget about it, it will mess my game