If you want to make a fully personalized Silverlight or Flash application, then you shouldn’t miss out this post.
Splash Screen is a very user friendly way to notice how long you have to wait for the application to load. You may also add some graphics, advertisements or animations to entertain the users before the they get bored by waiting.
Flash and Silverlight have completely different mechanisms in adding the splash screen. Before we start, let’s take a look on the comparisons and demo first.
Comparison
Flash implementation: 30 minutes
Silverlight implementation: 50 minutes (Implemented First)
What’s the difference:
- Creating Loading Splash Screen
Source codes
Demo Samples:
Creating Loading Splash Screen in Flash
Adding Splash Screen in Flash is not as easy as you can imagine. Unless you are loading an external swf, otherwise you have to do a lot of preparation in making the Splash Screen. Another alternative is that you may try to use Flex. It provides a much more convenient way to add splash screen.
Usually, the main problem is that the ActionScript will only execute once everything is downloaded. In such circumstance, you have no way to display loading details.
The main cause is that when you export Movie Clip, you will usually check the box “Export in First Frame”. It means that this movieclip will be downloaded before the swf will execute.
However, if you don’t check this item, some of your resources may not be included into the swf during compile time.
Therefore, to get rid of this, you should put your MovieClip onto the stage. This makes sure that the Flash will include this resource as well.
Well, it sounds difficult, right? Anyway, if you are still interested, download my sample source code and see how it works.
Creating Loading Splash Screen in Silverlight
Splash Screen in Silverlight is independent with the application. It means that you can apply different kind of splash screen without modifying the application. You may even share your splash screen design with others!
Anyway, let me show you the minimal steps in creating your own splash screen.
- First of all, create a SplashScreen.xaml file and add the followings:
<Canvas
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Width=”550″ Height=”550″>
<Grid>
<TextBlock Text=”Loading: 0%” x:Name=”Label”/>
</Grid>
</Canvas>
- Open the html that hold your Silverlight Application. Add a new parameter to the embed syntax.
<param name=”splashscreensource” value=”SplashScreen.xaml”/>
<param name=”onSourceDownloadProgressChanged” value=”onSourceDownloadProgressChanged” />
Please make sure that the SplashScreen.xaml is placed in the same folder with the html.
- Add the below JavaScript function
function onSourceDownloadProgressChanged(sender, eventArgs)
{
sender.findName(”Label”).Text = “Loading: ” + Math.round((eventArgs.progress * 1000)) / 10 + “%”;
}
- Lastly, make sure you application is big enough or you will never see your own splash screen.
For more information, please refer to: Define a Simple Silverlight Splash Screen