Sonntag, 28. August 2011

Flash/Flex: Load resources due the browser and handle them with the current browser settings of the requested file-type (directly open, always save, …)

Problem statement
If you are running in your flash-context you have very limited options for file-handling: You can only open a file-download dialog where the user must select location and filename. There is no way as is in browser to always save and directly open the document of a specific type. It might annoy your users that they always have to manually locate the downloaded file and after that double click it.

Solution
Load the resources via the embedding website and an embedded iframe.

If you have to to supply credentials for the requested resource and you currently transmit them encoded in the URL, you should read the following blog-article: TODO

AS-Code
public 
function loadResourceViaBrowser(filename: String, loadViaBrowser:Boolean): void {

    if (!ExternalInterface.available){
       throw new Error();
    }

    var url:String = "http://localhost:8080/resource/someDocument.doc";
    ExternalInterface.call("loadResource", url);
}


JS/HTML-Code


    
	
		
	
        
		
        
    
	
    	    
	    
   
   

Keine Kommentare:

Kommentar veröffentlichen