The other day I was writing the code for a simple animated movie. I decided to use a host flash to get the user started quickly and then create a separate SWF file for each scene in the movie. The host flash would then preload the next scene while the current one was playing. MovieHost.as would be the document class for the host movie and Scene.as document class for all the scenes. Simple right? Budget: 6-7 hours including the stop frame animations…
Well, not quite so. I created all the animations in all the swiffs, set up the hos flash to load them in, pressed command+enter to verify my effectiveness. The host flash fires up and loads the first scene but the scene’s code does not seem to run at all. And no error messages? After all this is AS3 - WTF??
I won’t bore you with the details of all my testing, but it went to the point where I started to research the use of explicit application domains and such. After some hours I found the reason, and here it it:
From the Flash documentation on the ApplicationDomain class:
“You cannot override a loaded class definition with a newer definition.”
This says it all really. Close to the top of my HostMovie.as class (where I hadn’t been for a while) I found this line:
private var _currentScene:Scene;
Even though this variable was not being used in any way, the host flash still had a compiled version of the class Scene.as when the scene swiffs were being loaded. I f you look at the comment from the documentation again you realize that of course no code from the loaded swf could run, it’s document class had been discarded in favor of the one allready existing in the host flash.
I removed the unused property definition from HostMovie.as and everything from there on went as planned.
A really interesting project I’ve been doing at work is finally live after a little over a month in design and development. I am quite pleased with the result as it is a fully dynamic (with content management system on the way) all Flash, language extendable solution.
The language menu has had to be hidden from view for now. That’s because the site hasn’t been translated yet, but after the first one is in I will be enabling the language selection. From there, extending the site to other languages is a matter of translating and publishing through the CMS with no touching of neither FLA-files or XML needed.
A tricky part of this project was getting the site swf, which filles the entire browser, to scale to fit the browser window, but not so that it would crop the site without displaying scrollbars on smaller screens. The solution was a little javascript that I published in an earlier post.
MasterPhoto captures stills and video by using model helicopters to reach heights and angles unmatched withother types of equipment. The results they can achieve is really stunning. Check out the site!
Creating Flash content that fills the entire browser window right up to the chrome is nothing new. Normally it is accomplished by setting the swf’s width and height to 100% in the object and embed tags and controlling how different elements respond to resizing with ActionScript within the Flash Movie. But in a recent project I needed to ensure that the swf did not scale below a certain size so that the browser is forced to display it’s scrollbars. This is because while the stage of the movie scales the main content is not scaled, only centered. That makes the browser crop your swf, effectively rendering the use of small(er) screen resolutions impossible.
Because of this I had to write a small JavaScript to gain back some control over how the move resized. Here you go, you can either download only the JS-file or the entire zipped example above.
Although a bit late for this season, I thought I’d share a small christmasy ActionScript nugget with you. This stuff was developed some time ago, so it’ll happily compile to Flash Player 6 if needs be. The script simply replicates a small, white particle that resembles a snow flake and animates it so that it falls from the sky. It also imitates 3D by altering the size and speed of the flakes and you can put any graphic you want inside the snowFlake movie clip to make it behave like a particle of snow.
I’ve actually had much use for it for various clients and projects. Go ahead and download it here:
Flash supports XML. Consultants and project managers support Excel. Have you ever wished that either Excel or any other spreadsheet application, or any other application for that matter, had a decent exporter for XML data? Not that proprietary-Microsoft-not-terribly-W3C-compliant-type, but real, simple, proper XML? Well I have, and instead of waiting for it I decided to create a small Flash application that certainly helps!
Not many desktop applications export XML at all, but make that CSV (Comma Separated …something) and quite a few do. A typical CSV export from an Excel spreadsheet could look like this:
Now wouldn’t you much rather have that data formatted a little more like this?
Nice and tidy - and best of all; Flash supports it natively!
This is just something I started i while ago which wasn’t put to good use until recently. It’s basically a listing module for Flash applications in which you can apply different criteria as filters and make the matching list rows appear instantainiously.