Skip to main content
Participant
February 23, 2018
Question

Lagging issue while adding 300 or more movie Clips

  • February 23, 2018
  • 2 replies
  • 1181 views

Hi all,

My app requires  2500 movie clips But as the number of movie clips exceeds 400, the app starts lagging. I have tried using shapes instead of movie clip but it's almost the same.

can anybody suggest what's going wrong or how many movie clips I can add to app??

Many thanks.

This topic has been closed for replies.

2 replies

JoãoCésar17023019
Community Expert
Community Expert
February 23, 2018

Hi.

2500 objects is a huge amount and will require a lot of graphical and code optimization.

You may need a framework like Starling to achieve this.

Please see this demo:

https://gamua.com/starling/first-steps/

Anyway, in what kind of situation you need all these objects? Can you give us an example?

Regards,

JC

kglad
Community Expert
Community Expert
February 23, 2018

no it won't.  with a decent gpu it shouldn't cause noticeable lag unless you're doing something significantly time-consuming.

billiardBalls

JoãoCésar17023019
Community Expert
Community Expert
February 23, 2018

o_O

Really?!

Please give us an example with code (your link is broken).

I tried a benchmark here rotating sprites with the basic transformation properties randomized and I could only get a stable decent 60 fps with around 250 instances using the regular Display List.

kglad
Community Expert
Community Expert
February 23, 2018

can you benefit from using cacheAsBitmap?  that's usually the most beneficial with the least effort.

here's the full-spiel (excerpted from Flash Game Development: In a Social, Mobile and 3D World)

Greatest to Least Benefit

1.   Use stage blitting (if there is enough system memory).

2.   Use Stage3D.

3.   Use partial blitting.

4.   Use cacheAsBitmap and cacheAsBitmapMatrix with mobile devices.

5.   Explicitly disable mouse interactivity when mouse interactivity not needed.

6.   Do not use Filters.

7.   Use the most basic DisplayObject needed.

8.   Reuse Objects whenever possible.

9.   Event.ENTER_FRAME loops: Use different listeners and different listener functions applied to as few DisplayObjects as possible.

10. Use reverse for-loops and avoid do-loops and while-loops.

11. Pool Objects instead of creating and gc'ing Objects.

12. Strictly type variables whenever possible.

13. Use weak event listeners and remove listeners.

14. Replace dispatchEvents with callback functions whenever possible.

15. Explicitly stop Timers to ready for gc.

16. Stop Sounds to enable Sounds and SoundChannels to be gc'd.

Easiest to Hardest to Implement

  1. Do not use Filters.
  2. Always use reverse for-loops and avoid do-loops and avoid while-loops.
  3. Explicitly stop Timers to ready them for gc (garbage collection).
  4. Use weak event listeners and remove listeners.
  5. Strictly type variables whenever possible.
  6. Explicitly disable mouse interactivity when mouse interactivity not needed.
  7. Replace dispatchEvents with callback functions whenever possible.
  8. Stop Sounds to enable Sounds and SoundChannels to be gc'd.
  9. Use the most basic DisplayObject needed.
  10. Always use cacheAsBitmap and cacheAsBitmapMatrix with air apps (i.e., mobile devices).
  11. Reuse Objects whenever possible.
  12. Event.ENTER_FRAME loops: Use different listeners and different listener functions applied to as few DisplayObjects as possible.
  13. Pool Objects instead of creating and gc'ing Objects.
  14. Use partial blitting.
  15. Use stage blitting.
  16. Use Stage3D.