Problems with onEnterFrame

Hi everyone.

I’m trying to set up a script which would force an object to move through the stage untill a particular point and than change direction.

i wrote something like that:

onClipEvent (enterFrame) {
moveUp = function () {
this._y -= 1;
if (this._y<-30) {
this.onEnterFrame = moveDown;
}
};
moveDown = function () {
this._y += 1;
if (this._y>600) {
this.onEnterFrame = moveUp;
}
};
this.onEnterFrame = moveUp;
}

but it doesn’t work. the object moves only one direction and does not change it.

if enybody can see any error, please help!

thank you for your attention.

Personally, I’d use a series of tweens to accomplish this. [AS]var tw1 = new mx.transitions.Tween(mc,"_y",mx.transitions.easing.None.easeNone,mc._y,-30,25);
tw1.onMotionFinished = function(){
var tw2 = new mx.transitions.Tween(mc,"_y",mx.transitions.easing.None.easeNone,mc._y,600,25);
}[/AS]