Mar 192007
Downloader.as code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | /* * This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License. * http://creativecommons.org/licenses/by-nc-sa/3.0/ */ package hangunsworld.util{ import flash.net.FileReference; import flash.net.URLRequest; import flash.display.DisplayObject; /* * Downloader * Downloader class allows you to download a file easily. * * @author: Han Sanghun (http://hangunsworld.com/blog) * @last modified: 2007-03-23 * @language version: ActionScript 3.0 */ public class Downloader{ private var file:FileReference; private var req:URLRequest; /* * Downloader Constructor */ public function Downloader(){ file = new FileReference(); req = new URLRequest(); } /* * downloadSWF * Download an SWF file that contains the provided DisplayObject. * @param obj A DisplayObject to download. */ public function downloadSWF(obj:DisplayObject):void{ req.url = obj.loaderInfo.url; file.download(req); } /* * downloadURL * Download a specific file. * @param url An URL of a file to be downloaded. */ public function downloadURL(url:String):void{ req.url = url; file.download(req); } } } |
1 2 3 4 5 | import hangunsworld.util.Downloader; var dw:Downloader = new Downloader(); dw.downloadURL("http://somedomain.com/somefile.as"); dw.downloadSWF(this); |
One Response to “[AS3] Downloader class”
Sorry, the comment form is closed at this time.
Downloader class was modified….
Downloader 클래스의 패키지를 com.hangunsworld.util 에서 com.hangunsworld.net 으로 변경하였습니다. 아무래도 util 보다는 net 패키지에 있는 것이 더 적당한 것 같아서요.
그리고 addEventListener, removeEventListe…