Sorry for being away for a while.

It is a simple example to play .flv files from the local system. Earlier in my Jukebox tutorials I had used a fileOpen component. As the component is no more available for download, I thought of showing this alternative way to access files from local system rather than rewriting the juke box tutorials again.

I hope readers would be ablw to use this concept while building their own mp3 players.

In case there is a problem, just send me a mail (no spam, please) .

Just create a new AIR project in Flex Builder 3 and use the following code . Then click Run to see the application.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:WindowedApplication xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”absolute” backgroundGradientAlphas=”[1.0, 1.0]” backgroundGradientColors=”[#FBFAFC, #F3F3F4]”>
<mx:Script>
<![CDATA[
import flash.filesystem.File;
import mx.events.FileEvent;

/*****************************
Create a file object and point it to documentsDirectory.
It is the My Documents directory in case of Windows and
Documents subdirectory of the user directory in case of Mac OS.
******************************/

private var file:File = File.documentsDirectory;

/*****************************
browseForOpen method opens up a browse directory dialog
box to open a file from My Documents directory
(Documents directory in case of Mac OS) for file browsing
and upon selection of a file onSelect method is called.
******************************/

private function fileOpen():void {
file.browseForOpen(“Select a file”);
file.addEventListener(Event.SELECT, onSelect);
}
/**********************************
onSelect method assigns the url property of the file object to the
variable vUrl and the name property to the variable vName as a string.

**********************************/
[Bindable]
private var vUrl:String;
[Bindable]
private var vName:String;
private function onSelect(event:Event):void {
vUrl = file.url;
vName = file.name;
myVideo.play();
timer.visible=true
}

private function closeVid():void {
myVideo.stop();
timer.visible=false;
vidName.visible=false;
}

]]>
</mx:Script>
<mx:VideoDisplay x=”70″ y=”26″ width=”379″ height=”234″ id=”myVideo” source=”{vUrl}”/>
<mx:Button click=”fileOpen()” label=”Open” x=”70″ y=”289″/>
<mx:Button x=”134″ y=”289″ label=”Close” click=”closeVid()”/>
<mx:Label x=”90″ y=”10″ text=”{vName}” id=”vidName” fontSize=”10″ fontWeight=”bold” color=”#0E5B87″/>
<mx:Label x=”210″ y=”291″ id=”timer” text=”{myVideo.playheadTime}/{myVideo.totalTime}” visible=”false”/>
</mx:WindowedApplication>
If everything is OK and the application works, then start packaging for distribution.

With release of next version of Flash Player, You will be able to create your own media player . Future seems so bright.