Học Actionscript 3.0 - p 10

Removing Event Listeners Garbage Collection: A Recommended Optional Parameter for Event Listeners Garbage collection is the method by which Flash Player purges from memory objects that you no longer need. Garbage collection and memory management typically are not topics you need to concern yourself with when just getting started with ActionScript . However, garbage collection frees up memory so it’s available for your SWF to use throughout its runtime life, so it’s a good thing to be aware of. There are some coding practices that you can adopt immediately, and relatively painlessly—even at the outset of your learning—that may prove to be. | Removing Event Listeners Garbage Collection A Recommended Optional Parameter for Event Listeners Garbage collection is the method by which Flash Player purges from memory objects that you no longer need. Garbage collection and memory management typically are not topics you need to concern yourself with when just getting started with ActionScript . However garbage collection frees up memory so it s available for your SWF to use throughout its runtime life so it s a good thing to be aware of. There are some coding practices that you can adopt immediately and relatively painlessly even at the outset of your learning that may prove to be useful habits in the long run. Using weak references is such a practice. We want to just scratch the surface of this subject laying the groundwork for conventions that we ll use throughout the remainder of this book and then refer you to additional resources for more information. There are three optional parameters that you can add to the end of the addEventListener method. Here is the syntax of the method which will look partly familiar. The optional parameters we ll discuss are in bold. NAME eventResponse useCapture Boolean priority int weakReference Boolean The first two optional parameters control when the listener function executes. You may never need to adjust these values often but here s a quick snapshot of what they do. The first optional parameter useCapture allows you to handle the listener event before it reaches its target if set to true or once the event has reached its target if set to false and is bubbling back up through the display list. The default false behavior is to react to all events captured at or after the event reaches the target and this is the configuration you will use most of the time. Using true is akin to clicking on a button but capturing the event before it reaches the button. It will appear as if nothing happened. The only practical use of this feature

Bấm vào đây để xem trước nội dung
TÀI LIỆU MỚI ĐĂNG
15    66    1    20-04-2024
153    57    1    20-04-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.