A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] Truly deleting a movieclip

  1. #1
    Member
    Join Date
    Apr 2007
    Posts
    31

    [RESOLVED] Truly deleting a movieclip

    Im using a tilebased method, and in it I create movieclips using the new keyword paired with addChild. I want to free all memory used with the movieClips when it is time to delete them, including deleting it off the stage, of course.

    Do I use delete, removeMovieClip(), set it to something (null for example), something else, or a combination of some of them?

    Thanks.

  2. #2
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,358
    you use removeChild and delete or null and variables that reference that movie clip. You use delete if the reference is a dynamic variable assigned to a dynamic instance and you use null if the reference is a class property or a non-dynamic property of an inatance (null actually works in both cases so if you're confused about when to use which, use null). This also includes all listeners for that movie clip be removed since a listener counts as a reference.

    Event then, however, the movie clip may still take up some memory until the automatic "garbage collector" (or GC) comes through and sweeps up all the trashy memory in player. This could take a while, frames, seconds, or even longer. The best thing you can do is just make it available for cleaning which means removeChild and remove all references.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center