[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 725
  • Last Modified:

Cannot get .wmv files to Download Properly, navigateToURL, download() method

I have wmv files that i need available for download from an swf (both swf and .wmv's will be on a DVD or CD). The wmv files are in a folder named WMV which is at the same level as the swf. I just want the user to be able to click on a button and select "Save As" and download the file. I've been trying to use the download() method but keep getting IO Errors and also tried using navigateToURL but it tries to download it through firefox (no "Save As" option, just tries to open with Windows Media Player) and windows media player says it can't find the file.

I'm sure I'm probably missing something very simple, but I'm new to AS 3, and Any help would be Awesome!
Thanks!!
0
somers3135
Asked:
somers3135
  • 5
  • 4
1 Solution
 
CyanBlueCommented:
Create a dummy.zip file in the same directory where you have the WMV file stored...  Replace the file name with the dummy.zip file to see if that works with the download() function...  
If that works, there is a chance where the web server prohibits downloading the WMV file type...
If that does not work, there is problem with either the path of the file or the script itself...

The navigateToURL() function relies on the web browser to initiate the given protocol, so it is natural to open up that file with the application of the associated MIME type...

CyanBlue
0
 
somers3135Author Commented:
Thanks for the Reply CyanBlue!

'm lookin all over for a solution and it seems like the FileReference.download is the way to go, but even Adobe's Solution is not working.

http://kb.adobe.com/selfservice/viewContent.do?externalId=3637d5c3

If i keep it like they have it, I get errors that it only accepts http or https. Then, if i put in the http://, it shows the download dialog box, but after i click save it either gives me the Unhandled IOErrorEvent message, or it doesn't do anything, just like the link describes. I'm totally lost. Here is the relevant code I'm using.  

var fileReference:FileReference = new FileReference();

function myFunction(event:MouseEvent):void
{
      var urlRequest:URLRequest = new URLRequest("http://dummy.zip");
      fileReference.download(urlRequest);
}
this code currently displays the Unhandled Error Event

I've tried putting the code exactly like it is on the link provided, but same thing.

p.s. - dummy.zip did not work
0
 
CyanBlueCommented:
Try this and see what happens...  Make sure that you are providing the full URL to the dummy.zip file...

CyanBlue
var fileRef:FileReference = new FileReference();
function downloadFile(e:MouseEvent):void
{
	fileRef.download(new URLRequest("http://www.domain.com/dummy.zip"), "dummy.zip");
}
 
download_btn.addEventListener(MouseEvent.MOUSE_DOWN, downloadFile);

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
somers3135Author Commented:

Almost There!! Where did you get www.domain.com from?? :)    So the dummy.zip works but when I try to use a .wmv, It appears as though it has worked until I try to open it, I get an error from windows media player saying that "The file you are attempting to play has an extension that does not match the file format." The saved file is also only a fraction of the size as the original.
0
 
CyanBlueCommented:
I guess you will have to provide the full URL when using the FileReference...  I've used it like that without doubting it till now...  ;)

I think it has to do with your server setting the MIME type of the WMV file to a streaming media or sort...  That's why it is invoking the Windows Media Player to try to open up the file...  I suggest you either use a server side script to force the file downloading the WMV file or simply ZIP up the file to make it downloadable file...

CyanBlue
0
 
somers3135Author Commented:
I just tried it again but with an .FLA and the same thing happened, also tried zipping a file, but no luck, is it  just pulling the filename?  Know of any good tutorials or places to learn the server side script to force download? (never worked with that before)
0
 
CyanBlueCommented:
It's not as easy as pie, but you can try this PHP solution...
     http://www.boutell.com/newfaq/creating/forcedownload.html

CyanBlue
0
 
somers3135Author Commented:
looks like I'm movin back to AS 2.0 for now, the project leader says that the links need to download the wmv's directly, can't be inside a zip file, although i did get the zips to work with the navigateToURL.  Thanks for all your help Cyan, probly need some help with the server side scripts pretty soon!
0
 
CyanBlueCommented:
Dang...  That sucks...  :(

CyanBlue
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now