Hi
I am currently using filereference in as3 to load a file from the users local disk and display instantly within a loader on the stage. This works fine but i am now needing to load files that are already stored on a server not the local disk, is this possible?
I have tried loading the url into a loader object but this takes far too long if the image is quite big where is filereference is almost instant.
My current code is:
var mFileReference:FileReference;
browseButton.addEventListener(MouseEvent.CLICK, onBrowseButtonClicked);
function onBrowseButtonClicked(event:MouseEvent):void {
mFileReference=new FileReference();
mFileReference.addEventListener(Event.SELECT, onFileSelected);
var swfTypeFilter:FileFilter = new FileFilter("JPG/PNG Files","*.jpeg; *.jpg;*.gif;*.png");
var allTypeFilter:FileFilter = new FileFilter("All Files (*.*)","*.*");
mFileReference.browse([swfTypeFilter, allTypeFilter]);
}
function onFileSelected(event:Event):void {
mFileReference.addEventListener(Event.COMPLETE, onFileLoaded);
mFileReference.load();
browseButton.visible=false;
}
function onFileLoaded(event:Event):void {
var fileReference:FileReference=event.target as FileReference;
var data:ByteArray=fileReference["data"];
mFileReference.removeEventListener(Event.COMPLETE, onFileLoaded);
var movieClipLoader:Loader=new Loader();
movieClipLoader.loadBytes(data);
movieClipLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMovieClipLoaderComplete);
}
function onMovieClipLoaderComplete(event:Event):void {
var loadedContent:DisplayObject=event.target.content;
var loader:Loader=event.target.loader as Loader;
container.addChild(loader);
}
Is there anyway i can take out the browse and selected stages and just load the server based image? Any help would really be appreciated
Thanks