Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-25-2004, 07:06 PM   #1
asc
Registered User
 
Join Date: Jun 2004
Posts: 4
Send a message via AIM to asc
Question 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);
};
asc is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:53 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.