Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to delete a custom class instance?

New Here ,
Oct 05, 2008 Oct 05, 2008
hey everyone, i need some help with deleting class instances. say i have a bullet class. say the bullet class checks when the bullet hits an enemy. i need help with how to delete the bullet when it hits the enemy.

im really struggling with this and any help would be helpful.

thnx
TOPICS
ActionScript
660
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 05, 2008 Oct 05, 2008
Do all of the following:
(1) removeChild so that it is not on the display list anywhere.
(2) Remove all references to the display object. For example, you can set them to null.
(3) Remove all event listeners attached to the instance.
(4) Think positive thoughts and hope it works.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 05, 2008 Oct 05, 2008
hi, can you show me how to do that with code within my deleter class?
i dont know if what i have is correct or not so feel free to change it.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 05, 2008 Oct 05, 2008
it can't be done in a deleter class unless all references are passed to the class or created in the class so the deleter class has access to all references.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 05, 2008 Oct 05, 2008
what do you mean? what are references?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2008 Oct 06, 2008
LATEST
anything that refers to the movieclip you're trying to use.

for example, when you add a listener, that creates a reference so you need to remove the listener. when you use a variable to point to your movieclip, that variable needs to be removed. when you store the movieclip in an array, that array element needs to be removed.

and, in your situation, you're not removing the movieclip. you're removing the array reference only so you can be sure your movieclip is not going to be gc'd.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines