Page 1 of 1

Moving Buttons paralell

Posted: Thu May 29, 2014 1:01 pm
by alexd1991
Hello,

I am a beginner and try to move some buttons in a loop.

At first the button falls down and then it moves to the black box at the right side.

s7 directupload net/images/140529/7k8ye9hg.jpg

It works fine with one button. But with more than one button, the next button falls down when the first button finished the move. I want decide when the next button falls down.
E.g. Every 3 seconds a button falls down.

The Speed of the first move and the second move is different.

Here is my code:

Code: Select all

   repeat with i = 1 to akf --akf=number of buttons     
      create button "packet"&i
      set the label of it to " "
      set the width of it to 16
      set the height of it to 14
      set the loc of it to 454,153
      set the backgroundColor of it to 140,118,85
      set the borderColor of it to 140,118,85     
      set the layer of graphic "server" to top
      set the moveSpeed to 500
      move it from 454,153 to 454, 205 
      set the moveSpeed to abf ---dynamic move speed
      move it from 454,205 to 750, 205 
      set the visible of it to false  
   end repeat
I tried some ways with "without waiting" or "wait 3 secons", but nothing works.

Could you please help me?

Thanks, Alex

Re: Moving Buttons paralell

Posted: Thu May 29, 2014 1:24 pm
by [-hh]
..........

Re: Moving Buttons paralell

Posted: Thu May 29, 2014 1:48 pm
by dunbarx
Please also check out the "moveStopped" message. This might be useful to initiate the next pass through your loop.

On another note, you should experiment with the "templateButton". This virtual object can hold all the properties you are setting by hand, and every new button you make will inherit those, so you do not need all that code each time through the loop.

Craig Newman

Re: Moving Buttons paralell

Posted: Thu May 29, 2014 3:31 pm
by alexd1991
Thanks for your answers.

I tried it with "lock moves", but then all packets drop at the same time.

How can I implement the "moveStopped" message?
I tried it like below:

Code: Select all

on moveStopped
      set the moveSpeed to abf
      move packet1 from 454,205 to 750, 205 
      delete packet1
      end moveStopped
But it doesn't work :/

Re: Moving Buttons paralell

Posted: Thu May 29, 2014 4:22 pm
by dunbarx
Hi.

Make sure you use the "move" command "without waiting" or the moveStopped message is not sent.

Make a test stack. Put two buttons on it. Name one of those buttons. In the other button, write a handler that moves the first one. Make sure to use the "without waiting" parameter. In the card script:

Code: Select all

on movestopped
   answer the target
end movestopped
Can you make this work with your multiple button project?

Craig

Re: Moving Buttons paralell

Posted: Thu May 29, 2014 4:30 pm
by dunbarx
I think the "lock moves" idea will not work for you if you want sequential action. That tool is designed mainly to queue "move" commands and release them as a batch.

You want to trigger each new control in turn. This might be done with a "send in time..." construction, as Hermann mentioned earlier, but the "moveStopped" message likely makes that process simpler and more straightforward. It is sent when the move is stopped, and therefore contains within itself the timing capability you are looking for.

Craig

Re: Moving Buttons paralell

Posted: Thu May 29, 2014 6:35 pm
by [-hh]
..........

Re: Moving Buttons paralell

Posted: Thu May 29, 2014 6:37 pm
by dunbarx
Hermann.

I cannot find it in my heart to criticize you. You don't even know what day it is.

Craig