Flex Flex Flex

I have heard about Flex for some time. It’s released by Adobe, it’s open source, can compile for both web browser or desktop, it’s great for data visualisation, and it is quick and simple. Only until recently, I bought a kind of a dummy book to know more about Flex. Flex has jumped to version 3, I heard about it when it was still version 2.

After going through the book on how to prepare Eclipse or Aptana IDE to create my first Hello World using Flex, a lazy bump like me went straight ahead to Adobe website to download the trial version of Flex Builder. No doubt, it is the simplest an easiest way to design, write and compile those Flex apps. Without any knowledge of Flex, I spent one afternoon to create simple RSS feed reader. Not that I am smart, but it is really simple.

Recently, the video player plug-in that we use for our class blogs (yes, I teach) are not showing M4V and MOV files on PCs, even QuickTime is properly installed. So the try Flex out, I have written a simple video player that accept parameters (video link) from the embed code. The player plays M4V and MOV well on all the computers and browsers we have in the lab (Mac, PC, IE, Safari and Firefox). The the source code in Flex Builder is only like the following:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300" applicationComplete="initApp()" >
<mx:Script>
<![CDATA[
     private function initApp():void
     {
     	vid.source = Application.application.parameters.vurl;
      }
]]>
</mx:Script>
<mx:VideoDisplay x="0" y="0" width="400" height="300" autoPlay="false" id="vid"/>
<mx:Button x="297" y="275" label="?" toolTip="Play" width="32" id="playbutton" click="vid.play()" />
<mx:Button x="365" y="275" label="?" toolTip="Stop" width="32" id="stopbutton" click="vid.stop()" />
<mx:Button x="331" y="275" label="?" toolTip="Pause" width="32" id="pausebutton" click="vid.pause()" />
</mx:Application>

Yes, it is less than 20 lines of code. Flex Builder will generate a Flash video player that can be embeded in any HTML document. You do need to have a few more files to go with the SWF file, but guess what? I don’t have to code those files. I just copy and put it is the right place, it will run as smooth as silk

Leave a Reply