开发者

Empty space after tweening movieclip

this may seem a bit vague/confusing but i hope you can get it.

I'm filling arrays from a XML. These arrays have dynamic textFields inside them, and these textFields are childs of a movieclip.

I tween this movieclip, therefore making the array of textFields animate on the stage one by one. There are two sources of XML, one from an actual site, and another from a XML stored in the hdd. First i fill the arrays of textFields, and then animate the movieclip. I do this for the first one, then animate it, do it again for the 2nd one, animate it, again for the 1st one, animate it, so on so on.

myTween = new Tween(mc,"x",None.easeNone,sizeOfStage,0开发者_如何学C - mc.width,mcSpeedAuto,true);

my tween ends at 0 - mc.width, the problem is, if i tween first the "bigger" XML, when the next one which is smaller gets tweened, there's loads of empty space before it tweens the big one again (tweening whitespace?).

myTween.addEventListener(TweenEvent.MOTION_FINISH, onFinish);

onFinish i clear all the arrays (otherwise the tweening of the 2nd one would still have information of the 1st one e.g: 1st has 25 fields, second has 10, 1st shows it's 25 fields, 2nd shows 10, and the 15 that were left from from the 1st one) and call the tween on the 2nd one. I thought that by doing this i'd be clearing all that white space too, apparently not. I think the mc.width just keeps the "bigger" value and always tweens with that, taking longer to end in the 2nd case. I've tried setting the mc.width as the sum of textfield width's everytime i fill the arrays, but this hasn't worked either, so i'm not quite sure what the problem is :/

Is this too confusing? Any ideas?

Thanks in advance.


Note: Using the default as3 Tween class is bunk. I say that because a lot of times the tween will get collected by the GC before it finishes the animation (which it sounds like that's where your "white space" is coming from).

I suggest a new tweener. There's a lot of talk about which tweener best for performance, but I personally go for ease of when my tweens are fairly minimal (like your example).

Good replacement tweeners:

  • Google Caurina Tweener (what I use)
  • Grant Skinner's GTween
  • TweenLite
  • TweenMax

The last two are based on the same engine. There's talk of Tweener being low on the performance scale, but I prefer it per it's originality and ease-of-use. Choose wisely!

** edit - example using Caurina Tweener **

import caurina.transitions.Tweener;

/* tweens "myClip" from it's current alpha to alpha=1.0 in 250ms (1/4
second) using the "linear" functionality */ Tweener.addTween(myClip,
{alpha:1.0, time:0.25, transition:"linear"});

/* tweens "otherClip" from it's current x position to x=100 in 500ms
(1/2 second) using the "easeOutCirc" functionality */
Tweener.addTween(otherClip, {x:100, time:0.5,
transition:"easeOutCirc"});

Also, here's a list of transition types for tweener (click on a tween to see it's animation graph play)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜