SpriteHand
Module Border
  Silverlight 1.1 Alpha Refresh Migration
Module Border
Location: BlogsAndy's Blog    
Posted by: host 8/3/2007 7:23 AM

Last Friday, July 27th, the 1.1 Alpha Refresh of Silverlight was released into the wild, breaking any previous Silverlight Alpha applications... including mine of course...

This morning I released updated versions of Silverlight Rocks! and Destroy All Invaders which are compatible with the 1.1 Alpha Refresh. Here are links to the updates (they use the same url's as previously so no need to update links you may have elsewhere):

Silverlight Rocks!       [source and info]     [play it]
Destroy All Invaders   [source and info]     [play it]

There are lots of useful blog entries with help on migrating from 1.1 Alpha to the 1.1 Alpha Refresh but I did hit a couple of issues that I didn't see mentioned elsewhere...

Storyboard.Begin() Behaves Differently
IMPORTANT: Read below for update to this problem!! The biggest snag I hit was that the behavior of Animation.Storyboard.Begin() apparently changed with the 1.1 Alpha Refresh. In the previous Alpha, it was possible to use a Storyboard DoubleAnimation to mimic a timer and form a Game Loop around it. But in the latest refresh, calling Storyboard.Begin() will cause the immediate execution of it's Completed event. This causes an endless loop with no UI updates when you call Storyboard.Begin() at the end of you game loop.

I wasn't able to find a way around this Storyboard.Begin() issue so instead I replaced my Storyboard timer with a browser timer like so:

System.Windows.Browser.HtmlTimer timer;
timer = new System.Windows.Browser.HtmlTimer();
timer.Interval = 20;   // not really reliable :(
timer.Tick += new EventHandler(timer_Completed);

There are two problems with this. The first is that HtmlTimer is marked obsolete and has the following compiler warning:

System.Windows.Browser.HtmlTimer' is obsolete: 'This is not a high resolution timer and is not suitable for short-interval animations. A new timer type will be available in a future release.

... and the second problem is that the Interval property does not seem all that reliable in determining frame rate (as the compiler warning states). But, it does seem somewhat adequate at least until "a new timer type is available in a future release" (let's hope that warning is accurate).

UPDATE: Thanks to John Donnelly and Chris Cavanagh for both setting me straight on the Storyboard problem! It turns out the change in behavior for Storyboard is that you must have an animation target for the Storyboard, or an exception is thrown. Here is an example of setting up the Storyboard as timer:

 <!-- Set up our game timer. As of Alpha 1.1 Refresh, you NEED to give the timer a bogus target to avoid exceptions -->
  <Canvas.Resources>
    <Storyboard x:Name="timer">
      <DoubleAnimation Duration="00:00:00.01" Storyboard.TargetName="bogusTimerTarget" Storyboard.TargetProperty="Width" />
    </Storyboard>
  </Canvas.Resources>

  <Canvas Name="bogusTimerTarget">
  </Canvas>

I have updated both Silverlight Rocks and Destroy All Invaders samples with this fix.

Silverlight Template and SDK Have Wrong Silverlight.js
It turns out that the Alpha 1.1 Refresh SDK and Visual Studio Project Template add in the wrong version of Silverlight.js. The end result of this is that if a user visits your Silverlight-enabled web page and they do not have Silverlight 1.1 installed, the little icon that appears to install will point them to the 1.0 install instead of 1.1. The solution is to "borrow" the correct 1.1 version of Silverlight.js from somewhere else as described in this very helpful forum post.

Hidden Visibility went Bye-bye
This is the one breaking change that I knew about before going into the conversion and was the easiest to solve. Basically just do a find-and-replace for Hidden wherever it is used to assign Visibility, and replace it with Collapsed.

Well, that's about it. I have to say the conversion took me longer than anticipated because of the first two issues. But being this is still only Alpha I am anticipating even more fun migrations in my near future :)

Permalink |  Trackback

Comments (3)   Add Comment
Re: Silverlight 1.1 Alpha Refresh Migration    By Anonymous on 8/3/2007 11:50 AM
Andy - I hit pretty much the same problems updating some Silverlight stuff (http://chriscavanagh.wordpress.com/2007/08/03/silverlight-11-2d-physics-sample-updated/). However I didn't have the same issues with Storyboard.Begin(). All I needed to do was give the DoubleAnimation inside it a dummy Target element. You can download my source and take a look (http://chriscavanagh.wordpress.com/2007/08/03/new-silverlight-11-alpha-2d-physics-source/ - Page.xaml.cs in the SilverlightPhysics project); maybe it'll give you some clues/hints...

- Chris Cavanagh

Re: Silverlight 1.1 Alpha Refresh Migration    By Anonymous on 8/14/2007 10:59 AM
I've got the same error, but have already used a target in the Double Animation. what's going on?

this._slideShowActivateAnimation.begin()

















Re: Silverlight 1.1 Alpha Refresh Migration    By Anonymous on 8/14/2007 12:05 PM
Can you post a small example and your exact exception message?


Title:
Comment:
Add Comment   Cancel 
Module Border Module Border
Module Border
  Subscribe
Module Border
RSS   Twitter
Module Border Module Border
Module Border
  Diversions
Module Border

TALKING RAGDOLL
This Windows Phone 7 App was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine. It gets interesting when you import your friends photos and have your way with them!

MORE INFO



DROPPYPOP
This Windows Phone 7 game was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine.
DEMO

MORE INFO



BOSS LAUNCH
This physics game won first place in the Server Quest Contest. Created using Silverlight 2, the Physics Helper Library,  and the Farseer Physics Engine.
PLAY IT

MORE INFO



DESTROY ALL INVADERS
A scrolling shooter game where the objective is to destroy the invading UFO's flying over a neighborhood of your choosing. Imagery provided by Microsoft Virtual Earth. Created using Silverlight 2.
PLAY IT

INFO AND CODE



PHYSICS HELPER DEMOS
These demos were created for the Physics Helper Library, which makes it easy to create physics games and simulations using Expression Blend, Silverlight, and the Farseer Physics Engine.
PLAY IT

INFO AND CODE



HOOK SHOT
This little basketball game took first place in the TeamZoneSports Silverlight Contest. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SORT THE FOOBARS
A game where you need to sort the good foobars from the bad ones. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



POLYGON PHYSICS DEMO
A demo showing polygon physics where the user draws physics objects with the mouse. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SILVERLIGHT ROCKS!
Destroy the asteroids before they destroy your ship! Created using Silverlight 2.
PLAY IT

INFO AND CODE



FISH GAME
A simple game of harpoon-the-fish. Written using the AJAX Sprite Toolkit.
PLAY IT

INFO AND CODE

Module Border Module Border
Module Border
  Search_Blog
Module Border
Module Border Module Border
Module Border
  Blog_Archive
Module Border
Module Border Module Border
Copyright (c) 2013 andy.beaulieu.com - Login