Using an update loop
Listening for events can be expensive. For a handler to receive an event, Flash must create an object in memory that represents that event. Repeatedly allocating memory can hurt the performance of your app, and this is especially true if you are listening for Event.ENTER_FRAME
from a large number of display objects.
Let us see how to minimize the impact of handling multiple ENTER_FRAME
events by making some adjustments to the architecture of your example app. We will also add some additional code to individually control the speed of each bubble, making the app a little more polished.
How to do it...
You will be required to make code changes to both Main.as
and Bubble.as
:
- First start by opening
Bubble.as
. - Within the constructor, ...
Get Flash iOS Apps Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.