Home >
For any developer moving into Silverlight from Flash, one quickly notices that there is no enter frame event in Silverlight. Each Silverlight control does not inherently have a timeline, but instead can have any number of storyboards. A nice way to create your own enter frame event is by using storyboard looping.
Storyboard looping can be done in a handful of ways, but since I’m writing about scripted animation, I’ll talk about creating your storyboard using c#.
First, you create a new storyboard (called sb in my example). Second, you add an event handler for the storyboard completed event. Third, you add the event to the controls resources. Finally, you start your newly created storyboard.
sb = new Storyboard(); sb.Completed += new EventHandler(sbCompleted); this.Resources.Add(“sb”, sb); sb.Begin();
In the sbCompleted method, you just start the storyboard, thus creating the loop.
The sbCompleted method is also where you would put your enter frame logic.
void sbCompleted(oject sender, EventArgs e)
{
// some enter frame logic...
sb.Begin();
}
This technique, along with extending your silverlight control’s properties, to match the properties you may already have for a Flash project will give you a way to port ActionScript logic to c# and Silverlight.




Facebook Application Development
Comments
Leave a comment