Page 1 of 1

How to keep an object moves together with scrollbar drag

Posted: Fri May 09, 2008 11:22 am
by alex298
Hi,

I don't know how to keep an object moving hand in hand with a scrollbar. Here's my problem:

1. I layout a group "MyImage" with a vertical scrollbar in a card. There is a picture loaded in the group "MyImage".

2. A field "test" is layout in some position inside the group "MyImage".

I wish that the field "test" will always keep in the same position relative to the picture inside the group "MyImage" when the vertical scrollbar drag up and down.

I tried to use the following code:
on scrollbarDrag
## Get the co-ordination of group "MyImage"
put the left of group "MyImage" into x1
put the top of group "MyImage" into y1

## Update the new position
set the loc of field "test" to item 1 of the loc of field "test", item 2 of the loc of field "test" + the vscroll of group "MyImage"
end scrollbarDrag
Obviously the above codes do not works. The the vscroll of group "MyImage" keeps updating the "total amount" while the vertical scrollbar is dragging.

Could you please provide some idea how to do it?

Thanks and best regards

Posted: Fri May 09, 2008 1:53 pm
by Mark
Hi Alex,

You don't need any script to do this. Just group the field and the image together and they will scroll together.

Best,

Mark

Posted: Fri May 09, 2008 2:40 pm
by alex298
Hi Mark,

Thanks for your kind assistance. Actually I think to group the group "MyImage" and field "test" before.

Since many pictures will be showing one by one in the group "MyImage", therefore the field "test" will also be used with other pictures. If I group the field "test" with the group "MyImage", I have to group, ungroup and group for a picture, then group, ungroup and group for other pictures......

Moreover I have more than one objects to display on the group "MyImage", the grouping method will be quite tedious. That's why I am thinking to use scripts to do that.

Thanks and best regards

Posted: Fri May 09, 2008 2:47 pm
by Mark
Alex,

That sounds way too complex. I don't know exactly what you are trying to do, but usually there are two ways.

Use one group, with an image and a field, and change the text of the image or the filename as necessary.

Or create one group with an image and a field, and clone it before setting the text of the image or its filename. Delete the group when you don't need it anymore.

Usually, it isn't necessary to create a new group for each image you want to display.

Best,

Mark