1 Reply Latest reply on Mar 8, 2011 9:31 AM by Stefan Horochovec

    convert FileReference to URLRequest?




      I am very new to Flex.  I need to build a little component that will read the running time of a collection of local MP3 files and return the runtimes to a webapp, which is building the metadata for a digital talking book for the blind.  Flex 4 seems to be the most direct path.


      I have hacked on some sample MP3 player code and changed it so it prints String(Sound.length) when I play a local MP3 file by name, with, for example,


      <net:URLRequest id="myURLReq" url="sample.mp3" /> and




      Then I typed in the Adobe cookbook example for uploading a local file via PHP to a server, using FileReferenceList.browse(), and that works.


      Now I want to merge these two functions, where I pick the local MP3 files with FileReferenceList.browse(), and load each FileReference into a Sound object.  My question is how can I turn a FileReference object into the local equivalent URLRequest that I can pass to Sound.load()?  Is there some kind of cast?  Do I pick apart the object into data fields and reassemble it by hand?


      Thanks so much for your help!



        • 1. Re: convert FileReference to URLRequest?
          Stefan Horochovec Level 2



          How its work the URLRequest at "net" namespace? The result of your question depends this object.


          You can upload a data easly in Flex. Like this code above:





          private var fileReference : FileReference = new FileReference();

          protected function button1_clickHandler(event:MouseEvent):void



          this.fileReference.addEventListener(Event.SELECT, onSelect);

          this.fileReference.addEventListener(Event.COMPLETE, onComplete);



          protected function onSelect(event:Event) : void





          protected function onComplete(event:Event) : void







          <s:Button x="10" y="10" label="Button" click="button1_clickHandler(event)"/>


          In this.fileRefecente.data on onComplete function you have the mp3 file, for example. If you can past the source of this player ir more easy to understand and indicate the correctly solution for your case.