If you've ever wondered how to preload a NeoSwiff WinForms application, this article is for you.
Unlike Flex, when you build an application in NeoSwiff there is no download progress indicator automatically inserted for you. Thus, if your application .swf file runs 150K in size, your users will see a blank screen until the download completes and the application can be interacted with. This could potentially be a long time waiting without feedback, especially on slower connections, and isn't good for usability.
The solution is to create a preloader. The preloader needs to be small in size so that it downloads quickly to present the user with feedback as fast as possible. The application .swf downloads in the background, and the preloader displays the download progress. Once the application is fully downloaded, the preloader hands over control to the application.
In the samples that ship with NeoSwiff, a basic preloader is one of them. I've extended the functionality of the sample in two ways. First, I've made the preloader dynamic, meaning you can load in any .swf without having to re-compile and hard-code the url (as in the sample). Second, I've made the preloader automatically adjust its layout so that any time the browser is resized the preloader adjusts itself accordingly (and thus there isn't a hard-coded width and height).
You can download my NeoSwiff Preloader here. Source code is included in the download, licensed under the MIT license. Portions of the code were contributed by GlobFX, used with permission.
To see the preloader in action, check out this page.
Instructions for use are included in the download, but essentially all you need to do is replace the FlashVars (in both the object and embed tags) in the preloader.html file. Replace the title variable with the title of your application, and replace the url variable with the path to your .swf file.
The preloader ended up being around 7k when all was said and done, so it will load quickly when the .html page is visited. Your application .swf will download in the background and the preloader reports the download progress, then transfers control to the application .swf once the download completes.
Enjoy!

Leave a comment