Using SWF animation for HTML5


#1

Hi everyone,
i am trying to port a game from Flash/AS3 to OpenFL/Haxe.
And i had problems using SWF animation for HTML5. If several animations are running, then the speed of the game decreases.
I am using a test example https://github.com/vlkozlov/HaxeTest
When 50 simple animations start, FPS reduced to 5.
haxedef name=“canvas” and stage.frameRate = 30 raise FPS to 20.
Real game animation will be even slower.

What are the possibilities of increasing the FPS?

Thanks for your help!


#2

The SWF system has not been designed with optimizations in mind for many fast animations. There probably is a lot of low-hanging fruit in there. The focus has been on accuracy, and allowing instance IDs and other methods where you can bind animations in code.

It would be nice if we could get testing on this pull request:

There also are a lot of changes in this fork, designed specifically around MovieClip animation:

I believe all the code is isolated within openfl.display.MovieClip for the runtime performance. I would love to see additional performance here, but I think one of the biggest things holding this back has been a lack of good tests for SWF assets, so we can try and confirm that we have not caused regressions.


#3

Thank you @singmajesty!
I will try to use your advice. And I will inform you about the results. :grinning:


#4

Hello @singmajesty!
We solved the problem with playing МovieClip.
We tested pull request with corrected method __updateSymbol. The speed increase was small.
Therefore, we used cached MovieClip. Each frame of MovieClip has been converted to BitmapData. The speed has greatly increased.


#5

That seems like a good plan for now. I’d love to see improvements come to MovieClip’s performance in the future, but for now that’s a known way to speed things up! You can also convert to one large BitmapData and use Tilemap


#6

Ok! Maybe we will use Tilemap in the future.