View Full Version : how to acheive "bounce" ?
ommmm
01-12-2002, 01:28 AM
At the 54k version of http://www.padmagraphics.com/ the vertical nav bars kind of bounce. I've seen this before and it seems more elaborate than a tween. How is it done?
Thanks!
pixelwit
01-12-2002, 03:04 AM
The effect you are asking about is achieved with ActionScript. The code generally looks like this: function move () {
x = _root._xmouse;
xPos = (xPos*flex) + ((x-_x)*drag);
_x += xPos;
y = __root._ymouse;
yPos = (yPos*flex) + ((y-_y)*drag);
_y += yPos;
}The values for "drag" and "flex" need to be defined and should both be between 0 and 1.
Place the code on an enterFrame event with the object you want to control.
Hope this helps,
-PiXELWiT
http://www.pixelwit.com
ommmm
01-12-2002, 04:24 AM
Thanks for your help! It seems to me that the bouncing of the bars is not dependent on the mouse position other than the rollover action so I'm not sure, but you seem to be defining for me the action of the text following the mouse which I'm not interested in at this point. At any rate, I'm not understanding the syntax of that either. I have the following code as the object action of a button with one state in a movie clip with only 1 frame. Nothing happens when I rollover the button and there are no script errors thrown.
on (rollOver) {
ifFrameLoaded (1) {
function move () {
flex = .7;
drag = .3;
x = _root._xmouse;
xPos = (xPos*flex)+((x-_x)*drag);
_x += xPos;
y = __root._ymouse;
yPos = (yPos*flex)+((y-_y)*drag);
_y += yPos;
}
}
}
megan
Billy T
01-12-2002, 07:02 AM
see attached
pixelwit
01-12-2002, 07:10 AM
I attached a file to help explain things.
Hope it helps,
-PiXELWiT
http://www.pixelwit.com
pixelwit
01-12-2002, 09:35 AM
Beat to the punch by BillyT and my script has a typo. I'm not doing so good.
The line in my script:
_xscale = _yscale = step;
Should be:
_xscale = _yscale += step;
I fixed it and attached the corrected file.
It ought to work much better.
-PiXELWiT
http://www.pixelwit.com
pixelwit
01-12-2002, 09:49 AM
Billy,
I shortened up that prototype in your script.
Was:Movieclip.prototype.elasticScale = function(target, accel, convert) {
xScale = xScale * accel + (target - this._xscale) * convert
yScale = yScale * accel + (target - this._yscale) * convert
this._xscale += xScale
this._yscale += yScale
}Changed to:Movieclip.prototype.elasticScale = function(target, accel, convert) {
step = step * accel + (target - this._xscale) * convert
this._xscale = this._yscale += step
}Might be helpful if you ever get a ton of bouncy things.
-PiXELWiT
http://www.pixelwit.com
Billy T
01-12-2002, 10:08 AM
nice one ;)
Thanks man
ommmm
01-12-2002, 05:53 PM
Thanks Billy T and PiXELWit! This is great fun. I learn best backwards, because I'm lazy? I don't know. But I like deconstructing. Thanks for sharing your wisdom and code.
megan
Jesse
01-13-2002, 05:46 AM
Remeber to add these little pearls of wisdom to the movie section fellas :)
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.