Archive for the ‘Flex’ Category
Archive solutions in Flex/Air environment – FlashArchiver (FAR) and WINE
Using zips in a combined Flex/Air environment isn’t that trivial.
When running through FlashPlayer in browser, a compressed zip needs a Adler32 checksum to be valid. This isn’t a standard feature in any of the php zip libraries that I’ve seen.
Edwin van Rijkom’s FAR archive (http://code.google.com/p/vanrijkom-flashlibs/) is a very slick solution to get around this. It uses a custom file format based on zip compression. In the server end, it’s command line archiving tools (win, osx and “linux”, read on…) does a neat job in compressing, and in the Flex/Air client delivers the decompressed files continously while streaming the archive – quickly enough to handle large files. The native not-quite-zip format might also initially confuse a nosy mind…
One major problem: The linux version doesn’t work well in apache-php-server environment because of dependencies of X server, wich causes “Gtk-WARNING : cannot open display” error. It might be possible to solve by creating an environment where X server is running, but that seems very unnessecary and odd for a command line tool. At least to me – wich basicaly means that it’s beyond my limited linux knowledge…
One working solution: Running the windows version of the far compressing tool through Wine. Not that elegant, maybe, and maybe not that secure either, but at least it works! This is how I’ve managed to get it to work:
- Installing Wine on my Debian server
- Putting the windows archiver tool far.exe in an application directory, /var/tools/far/bin/far.exe
- Creating an output directory for the resulting archive files, /var/tools/far/output/, also setting it’s chown to www-data to be able to be reached by Apache.
- Creating a /var/www/.wine/ directory, setting its chown to www-data – also to be able to be reached by Apache2. (Maybe there’s another solution that putting it in /var/www/ – haven’t figured out yet.)
- Calling it from my php script like this, creating a new far archive (newarchive.far) from the files in the directory filesdirectory/:
<?php $command = 'wine /var/tools/far/bin/far.exe /var/tools/far/output/newarchive.far filesdirectory/'; $return = exec($command, $output, $result); ?>
Thanks Lasse for help regarding the Gtk problems, and MathieuK and Mike on StackOverflow for sorting out the Wine stuff! And Edwin of course!
FlexBuilder 3 as plugin in Eclipse 3.5 Galileo
Just found this article describing how to run FlexBuilder 3 plugin in newer versions of Eclipse (3.4 & 3.5). Just trying it out, and it seems to work. Good news! This makes it possible to set up an environment including plugins that depend on the newer versions. In my case, it’s above all the nWire Php plugin that is interesting. Thank you, Adam Ness!
AS3: Loading sound from bytearray
When fiddling with using zip in Flex/As3, I discovered that the Sound class doesn’t have a .loadBytes method (corresponding to the Loader class .loadBytes method). I was able to get the byteArray data out of the zip, but no way to feed a Sound object with it! Grr..!
Luckily, there are lots of gifted bravehearts and generous brightheads around in the blogosphere!
Thanks to article by Chris at flexiblefactory.co.uk about reading sound from a FileReference, I could make it work! Here is how his elegant solution works – well, at least “kind of how”…:
- Reading the mp3 bytearray code from the file
- Building a SWF from the ground up, including the messy header stuff, and embedding the mp3 data into it
- Loading the SWF into a Loader object, and typecast it from there as a SoundClass to a Sound object
- Play!
Thank you, Chris!
Leave a Comment
Comments (1)
Comments (2)