Moving Buttons paralell

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
alexd1991
Posts: 2
Joined: Thu May 29, 2014 12:37 pm

Moving Buttons paralell

Post by alexd1991 » Thu May 29, 2014 1:01 pm

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
Last edited by alexd1991 on Thu May 29, 2014 3:21 pm, edited 1 time in total.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Moving Buttons paralell

Post by [-hh] » Thu May 29, 2014 1:24 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:44 pm, edited 1 time in total.
shiftLock happens

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10335
Joined: Wed May 06, 2009 2:28 pm

Re: Moving Buttons paralell

Post by dunbarx » Thu May 29, 2014 1:48 pm

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

alexd1991
Posts: 2
Joined: Thu May 29, 2014 12:37 pm

Re: Moving Buttons paralell

Post by alexd1991 » Thu May 29, 2014 3:31 pm

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 :/

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10335
Joined: Wed May 06, 2009 2:28 pm

Re: Moving Buttons paralell

Post by dunbarx » Thu May 29, 2014 4:22 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10335
Joined: Wed May 06, 2009 2:28 pm

Re: Moving Buttons paralell

Post by dunbarx » Thu May 29, 2014 4:30 pm

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

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Moving Buttons paralell

Post by [-hh] » Thu May 29, 2014 6:35 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:43 pm, edited 3 times in total.
shiftLock happens

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10335
Joined: Wed May 06, 2009 2:28 pm

Re: Moving Buttons paralell

Post by dunbarx » Thu May 29, 2014 6:37 pm

Hermann.

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

Craig

Post Reply