decaying sinusoidal scaling function
I've been using a parameterless function to scale movieclips on my site. The drawback to this approach is that every movieclip gets scaled in the same way. I started making a function with parameters and I have it working. The only problem is that I can not see the oscillation. I think it may oscillate too fast. Any way to slow the scaling down? Thanks.
-b
Here is the actionscript v2.
//nGrow-final percent scale value of movieclip.
//nElastic-proportional to the number of oscillations.
//nSpeed-inversly porportional to the time for the final scale value to reach steady state
var isOver:Boolean = true;
function sinusoidalScale(nSpeed:Number, nElastic:Number, nGrow:Number, mcClip:MovieClip):Void {
trace("nSpeed= "+nSpeed);
trace("nElastic= "+nElastic);
trace("nGrow= "+nGrow);
trace("mcClip= "+mcClip);
var nOriginalScale:Number = getProperty(mcBlockOne, _xscale);
trace("original scale= "+nOriginalScale);
if (isOver) {
for (var x = 0; x<=1500; x=x+1) {
mcClip._xscale = ((Math.exp(-x/nSpeed)*nGrow*Math.sin(nElastic*x)+nGrow)*100);
mcClip._yscale = ((Math.exp(-x/nSpeed)*nGrow*Math.sin(nElastic*x)+nGrow)*100);
}
var nFinalScale:Number = getProperty(mcBlockOne, _xscale);
trace("final scale= "+nFinalScale);
}
else {
nFinalScale = nOriginalScale;
nOriginalScale = nOriginalScale/nGrow;
var xStart:Number = (-1*(Math.log((nFinalScale-nOriginalScale)/nFinalScale))*nSpeed);
trace("xStart= "+xStart);
for (var x = xStart; x<=1500; x=x+1) {
mcClip._xscale = (nFinalScale*Math.exp(-x/nSpeed)+nOriginalScale);
mcClip._yscale = (nFinalScale*Math.exp(-x/nSpeed)+nOriginalScale);
}
}
}
//Function call
mcBlockOne.onRollOver = function() {
trace("Mouse is over Button");
isOver = true;
sinusoidalScale(300, .03, 2, mcBlockOne);
};
mcBlockOne.onRollOut = function() {
trace("Mouse is not over Button");
isOver = false;
sinusoidalScale(300, .03, 2, mcBlockOne);
};
|