Page 1 of 1

Wait until the move is done(?)

Posted: Wed Nov 20, 2013 5:47 pm
by rumplestiltskin
I've got a handler that does this:

move graphic "ball" to 300,300 in one second
--then we do other things

The problem is that the "other things" start before the move is complete. I tried adding "wait 1 second" after the first line of code but that seems to freeze everything so you don't see the object move properly and the other things (that do some more movement) don't work properly because the position of the object isn't where it should be. So I'm looking for the equivalent to "wait until the move is done", as in:

move graphic "ball" to 300,300 in one second
wait until the move is done
--then we do other things

Any suggestions welcomed!

Thanks,
Barry

Re: Wait until the move is done(?)

Posted: Wed Nov 20, 2013 6:23 pm
by Klaus
HI Barry,

you do not need to do anything!
...
move graphic "ball" to 300,300 in one second
put "Done"
...
"Done" will appear in the message box AFTER the graphic has stopped.
Just tested, that is "normal" behavior :D

If you want to continue the script immediately after the object starts moving, add this:
...
move graphic "ball" to 300,300 in 1 secs WITHOUT WAITING
put "Done"
...
"Done" will appear immediately in the message box.


Best

Klaus

Re: Wait until the move is done(?)

Posted: Wed Nov 20, 2013 6:25 pm
by rumplestiltskin
Klaus,

Thanks. However, what I need to do is wait until the object has finished moving before the script continues.

Barry

edit: If I leave off the "without waiting", that should do it?

Re: Wait until the move is done(?)

Posted: Wed Nov 20, 2013 6:25 pm
by chris25
I created a start button and two extra buttons and then put this code into the start button:

on mouseup
move button "b1" from 200,250 to 250,300 in 2 seconds
wait 2 seconds
move button "b2" from 200,250 to 350,400 in 2 seconds
end mouseup
I do not know if this helps if you compare it with anything you have done, but it worked as expected. Hope I have not misunderstood you.

kind regards
chris

Re: Wait until the move is done(?)

Posted: Wed Nov 20, 2013 6:35 pm
by rumplestiltskin
Yes, all I needed to do was leave off the "without messages" and that resolved it.

move graphic 1 to 300,300 in 1 second
wait .2 seconds -- just so the user sees the object has, indeed, been moved back to the starting point before moving it again.
rest of stuff gets done

Thanks Klaus and Chris! As is usual, all I needed to do was have a few sets of new eyes to help clarify this.

I-am-not-worthy...

Barry

Re: Wait until the move is done(?)

Posted: Wed Nov 20, 2013 6:38 pm
by chris25
neither am I....but getting others to disagree with you helps....