Hi, and thanks to anyone in advance who knows how to solve this. I am creating a vertical menu with sub-links, which expand out once the main link is pressed, pushing all the buttons below them downwards (with easing). Except when i give one of the links a _y position to ease to, it never fully makes it to it, by under 1 pixel, leaving it slightly blurred.
For example, i want to ease one of the buttons below the clicked-on button to _y = 300. but it eases to 299.5.
the equation for this is…
onClipEvent (enterFrame) {
dist = _root.link_03_pos - this._y;
travel = dist / _root.speed;
this._y += travel;
}
_root.link_03_pos is passed a new _y position when any button is pressed.
Why, when the dist is smaller than 1, does flash stop moving the mc?
Because that equation never evaluates to zero. You could divide the distance by the speed infinitely and it would never in your wildest dreams equal zero (only very, very close).
Solution is something like this:
onClipEvent (enterFrame) {
if (Math.abs(_root.link_03_pos) - Math.abs(this._y) > 1) {
this._y += (_root.link_03_pos - this._y) / _root.speed;
} else {
this._y = _root.link_03_pos;
}
}

Thanks canadian, one thing i dont quite understand is, why would flash stop dividing below 1? fair enough that it would never equal 0, but, say for example the dist got down to 0.8, which was then divided by 10 (_root.speed), making the travel 0.08, in turn making the new _y position 0.72?
But it just dosent do this? its like it simply stops below 1? Or is it simply a coincendence with something im missing?
Also, your script only works one way, once the [COLOR=#000000][/COLOR][COLOR=#0000FF]root[/COLOR].[COLOR=#000080]link[/COLOR][COLOR=#000080]03[/COLOR]_pos is smaller than this._y, its a negative dist and just jumps to the new position, rather than easing.
Thanks for helping, its really appreciated. :thumb:
you dont need the two Math.abs() methods in the ‘if’ statement. if you use just the one it’ll work for either start and end point.
[AS]
onClipEvent (enterFrame) {
if (Math.abs(_root.link_03_pos-this._y)> 1) {
this._y += (_root.link_03_pos - this._y) / _root.speed;
} else {
this._y = _root.link_03_pos;
}
}
[/AS]
[COLOR=#000000][/COLOR]