Jump to content
Search Community

Text scroll performance

floouuu test
Moderator Tag

Recommended Posts

Hello!

 

First of all: Thank you for your great work!

 

I`m trying to move a dynamic TextField from the bottom of the screen to the top and it works. It runs nice and smoothly on my PC. The problem starts when I run the .swf on a target, which is not as powerful as my developement PC. The text animation becomes quite choppy.

I tried several things (cache text as bitmap via BitmapData, using TweenLite and now using BlitMask) to improove the performance and I could manage to get 11-12 FPS on the target hardware. That`s "ok".. but it would be nice to squeeze out some more FPS.

 

Globally I define a Blitmask:

var txtMask:BlitMask = null;

I initialize it:

txtMask = new BlitMask(txtMessage, 0, 680, movieWidth, textAreaHeight,true);

...and start the animation:

	txtMessage.text = msg;
	txtMessage.y = movieHeight;
	txtMessage.height = txtMessage.textHeight + 4;
	txtMask.update(null, true);
	TweenLite.to(txtMessage, Number((txtMessage.height + textAreaHeight) / textScrollSpeed), {y:(movieHeight - textAreaHeight - txtMessage.height),onComplete:onTextScrollFinish, ease:Linear.easeNone,onUpdate:txtMask.update,useFrames:false,immediateRender:true});

I also tried to tween the scrollY attribute of the BlitMask, but this didn't change anything (as expected).

 

So I guess I just wanted to ask if someone has an idea how I could further inprove the performance of the TextField animation. Would it help to try the ThrowProps plugin?

 

Thank you for your time :-)

Link to comment
Share on other sites

Nothing in your code immediately stands out as a possible cause for low performance. Regular tweens utilise very little CPU by themselves, so I can't see ThrowProps changing that for you. However I'm wondering: what do movieWidth and textAreaHeight equal in your tests, and what kind of hardware are you targeting?

 

Large bitmaps (e.g. let's say larger than 500x500) use a lot of resources to render (although still usually better than vector rendering) so my first instinct is to attribute your performance woes to flash's capability to render large bitmaps.

  • Like 1
Link to comment
Share on other sites

I'm with Jamie - I don't see anything obvious, but it's tough to know what else is going on in your file. Flash is actually pretty darn good at rendering bitmaps (even large ones, although it's best to avoid scaling/rotation), but it struggles quite a bit with large text blocks and/or complex vector graphics. You didn't accidentally set txtMessage.visible to true anywhere, did you? As long as you're using the BlitMask, txtMessage.visible should remain false (the BlitMask does that for you, but it can't prevent you from manually setting it back to true). The goal is to minimize the area on the screen that Flash must render. And keep in mind that even if you have objects off the edge of the screen (technically invisible), Flash still has to render them unless their "visible" property is set to false or they're removed from the display list. 

Link to comment
Share on other sites

Hello!

 

First of all: Thank you for your replies.

 

I attached the working directory as a zip file for better understanding. The lines 45 - 49 are for testing purpose only and will be uncommented in the final version. This is a flash movie which is loaded by a different swf and the setDynamicContent methode will be called by the parent swf.

Because of the 500 kB upload limit, I had to eliminate the com folder. You will have to place the com./greensock folder hirarchy into the project folder in order to compile the swf.

 

There is a big image in the file which is scaled down and the text starts rolling when all image tranformations are complete.

 

Is it somehow possible to precalculate portions of the text-moving tween?

 

Thank you again for your help and have a nice day!

 

Florian

Programm2013.zip

Link to comment
Share on other sites

Well, that's an awfully large display area for such a weak processor. It's got to push a lot of pixels around 50 times per second. 

 

Honestly, optimization is a very deep topic and there are all sorts of things that can be done, but I didn't have time to comb through every aspect of your file to devise the best techniques, but I'll offer a few things:

  1. I noticed you're using a TransitionManager - I'm not certain, but if it's anything like most of Adobe's stuff, it probably isn't very well optimized. Have you tried removing that? 
  2. You've still got some text that's displaying normally, without being converted to a bitmap (blitted). You might want to try rasterizing that stuff because Flash is much slower at rendering vectors and text than it is raster pixels. 
  3. Some of your text is selectable. I'd recommend disabling that and also disabling mouse interaction on objects that don't require it. Set mouseEnabled to false. That frees the Flash Player from having to track mouse interaction on those objects.
  4. If there's any way to reduce the screen area where pixels are changing (text is scrolling), that'd help. The more pixels Flash has to redraw, the more strain on the CPU. 
  5. Maybe try using Starling or Stage3D. I'm not sure if that'd work for you on your target platform - it relies on GPU rendering I believe, but if your target platform has a weak GPU or doesn't allow it to be tapped into, it won't help. Note: BlitMask isn't built to be used with Starling.
  6. Is the native screen resolution on your target platform exactly 1920x1080 or is it having to scale everything? Scaling all the graphics in the player could certainly negatively impact performance. 
  7. Make your text anti-aliased for animation, not readability (and not custom). 
  8. If you can, remove any filters, especially from animated objects (or objects that are composited with animated stuff).
  9. If nothing else works, you could consider taking chunks of the animated stuff and making it into raw video so that the playback could potentially be GPU-accelerated. Of course file size would shoot up drastically if you make stuff into videos, but it might perform better. 

Again, you're asking a LOT from a slow processor to manage such a large swf (1920x1080). 

 

I hope some of that helps. 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...