Having a callback function is important, as it allows the caller of the function to know when the
animation is done. In the example presented here, the callback function is used to re-enable the buttons
and keep track of which node is currently displayed in the scene. In a more complex application the
callback function could be useful in any number of ways.
Example 2: Slide Replace
The slide replace, as the name implies, slides one node into the scene as the current one slides out. This
example has a node sliding in from the left as the existing node slides out of the scene to the right. To
achieve this effect, a clipped group is created containing both nodes, and the group and the clipped area
are then animated.
The screenshot in Figure 3-3 shows the animation halfway done, where the new node is on the left
with its left side clipped. The node being replaced is moving to the right and has its right side clipped.
Figure 3-3. Slide replace
Listing 3-4 shows the code that implements this transition.