Hey: why slave away to do something that somebody has already done?
http://lists.runrev.com/pipermail/use-l ... 66416.html
The script below will allow you to rotate an image about any predefined point.
Create a button.
Create an image.
Place the button at any point relative to the image. (Perhaps use a grab me in a mousedown handler.)
Click the button.
The image will rotate about the center of the button.
(For your application you would replace the center of rotation with the center of mass.)
on mouseUp
set the angle of img 1 to 0
put the loc of me into myLoc
--Set the coor of the rotation Pt
put item 1 of myLoc into x0
put item 2 of myLoc into y0
--Get the loc of the image
put the loc of img 1 into tLoc
put item 1 of tLoc into xC
put item 2 of tLoc into yC
--Get the distance between the roation pt and the image center
put sqrt ( (xC - x0 )^2 + (yC - y0)^2 ) into L
--Get the angle of the line from the rotation center to the image center
put atan2(yC-y0, xC-x0) *180/pi into phi0
put 0 into tAngle
repeat 360 times
lock screen
set the angle of img 1 to -tAngle
put phi0 + tAngle into phi
set the loc of img 1 to (x0 + L * cos(phi*pi/180)), (y0 + L * sin(phi*pi/180))
unlock screen
add 1 to tAngle
wait 10 millisec --or whatever
end repeat
end mouseUp
on mouseDown
grab me --So that you can relocate the rotation center.
end mouseDown