views:

26

answers:

1

Hi all, im making a drop down menu in flash and i want it to slide down. At the moment im using a linear slide ( _y += 5, _y -= 5) etc.

I know there are other types of transitions like exponential and the like, how would i go about implementing them? I also remember there was a website once that showed all sorts of slide animations in javascript using different techniques.

A: 

A simple slide animation would be:

y = y*(1-speed) + (target_y)*(speed)

Iterating that causes the box to slide, slowing down as it moves there. Speed should be between 0 and 1. With speed 0.5, the distance between the current and target would be halved every moment.

or:

t = 0.1
while y < target_y do
y = y + t
t = t + 0.1
end
y = target_y

Which causes it to accelerate until it goes beyond the target, where it stops. As an alternative to + 0.1, you could do * 1.1 or something similar, causing an exponential, rather than quadratic, motion.

TaslemGuy