By just adding a little more on the Carousel, you can create a brand new Crousel effect. Today, I am presenting you the advanced Carousel Effect which support various layers with additional Drill Down and Drill Up effects.
You can also experience how did I simulate the frame based animation by StoryBoard. A pretty good reference for you to learn Silverlight.
Comparison
Flash implementation: 50 minutes
Silverlight implementation: 1 hour (Implemented First)
What’s the difference?
- Tween [AS3] vs Storyboard [C#]
Source codes
Image Advance Carousel [Flash 9, AS3] (235.5 KiB, 3,380 hits)
Image Advance Carousel [Silverlight 2, C#] (298.5 KiB, 6,256 hits)
Flash
Silverlight
Tween [AS3] vs Storyboard [C#]
In AS3, the Class fl.transitions.Tween is very similar to StoryBoard in C#. Below is a simple demonstration which fade out an object in 3 seconds.
// AS3
import fl.transitions.*;
import fl.transitions.easing.*;
var storyBoard:Tween = new Tween(displayObject, "alpha", None.easeOut, 1, 0, 3, true);
storyBoard.addEventListener(TweenEvent.MOTION_FINISH, on_motion_finish);
function on_motion_finish(e:TweenEvent):void{
trace("finish");
}
What about in C#? let’s see how can we create Storyboard purely by code. Please be careful when using Storyboard.SetTargetProperty, you have to use “(LayoutRoot.Opactiy)” as the argument, don’t miss out the blankets!
There has been many chances on the Storyboard since Silverlight 1. You will find a lot of “wrong” information from the Internet which can not work properly in beta 2.
// C#
Storyboard storyboard = new Storyboard();
DoubleAnimation doubleAnimatoin = new DoubleAnimation();
doubleAnimatoin.From = 1;
doubleAnimatoin.To = 0;
doubleAnimatoin.Duration = new Duration(new TimeSpan(0, 0, 3));
Storyboard.SetTarget(doubleAnimatoin, displayObject);
Storyboard.SetTargetProperty(doubleAnimatoin, new PropertyPath("(LayoutRoot.Opacity)"));
storyboard.Children.Add(doubleAnimatoin);
storyboard.Begin();
