# Problems with onEnterFrame

**URL:** <https://forum.kirupa.com/t/problems-with-onenterframe/182936>\
**Category:** flash\
**Created:** [March 22, 2006, 4:37pm UTC](https://forum.kirupa.com/t/problems-with-onenterframe/182936 "2006-03-22T16:37:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ka\_ci](https://avatars.discourse-cdn.com/v4/letter/k/bb73d2/32.png) [@ka\_ci](https://forum.kirupa.com/u/ka_ci)\
**Post date:** [March 22, 2006, 4:37pm UTC](https://forum.kirupa.com/t/problems-with-onenterframe/182936/1 "2006-03-22T16:37:10Z")

</div>

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.

---

<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:** [March 22, 2006, 5:22pm UTC](https://forum.kirupa.com/t/problems-with-onenterframe/182936/2 "2006-03-22T17:22:12Z")

</div>

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]
