As3 event listening and removechild Solutions

Source: Internet
Author: User

I used to think that I added a listening event to an object and then removed it. Then, his event will not be executed. In fact, this is an error!

As3 is not Js. Its display, storage, and time listening are independent. It will not be deleted because you have deleted one of them!

If the addeventlistener of this object is not a function or method, removeeventlistener is required!

We need to understand that addchild is not equal to attachmovie, but it is actually two different things.
This is irrelevant to the weak reference. If you only use removechild, the MC will always occupy the memory, and all events will be executed. Flash regularly cleans up the unreferenced content. If the new variables have not been changed or deleted, they will always exist.
Therefore, after removechild (A), you should write another A = NULL statement to destroy this reference. In the end, this part of content will be automatically cleared.

Weak references refer to events. If you send an event to a and there is no removeeventlistener before deleting a, the event will always exist, even if a is deleted long ago. If the event is written as a weak reference, it will be automatically cleared by the system.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.