pashminakazi commented on issue #867:
URL: https://github.com/apache/royale-asjs/issues/867#issuecomment-648031009
@aharui
**I have replaced**
**<mx:LinkButton styleName="htmlLink" label="{data.at_Name}" toolTip="Save
File"
click="btnDownload_clickHandler(data.at_Name,data.at_Bytes,data.at_Status)"/>**
```
private function
btnDownload_clickHandler(name:String,file:mx.utils.ByteArray,status:String):void
{
if(status!= "0") {
frd = new mx.net.FileReference();
frd.addEventListener(org.apache.royale.events.Event.OPEN,
openHandler);
frd.save(file,name);
}
else
Alert.show("File has been Removed.");
}
```
**With**
```
<mx:DownloadButton styleName="htmlLink" id="downloadButton"
label="{data.at_Name}"
toolTip="Save File"
click="btnDownload_clickHandler(data.at_Name,data.at_Bytes,data.at_Status)"/>
```
```
private function
btnDownload_clickHandler(name:String,file:mx.utils.ByteArray,status:String):void
{
if(status!= "0") {
downloadButton.defaultFileName = name;
downloadButton.data = menuDataXMLList.toString()
}
else
Alert.show("File has been Removed.");
}
```
```
<fx:Declarations>
<fx:XMLList id="menuDataXMLList">
<menuitem label="label-1">
<menuitem label="label-1-1"/>
<menuitem label="label-1-2"/>
</menuitem>
<menuitem label="Switch Locale" id="admin" >
<menuitem label="label-2-1"/>
<menuitem label="label-2-2"/>
<menuitem label="label-2-3" id="admin" />
</menuitem>
</fx:XMLList>
</fx:Declarations>
```
if i remove **downloadButton.data = menuDataXMLList.toString()** then file
Name is shown
if i added **downloadButton.data = menuDataXMLList.toString()** file Name
doesn't visible,in both situation file download doesn't work.
As discussed in (https://github.com/apache/royale-asjs/issues/838) I have
added
```
COMPILE::JS {
var saveData = (function () {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
return function (data, fileName) {
var json = JSON.stringify(data),
blob = new Blob([json], {type: "octet/stream"}),
url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
};
}());
var data = { x: 42, s: "hello, world", d: new Date() },
fileName = name;
saveData(data, fileName);
}
```
But after this there's a compilation Error
Implicit type coercion of blob from Object to etc
Access of possibly undefined URL with reference window
So i commented this part.
I am trying to fix this issue from last 2 to 3 days with multiple
changes,nothing works for me,
I you have time then please write a correct code for me,or instruct me to
write code
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]