Archive for Flash

Flex Data Services and Java JDKs

If you’re a newbie just starting on Flex Data Services 2.0 (FDS) and J2EE development, you will most likely go and download FDS from Adobe with the integrated JRun 4 application server immediately followed by a Java Development Kit (JDK) from Sun (if you don’t already have one).

And if you’re one to always have the latest and greatest or are just following the first link that you see on Sun’s webpage like any newbie would, you’ll probably grab a JDK targetting Java 1.5 and think that you can compile some of your own classes and go merrily along. Not quite so fast–you’ll actually need to tweak your JRun 4 installation if you plan on using the latest Java 1.5 JDK (it’s really pretty easy–see below the fold for more details). If, rather, you just want to get going right out of the box with the default installation, however, what you really want is the older Java 1.4.2 JDK.

Read the rest of this entry »

Comments

FZip: Zip Archives for ActionScript 3

Wow, Claus Wahlers and Max Herkender are quickly closing the gap between ActionScript 3 and other development platforms’ libraries (read Java and .NET) with their newly-released FZip library. If you haven’t already heard, FZip allows for progressively decompressing zip archives directly in the Flash Player. What’s even better, it’s licensed under the free and very unobstrusive zlib/libpng license and as such, is unencumbered for use in commercial products.

While it does require a slight modification to zip files on the server-side to include Adler32 checksums for zlib compatibility, this can be readily managed with a few lines of server-side scripting and made to be almost invisible.

One immediately useful application for FZip is managing skins for icon and graphic heavy RIAs as suggested in Claus’ demo. The small file size typical of icons makes downloading them one-by-one over HTTP extraordinarily inefficient, as the handshaking and headers needed for making each request are sometimes as large as the image itself. Previously, the chief alternatives to this madness were either placing your icons and other graphical assets in the main application’s library itself (as Macromedia was wont to do with their component sets), or if dynamic skinning was desired, in a shared library SWF. While SWF based approaches solved load time problems, they created another: modifying skins and icons now required the ability to edit and/or recompile SWFs. This isn’t much of an issue for a professional Flash designer or developer, but effectively placed the ability to reskin a RIA outside the reach of most users.

However, if you now place all of your skin icons in a FZip archive and load them into your application from there, not only can all of your icons and graphics be retrieved as a single request, making a new skin is now no more difficult than opening up a zip file and modifying some of the contents. This makes life much easier for making changes to icons and seeing the results without having to recompile your entire application for each miniscule change.

Comments

Array Extras for Actionscript

Late last fall, with the advent of Firefox 1.5, Mozilla added a handful of new Array methods with the update of the Gecko browser engine to JavaScript 1.6. Apparently, these have also found their way into ActionScript. Sharp eyed Daniel Hai noted last month that these were silently added into Flex 2.0 Beta 2 as undocumented methods, and this past week, they’ve finally made their debut in the Beta 3’s Array documentation.

These new additions to the Array class bring a couple of item locator methods, indexOf() and lastIndexOf(), which behave much like their corresponding String analogues, and a set of more interesting iterative methods: every(), filter( ) forEach(), map(), and some(). Each of these latter methods take a callback function to be invoked on each item in the array, and collectively, allow arrays to be used much like lists in functional programming.

While these new methods don’t add any new functionality that couldn’t be done in the past via relatively simple loops, they do make working with arrays quite a bit easier and help simplify the idioms used in array operations. In the last few days, I’ve taken to them so much that I even threw together a quick ArrayExtras backport implementing these as mixin methods for ActionScript 2.0.

With the significant retooling and polish that’s been going into ActionScript 3.0, it’s great to see that Adobe is leading the way with E4x support and the incorporation of Mozilla’s Array extras as we move towards the 4th edition of ECMAScript.

Comments

Parsing Excel Files with ActionScript 3.0

Back in January, I had started learning ActionScript 3.0 by picking a particularly interesting problem that had been dogging me since I first started building web-based applications in the late 1990s. That problem is, how to build client-side programs that can parse and render binary file formats within a browser without the need to download separate plugins or ActiveX controls for each one. To do that, you need to able to parse binary data on the client. And when I saw the ByteArray class in Flex 2.0, I smiled.

I decided to go after Excel files. Yes, many machines have Excel or comparable spreadsheet application already installed on them. And Microsoft does offer a free downloadable viewer for Excel files. But wouldn’t it be just neat-o to be able to view Excel documents directly in the browser without needing anything but the Flash Player? Or even better yet, import data straight from .xls files into a Flash RIA?

After a few nights of work, I managed to import some basic .xls files and correctly parse out column and row data for strings and numbers. That was January, and then a maelstrom of client work happened (including a particularly painful stretch of 12 consecutive 16-hour workdays at a remote site). And the Flex 2.0 APIs changed. And changed again with each new beta. Not that I blame Adobe–each time it’s been for the better. Seriously, does anyone like having to import trace in every single class that you’re debugging? It was just that I hardly had time to sleep, let alone code anything fun. Thankfully, my good friend Darron Schall had been keeping my code updated to the latest versions of the Flex 2.0 beta in preparation for his recent presentation at Flash in the Can.

However, I’ve finally managed to get back to working on it, updating it yet again to Beta 3, adding a couple new features, and preparing it for public consumption. Next up is allowing for the file path to the .xls file to be specified programmatically (it’s currently hard-coded), and exposing the parser as a library that can be used by other projects.

So, without further ado, here’s a couple of demos: A very basic test, as both the Excel file and loaded into my Flash-based viewer. And a slightly more complex example, with the data available as the Excel file and loaded into the viewer (requires Flash Player 9).

Comments (4)