域卡的卜 Vicker’s Blog

Hong Kong Adobe Flash platform (Flex, Flash and AIR) developer
  • rss
  • Home
  • About
  • Resume
  • Flickr
  • Contact

Flex FAQ #3: 點樣用 Flex FileReference 下載檔案

Vicker | August 17, 2007 | 1:05 am

本來呢個問題應該好簡單~
基本上一個 ActionScript developer 可以即時答得出


var t_file_ref:FileReference = new FileReference ();
var t_url_request:URLRequest = new URLRequest ("some_path/some_file.type");
t_file_ref.download (t_url_request);

但係原來o係某 d 情況佢係會 malfunction 既…
而且係你估都估唔到~ 加上玩足你幾個鐘…

為免大家中招所以寫左呢個 example

睇落好似無分別~就算 click “這個不能下載” 都出現左下載畫面但係當你以為 download 左既時候…
你會發覺乜都見唔到…其實問題係在於 FileReference o既 instance declaration method如果o係 function
裡面 declare 既 temporary variable當 function 完成之後 FileReference instance 就會o係 select event 之前消失結果… download 左個桔…
解決方法係將 FileReference instance 放o係 class member variable


public class some_class
{
	private var _file_ref:FileReference;
	function some_function ()
	{
		this._file_ref = new FileReference ();
		...
	}
}

其實呢個問題… 都幾荒謬… 不過可以玩謝好多 developer…Adobe o既 Technote 有詳細解釋~
http://kb.adobe.com/selfservice/viewContent.do?externalId=3637d5c3&sliceId=1English title: How to download a file in Flex using FileReference

Related posts

  • Essential ActionScript 3.0 and ActionScript 3.0 Design Patterns (0)
  • PURE ACTIONSCRIPT vs FLEX vs LASZLO (0)
  • Google 同 Yahoo! improve Flash indexing (0)
Categories
Flex
Tags
ActionScript, Adobe, download, filereference, Flash, Flex, Flex FAQ, javascript, urlrequest
Comments rss
Comments rss
Trackback
Trackback

« Flex FAQ #2: 點樣清除亂左既 subclipse .svn 資料 點先算係一份好既 FYP? »

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Meta

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Certification


Adobe MAX 2008

Categories

Archives

Tag Cloud

stylesheet braille flash video encoder validation OO XHTML Cyber Formula WYSIWYG business APICTA Flash flysforum MOV hyperlink FYP depth manager Molyx color selector algorithm family Apple frame design pattern suck UI good dog u Lego hea John Koch textfield HTML form assembly meta W3C SEO PS2 Andy Chun Yahoo the core Misaki Ito VideoDisplay web page include textformat Gary Wong webxact Flex component Adobe Macromedia CityU music AdvancedDataGrid CSS Flex Builder Chris Liang WarCraft Google protoype PHP accessibility XML bobby sitemap OSS Flex FAQ HKICTA prototype Battlenet Tim Shiu exhibition color Densha Otoko ActionScript FLABER flysbookmark WMV gundam Mac MovieClip WCAG presentation Web Usability Experts Exchange freelance job hunting Eva Shi ACSS Adobe MAX flv JAWS blog AIR birthday bt Munsang College Hacken Lee Laszlo YouTube form

Flickr

flyunited.jpg 0511_web_usability_asg_a.jpg wanshan.jpg diarybox1.jpg tcmd2.jpg DSCN4338 DSCN4289 0509_battle_system_1_5.jpg munsang1.jpg 469790470_55a3908526_b iad2.jpg DSCN4411 07082007084.jpg DSCN7195 DSCF0016 guesthouse1.jpg 0607_flaber_1_1.png 11092007101.jpg

Blogroll

  • Eva’s Blog
  • Way’s Blog

RSS FxAIR.org

  • ActionScript for Random Numberic Text Lucky Draw
  • Post in cookbook to win a copy of Flex 3 Pro
  • Adobe Flash Player 10 Release is out
  • Adobe CS4 Launch Seminar
  • Flex 3 + external swf with embedded video
  • Flex & AIR @ BarCamp Hong Kong on 6 Sep.
  • Mojave Experiment by Microsoft
  • FotoViewr beta
  • RIAJobs
  • Cairngorm on opensource.adobe.com
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox