ok, im having an interesting problem…im trying to use fileReference.download to allow users to download content from my site.
the problem is, when i test it in Flash…it works flawlessly. when i publish it and upload it to my server it doesnt download. it’ll bring up the download box… but it wont initiate the download.
Here is my AS…just to help you out with my code, what i am doing is dynamically creating text boxes using the amount of XML nodes in my xml file. it will then assign the proper download file to that text box/download button.
its just not initiating the download in my browser…is it an AS or browser problem…maybe serverside? help is appritiated.
[AS]/////File Reference ActionScript/////
import flash.net.FileReference;
var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void {
trace("onSelect: " + file.name);
}
listener.onCancel = function(file:FileReference):Void {
trace(“onCancel”);
}
listener.onOpen = function(file:FileReference):Void {
trace("onOpen: " + file.name);
}
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}
listener.onComplete = function(file:FileReference):Void {
trace("onComplete: " + file.name);
}
listener.onIOError = function(file:FileReference):Void {
trace("onIOError: " + file.name);
}
this.fileRef = new FileReference();
var fileName:String;
var mc:Object;
////Create Download Items
var fileSpacing:Number = 20;
var txtColor:Color;
function loadFiles():Void{
_parent.projectTxt.linkBtn.enabled = false;
for(i:Number = 0;i<_root.caseNav.XMLRoot.childNodes[3].childNodes[1].childNodes.length;i++){
pad = i - 1;
filetxtBox = this.attachMovie(“filetxtBox”,“filetxtBox”+i,this.getNextHighestDepth());
filetxtBox.txtBox.text = _root.caseNav.XMLRoot.childNodes[3].childNodes[1].childNodes*.childNodes[0].firstChild.nodeValue;
filetxtBox.txtBox.autoSize = true;
filetxtBox._x = -280;
filetxtBox._y += 10;
filetxtBox._y = this[“filetxtBox”+pad]._y + fileSpacing;
downloadBtn = this.attachMovie(“downloadBtn”,“downloadBtn”+i,this.getNextHighestDepth());
downloadBtn._y = filetxtBox._y;
downloadBtn._x = filetxtBox._x + 300/250/;
this[“downloadBtn”+i].onRelease = function():Void{
//turns 'this'(the box name) into an array
var aArray:Array = new Array(this);
//turns aArray into a string
var sString:String = aArray.toString();
//pulls the index of the string (44th & 45th character)
var string:String = sString.charAt(44);
var string1:String = sString.charAt(45);
//incase of 2 digits
output = string + string1;
//fileName = _root.caseNav.XMLRoot.childNodes[3].childNodes[1].childNodes[output].childNodes[0].firstChild.nodeValue;
file = _root.caseNav.XMLRoot.childNodes[3].childNodes[1].childNodes[output].childNodes[1].firstChild.nodeValue;
//download file
fileRef.download("http://www.-------.com/test/" + file, file);
}
this[“downloadBtn”+i].onRollOver = function():Void{
//turns ‘this’(the box name) into an array
var aArray:Array = new Array(this);
//turns aArray into a string
var sString:String = aArray.toString();
//pulls the index of the string (44th & 45th character)
var string:String = sString.charAt(44);
var string1:String = sString.charAt(45);
//incase of 2 digits
outputColor = string + string1;
mc = _level0.caseLoader.fileRefLoader["filetxtBox"+outputColor];
txtColor = new Color(mc);
txtColor.setRGB(0xFFFF00);
}
this[“downloadBtn”+i].onRollOut = function():Void{
mc = _level0.caseLoader.fileRefLoader[“filetxtBox”+outputColor];
txtColor = new Color(mc);
txtColor.setRGB(0xcccccc);
}
this[“downloadBtn”+i].onDragOut = function():Void{
mc = _level0.caseLoader.fileRefLoader[“filetxtBox”+outputColor];
txtColor = new Color(mc);
txtColor.setRGB(0xcccccc);
}
}
}[/AS]