Filereference download extension

Hi there,
i’ve got a pic gallery from kirupa which i modified a bit.
I’ve added a download button with filereference. The thing is everthing works when the download button is pressed.
But if somebody wants to download a picture and wants to change the name the file isn’t recognised because the extension is lost.
Flash doesnt read after the dot (example .jpg). If you dont change the name of the file which you save it keeps its extension.
here’s my code for the download and the link

var fileRef:FileReference = new FileReference();
var listener:Object = new Object();   
listener.onCancel = function(file:FileReference):Void {
   trace(file.removeListener(this)); // GEANNULEERD
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
    downloaded = Math.round(bytesLoaded  / bytesTotal *100)+"%";
    if (bytesLoaded == bytesTotal){
        downloaded_mc._visible = true;;
        downloaded = "";

function downloadPICT(){[p]);

ive tried to put it like this but it doesnt work

function downloadPICT(){[p]+".jpg");

PS download[p] is read from an XML file its the link to the downloadfile, which looks like this

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images titel="DJ CHUCKIE" omschrijving="HEINEKEN FULL MOON PARTY" datum="VRIJDAG 5 JANUARI">