# Using download class

**URL:** <https://forum.kirupa.com/t/using-download-class/301601>\
**Category:** Uncategorized\
**Created:** [December 11, 2009, 10:28pm UTC](https://forum.kirupa.com/t/using-download-class/301601 "2009-12-11T22:28:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maruf89](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@maruf89](https://forum.kirupa.com/u/maruf89)\
**Post date:** [December 11, 2009, 10:28pm UTC](https://forum.kirupa.com/t/using-download-class/301601/1 "2009-12-11T22:28:57Z")

</div>

So i can’t find a single tutorial that shows you how to add a download link to ur fla file. I got this snippet from the adobe file reference :

```auto
package com.mysite.Download {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.FileReference;
    import flash.net.URLRequest;
    import flash.net.FileFilter;
	
    public class FileReference_download extends Sprite {
		
        private var downloadURL:URLRequest;
        private var fileName:String = "Resume.pdf";
        private var file:FileReference;
        public function FileReference_download() {
            downloadURL = new URLRequest();
            downloadURL.url = "../resume/.pdf";
            file = new FileReference();
            configureListeners(file);
            file.download(downloadURL, fileName);
        }
        private function configureListeners(dispatcher:IEventDispatcher):void {
            dispatcher.addEventListener(Event.CANCEL, cancelHandler);
            dispatcher.addEventListener(Event.COMPLETE, completeHandler);
            dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            dispatcher.addEventListener(Event.OPEN, openHandler);
            dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            dispatcher.addEventListener(Event.SELECT, selectHandler);
        }
        private function cancelHandler(event:Event):void {
            trace("cancelHandler: " + event);
        }
        private function completeHandler(event:Event):void {
            trace("completeHandler: " + event);
        }
        private function ioErrorHandler(event:IOErrorEvent):void {
            trace("ioErrorHandler: " + event);
        }
        private function openHandler(event:Event):void {
            trace("openHandler: " + event);
        }
        private function progressHandler(event:ProgressEvent):void {
            var file:FileReference = FileReference(event.target);
            trace("progressHandler name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
        }
        private function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
        }
        private function selectHandler(event:Event):void {
            var file:FileReference = FileReference(event.target);
            trace("selectHandler: name=" + file.name + " URL=" + downloadURL.url);
        }
    }
}

```

and i updated it to where it is in my class files, and updated the download link. other than importing it into my file via import com.mysite.Download.Download I’m not sure how to go about linking this 1 file to a download button. I’m not exactly sure how to label the variable for it either
