Page 1 of 1
Objects placed on Image Move when size changed
Posted: Thu Jan 30, 2020 3:40 pm
by trags3
I am working on an app that requires hidden objects on an image. As the app is run some of those objects need to be visible and sometimes not. If the image size of the main background image changes the placed objects are no longer in the correct place. I know there is a solution, I just don't know what that solution is!
Thanks
Tom
Re: Objects placed on Image Move when size changed
Posted: Thu Jan 30, 2020 3:51 pm
by FourthWorld
You can prevent the image from resizing by setting its lockLoc property to true.
If you want the image to resize, you can adjust the placement of the other objects by setting their location (or short, loc) property.
Re: Objects placed on Image Move when size changed
Posted: Thu Jan 30, 2020 5:27 pm
by dunbarx
I think the issue is that the overlying controls are not scaling position as the image resizes. Tom, is this so?
If it is, grouping the lot will not help. You will have to calculate the change in the background image, and shift the controls accordingly. One issue here is that unless you also scale the rects of those controls, they will stay the same size, which may not be what you want.
Write back. (Bogs!)
Craig
Re: Objects placed on Image Move when size changed
Posted: Thu Jan 30, 2020 6:21 pm
by trags3
Thanks, Craig,
I am pretty sure this is the issue. I think I can work it out now.
Tom
Re: Objects placed on Image Move when size changed
Posted: Thu Jan 30, 2020 6:39 pm
by dunbarx
Ah.
There are some threads about this very thing, though it may take some effort to find them via keywords.
Basically, pixel by pixel, since you know the change in the rect, and, say, the "old" and "new" topLeft, the math is straightforward. Or you can do the whole thing at once if you lock the screen and do one set of calculations. But "live" scaling is so much sexier.
Thanks for replying before Bogs had a chance to razz me.
Craig