Spinning object animation
Alejandro Tejada
capellan2000 at gmail.com
Sat Mar 3 22:39:59 EST 2012
Hi All,
This handler change the frames of an animated
gif to simulate a rotating object, but is not
working as expected. One of these animations
moves in the opposite direction in which it
is dragged with the mouse... :-(
The user should click inside the image, holding
down the mouse button and moving inside the
image from left to right or viceversa and
the animation should change of frames.
If you want to see this strange effect
download, for example, these gif images:
http://www.createdesignsolutions.com/images/spinning_globe.gif
http://www.tabletopstudio.com/images/3d/ezspins/vase_nb.gif
Create a new stack, with two cards and import
each image to a different card.
Now, paste the following script in the
stack script editor:
local tMouse,tLoc,tImageFrame
on mouseenter
if word 1 of the target is "image"
then
set the lockCursor to true
set the cursor to hand
end if
end mouseenter
on mouseleave
mouseup
if word 1 of the target is "image" then set the lockCursor to false
end mouseleave
on mousedown
put 1 into tMouse
put the mouseloc into tLoc
put item 1 of tLoc into tLoc
put the currentframe of img 1 into tImageFrame
put tImageFrame && the currentframe of img 1
end mousedown
on mouseup
put empty into tMouse
put empty into tLoc
put empty into tImageFrame
end mouseup
on mouseMove x,y
if tMouse = 1
then
if (abs(tLoc - x) mod 12) = 0
then
switch
case (tLoc - x) > 0
put tImageFrame && the currentframe of img 1
if the currentframe of img 1 = the framecount of img 1
then
set the currentframe of img 1 to 1
put tImageFrame && the currentframe of img 1
else
set the currentframe of img 1 to the currentframe of img 1 +
1
put tImageFrame && the currentframe of img 1
end if
break
case (tLoc - x) < 0
put tImageFrame && the currentframe of img 1
if the currentframe of img 1 = 1
then
set the currentframe of img 1 to the framecount of img 1
put tImageFrame && the currentframe of img 1
else
set the currentframe of img 1 to the currentframe of img 1 -
1
put tImageFrame && the currentframe of img 1
end if
break
end switch
end if
end if
end mouseMove
Thanks in advance!
Al
--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/Spinning-object-animation-tp4442898p4442898.html
Sent from the Revolution - User mailing list archive at Nabble.com.
More information about the use-livecode
mailing list