# Mathematics and easing

**URL:** https://forum.kirupa.com/t/mathematics-and-easing/279512
**Category:** Uncategorized
**Created:** [January 15, 2009, 2:55pm UTC](https://forum.kirupa.com/t/mathematics-and-easing/279512 "2009-01-15T14:55:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![marcogiannini](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@marcogiannini](https://forum.kirupa.com/u/marcogiannini)
#### Post date: [January 15, 2009, 2:55pm UTC](https://forum.kirupa.com/t/mathematics-and-easing/279512/1 "2009-01-15T14:55:05Z")

</div>

hello all,  
I need some math help I think…  
I’ve built a code to cyclically move a scene on the bottom of my stage; I’ve done this to make a slowing-and-stop-easing effect at anytime the command will arrive. The entire scene mc is \_x long something like 6000 px  
The whole code goes in this way:

1. importing on the stage (with attachMovie) a mc with this code inside:

onClipEvent(enterFrame) {  
\_parent.\_parent.fondo\_mc.\_x -= countermovement;  
if (\_parent.\_parent.fondo\_mc.\_x \<= -5800) {  
\_parent.\_parent.fondo\_mc.\_x = -30;  
}  
}

1. In the main timeline this code:

var c countermovement:Number = 6;  
attachMovie(“procemuovifondo”, “procemuovifondo”, 5000);

function slowAndStop () {  
procemuovifondo.onEnterFrame = function () {  
if (countermovement \> 0) {  
countermovement --;  
trace (“counter” + countermovement);  
} else {  
removeMovieClip(procemuovifondo);  
}  
}  
}

The code goes right, but I need to improve it.  
Now there is just a variable, I tought to use two vars to implement the whole code in a setInterval, but maybe it’s unuseful, and actually I can’t use it in the right way.  
Second issue: actually when slowAndStop function is called the scene slow too fast, if I take it to 15 it slow better but the scene is running too fast…

The best would be that the scene slow down and stop following:  
A) a temporal variable (and I can try to implement it with setInterval, that for istance is a cycle)  
B) an indipendent moving variable, so that on one side I set the speed, on the other side I set the slow-and-stop in a matter of time with countermovement.

I also tried to use a second variable:  
var counter:Number = 15;  
// set the \_x increment  
var countermovement:Number = counter/2;

but the scene slow and goes backward a bit :ogre:

thanking you in advance
