net.rim.device.api.animation
Class AnimationTrigger

java.lang.Object
  extended by net.rim.device.api.animation.AnimationTrigger

public class AnimationTrigger
extends Object

Defines a class you can use to trigger animations to begin or end. You create the trigger, then add it to an animation as either a begin or end trigger. When you call the fire() method, the associated animation starts or ends.

Scheduling an Animation to Begin on an AnimationTrigger

 // Create the animator.
 Animator animator = new Animator(25);
 // Create an event in which this class is the event source.
 AnimationTrigger myTrigger = new AnimationTrigger();
 // Use a scalar for alpha
 AnimatedScalar alpha = new AnimatedScalar(1.0f);
 // Create an animation which will begin when the custom event is fired.
 Animation fadeoutAnimation = animator.addAnimationFromTo(alpha, AnimatedScalar.ANIMATION_PROPERTY_SCALAR, 1.0f, 0.0f, Animation.EASINGCURVE_LINEAR, 1000L);
 // Add a scheduling rule to only start when the custom event is fired.
 // The animation will begin 500ms after the trigger is fired.
 fadeoutAnimation.addBeginTrigger(_myTrigger, 500);
 ...
 ...
 protected boolean navigationClick(int status, int time)
 {
     // Trigger my animation to start.
     _myTrigger.fire();
 }
 

Chaining Animations so one begins when another ends.

 // Create the animator.
 Animator animator = new Animator(25);
 // Use a scalar for alpha
 AnimatedScalar alpha = new AnimatedScalar(1.0f);
 // Create an animation to fade out
 Animation fadeoutAnimation = animator.addAnimationFromTo(alpha, AnimatedScalar.ANIMATION_PROPERTY_SCALAR, 1.0f, 0.0f, Animation.EASINGCURVE_LINEAR, 1000L);
 // Create a second animation to fade in
 Animation fadeinAnimation = animator.addAnimationFromTo(alpha, AnimatedScalar.ANIMATION_PROPERTY_SCALAR, 0.0f, 1.0f, Animation.EASINGCURVE_LINEAR, 1000L);
 // Add a scheduling rule to start the second fadein when the fade out animation is ended.
 fadeinAnimation.addBeginTrigger(fadeoutAnimation.getEndTrigger(), 0L);
 ...
 // Begin the fadeout animation
 fadeoutAnimation.begin(0L);
 

See Also:
AbstractAnimation.addBeginTrigger(AnimationTrigger,long), AbstractAnimation.addEndTrigger(AnimationTrigger,long), AbstractAnimation.getBeginTrigger(), AbstractAnimation.getEndTrigger()
Since:
BlackBerry API 6.0.0

Constructor Summary
AnimationTrigger()
           Class constructor.
 
Method Summary
 void fire()
           Fires the trigger.
 long getTriggerTime()
           Gets the system time when the trigger was fired.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

AnimationTrigger

public AnimationTrigger()

Class constructor.

Creates an AnimationTrigger that can be used to trigger animations to begin or end.

Since:
BlackBerry API 6.0.0


Method Detail

getTriggerTime

public long getTriggerTime()

Gets the system time when the trigger was fired.

Returns:
The system time when the trigger was fired.
Since:
BlackBerry API 6.0.0

fire

public void fire()

Fires the trigger. Any animations scheduled to begin or end on this event will be triggered by this call.

Since:
BlackBerry API 6.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal