Sign In|Join
Home/Silverlight.NET Forums/General Silverlight/New Features in Silverlight 3/ObjectAnimationUsingKeyFrames Silverlight 3 Problem
Last post Jul 15, 2009 01:42 AM by Aaron B
0 Points
1 Post
Jul 15, 2009 01:42 AM | LINK
i have an ObjectAnimationUsingKeyFrames that was working in Silverlight 2. i upgraded to Silverlight 3 and now it seems to skip the last frame.
the XAML looks like this:
<Image x:Name="LayoutRoot" VerticalAlignment="Center" Source="BusyImages/00_32x32-32.png" Stretch="None"/>
the code looks like this:
}
if you slow it down to 2 frames per second it’s easy to see where the frame is missing.
Silverlight 3
Aaron B
0 Points
1 Post
ObjectAnimationUsingKeyFrames Silverlight 3 Problem
Jul 15, 2009 01:42 AM | LINK
i have an ObjectAnimationUsingKeyFrames that was working in Silverlight 2. i upgraded to Silverlight 3 and now it seems to skip the last frame.
the XAML looks like this:
<UserControl.Resources> <Storyboard x:Name="BusyImageStoryboard" RepeatBehavior="Forever"> <ObjectAnimationUsingKeyFrames x:Name="BusyImageTimeline" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="Source"/> </Storyboard> </UserControl.Resources><Image x:Name="LayoutRoot" VerticalAlignment="Center" Source="BusyImages/00_32x32-32.png" Stretch="None"/>
the code looks like this:
public partial class BusyImage: UserControl { public BusyImage() { InitializeComponent(); AddImageKeyFrames(BusyImageTimeline.KeyFrames, 18, 40.0, index => "BusyImageFrames/"+index.ToInvariantString().PadLeft(2, '0')+"_32x32-32.png"); BusyImageStoryboard.Begin(); } private static void AddImageKeyFrame(ObjectKeyFrameCollection keyFrames, int offsetInMilliseconds, string url) { keyFrames.Add ( new DiscreteObjectKeyFrame { KeyTime = new TimeSpan(0, 0, 0, 0, offsetInMilliseconds), Value = new BitmapImage(new Uri(url, UriKind.Relative)) } ); return; } private static void AddImageKeyFrames(ObjectKeyFrameCollection keyFrames, uint frameCount, double framesPerSecond, Func<uint,string> GetFrameURL) { var millisecondsPerFrame = 1000.0/framesPerSecond; for (uint index=0;index!=frameCount;++index) AddImageKeyFrame(keyFrames, (int)((double)index*millisecondsPerFrame), GetFrameURL(index)); return; }}
if you slow it down to 2 frames per second it’s easy to see where the frame is missing.
Silverlight 3