Skip to main content
Participating Frequently
November 28, 2010
Question

Delay movement how?

  • November 28, 2010
  • 1 reply
  • 335 views

Hello,
I have an object that you can control with the arrow keys, and I also have another object that have this code:


this._y = _root.object_mc._y
this._x = _root.object_mc._x


Alright, but I want my second object to wait one second before getting the same position as object_mc, and when object_mc moves again the second object will keep delaying one second before getting the new position.
Is that possible?

Thanks.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
November 28, 2010

yes, you can use setTimeout(f,delay) to call function f() after delay milliseconds.

(note:  setInterval(f,delay) will call f() every delay milliseconds until clearInterval() is called.  be careful with this.)