Archive for July, 2009
Runtime Shared Libraries – indispensable and infuriating!
Jul 22nd
Utilizing the RSL (Runtime Shared Library) mechanism in Flex is arguably one of the quickest and easiest ways to drastically shrink your Flex application’s file size. The RSL mechanism essentially allows you to compile your Flex application without embedding the Flex framework into the code. So, if the Flex framework isn’t compiled into the Flex application (final SWF file), then how does the application work? The real genius comes in at this point… The Flash Player – as of version 9.0.60 – can now cache signed RSLs containing the Flex framework. If the Flash Player caches these frameworks, it means that if you have viewed a Flex site using the 3.2.0 SDK and you launch another Flex application using the same SDK, you do not have to download the whole framework from the server!
For more information and a brief tutorial, visit this link on the Adobe Labs site.
However, it’s not always as quick and easy as some might like to believe. Recently i’ve been playing around with RSLs and different versions of the Flex SDK and i’ve been encountering the dreaded Error #1001 runtime error. This pernicious and convoluted little error can cause a spontaneous force of attraction between your forehead and your desk. It’s quite strange indeed… Well, after a bit of digging and some messing around, i seem to have noticed a general pattern for failure and subsequently getting the error message above, and how to fix it…
I’ve created a Flex project and have merrily gone about my day coding, styling, flexisizing etc… I’ve set my project to use RSLs (using the 3.2.0 Flex SDK) and everything is working just fine. Now i notice on the Adobe Labs site that there’s a new Flex SDK available (say… 3.3.0). I decide to chuck the current SDK and replace it with the new one… Only to see the following after a compile of the project:
Eek. Nothing like a good ol’ spanner in the works, eh?
After a bit of scratching around in the 3.3.0 SDK folder, i came upon the flex-config.xml file (located at $FLEX_INSTALL_PATH/sdks/$SDK_VERSION/frameworks). If you scour through the file, you’ll see that towards the bottom there’s a node called runtime-shared-library-path. Here’s what it looks like in the 3.3.0 SDK:
<runtime-shared-library-path> <path-element>libs/framework.swc</path-element> <rsl-url>framework_3.3.0.4852.swz</rsl-url> <policy-file-url></policy-file-url> <rsl-url>framework_3.3.0.4852.swf</rsl-url> <policy-file-url></policy-file-url> </runtime-shared-library-path>
Check out the two rsl-url properties… One is the name of a SWZ (signed SWF) file and the other is a plain SWF file… Notice the naming of those URLs and then refer back to the image above. Flex Builder obviously didn’t change the RSL linkages when i changed my SDK in my Flex project.
The SOLUTION:
Open your Flex Project Properties dialog, select the Flex Build Path option on the left, then the Library Path tab at the top. You will then see something like this:
Notice how the version numbers of the RSL files do not correlate with the version of Flex SDK? For some reason, Flex doesn’t change the RSL linkage when you switch SDKs in a Flex Project. I wonder whether this is a bug or a feature (like i often wonder about the ON button on Windows machines).
Anyway, the quick fix for this is as follows:
Simple select the Flex SDK and hit the REMOVE button on the right. The Add Flex SDK button will then become active and you can go ahead and click on it. This will scan the flex-config.xml file we looked at earlier and pick up the correct files to use for the RSL.
Done! You can now close the Properties dialog.
Go ahead and clean your project at this point by going to the menu, Project -> Clean. This will delete all the compiled code that was previously generated and it will then trigger a new build. Once the build has completed, run your Flex application…
Oh, don’t you just love it when shit works?!
Formatting your Flex code in Flex Builder 3
Jul 9th
Oftentimes i will be searching the net for a useful class or code snippet, only to be horrified by its inherently ugly formatting. I’m obsessed with code neatness and readability, and it really pisses me off when i have to reformat an entire class by hand.
Enter Flex Formatter from Ernest Pasour
This incredibly useful little set of three plugins for Flex Builder 3 (and possibly Flash Builder 4 – i haven’t tried yet, can someone confirm this?) provides you with a vast variety of code formatting options. Below is a couple of screenshots of the configuration pages:
ActionScript
MXML
Even apart from all of its amazing code reformatter tools, FlexFormatter 0.6.24 has the ability to generate ASDoc comments! By now you should be convinced, so here’s the installation process:
- Download zip file from here
- Unzip contents (3 .jar files) to your plugins directory inside of your Flex Builder 3 installation
- Restart Flex Builder and you will notice there will be 5 new buttons in your toolbar:
Happy formatting!
Union Platform – Part I (Installation)
Jul 8th
We’ve all heard about Colin Moock at some point in our Flash/Flex development career. Colin has authored a great many ActionScript books throughout the years and as a consequence has helped thousands – including myself – to learn ActionScript. Now Colin has hit the community with something incredible… the Union Platform.
Here is the official definition of the Union Platform from http://www.unionplatform.com: “Union is a development platform for creating multiuser applications. It includes the Union Server, a multiuser communications server, and Reactor, a framework for creating Adobe Flash client applications.”
Essentially what this means is… you can now build realtime chat applications, MMORPG games, and anything else that could use a little realtime flavour
Installation
In this part of the series on the Union Platform i will be showing you how to install the Union server on your *nix machines and Window$ machines. Let’s leave the hideous beast (Window$) for last, and begin with a real operating system that is actually a pleasure to work with, and doesn’t make you praise whichever god you worship that your legs can’t bend backwards at the knees to kick yourself in the balls for ever getting roped into that shitty OS.
I’ll be Linux Mint for my *nix installation explanation, and this will work on Macs too in much the same way.
The Union Platform Server is a Java application that will run on your server and listen on port 9100 and 9101 for traffic. Be sure to check that your firewall doesn’t block this port before you begin…
First things first, head over to the downloads page on the Union site and download the GZipped tarball to your desktop.
Next, unzip the tarball’s contents (tar -xf union_1.0.0_alpha2.tar.gz). This will create a folder called union on your desktop. Now, move either the folder in its entireity or the contents to a folder somewhere on your machine.
Perfect. So now we have all the files we need. Make sure that you have Java installed and working correctly on your machine or otherwise this will not work. You will need to make sure that this folder had execute permissions, so issue the command chmod 775 * to give all the files the necessary permissions.
Usage
Once this is done, we’re done! To start the Union Platform Server issue this command: ./startserver.sh from inside the folder you unzipped. You will now see your terminal bombarded with debug messages notifying you of Union‘s successful start.
Window$ users please note: the instructions above are pretty much the same for Window$; merely extract the files to your machine and run the batch file startserver.bat.
Administration Panel
Colin Moock and crew have been generous enough to provide us with a Flex administration panel for the server, and you can find it here. Download the SWF, and open it in your browser. You will be met with a login screen like this:
NOTE: If you look in the union.xml configuration file, you will find the password that is used by the server. By default it is password. Also note that the administration panel runs on port 9110.
Once you have logged in, you will see a screen like this:
Pretty bloody cool if you ask me!
Join me in the next part of this series when i will be demonstrating how to build a simple realtime chat application!








