Flex/AIR rocking Javapolis

I have been relatively quite the last weeks mainly because my current project was to be kept secret until today.
Today I presented together with my current client Stephan Janssen the result of 5 months Flex and AIR development.
Boy when do you get the chance to present you work in front of 3000! Java developers ๐Ÿ˜‰

It was really amazing and the feedback is really overwhelming. We presented at the Keynote right after the Adobe team (Bruce Eckel, James Ward, Christoff Rooms).
I think most of the Java people liked it and are now seriously looking at Flex and AIR.

So some notes about the actual project we presented. It is version 2 of Parleys a website dedicated to present presentations from various Java conferences.
The current client (version 1) was build with Java Script and is now rebuild with Flex and AIR. The actual application will be available as soon as AIR gets out of Beta so beginning 08.
Continue reading

Resumable Downloads with AIR

I`m just developing an AIR project were the client needs to be able to synchronize big loads of data. So I thought it would be cool if the user can pause and resume downloads.
I first thought that this would not be possible but then i looked at the Adobe Media Player and he does it as well (Look into the Download Manager). The trick seems to be easy.
After a quick search through the Http specification i found out that you can write a custom header to use with the URLStream class. With Http specification 1.1 you can define a range of bytes you want to download so you don`t have to start from the beginning.
Here is how a sample Request looks like:
GET /files/richflv/help/ExportOptions.flv HTTP/1.1
Referer: app-resource:/LoadingTest.swf
x-flash-version: 9,0,60,153
Range: bytes=1200000-1300000
User-Agent: Mozilla/5.0 (Windows; U; en) AppleWebKit/420+ (KHTML, like Gecko) AdobeAIR/1.0
Host: www.richapps.de
In Actionscript we can write a custom header like this:
var header1:URLRequestHeader = new URLRequestHeader(“range”,”bytes=”+currentBytesPosition+”-“+toRange);
var re:URLRequest = new URLRequest(downLoadURL);
currentBytesPosition = toRange;

This should work with most servers/files. To make sure it works you can first make a request and analyse the response header. It should include something like this:
Accept-Ranges: bytes

I think you get the idea! This is pretty powerfull especially if you want to synchronize big chunks of binary data and the client closes the client in between.
On the next startup you can simply resumeย  the download at the position were the client closed your AIR app. There are so many hidden goodies in AIR/AS3.0!

RichWav Sneek Peak

During the nights of MAX Europe i worked a bit on my wav mixer tool (now oficially called RichWav ;-)) and made some nice improvements.
You can now create multiple tracks and have a library of wav files that you just drag to a track. Every track can have multiple samples.
If you press play every track gets converted internally to a wav wich is embedded in an swf and returned to the Loader. This works pretty fast even for a lot of tracks.
The best thing for sure is that you can save the whole thing down to one wav on your harddisk. Just wanted to give an update to what i`m doing in my free time right
now as an excuse for not updating RichFLV to Beta 2.ย  I did it already but need some tweaking – if one needs a Beta2 update of RichFLV very urgent let me know and i send you what i have so far :-)

MAX Europe Presentation files online

Finally here are my slides from my session about “Bits And Bytes With AIR”. You can get the Flex sample project here.
It shows you how to analyze an flv file and extract the sound data as an mp3 file.
The whole presentation itself is done in AIR. It might be a bit difficult to navigate.
You the cursor keys to go back and forward. Sometimes you can trigger animations or different states within one screen. You can do this with the Up and Down keys.
I know it`s not very userfriendly but i thought it would be cool to give a presentation about AIR in AIR ๐Ÿ˜‰
The original reason i did it in AIR was that i was sick of my boring powerpoint presentations. I was really envious about all the people that could use keynote on their Macs.
So i build this little presentation tool with Flex and AIR with some funky transitions done with Papervision 3D. You can change the transition type with these keys:

– R = Replace

– B = Box

– S = Switch

– I = Inside Box

– N = None

Use those keys to change the transition types and then the cursor keys to actually switch the slides.
Below are some screens from the transitions. Is there still anyone thinking Flex is not as expressive as Flash? ๐Ÿ˜‰




Some details about my MAX session

Because I was a bit late with submitting details about my talk at MAX in Barcelona i`ll do some advertisement here :-)
I will show some examples (RichFLV, RichMP3, WaveMixer), some theoretical background (bitwise operators…), talk about IDataInput/IDataOutput classes and walk through a full example of how to analyze an flv and extract the sound data out of it as an mp3.
The main motivation to give this presentation is that I`m still fascinated how powerfull this stuff is. I`ve always been a Flash/Flex developer and therefore have never worked with really low-level stuff.
When i realized how much power you gain if you learn a bit of this dry stuff I knew it is worth the effort. So if you`re like me – an actionscript developer that until now never really had the need to learn the basics about bits and bytes come and join my talk on monday 10am-11am. Also I`m really nervous about speaking at MAX I put a lot of effort into this talk and want to have a full house ๐Ÿ˜‰

I think MAX will really rock and i`m looking forward meeting all my heroes, especially Ty Lettau who in my opinion is the first real RIA designer out there. Be sure to catch his talks!

Richapps@MAX: What do you want to know about ByteArrays?

It`s official now! I will have a session at MAX in Barcelona. The session will be called “Bits and Bytes with AIR”.
I have a basic outline for my talk finished. It will be an introduction targeted at the intermediate Flash/Flex/AIR developer for whom the ByteArray class is still a mystery and who wants to find out more about its use. Part of the talk will be about the very basics (bits and bytes) and the other part will be a more practical one where I show how you can put this knowledge to good use ( Analyzing and manipulating Mp3, Wave, SWF and FLV files). ย I want to take one example and explain it in more detail. I thought of showing how to analyze an FLV file and extract the sound as an mp3 or how to mix two wave files.
So it would be cool if you would leave a comment what you`d like to get explained. This is your chance to make this a valuable session for everyone. Go ahead leave a comment or write me a mail to: benz (at) richapps.de

Reading Waveform and mixing Waves with AS 3.0 (source included)

So here is part 2 (part1) of this nights sleepless hours product.
This is a little example of how to load multiple wave files and show the waveform of each wave file.


You can also save a Mix of all files as one wav. This uses my new Wave Mix class which is super simple to use.
You have to pass it an Array of WaveReaders in the constructor like this:

var waveMix:WaveMix = new WaveMix(myWaveReaders);

Then you just call the mix() method of the WaveMix class and it return a ByteArray which is the new wave file.
You can now use this to save the bytes to the filesystem or send them to a server.
var waveBytes:ByteArray = waveMix.mix();

There are still some problems with wave files of different sample sizes. It works best if all files are 44500 Hz, 16Bit, Stereo wave files.
I`ll work on that :-)
I know it`s al a bit ugly unfinished code but it`s all from one night so bear with me.

Get The AIR file here.
and Code here.

Load and Play .wav files at rumtime with AS 3.0 (source included)

This is a follow up to my previous post about mixing wav files with Actionscript. I couldn`t sleep tonight so I have hacked together some classes that make it easy to load and play wave files at runtime with Actionscript 3.0.
You know that it`s not natively possible to load and play wave files at runtime. The trick is to load the wave file as a ByteArray (e.g. with Loader, FileStream, URLStream…) and than construct a swf file in memory that has the wave bytes embedded. First i created a swf file in memory that has the wave sound embeded and played it back with a StartStream-Tag. I did not liked that method because it does not give you good control over the playback of your sound. So the solution was to create a SWF file that defines a sound that is linked to a class so you can access the Sound Object directly. For those interested in details here is how the SWF file that i create in memory looks like:


Here is a overview of the classes you need if you want to load a wave at runtime:


What the WaveMix class is for will be revealed in the next post :-)
In order to load a wave sound these are the basic steps:
// Create a new Wave Reader
waveReader = new WaveReader();

// Create a wave SWF
var waveSwf:WaveSWF = new WaveSWF(waveReader);
waveSwf.addEventListener(Event.COMPLETE, onWaveReady);

private function onWaveReady(evt:Event):void{
sound = WaveSWF(evt.target).sound;
channel = sound.play(0,0);

Now you can use all methods of the Sound Object to work with your sound.

All this is still a bit buggy (all hacked together this night :-). So use it at your own risk.

I`ve prepared a little example in AIR that let`s you load a wave sound. The Wave has to be a PCM encoded (uncompressed) wave file.
Download AIR Example
Download Flex Project (Source)
Let me know what you think ๐Ÿ˜‰
This was a pretty long night :-) so in the next post i`ll add something to this (reading waveforms + mixing sounds)