Stop the animation while it is in progress?
Stop the animation while it is in progress?
- Subject: Stop the animation while it is in progress?
- From: Bob Ueland <email@hidden>
- Date: Wed, 14 Nov 2007 06:58:17 -0800 (PST)
Hi I have a simple image that I animate (move horizontally) on the screen from startLoc to endLoc. The animation happens when the user clicks on the Animate button (which triggers the animate action). The animation happens during 6 seconds (I set duration=6.0). There is also a Kill button (which triggers the kill action). What I want is to kill the animation while in progress. I tried to do it by setting location of the image outside screen, but it did not work. How What should I do in order stop the animation while it is in progress?
- (IBAction)animate:(id)sender
{
position.origin.x = startLoc;
[view setFrame:position];
position.origin.x = endLoc;
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:duration];
[[view animator] setFrame:position];
[NSAnimationContext endGrouping];
}
- (IBAction)kill:(id)sender
{
position.origin.x = startLoc;
[[view animator] setFrame:position];
}
@end
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden