<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>戈壁滩上的狗尾巴花 &#187; URLRequest</title>
	<atom:link href="http://liguoliang.com/tag/urlrequest/feed/" rel="self" type="application/rss+xml" />
	<link>http://liguoliang.com</link>
	<description>戈壁滩上盛开的一坨狗尾巴花</description>
	<lastBuildDate>Fri, 10 Sep 2010 13:46:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Flex: 使用URLRequest下载文件时的权限验证</title>
		<link>http://liguoliang.com/2010/flex-%e4%bd%bf%e7%94%a8urlrequest%e4%b8%8b%e8%bd%bd%e6%96%87%e4%bb%b6%e6%97%b6%e7%9a%84%e6%9d%83%e9%99%90%e9%aa%8c%e8%af%81/</link>
		<comments>http://liguoliang.com/2010/flex-%e4%bd%bf%e7%94%a8urlrequest%e4%b8%8b%e8%bd%bd%e6%96%87%e4%bb%b6%e6%97%b6%e7%9a%84%e6%9d%83%e9%99%90%e9%aa%8c%e8%af%81/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 15:49:08 +0000</pubDate>
		<dc:creator>老李</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[FileReference]]></category>
		<category><![CDATA[URLRequest]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/01/1132/</guid>
		<description><![CDATA[<p>权限验证:</p>
var fileRef:FileReference = new FileReference();
		var request:URLRequest = new URLRequest(serviceUrl);

		request.method = URLRequestMethod.POS]]></description>
			<content:encoded><![CDATA[<p>权限验证:</p>
<pre class="java" name="code">var fileRef:FileReference = new FileReference();
		var request:URLRequest = new URLRequest(serviceUrl);

		request.method = URLRequestMethod.POST;
		var encoder : Base64Encoder = new Base64Encoder();
		encoder.encode(userName + &quot;:&quot; + password);
		request.requestHeaders.push(new URLRequestHeader(&quot;Authorization&quot;, &quot;Basic &quot; + encoder.toString())); // ** 增加认证信息

		fileRef.addEventListener(Event.OPEN, onFileDownloadBegin);
		fileRef.addEventListener(Event.COMPLETE, onFileDownloadComplete);
		fileRef.addEventListener(IOErrorEvent.IO_ERROR, onFileDownloadError);
		fileRef.addEventListener(Event.CANCEL, onFileDownLoadCancel);
		fileRef.download(request, getExportFileName(serviceUrl));</pre>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/flex-%e4%bd%bf%e7%94%a8urlrequest%e4%b8%8b%e8%bd%bd%e6%96%87%e4%bb%b6%e6%97%b6%e7%9a%84%e6%9d%83%e9%99%90%e9%aa%8c%e8%af%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex: 使用URLRequest进行下载, 并监听有关事件</title>
		<link>http://liguoliang.com/2010/flex-%e4%bd%bf%e7%94%a8urlrequest%e8%bf%9b%e8%a1%8c%e4%b8%8b%e8%bd%bd-%e5%b9%b6%e7%9b%91%e5%90%ac%e6%9c%89%e5%85%b3%e4%ba%8b%e4%bb%b6/</link>
		<comments>http://liguoliang.com/2010/flex-%e4%bd%bf%e7%94%a8urlrequest%e8%bf%9b%e8%a1%8c%e4%b8%8b%e8%bd%bd-%e5%b9%b6%e7%9b%91%e5%90%ac%e6%9c%89%e5%85%b3%e4%ba%8b%e4%bb%b6/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 15:46:47 +0000</pubDate>
		<dc:creator>老李</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[DownLoad]]></category>
		<category><![CDATA[URLRequest]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/01/1131/</guid>
		<description><![CDATA[<p>使用URLRequest下载文件. &#8211; 无权限认证
</p>

// 下载文件
	protected function downloadTemplateFile():void {
		var fileRef:FileReference = new FileReference();
		var u]]></description>
			<content:encoded><![CDATA[<p>使用URLRequest下载文件. &#8211; 无权限认证
</p>
<pre class="java" name="code">
// 下载文件
	protected function downloadTemplateFile():void {
		var fileRef:FileReference = new FileReference();
		var urlReq:URLRequest = new URLRequest(_pathTemplateFile);
		fileRef.addEventListener(Event.OPEN,onDownloadBegin);
		fileRef.addEventListener(Event.COMPLETE, onDownloadComplete);
		fileRef.addEventListener(Event.CANCEL, onDownloadCancel);
		fileRef.addEventListener(IOErrorEvent.IO_ERROR, onDownloadError);
		fileRef.download(urlReq);
	}

	// 模板文件下载开始时响应.
	protected function onDownloadBegin(e:Event):void {
		appendTextToOutPut(RM.getString(BUNDLE_ASMT_MGT, &quot;template.download.begin&quot;));
	}

	// 当下载结束后响应. */
	protected function onDownloadComplete(e:Event):void {
		var file:FileReference = e.target as FileReference;
		appendTextToOutPut(RM.getString(BUNDLE_ASMT_MGT, &quot;template.download.success&quot;, [file.name, FileUtils.formatFileSize(file.size)]));
		log.info(&quot;模板文件下载结束: &quot; + file.name + &quot;-&quot; + file.size);
	}

	// 当下载取消时响应. */
	protected function onDownloadCancel(e:Event):void {
		appendTextToOutPut(RM.getString(BUNDLE_ASMT_MGT, &quot;controller.download.canceled&quot;));
	}

	// 当下载出现错误时响应. */
	protected function onDownloadError(e:IOError):void {
		appendTextToOutPut(RM.getString(BUNDLE_ASMT_MGT, &quot;template.download.error&quot;, [e.message]));
		log.error(&quot;下载出错&quot; + e.message);
	}</pre>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/flex-%e4%bd%bf%e7%94%a8urlrequest%e8%bf%9b%e8%a1%8c%e4%b8%8b%e8%bd%bd-%e5%b9%b6%e7%9b%91%e5%90%ac%e6%9c%89%e5%85%b3%e4%ba%8b%e4%bb%b6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
