Archive

Archive for January, 2005

tweening alternative

January 31st, 2005 Randy 1 comment

Hello blog fans and happy new year. Recent news for the multitude of readers of this blog: I have joined the team at gskinner.com and I'm learning a lot! Flash all day every day. The guys are constantly feeding me with cool and better ways of doing things. Here is one such technique:

A previous blog mentioned the tween class, which itself has a certain amount of overhead. Here is a more direct technique to do the same thing.

Actionscript:
  1. myIntervalID:Number = setInterval(this, "tweenOutPin", 50, myMovieClip, oldX, newX, oldY, newY, getTimer(), duration);
  2.  
  3. function tweenOutPin(p_pin:MovieClip, p_oldX:Number, p_newX:Number, p_oldY:Number, p_newY:Number, p_startTime:Number, p_duration:Number):Void {
  4. var t:Number = getTimer()-p_startTime;
  5.    if (t <= p_duration) {
  6.       p_pin._x = linearTween(t, p_oldX, p_newX-p_oldX, p_duration);
  7.       p_pin._y = linearTween(t, p_oldY, p_newY-p_oldY, p_duration);
  8.    } else {
  9.       p_pin._x = p_newX;
  10.       p_pin._y = p_newY;
  11.       clearInterval(myIntervalID);
  12.   }
  13. }

Categories: Flash development Tags: