Skip to main content
Inspiring
July 17, 2012
Question

help me optimise animation

  • July 17, 2012
  • 4 replies
  • 883 views

So I have a particle emitter type effect where i move fingers across the screen and little stars appear. The problem is that they really stutter when more than one finger drags them across the screen.

I have rendered in GPU mode. What else can I do to improve the render?

The particles are moviclips from the library that load dynamically

This topic has been closed for replies.

4 replies

Inspiring
July 17, 2012

Have you looked into cacheAsBitmap and cacheAsBitmapMatrix.

joeboy_ukAuthor
Inspiring
July 18, 2012

I have but I have never seen them make any difference in the past.

Does anyone have a good example of it in use that I could see to understand where and when to do the cache?

Inspiring
July 18, 2012

I dont know amy links of hand.... but examples would be.....

say your library instanse of your star is called Star

then you would use

Star.cacheAsBitmap = true;

addChild(Star);

the above code would be used if the stars move x and or y (up and down)

Star.cacheAsBitmap = true;

Star.cacheAsBitmapMatrix = Star.transform.concatenatedMatrix;

addChild(Star);

the above code would be used if the stars sacle and or rotate

If you are using Math then always use round.... ie

Star.x = Math.round(Math.random() etc etc

//then which ever cacheAsBitmapMatrix is needed

Star.cacheAsBitmap = true;

addChild(Star);

note cacheAsBitmap wont work on any thing that has multiple frames in it

so for example if you double clicked into your star and there are you may

have on keyframe 1 an image of your star. one keyframe 2 you may have

an image of your star exploding.

in that case you will need to export these images out as pngs and then

inport them back into flah. then inside the star you replace the keyframe 1

star with the png of the star and replace keyframe 2 exploding star with

the png exploding star. Then no actionscript will be needed

Thats all i do and i have never had any problems but ive only had experience

with android and not ios

Another tip to help save memory and optimise graphics is to make sure all

images, objects, fonts etc are always place on a round pixel... ie

myImage.x = 10;

myImage.y = 10;

and not

myImage.x = 10.4;

myImage.y = 10.8;

This is also true for things you place on the stage with out using actionscript

ie

if you have an image that you placed on stage without actionscript make sure

it is on a rounded pixel