I've been working on refactoring someone else's stacks, using groups for graphics that are repeated on multiple cards to reduce the size a bit.
The problem I'm running into is when a group of images is in a different position on one card than the other. Since changing anything in a group changes it everywhere, I now have to make sure locations are set explicitly in the code on each "on openCard".
Unfortunately, when I use "set the location of group X to X,Y" it sets the location of the group to some wrong, and seemingly arbitrary location.
For instance, I say " set the location of group "BodyParts1" to 171,386" and when I run it, the group is in the wrong place, and checking the properties of the group, I see the location is 149,630. If I say "put the location of group "BodyParts1" into tGroupLoc, then checking the variable shows me... 149,630.
I've even tried using move instead of set location to see if that would work better. Same thing, I tell it to go to a point, it goes to a totally different point. I thought I had it for a bit, as it was moving it to a point that was only +4,+4 off from what I told it. Okay, I can adjust for that. But, then I had to go to the first card of the project and set locations there since I had moved it at the end of the stack. And once I got those set, returning to the last card of the stack the move command now chose a completely different point to wrongly move it to.
What am I missing here? It is almost like I am setting it relative to some unknown point, but I'm not. I'm specifically declaring what point to set the location to, and it's just not listening. Does setting the location of a group work entirely different than setting the location of another object? If so, it would be nice to see this in the documentation of loc, location, and move.
Any help would be greatly appreciated.
set location of group doesn't set it to the point I specify
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: set location of group doesn't set it to the point I spec
By default, groups have a margin. It may be that the location is correct, but the display is off because of the margin? Try setting the margin of the group to 0 and see if that fixes the +4,+4 issue at least.
Re: set location of group doesn't set it to the point I spec
For the other issues, it may be that there is a discrepancy between the screen coordinates and the coordinates relative to the top left of the stack?
Re: set location of group doesn't set it to the point I spec
What Sparkout is alluding to might be worth an experiment. What happens if you set the topLeft of the group instead of its loc?
Craig Newman
Craig Newman
Re: set location of group doesn't set it to the point I spec
SparkOut is probably right about the margin.
The overall issue had to do with location not being locked on the group or the images in the group and the fact that the group members were being hidden and shown, causing the group to automatically resize to just fit the visible images. Since location is based on the center point of the group, resizing caused elements to be out of place. That's probably not a very good explanation, but basically, locking the location and size of the group and all the members is now allowing me to set the location of the group and have all the images show up in the right places.
I'm finding groups to be very useful, but still struggling with some of the positioning concepts and how they differ. Setting the topLeft probably would have given me much more consistent results, and maybe worked as I wanted. I will have to experiment with using that instead of location in similar situations in the future. The topLeft point might have stayed stable even when resizing, it certainly wouldn't have changed as much as location and been easier for me to grasp what was happening.
Thanks for the help and tips!
The overall issue had to do with location not being locked on the group or the images in the group and the fact that the group members were being hidden and shown, causing the group to automatically resize to just fit the visible images. Since location is based on the center point of the group, resizing caused elements to be out of place. That's probably not a very good explanation, but basically, locking the location and size of the group and all the members is now allowing me to set the location of the group and have all the images show up in the right places.
I'm finding groups to be very useful, but still struggling with some of the positioning concepts and how they differ. Setting the topLeft probably would have given me much more consistent results, and maybe worked as I wanted. I will have to experiment with using that instead of location in similar situations in the future. The topLeft point might have stayed stable even when resizing, it certainly wouldn't have changed as much as location and been easier for me to grasp what was happening.
Thanks for the help and tips!