Moving and stop

Hi! All,\r\rI put the following script in a MC and have the MC moves gradually from left to right:\r\ronClipEvent (load) {\r speed = 2;\r&nbsp &nbsp &nbsp &nbsp startX = this._x;\r}\ronClipEvent (enterFrame) {\r&nbsp &nbsp &nbsp &nbsp this._x = this._x+speed;\r&nbsp &nbsp &nbsp &nbsp if (this._x>500) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this._x = startX;\r&nbsp &nbsp &nbsp &nbsp }\r}\r\rNow, I want the MC moves a short distance, say 100 pixels, and stops for a while, say 5 seconds, and again moves and stops…\r\rThanks for anybody help me on this.\r\rJames

Use an if condition combined with a function using getTimer; getTime at start, save in var, get again in the function and check the difference against the value you want, when value is reached, move again…i know this is kinda short, you ok with actionscript? (btw, timer gets milliseconds, don’t forget the conversion -5secs=5000millisecs)

Thanks eyezberg,\r\rPer your advise, I revised my script as follows:\r\ronClipEvent (load) {\r_ _ _ _ _ _ _ _ speed = 2;\r startX = this.x;\r}\ronClipEvent (enterFrame) { \r\r _ _ _ for (i=1; i<4; i++){\r\r_ _ _ _ _ _ _ _ this.x = this.x+speed;\r\r _ _ _ _ _ _ _ \r _ _ _ _ _ _ _ if (this.x==100+(i-1)*100){\r _ _ _ _ _ _ _ _ _ _ _ currentTime = int(getTimer()/1000);\r_ _ _ _ _ _ _ _ _ _ _ _ if ((time+5)<=currentTime) {\r speed=0;\r_ _ _ _ _ _ _ _ _ _ _ _ time = currentTime;\r_ _ _ _ _ _ _ _ _ _ _ _ }\r\r_ _ _ _ _ _ _ _ }\r\r if (this._x>500) {\r this.x = startX;\r }\r _ _ _ }\r}\r\rI just want to stop at 100, 200, and 300. I know my “for loop” is not properly placed. Could give me some advise. Also I can’t stop the MC even I put a “if loop”. There should be something wrong. Appreciate your help.\r\rJames

Hi, All,\r\rI now work from other direction and the MC can move about 2 sec and then strop for about 3 sec…The script is as follows:\r\ronClipEvent (enterFrame) {\r&nbsp &nbsp &nbsp &nbsp if (_root.delay) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this._x += 2;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp if (int(getTimer()/1000) > _root.lastTime+1) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _root.delay = false;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this._x += 0;\r\r&nbsp &nbsp &nbsp &nbsp }\r&nbsp &nbsp &nbsp &nbsp } else if (int(getTimer()/1000) == _root.lastTime+5) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _root.lastTime = int(getTimer()/1000);\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _root.delay = true;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \r&nbsp &nbsp &nbsp &nbsp }\r}\r\rHowever, I don’t know how to control the MC to stop at every 100 pixels. Appreciate if anybody can help me…

Maybe make sure _x is 0 onLoad (so +2 eventually gets you to 100, 200…) and nest another if (this._x=i), right before you set up a loop for(i=100;i<whateverYouNeed;i+=100)…\rPost the result once e’thing works :wink:

Thanks for reply.\r\rIt will be no problem to get 100,200,…if I set x +=1; or move the MC starting position. The problem is that I really don’t know where to put the “for loop” and “if clause”. I tried to put them as follows but it doesn’t work.\r\ronClipEvent (enterFrame) {\r\rfor (i=100;i<whateverYouNeed;i+=100){\r if (root.delay) {\r\r _ _ _ \r this._x += 1;\r\r _ _ _ _ _ _ _ _ if (this._x=i){ \r \r if (int(getTimer()/1000) > _root.lastTime+1) {\r _root.delay = false;\r this.x += 0;\r _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ }\r }\r } else if (int(getTimer()/1000) == _root.lastTime+5) {\r _root.lastTime = int(getTimer()/1000);\r _root.delay = true;\r \r }\r}\r}