views:

5

answers:

0

I am trying to allow download of a particular file that the user has generated (or will generate). If they try to download the file AFTER generating, the fileReference does not seem to create the new object (it downloads the old file).

Code is something like this:

private function downloadFile():void
{
    var node:XML = XML(myTree.selectedItem);

    FILE_URL = {something based on node}; // works fine (don't remember code)

    fileRef = new FileReference();
    urlRequest = new URLRequest(FILE_URL);
    fileRef.download(urlRequest);
}

which is called from this xml object:

<mx:Tree id="myTree" doubleClick="{downloadFile()}">
...
</mx:Tree>

So when the user tries to download the already existing file, it works fine (they get the file that existed before they view the webpage). If they generate the file and then try to download from the tree, they get the OLD file. (They must restart webpage to get the new file). I'm a bit confused as I have the line "fileRef = new FileReference" when they double-click on an item.

Any thoughts on this?