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

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:

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:

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?

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:


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

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

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.