Groups | Blog | Home
all groups > flash actionscript > november 2006 >

flash actionscript : tweening more than one property at a time



stephan.k
11/11/2006 6:55:14 PM
Dear Forum

I'm trying to find out how to efficiently scale both xscale and yscale with
one tween instance. Is that possible?

I'm picturing something like this:
scTween:Tween = new Tween(targetClip, {"_xscale","_yscale"}, Regular.easeOut,
0, _targetScale, 0.5, true);

Any insight appreciated.

Thanks

Stephan

LuigiL
11/12/2006 12:00:00 AM
No. The Tween Class accepts a property - passed as a string value - as an
argument. Not an object. Fuse is an excellent choice as a third party solution
by the way. But you can also write your own methods that use the Tween Class to
build your own custom animations. Attached an example of a function (in a
class) that will first animate a movieclip using the _x property of the
provided movieclip and then moves the movieclip over the _y axis.



/**
* Animates a box, starting with the _x properties,
* then animate _y properties (if provided).
* Dispatches an event 'Drawn' when animation is completed.
*
* @param target_mc The mc that will be animated
* @param props An object holding the properties that will be animated
* @param func A function to pass to the Tween Class
* @param xFinal Number, final width of the box
* @param yFinal Number, final height of the box
* @param xDelay Number, duration of the Tween
* @param yDelay Number, duration of the Tween
*/
public function animateBoxOverX(target_mc:MovieClip,
props:Object,
func:Function,
xFinal:Number,
yFinal:Number,
xDelay:Number,
yDelay:Number):Void{
var thisObj:Box=this;
var xTween:Object=new
Tween(target_mc,props.xProp,func,props.xInit,xFinal,xDelay,true);
if(props.yProp){
xTween.onMotionFinished=function():Void{
var yTween:Object=new
Tween(target_mc,props.yProp,func,props.yInit,yFinal,yDelay,true);
yTween.onMotionFinished=function():Void{
var evtObj:Object=new Object();
evtObj.target=thisObj;
evtObj.mc=target_mc;
evtObj.name=target_mc._name;
evtObj.type="Drawn";
thisObj.dispatchEvent(evtObj);
};
};
} else {
xTween.onMotionFinished=function():Void{
var evtObj:Object=new Object();
evtObj.target=thisObj;
evtObj.mc=target_mc;
evtObj.name=target_mc._name;
evtObj.type="Drawn";
thisObj.dispatchEvent(evtObj);
};
}
}
myIP
11/12/2006 1:47:25 AM
Hmmm?.I never tried to pass multiple properties in a Tween class like that.
Then again I really don?t use Flash?s Tween class that often. In the past I
have used Fuse Kit. If you install this plug-in you will be able to do such a
thing you are asking. Use ZigoEngine;

http://www.mosessupposes.com/Fuse/fuse2.0docs/index.html
AddThis Social Bookmark Button