I am making a game with flash as3. I create a movieclip that contain开发者_Python百科s all of the games content within it. I pretty much encapsulated the game within this one movie clip. after the game is over I remove the movieclip off the screen. but yet, all the other movieclips within the main movieclip still keep playing.
I could create a deconstructor that removes all the items. but that seems like much to do. is there something easier ?
I tried making the movieclip null. but all the other movieclips Timers keep going off still and causes errors to go off.
myButton.addEventListener(MouseEvent.CLICK,myButton_Clicked);
...
function myButton_Clicked(event:MouseEvent)
{
this.removeChild(this.getChildByName("myMovieClip"))
}
try this!!!
You must remove listeners in the sub movies, otherwise they can't be garbage collected when you try to remove or nullify the main clip. You could add a destroy(); method in each of the sub-clips that does this and call that from the parent clip.
精彩评论