web oriented universal language

SWHX! ...and relax...

Posted on 2007-04-19 by Ian Thomas in General

So - we've completed our company's switchover to using SWHX - Screenweaver HX, for the uninitiated - and I thought I'd ramble on a bit about why, how, and how it's worked out for us.

Background

I work for a small educational software company in Wales. We produce bilingual CD-ROMs for the home and schools market. Up until three years ago, everything we did was in Director, but at that point I put my foot down and we made the move to Flash.

Why a Flash wrapper?

We've always had a few extra bells-and-whistles on our projects that require more than just a multimedia presentation. Notably configuration, user management and report creation, all of which requires some sort of local-file-system access. We've also always needed things like Windows registry access, because of the way our installers work.

Flash can't do any of those things - so we needed some sort of Flash wrapper or projector that provided that extra functionality.

Attempt 1 : Zinc

So, a short Google search and enquiry on a mailing list later, and we'd bought a license for Multidmedia's Zinc, pretty much the industry standard for Flash wrappers. Lots of features and APIs we could get our hands dirty with. It seemed to work, and we happily went off to create a whole selection of new Flash-based projects wrapped with Zinc projectors.

And a year and a half and about twenty projects later, we found that we were swearing every time we came to publish a project.

Why? Well, here's a few of the more notable issues:

  • Poor stability between versions. A new version of Zinc, when released, might introduce new (and useful) functionality. But it would break old functionality that we relied heavily on - and despite us raising the issues time and time again, it might not be fixed for several months.
  • Only produced Windows projectors, unless we paid out more money - and although we only create Windows projects at the moment, we're moving to Mac, too, since 95% of our code and assets are cross-platform (being in Flash).
  • GUI-driven. We could only generate applications from the (clunky) Zinc GUI, and since we have been moving more and more towards a command-line driven build system, this was a problem. Multidmedia does offer a command-line driven version, but at a premium - and it's only recently become stable.
  • Poor integration with Flash, requiring asynchronous callbacks and quite a lot of ugly Actionscript to control.
  • Cost. We only had one license! And were unwilling to pay out for more, given the instability and poor support; which meant that only one person (me!) could build the final product. Woe betide everyone if I was on holiday or ill...

Clearly not a great situation. Yes, a lot of that came from the fact that we are a small company, working with a very tight budget. But essentially we'd shelled out for a commercial product which, in the end, we weren't happy with.

However, I'd been watching the haXe mailing list for a while, and Edwin announced SWHX; and having had a read and a play with it I realised that it was a contender. So about a month ago I decided that we'd take the plunge. I started to alter our build environment to use SWHX; to see whether it'd work and whether it would do what we needed. So...

Attempt 2: SWHX

Well, what can I say? It was a very swift transition. There were a couple of features missing. Zinc has far more features than SWHX, but for the most part we don't need them! As for the couple of features we did need which SHWX didn't have...

I wrote them. And added them to one of SWHX's existing extensions (Systools). In each case, it took under a day. And I was able to do so for both Mac and Windows. (And got a nice warm fuzzy feeling from contributing back to an Open Source project.)

And now any developer in the company can check the source code of our latest projects out of the source control system, type a single command-line instruction, and an .exe file will be produced that, when double-clicked, installs a SWHX-powered Flash app on the user's Windows machine. We don't have the Mac support in as yet, but that's looking like under a week's work; because SWHX provides the sources for both.

So, what have been the advantages of the switchover? And why do I like working with SWHX so much?

  • Command-line integration. Because building any haXe app can be done from the command-line, there's no more clunky GUI to manually click buttons on.
  • Speed. Unlike Zinc, SWHX is very fast to launch, mostly because it's not bloated with functionality that you don't need. If you do need it, you add an extension; and the extensions are all small and load as needed.
  • Tight integration. Your Flash app can talk to the SWHX container synchronously, and very, very fast.
  • The haXe layer. You can customise your SWHX container using haXe, writing custom functions to do whatever is needed. For example, you can push all your filesystem manipulation code into your SWHX container. Your Flash app can then just issue commands to haXe - 'savePreferences()', for example, and your haXe layer can decide how exactly to do that for whatever platform you're on. This is a difficult thing to describe briefly, but I've found the haXe layer to be immensely powerful and might blog about it seperately. :-)
  • Cross-platformness. Okay, a couple of the SWHX extensions are Windows only, but if I want those features on the Mac, too, I'll write them. :-)
  • Extensibility and modifiability. Sure, Zinc supports the writing of DLLs; but with SWHX if there's a missing feature or a bug you can make the changes yourself and contribute them back.
  • Community (and authors). If there's an issue with haXe, Neko, SWHX or Systools; Nicolas, Lee, Edwin and the others are on hand on the mailing list immediately. Sometimes Nicolas has committed a fix before you've finished reading his email. At the very least, there'll be an answer for you within hours.
  • Text file configuration. Because all the sources for a SWHX wrapper application are just ordinary .hx source files, it plays well with a versioning system. It can also be customised by a build system to include version numbers and the like.
  • Oh, and, of course, being Open Source, it all costs rather less. :-D

In Conclusion...

So now we have a system that we're all happy with; and can publish any of our products from the source code by typing a line in a console. Sure, much of that is to do with using MTASC, Ant, NSIS and a handful of other utilities, but without SWHX, that chain would be broken.

And we're happy in the knowledge that we can extend SWHX as we need it.

Compared to where we were six months ago, typing 'build' is a joy. :-D

Edited to Add: Just thought I'd mention that all this is quite happily running on Vista as well as XP... we had an issue with haXe's installer, but once past that it all runs fine.

Comments

That is a really nice success history! I am very happy to see haXe spreading over the web =)

Cheers,
Ian Liu.
Posted by Ian Liu , 2007-04-19 13:07:46
It would be great to be able to use a cross platform database.
Zinc has recently gained support for sqlite which I still need to look into.
Can I use SWHX for that too?

This would enable me to let students log their progress to a central database on an smb share.
It would have to work from windows and mac without a webservice.
Posted by Kristof , 2007-04-19 15:46:55
Nice write up Ian! I'm currently doing exactly (well almost) what ur doing, including the 'theme' of the project (educational apps), here for local schools. Your systools is such a great addition to SWHX, I've been always promoting the haXe-SWHX-systools combo to any fellow flash developer. ^^

@Kristof: haXe supports sqlite, you can read up tutorials on it from http://haxe.org/tutos/sqlite. and as Ian described, you can write custom methods for SWHX haXe layer, including read/write/anything to sqlite :). hope that helps ^^

Cheers
Posted by gsarwohadi , 2007-04-19 16:43:03
gsarwohadi:

Thanks for that, but I can't claim that Systools is mine! I've contributed a handful of lines of code, but the bulk of it is other people's work.
Posted by IanT , 2007-04-19 17:34:02
Great writeup Ian, thanks for sharing!

I remember looking at Zinc and another swf2exe wrapper application for a project I was interested in doing, and it seemed there was a predominant issue of stability through either platform. That, and the app I was looking to build required the ability to pull (relatively) large amounts of data from an sql db. SWHX has pulled off the task without a hitch (a *very* large recordset too) and seems to do everything else I want with barely any effort. I hope haXe's popularity meets it's worth one day...

Thanks for the systools Browser addon btw, it is something I needed exactly!

Cheers,
Aaron
Posted by Aaron Fay , 2007-04-19 19:30:44
Hey Ian, this is great work! A few weeks ago in a popular forum site(mmistanbul.com), I was explaining the pros of using SWHX and even Apollo in some places AND how these technologies can change our work flow. But a fellow forum member made blunt remarks and favored Zinc. Now I can shoot back :) Thank you very much!
Posted by Veli Ogla Sungutay , 2007-04-27 06:41:24
Fantastic!
Great that you share your decision making process to thoroughly!

I have a question:
Is it possible to write a mixed AS2 ans AS3 swf app that can be run seemlessly in Adobe AIR, swHX, and the ie/safari/firefox browser plugins?
With intelligent access to the various advantages/enhancements that each wrapper provides?

Thanks .:.
Posted by gotjosh , 2007-09-16 06:20:07
Hi GotJosh,

Sorry for the delay in responding - I've only just seen your question.

Yes, it is perfectly possible to write an app that can run in AIR, SWHX or Safari/Firefox. We have several, including one which mixes AS3 and AS2.

The trick is to write a wrapper .swf which loads the app. That wrapper .swf is then responsible for talking to the relevant container.
Posted by IanT , 2008-07-24 17:43:36

Post a comment

Name:
Email:
Url:
Security: Please enter 1597 here.
remember me
Comment:
 
 
Haxe Powered Rss flux Valid XHTML 1.0 Valid CSS