View Full Version : Tweening scaleX, scaleY, x and y properties of sprite producing jumpy results
marlonpando
February 10th, 2010, 01:29 AM
I'm trying to make a textfield inside a sprite zoom upon mousing over the sprite. I'm instantiating tweens on the x, y, scaleX, and scaleY properties of the sprite. The x and y tweens are needed due to the top left registration. Also, the tweens are added to an array to ensure they finish.
Sometimes it works as I intended, but when I mouse over from the bottom right corner, the sprite jumps haphazardly towards the top left and back until i mouse out, instantiating another set of tweens to return the sprite to it's original state. I'm not sure what to do other than using a custom tweening engine such as Tweener.
I'm using the built in tweening classes and I'm hoping to find a solution within these parameters. Has anyone run into this kind of problem? Can you make any recommendations? I would be most appreciative of any helpful feedback.
IQAndreas
February 10th, 2010, 07:04 AM
That's just the way TextFields tween. :(
I had the same problem a while back, and there were some pretty interesting replies. In the end, I embedded the font which solved the problem (mostly):
http://www.kirupa.com/forum/showthread.php?t=339563
marlonpando
February 10th, 2010, 01:25 PM
Thank you IqAndreas.
I should have mentioned that I am embedding the font also.
I read through your thread and tried a number of things. I appreciate that you have shared your experience as you've been down this road. You have saved me quite a lot of frustration. "Jerky" is a more apt description than "jumpy".
The textfield drawn as bitmap approach works ... but ... my post is a dramatic simplification of what I'm trying to do. I'm also setting the widths of the sprite upon a stage resize event which means that I have to redraw the textfield as a bitmap for each resizing event as well. This seems too much for a textfield in order to achieve a result that doesn't look quite as clean as what I'm looking for.
I think I will try to center the registration point of the sprite and forego the x and y tweens to see if that works.
Thanks again, IqAndreas.
marlonpando
February 10th, 2010, 01:44 PM
It's still jerky but the sprite doesn't move away from the pointer which is an improvement.
marlonpando
February 10th, 2010, 03:41 PM
Actually, I found a way to get rid of the jerk. If you don't need the sprite to be transparent, the solution I found is to fill the sprite:
obj.graphics.clear();
obj.graphics.beginFill(0x000000);
obj.graphics.drawRect(0,0,obj.width, obj.height);
The textfield inside the sprite tweens on x, y, scaleX, and scaleY properties without any jerky movements. No need to center the registration either.
marlonpando
February 10th, 2010, 04:06 PM
If you need transparency, add a sprite to the sprite, fill it and set alpha to 0. It still works!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.