Mix08 – Session 1 – From Flash to Silverlight – A Rosetta Stone

There are lots of similarities and lots of differences in the way Silverlight operates as compared to Flash.  This session covers some of those, as well as some of the improvements to Silverlight 2 Beta 1. 

Basics

  • In Silverlight 2, all objects now inherit from the userControls base class. 
  • In Flash, X and Y are properties, you could create a “ball” object, and get and set X and Y as properties to make it more like Flash
  • The Point object is similar to the mouse object in Flash.  Create a Point and call it mouse, and the C# starts to look a lot like ActionScript in Flash.

The Helvetica of Easing Algorithms

  • This is a cool and very simple effect that is used regularly in Flash. 
  • Using storyboards and the X and Y properties you just created, you can calculate the distance between the click point and an object (a ball, etc), take a percentage(like 12% or 20%), and continually call the storyboard, making the object move across the canvas. 
  • Something like ball.X += (ball.X – mouse.X)*.12 , and the same for Y
  • The default frame rate for Silverlight is 60 frames per second, as opposed to 40 for Flash

User Controls that Govern Themselves

  • Instead of having the storyboards for child objects in the parent class, you can put them right into the user controls. 
  • The ability to remove an item is very easy to do in Flash.  It’s a bit more complex in Silverlight.
  • You can just remove it from the canvas’s Children collection, but that is a real bad idea for RIA applications that are data intensive!!  You can instead raise an event and bubble it up to the parent, and let the parent handle it. 

One Function to Rule Them All

  • You can have a method in the user control that will add behaviors to the objects on the canvas, such as duration, movement, transparency, etc. 
  • The presenter ran out of time, and moved the coverage of the rest of this idea into the OpenSpace sessions

Where did my downloader go?

  • This is a big difference from Silverlight 1.1
  • There used to be great object to get handle on images, etc. called the downloader object
  • Now in version 2, you need to create a WebClient stream object and stream it into the Silverlight object
  • Or, you can also use the BitmapImage and import it from the local directory

Conclusion

Even though the presenter did not get to cover all the material he wanted to, it was actually a good session to connect some of my Flash experience and .Net experience and blend it into some Silverlight code.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s