# Change the speed of a movieClip while it's moving between bountries

**URL:** <https://forum.kirupa.com/t/change-the-speed-of-a-movieclip-while-its-moving-between-bountries/330563>\
**Category:** flash\
**Created:** [February 9, 2013, 5:12pm UTC](https://forum.kirupa.com/t/change-the-speed-of-a-movieclip-while-its-moving-between-bountries/330563 "2013-02-09T17:12:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Plug\_Head](https://avatars.discourse-cdn.com/v4/letter/p/59ef9b/32.png) [@Plug\_Head](https://forum.kirupa.com/u/Plug_Head)\
**Post date:** [February 9, 2013, 5:12pm UTC](https://forum.kirupa.com/t/change-the-speed-of-a-movieclip-while-its-moving-between-bountries/330563/1 "2013-02-09T17:12:39Z")

</div>

I want the user to enter the speed (input text) in which a movieClip is moving back and forth between boundaries and then change it again as the mc is moving.  
I’ve managed to make the movieClip start moving whith a certain speed with an onEnterFrame event but when I try to change the speed, it skips the if statements that define the boundaries of the movement and the movieClip exits the scene.  
Any help??  
Here’s the code so far

```auto

 ///code written on movieClip that moves back and forth

onClipEvent(load){
    radious=this._width;
    var speed=0;
    rightWall=_root.range1._x+_root.range1._width; 
    leftWall=_root.range1._x;
}
    onClipEvent(enterFrame){
    if (_root.isOn==true){ //is on gets true with a start button
    speed=0.5*_root.rpm; // where rpm takes values from a text input box
    if(Math.abs(_x-leftWall)<radious){
    
    speed=-speed;
    }
    if(Math.abs(_x-rightWall)<radious){
     speed=-speed;
    }
    
    }
    }
    

```
