I wonder how can I work with mp3 that was loaded to to flash via fileReference.browse() method ?
Currently I've created an lash application that can load mp3 file from local hard drive to flash and provide an option to save mp3 file that was loaded back to the hard drive. But I can't find the way to work with mp3 that was loaded. I've heard about flash based editor that will be available in Aviary.(http://aviary.com/blog/posts/aviary-acquires-digimix), so there is a way to work with mp3 in flash, but how?
Here is my code:
import flash.net.FileReference;
import flash.net.FileFilter;
import flash.utils.ByteArray;
import flash.display.MovieClip;
import flash.net.*;
import flash.events.*;
import flash.media.Sound;
import flash.media.SoundChannel;
var fileReference:FileReference;
var myChannel:SoundChannel;
var mySound:Sound;
var mySprite:Sprite;
var mySprite2:Sprite;
mySound=new Sound();
myChannel=new SoundChannel();
load_btn.addEventListener (MouseEvent.CLICK, onLoadClick);
unload_btn.addEventListener (MouseEvent.CLICK, onUnloadClick);
function onLoadClick ( event:MouseEvent):void
{
fileReference=new FileReference();
var allTypeFilter:FileFilter = new FileFilter("mp3: (*.mp3)","*.mp3");
fileReference.browse([allTypeFilter]);
fileReference.addEventListener(Event.SELECT, selectHandler);
}
function selectHandler(event:Event):void
{
fileReference.removeEventListener(Event.SELECT, selectHandler);
fileReference.addEventListener(Event.COMPLETE, loadCompleteHandler);
fileReference.load();
}
function loadCompleteHandler(event:Event):void
{
fileReference.removeEventListener(Event.COMPLETE, loadCompleteHandler);
var loader:Loader = new Loader();
//loader.contentLoaderInfo.addEventListener(Event.COMPLETE, startPlay);
loader.loadBytes(fileReference.data);
}
function onUnloadClick (event:MouseEvent)
{
trace(fileReference.data);
fileReference.save(fileReference.data, "done.mp3");
}
Thanks in advance.