Gumbo Tips #1 FlexGlobals.topLevelApplication

I`ve not posted for a long time and it seems it will stay like this for a while as I`m hands down in work :-(
However I`m using my spare time to get up to speed with Gumbo. My learning project will be a new version of RichFLV (not saying that it will ever be ready :-)). So i thought I start a little series with small things I found while converting projects from Flex 3 to Gumbo.

Here is a first really simple one:

Application.application is no longer In Gumbo we have FlexGlobals.topLevelApplication instead.

I know you should rarely use Application.application because it reminds too much of the old devil root but sometimes it`s needed (or?)
For example if you want to create a popup and you create it not in the root of your app or in a non visual class in Flex 3 i would have done
something like this:

PopUpManager.addPopUp(progressWindow,DisplayObject(Application.application),true);

now in Gumbo you could use this

PopUpManager.addPopUp(progressWindow,DisplayObject(FlexGlobals.topLevelApplication),true);

Some info about this change can be found here: http://opensource.adobe.com/wiki/display/flexsdk/Spark+Application

BTW can anyone recommend a good code highlighting plugin? 😉

Loading/Playing mp3s without round-tripping to the server

One of the cool new features of Flash Player 10 is that you can load files from the client without uploading them to the server.
The only limitation is that you`ll only be able to access the raw bytes of the file and there is no way to find out the filepath (see problem discussion here). The problem is that until now we cannot pass mp3 bytes to the sound object or the netstream class so there is no easy way to play mp3s locally on the client (without first uploading them to the server).
So here is a solution that uses the old trick of generating a SWF file in memory which contains the mp3 associated with a linkageId.

Check out my solution here
bild-7Note that some mp3s might not work as the Mp3Reader class is not very optimized but it should show the general steps to chieve the goal.
Let me know if it`s useful and if you could make any enhancements.

Next we`ll look into how to load two mp3s and mix them and save them as a wav (PCM) file.

My take on sequencing Cairngorm events

I`m working with Cairngorm in nearly all of my projects and I like it because it somehow forces me to work structured. But there are some things that I don`t like or don`t get. For example sequencing of Commands in Cairngorm is done by subclassing SequenceEvent and putting all the logic for which event comes next directly into the Command itself. By doing so the command looses a lot of reusability. What if I want to use the same command outside of a sequence chain?
I would have to code two commands – one for the sequence and one that lives on it`s own. The other thing is that when i fire a cairngorm event from my view i have no way to know when the corresponding command is done. Only way would be through some sort of state variables in my model that keep track of the process. I believe that this approach is quite fragile because sometimes you might have to commands of the same instance running and you`ll never know which of same changed your model. And a model with hundreds of state variables just doesn`t look clean to me.
I lived with all these problems for some time know and never really thought about forking the original cairngorm framework because I like to work with the original framework to be safe for future changes.
But now I just can`t live with these problems anymore – so here is my first try into improving this stuff.
Continue reading

Adobe Premiere in AIR…

… not really 😉 but it`s impressive how far one can get in a few hours.
In this new version it`s now possible to edit multiple flv files and multiple mp3 files and combine them to one flv.
The binary stuff works pretty well but my main problem is the internal preview. It`s really difficult (impossible???) to play flvs and audio files and synchronize them.
Any suggestions?
So the solution for now is that everytime one clip is cut or the audio changes i create a new flv file in memory with all the changes applied and load that back into the preview.
Sure this takes some seconds and gets harder the bigger the files are but still it`s not that bad and you`ll get 100% accuracy.

Check out my screencast of the current progress here

richflvNextGen2.jpg

RichFLV – Apollo FLV Editing Tool

RichFlv can:

  • Read flv Metadata
  • read/edit/modify/delete cuepoints
  • cut flvs
  • convert the sound of the flv to mp3
  • convert flv to swf

The API i developed for RichFLV implements most of the FLV file specificaton and some parts of the SWF file specification in Actionscript.
It`s all done with pure Actionscript (Byte Array Baby!) so no external tools are used. The cool thing is that the only thing that depends on the apollo framework is the part were RichFlv actually saves the files to your desktop (FileStream.writeBytes()). The same could be done as a none apollo app in the browser and than send to the server. Imagine this as an extension to popular video sites. It would enable real flv remixing in the clients browser!

RichFlv is currently an alpha release so expect some limitations and bugs. Current known issues are:

  • All flvs will be saved with a framerate of 25/s
  • Exported SWF will only contain the Video information (no audio)
  • Cuepoint Timeline does not scale properly if application is resized
  • overall handling and accuracy needs improvements
  • I would not use files bigger than 30 mb.

These problems will be corrected until RichFlv reaches 1.0 status.
Future versions will have the ability to mix several flv together to one file. I have this all ready but need more time on the UI.

Download RichFLV Alpha 1

Updated to Alpha 2.0: See post here.


!!! New Version Available See This Post !!!

Watch a quick introduction Video here.

(Again it`s an alpha release – use on your own risk)
Here are some Screenshots:

Cue Point Editor

CuePoint Timeline

Cutting Slider

I`m always interested in your comments, bugs and suggestions. Post them here or write directly to: info@richapps.de

Richtube=Flex Youtube Interface

I got an official statement from youtube that my youtube app does not confirm to the youtube terms of use. So i made a camtasia record to show it here. I think this app shows well how Flex and Zinc can be combined for rapid application development and it`s a nice example of an occasionally connected client. I hope that the same type of applications will also be possible with apollo. Here a the key feautures:
– Search Youtube
– Display Videos in a Custom (not Youtube) Player.
– Save Videos Offline
– Organize downloaded Videos in categories
– Export downloaded Videos to ordinary AVI files and save them on your machine.

Have a look here.

I hope that youtube will make their service more open soon. I think one big point at the moment is that they need to place their ads and such an app prevents this. Maybe they could open the service under the restriction that you display ads from them in your app. Those ads could be updated everytime the app goes online.

Microsoft MAX like Flex Image View (with source)

Yesterday i installed Microsoft MAX. It`s the first app from Microsoft that uses WPF. I really like it but the first thing i thought was: “This can all be done in Flex too!” I especially liked the way the images reorder when you scale them. So back from work i tried it in Flex. I took the hybrid store example from adobe as a starting point.

You can view the result here.
And grab the source here.

Try scaling the images with the slider on the right and use the Devider and see what happens with the images. Also try to rescale your browser window. It is really easy to do such things with flex. It took about 20 minutes to do this (can you do this in ajax in this time?). It`s really just a rough sketch and if anyone improves it please leave a comment.
What i really like about Wpf is that it will become easier to sell Flex/Flash based apps because soon (when does Vista arrives?) normal desktop apps will look like Flex/Flash apps 😉

My First Steps With Flash Data Services

Today i finally got the time to install the flex data services. For me this is quite an adventure as i`m not really a server or java guy. So for me the first thing was to get tomcat. I know it would have been easier to use the integrated jrun but i think tomcat is a more common setup.

Installing Java Open Transaction Managet (JOTM)

With this decision comes the first problem. In order to use the data management features one has to install the Java Open Transaction Managet (JOTM). No big deal if you know that 😉 You can grab a version here.
Unzip the file and locate the lib folder. Now copy all of those jars into your tomcat project folder under WEB-INF/lib. Here i struggled for a moment. I thought know the CRM example that ships with FDS should work fine but it didn`t. The solution was to create a config file under TomcatInstallation/conf/Catalina/localhost/ . The file needs to be an xml file named after your webapp directory e.g. samples.xml. Assuming your webapp directory is called samples the content should look like this:
<Context docBase=”${catalina.home}/webapps/samples” privileged=”true”
antiResourceLocking=”false” antiJARLocking=”false”>
<Transaction factory=”org.objectweb.jotm.UserTransactionFactory” jotm.timeout=”60″/>
</Context>

Replace ${catalina.home}/webapps/samples with your location.
With this setup i was able to run the CRM samples. Next step will be to configure everything for messaging. What would be the best messaging provider for tomcat?
As i said i`m pretty new to all this server/java stuff but i`m allready really impressed by FDS.

Anyone knows of good tutorials for starters? Any suggestions?

Cheers
Benz