Page 1 of 1

Move a group in whilst moving an object in the group

Posted: Mon Sep 29, 2014 4:09 pm
by andrewferguson
Hi all,
I have a group of objects, and I want to move this group along the horizontal axis. At the same time, I also want an object that is in the group to move along the vertical axis whilst still moving with the rest of the group.

I know of a more complicated way that involves calculating where the object will be on the x and y axis once the move has finished, but I am hoping that there is an easier way.

Any ideas?

Thanks,
Andrew

Re: Move a group in whilst moving an object in the group

Posted: Mon Sep 29, 2014 5:04 pm
by zaxos

Code: Select all

on scrollGroup
  set the lockLoc of group "YourGroup" to true
  set the left of group "YourGroup" to (the left of this card - 1)
  set the left of btn "YourObject" to (the left of group "YourGroup)
  send "scrollGroup" to me in 25 milliseconds
end scrollGroup
a better way would be to put your group inside another group

Code: Select all

on scrollGroup
  set the lockLoc of group "YourGroup" to true
  set the lockLoc of group "YourGroup2" to true
  set the left of group "YourGroup" to (the left of group "YourGroup2"- 1)
  set the left of btn "YourObject" to (the left of group "YourGroup)
  send "scrollGroup" to me in 25 milliseconds
end scrollGroup

Re: Move a group in whilst moving an object in the group

Posted: Mon Sep 29, 2014 7:37 pm
by dunbarx
Hi.

Not sure whether you are moving under script control. or via the mouse, or whatever. But if under script control, then with several objects grouped, one of which is a button named "b1", put this into the script of another, independent button:

Code: Select all

on mouseUp
   set the startprop of grp 1 to the properties of grp 1
   set the startloc of btn 1 to the loc of btn 1
   repeat 100
      set the left of grp 1 to the left of grp 1 + 1
      set the top of btn 1 to the top of btn 1 + 1
      wait 2
   end repeat
   set the properties of grp 1 to the startprop of grp 1
      set the loc of btn 1 to the startloc of btn 1
end mouseUp
Move the test group to the left side of the card window. Click on the independent button. Does this help? Do you see what the set-up and clean-up lines do?

Craig Newman