Flash to Silverlight

You do Flash and now you want to add Silverlight to your skillset?
You've come to the right place.

Add the Ball Control and Watch it Fly

This is page 3 of Procedural Animation tutorial in the Getting Started series. As an introduction to Silverlight, this tutorial walks through animating objects with CompositionTarget.Rendering.

Add the Code to the MouseMove Handler

In “MainPage.xaml” select LayoutRoot and in the Properties panel add an event handler for the MouseMove event. Make sure to select the Event button with the lightning bolt icon if you can’t find the MouseMove event.

Place the following code in the new LayoutRoot_MouseMove event handler:

ball b = new ball();
Canvas.SetLeft(b, e.GetPosition(this).X);
Canvas.SetTop(b, e.GetPosition(this).Y);
LayoutRoot.Children.Add(b);

Before running the project to see your work, switch back to “MainPage.xaml” and ensure you’ve changed the LayoutRoot Grid to a Canvas.

Hit F5 to Run the application and you should be greeted with the following:

Get Microsoft Silverlight

Pages 1, 2, 3

 

This is just the beginning of what you can do! With the CompositionTarget.Rendering technique in hand you accomplish many of same type of effects as you would with ENTER_FRAME based animations.

At this point we've only animated positions, the next tutorial covers Color, Scale and Rotation.

blog comments powered by Disqus