Page 1 of 1

how to properly sequence 2 aemoveto's

Posted: Tue Jun 12, 2012 10:19 pm
by adventuresofgreg
Hi: I am moving a group using aemoveto for 100 milliseconds, then I want to move it somewhere else. I've been using "wait for 500 milliseconds with messages" after the first aemoveto, to allow that first move to finish before starrting the next aemoveto.

I understand that wait with messages is a problem in iOS deployment - is there a better way to control the sequence of moves?

thanks
Greg

Re: how to properly sequence 2 aemoveto's

Posted: Wed Jun 13, 2012 7:48 am
by malte
HI Greag,

you can either make use of the callbackMessage aeMoveTo sends, or use send in time to achieve what you want.

Code: Select all

in a button:

on mouseUp
  set the flag of me to not the flag of me
  if the flag of me then
    moveRandom
  end if
end mouseUp


in the card script:

on moveRandom
      aeMoveTo the long id of btn "myButton", random(the width of this stack),random(the height of this stack),500,"bounce"
end moveRandom

on aeMoveDone
  if the short name of the target="myButton" then
    if the flag of btn "myButton" then
      send "moveRandom" to me in 3 seconds
    end if
  end if
end aeMoveDone
Hope that helps. Malte

Re: how to properly sequence 2 aemoveto's

Posted: Wed Jun 13, 2012 4:23 pm
by adventuresofgreg
Hi Malte:

Thanks for that - yes, I have played with the aeMoveDone callback message a bit and I'm not really understanding how this can be used in a very large, complex script with many different moving items that are each coordinated in time. For example:

aemoveto thisthing for 5 seconds
wait 5 seconds
aemoveto thisthing for 1 second
wait 1 second
aemoveto differentThing for 4 seconds
aemoveto anotherThing for 4 seconds
wait 4 seconds
aemoveto thisThing for 2 seconds
aemoveto differentThing for 3 seconds
wait 3 seconds

If I was to use the aeMoveDone rather than using "wait", I would require a separate handler for each occurance of a aemoveto in the above script - it could get very confusing and complicated. yes? or am I not really understanding how to apply the callback?

Cheers,
Greg

Re: how to properly sequence 2 aemoveto's

Posted: Thu Jun 14, 2012 6:42 am
by malte
Hi Greg,

you can either give each control its on aeMoveDone handler, this can get confusing, or instead move the callback to card level and chack the name of the target (aeMoveDone is sent to the control that stops moving), or use a completely different strategy.

on moveIt pTarget,pX,pY,pTime,pEffect
aeMoveto pTarget,pX,pY,pTime,pEffect
end moveIt

and then change your original pseudo code to

aemoveto thisthing for 5 seconds
send "moveIt" && the long ID of thisTHing&","&x&","&y&","&1000 to this cd in 5 seconds
...

hth,

Malte

Re: how to properly sequence 2 aemoveto's

Posted: Thu Jun 14, 2012 5:30 pm
by adventuresofgreg
Thank you Malte. I have been playing with the callbacks and I'm slowly getting the hang of it.