# Simple easing effect not working, and I don't know why!

**URL:** <https://forum.kirupa.com/t/simple-easing-effect-not-working-and-i-dont-know-why/186174>\
**Category:** Uncategorized\
**Created:** [April 19, 2006, 3:47pm UTC](https://forum.kirupa.com/t/simple-easing-effect-not-working-and-i-dont-know-why/186174 "2006-04-19T15:47:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![graylensman](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@graylensman](https://forum.kirupa.com/u/graylensman)\
**Post date:** [April 19, 2006, 3:47pm UTC](https://forum.kirupa.com/t/simple-easing-effect-not-working-and-i-dont-know-why/186174/1 "2006-04-19T15:47:09Z")

</div>

Here’s my situation. I have a movie clip called mainClip. Within it is another movie clip called subClip. I am moving the mainClip along the y axis; when it reaches a certain point, then the subClip moves along the x axis.

Here’s the basic code:

```auto

myButton.onRelease = function() {
	onEnterFrame = function () {
		mainClip._y += 10;
		if (mainClip._y>=100) {
			mainClip._y = 100;
			mainClip.subClip._x += 100;
			if (mainClip.subClip._x>=100) {
				mainClip.subClip._x = 100;
			}
		}
	};
};

```

But the motions are too abrupt for my taste. So, I’m using a simple easing in script:

```auto

endY = 100;
endX = 100;
speed = 5;
myButton.onRelease = function() {
	onEnterFrame = function () {
		mainClip._y += (endY-mainClip._y)/speed;
		if (mainClip._y>=endY) {
			mainClip._y = endY;
			mainClip.subClip._x += (endX-mainClip.subClip._x)/speed;
			if (mainClip.subClip._x>=endX) {
				mainClip.subClip._x = endX;
			}
		}
	};
};

```

The problem is, the mainClip moves just fine, but the subClip won’t move at all. Anyone have any ideas as to why the second script won’t work?

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [April 19, 2006, 4:20pm UTC](https://forum.kirupa.com/t/simple-easing-effect-not-working-and-i-dont-know-why/186174/2 "2006-04-19T16:20:14Z")

</div>

Why not use [AS]myButton.onRelease = function() {  
endX = endY = 100;  
speed = 25;  
var tweenM = new mx.transitions.Tween(mainClip, “\_y”, mx.transitions.easing.Regular.easeOut, mainClip.\_y, endY, speed);  
tweenM.onMotionFinished = function() {  
new mx.transitions.Tween(subClip, “\_x”, mx.transitions.easing.Regular.easeOut, subClip.\_x endX, speed);  
}  
};[/AS] it’ll be easier to make any modifications in the future.:cowboy:

---

<div class="post-metadata">

**Author:** ![joran420](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joran420/32/2329_2.png) [@joran420](https://forum.kirupa.com/u/joran420)\
**Post date:** [April 19, 2006, 4:24pm UTC](https://forum.kirupa.com/t/simple-easing-effect-not-working-and-i-dont-know-why/186174/3 "2006-04-19T16:24:29Z")

</div>

try

var TargetXy:Object = {x:mainClip.[COLOR=#000080]subClip[/COLOR].\_x , y:mainClip.[COLOR=#000080]subClip[/COLOR].\_y)  
\_root.mainClip.localToGlobal(TargetXy)

and use targetXy.x value to compare

cause your getting subclips coords on Mainclips area so it wont match the X,Y that its at on the main timeline unless u translate it with localToGlobal

…I think

---

<div class="post-metadata">

**Author:** ![graylensman](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@graylensman](https://forum.kirupa.com/u/graylensman)\
**Post date:** [April 19, 2006, 5:22pm UTC](https://forum.kirupa.com/t/simple-easing-effect-not-working-and-i-dont-know-why/186174/4 "2006-04-19T17:22:09Z")

</div>

Thanks guys!  
joran, I’ll give your code a run.

BlueNar, I tried to use the tween Class, BUT - I discovered it wouldn’t work properly with another aspect of my full project. In the subClip, I’m attaching a movie clip containing buttons that trigger external swfs (using the kirupa transitions between external swfs AS). Turns out that the tween class doesn’t play nice with that script. Believe me, I know: I spent three nights tearing it apart to find out! If you have any ideas, please let me know - I’d much rather use the tween class.
