Can we stop animate in TGIFImage delphi component? - image

Sometimes i want to run gif image with animate once or twice,,and stop it,, is there possible to do that?

The animation is controlled by the Animate property of the TGIFImage control. Set it to True to animate, and set it to False to stop the animation.
There is also the AnimateLoop property. If that is True then the animation loops endlessly. Otherwise it runs once and then stops. If you want to run the animation once then set AnimateLoop to False and then set Animate to True.
Finally you have the OnLoop event. That fires each time a looped animation loops back to the start. So, if you want to show an animation twice or more then you need to set AnimateLoop to True and then count the loops in an OnLoop handler.

Related

An sssue about CocosBuilder timeline animation

I've created a CCLayer by using Cocosbuilder. There are two timeline animations called "MyAnim1" and "MyAnim2". None of them are auto-run. MyAnim1 is chained to MyAnim2. I'm using CCBAnimationManager to run the first animation. And it works and the second animation is chained to animation 1 as I expected. But here comes a problem. The first animation goback to its initial status when the second animation start. Is this a bug? Is there a way to keep my first animation status to the end status when the second animation starts?

KineticJS: Clicks to background layers stop firing after draw

KineticJS seems to have an issue with handling clicks on background layers after redrawing the stage.
I have a jsfiddle with a minimal example of this problem. http://jsfiddle.net/Z2SJS/
On line 34 I have:
stage.draw()
If this is commented out, events fire as they should. When this is present, after dragging the click events to the background will stop firing.
I know that in this example I am not doing anything that would require me to redraw the stage, but in my project I am using the dragstart and dragmove events to manipulate objects on multiple layers, and I then lose reference to my background clicks.
Is there something I need to do to ensure that redrawing the stage does not cause my events to stop firing?
Instead of using stage.draw() use foreground.draw()
here is the updated fiddle
Alternately: set dragOnTop: false inside the circle instantiation. Fiddle2

how to stop an animation but make it finish the current animation

I make a animation and make it runs it forever. And now I want to stop it after clicking a button. Then animation is rotating a image of a button from 0 to 360 degree.
I'd like to stop the animation but make the animation to finish the current cycle. For example, if the button is rotated at 200 degree, and I click the stop button, I want that the animation still runs to reach 360 degree and then stop.
The animation code is like below:
CABasicAnimation *anim2 = [CABasicAnimation animationWithKeyPath:#"transform.rotation"];
anim2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
anim2.fromValue = [NSNumber numberWithFloat:0];
anim2.toValue = [NSNumber numberWithFloat:-((360*M_PI)/180)];
anim2.repeatCount = HUGE_VALF;
anim2.duration = 10;
[self.imgBtn.layer addAnimation:anim2 forKey:#"transform"];
Thanks!
While you can get the animation from the layer using animationForKey:, you cannot modify the animation that way. As the documentation explains it:
Discussion
Attempting to modify any properties of the returned object will result in undefined behavior.
What you instead have to do
You have to remove the infinite animation and add another animation that makes the final end animation.
Use the presentation layer to determine the current rotation of your layer.
Remove the infinite animation
Add a new animation from the value you got from the presentation layer to the end state.
How to get the value from the presentation layer.
During animation your model doesn't change (when using Core Animation). Instead what you see on screen is the layers presentation layer. You can get then read the current value from the presentation layer just as if it was any other layer. In your case you could get the rotation using [myLayer valueForKey:#"transform.rotation"];
Alternately, you can create a single animation with a completion method that triggers the animation again, in an infinite loop.
Have the completion routine check a flag before submitting a repeat.
If the flag is false, don't trigger the animation again.
Then have your button action simply set the repeat flag to false. The current animation will run to completion, and then it won't be repeated.

UISlider TouchUpInside Not firing at ends of slider

My slider sets a flag in ValueChanged and then resets it in TouchUpInside. However, when I touch the handle and slide it all the way to the end of the slider, the TouchUpInside event doesn't get fired (and hence my flag doesn't get reset).
Do I need to handle another UISlider action when I slide the handle to the end of the slider? I tried TouchCancel thinking that maybe it was getting cancelled when my finger moved past the end of the slider bar, but that didn't work.
To solve this, I needed to use the TouchUpOutside action/event.

How can I trigger Core Animation on an animator proxy during a call to resizeSubviewsWithOldSize?

I have some NSViews that I'm putting in one of two layouts depending on the size of my window.
I'm adjusting the layout when the relevant superview receives the resizeSubviewsWithOldSize method.
This works, but I'd like to animate the change. So naturally I tried calling the animator proxy when I set the new frames, but the animation won't run while the user is still dragging. If I release the mouse before the animation is scheduled to be done I can see the tail end of the animation, but nothing until then. I tried making sure kCATransactionDisableActions was set to NO, but that didn't help.
Is it possible to start a new animation and actually have it run during the resize?
I don't think you can do this easily because CA's animations are run via a timer and the timer won't fire during the runloop modes that are active while the user is dragging.
If you can control the runloop as the user is dragging, play around with the runloop modes. That'll make it work. I don't think you can change it on the CA side.
This really isn't an answer, but I would advise against animating anything while dragging to resize a window. The screen is already animating (from the window moving) - further animations are likely going to be visually confusing and extraneous.
CoreAnimation effects are best used to move from one known state to another - for example, when a preference window is resizing to accompany a new pane's contents, and you know both the old and new sizes, or when you are fading an object in or out (or both). Doing animation while the window is resizing is going to be visually confusing and make it harder for the user to focus on getting the size of the window where they want it to be.

Resources