Hi!
I am making a program that uploads media content(images, sounds, video) to a server. My problem is that I dont understand how to load the media into my program and encode it with base64.
Flash is my target.
Currently I load images by calling the function _showFileDialog():
private function _showFileDialog(fileType: String, textField: TextField):Void
{
var fr:FileReference = new FileReference();
fr.addEventListener(Event.SELECT, function(e){
var fr:FileReference = cast(e.target, FileReference);
textField.text = fr.name;
fr.addEventListener(Event.COMPLETE, _onLoad, false, 0, true);
fr.load();
});
fr.addEventListener(Event.CANCEL, function(e){
textField.text = "Cancelled!";
});
fr.browse();
}
private function _onLoad(E:Event):Void
{
var fr:FileReference = E.target;
fr.removeEventListener(Event.COMPLETE, _onLoad);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _onImgLoad);
loader.loadBytes(fr.data);
}
private function _onImgLoad(evt:Event):Void
{
var loaderInfo:LoaderInfo = evt.target;
loaderInfo.removeEventListener(Event.COMPLETE, _onImgLoad);
var bmp:Bitmap = cast(loaderInfo.content, Bitmap);
}
QUESTION: What do I have to do to make this code load sounds and images?
and how do I encode the media to Base64?
Thanks!