Actionscript image download open custom viewer
i am downloading tiff images from WAMP server using our Flex AIR client. Using the following code for that.
public static function requestDownload(id:int, defaultName:String):void {
//POST params
var urlVars:URLVariables = new URLVariables();
urlVars.action = "download";
urlVars.fid = id;
var urlReq:开发者_如何学PythonURLRequest = new URLRequest();
urlReq.url = Config.getServerURL();
urlReq.data = urlVars;
Config.fileReference.addEventListener(Event.COMPLETE,FileDownload.requestDownloadResult);
try {
Config.fileReference.download(urlReq, defaultName);
}
catch (e:Error) {
Alert.show("Error in downloading the file");
}
}
public static function requestDownloadResult(e:Event):void {
Alert.show("File downloaded");
}
No issues with the download. It automatically prompts for a Save dialog. Works well. But i want to open the image being downloaded in a viewer(flash viewer or any) instead of the save dialog.
Please help me. Thanks Vish.
You can use a Loader
or an SWFLoader
class to load the image into your AIR application and then addChild
it to present it to the... er, I see you're downloading tiff images.
Flash by default doesn't support tiff format - it allows only jpg, png and gif images. You're going to have to load it into a ByteArray
using a URLLoader
and parse it using some ActionScript TIFF encoder. Remember to set the dataFormat
of URLLoader
to URLLoaderDataFormat.BINARY
精彩评论