Home  >  

Scripted Animation in Silverlight

Author photo
AddThis Social Bookmark Button

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.

Read more from Jeremy Bierly. Jeremy Bierly's Atom feed

Comments

Leave a comment


Type the characters you see in the picture above.

Tag Cloud

Poll: Sci-Fi Movies

What's Your Favorite Sci-Fi Movie of All Time?

Vote | View Poll Results | Read Related Blog Entry

Latest Features

  •     Welcome back to the series. This time we are goings to build a really exciting component that will be used to simply display information about the user. Well, you might say why to we need such a component, is there... Continue Reading
  •    Welcome back to our exciting Facebook ActionScript series. In this article we will discuss one of most important (and most exciting) features of the FB platform, it's the publishing of news. We all know when we log in to facebook,... Continue Reading
  • This article provides 10 tips and best practices (in no particular order) for maximizing the benefits that Dojo can bring to your next project. For a more thorough introduction to Dojo, see the article Dojo: The JavaScript Toolkit with... Continue Reading
  •     The notifications are one of the most interesting (and important) parts of the facebook area. In order to completely understand the Flash side of it, we need to understand the basics of the facebook notification, what it is and how... Continue Reading

Development Series

Get an overview of the tools and technologies that work together to allow developers to build Rich Internet Applications (RIAs) quickly and easily.

facebook icon Facebook Application Development

Anatomy of an Enterprise Flex RIA

Recommended for You

@InsideRIA on Twitter

Archives

  • Or, visit our complete archive.  

About This Site

Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.