It has been a long time that I didn’t implement text effect comparison. Text Rendering is a very interest topic when comparing Flash and Silverlight. It’s because they have different rendering system which result in a dramatic differences on performance and readability.
If you are going to make animations using text, I am sure Flash is much more better. Take a look on my previous sample “Text Tunnel“.
Nevertheless, I didn’t stress on performance for this entry. Instead, you could see how I handle Color Animation differently.
Vote for this sample
Flash is Better? (225 votes)
Silverlight is Better! (279 votes)
Comparison
Flash implementation: 1 hour 20 minutes (Implemented First)
Silverlight implementation: 1 hour
What’s the difference:
- Color Animation: Timeline method (Flash) vs ColorAnimation (Silverlight)
Source codes
Color Animation: Timeline method (Flash)
Tween Class in AS3 is not able to modify the color of an object. Of course, you may still modify the color integer value directly. However, the value is calculated in a linear way and it will not be what you are looking for.
Let’s back into basic, we are still able to tween the color of an object using the timeline approach. I won’t go into too much details here since it’s a bit hard to describe. You may download the source code and study it on your own.
ColorAnimation and StoryBoard (Silverlight)
For Silverlight, we may tween the color of an UI object using the following code:
// C#
// create a text block
TextBlock textAnimation = new TextBlock();
textAnimation.Text = "Text";
textAnimation.Foreground = new SolidColorBrush(Colors.Black);
LayoutRoot.Children.Add(textAnimation);
// add a new story board to fade out the text color
Storyboard moveStoryboard = new Storyboard();
ColorAnimation colorAnimation = new ColorAnimation();
colorAnimation.To = Colors.White;
colorAnimation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, FADE_DURATION));
Storyboard.SetTarget(colorAnimation, textAnimation);
Storyboard.SetTargetProperty(colorAnimation, new PropertyPath("(TextBlock.Foreground).(SolidColorBrush.Color)"));
moveStoryboard.Children.Add(colorAnimation);
moveStoryboard.Begin();