# Horizontal movement with AS

**URL:** <https://forum.kirupa.com/t/horizontal-movement-with-as/201203>\
**Category:** flash\
**Created:** [September 19, 2006, 12:04pm UTC](https://forum.kirupa.com/t/horizontal-movement-with-as/201203 "2006-09-19T12:04:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dokratos](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@Dokratos](https://forum.kirupa.com/u/Dokratos)\
**Post date:** [September 19, 2006, 12:04pm UTC](https://forum.kirupa.com/t/horizontal-movement-with-as/201203/1 "2006-09-19T12:04:01Z")

</div>

I’m trying to get a few movie clips to move horizontaly, with actionscript, while they respect a certain sequence. For an example of what I want to achieve with actionscript you can go to [www.ruisoaresesteves.com](http://www.ruisoaresesteves.com) and look at the animation there. That’s what I am trying to achieve but instead of a single strip animated with flash animation, I have that same strip cutted in 6 parts and want to get that effect with actionscript. I just don’t seem to get the code right:

Here’s what I currently have:  
[COLOR=blue]  
function initObject(myObject){

speed = 1;

\_root[myObject].onLoad = function () {

```
_root[myObject]._x += speed;

if (PCT6._x &lt;= -1353.0) {
    speed = -2
}
else if (PCT1._x &lt;= -1379.0) {
    speed = 0
    PCT1._x = 798
    }
if (PCT1._x &lt;= -578) {
    speed = -2
    PCT2._x = 798
}
else if (PCT2._x &lt;= -1402.0) {
    speed = 0
}
if (PCT2._x &lt;= -578.0) {
    speed = -2
    PCT3._x = 798
}
else if (PCT3._x &lt;= -1303.0) {
    speed = 0
}
if (PCT3._x &lt;= -503.0) {
    speed = -2
    PCT4._x = 798
}
else if (PCT4._x == -1407.0) {
    speed = 0
}
if (PCT4._x &lt;= -607.0) {
    speed = -2
    PCT5._x = 798
}
else if (PCT5._x &lt;= -1928.0) {
    speed = 0
}
if (PCT5._x &lt;= -1128.0) {
    speed = -2
    PCT6._x = 798
}
else if (PCT6._x &lt;= -2153.0) {
    speed = 0
};
};

```

}

initObject(“PCT1”);  
initObject(“PCT2”);  
initObject(“PCT3”);  
initObject(“PCT4”);  
initObject(“PCT5”);  
initObject(“PCT6”);[/COLOR]

But it doesn’t work. Can someone give a couple of hints on how to do this?
