Probably a very simple one but I’m puzzling for a while to move a movieclip in a rectangular way with speed control. So the object should move right (400,0) then down (400,400) then from right to left (0,400) and then up again (0,0) and this of course in an endless loop.

I tried this

onClipEvent(enterFrame) {

speed = 1;

this._x += speed;

this._y += speed;

```
if(this._y>0&&this._y<400){
this._y= 0
}
if(this._x>400){
this._x = 400
```

}

which works okay, till I get to point (400,0) but then I get stuck, could somebody give me a hint how I should work this simply look math out.