<?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>DFdou&#039;s Blog &#187; Remote Proxy</title>
	<atom:link href="http://nwhy.org/tag/remote-proxy/feed" rel="self" type="application/rss+xml" />
	<link>http://nwhy.org</link>
	<description>Life is short,Be yourself.</description>
	<lastBuildDate>Wed, 08 Sep 2010 05:34:51 +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>AAS3WDP-Chapter 6 Remote Proxy 远程代理</title>
		<link>http://nwhy.org/aas3wdp-chapter-6-remote-proxy.html</link>
		<comments>http://nwhy.org/aas3wdp-chapter-6-remote-proxy.html#comments</comments>
		<pubDate>Fri, 15 May 2009 02:10:09 +0000</pubDate>
		<dc:creator>DFdou</dc:creator>
				<category><![CDATA[AIR+FB+AS3]]></category>
		<category><![CDATA[AAS3WDP]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Remote Proxy]]></category>

		<guid isPermaLink="false">http://nwhy.org/?p=4291</guid>
		<description><![CDATA[这里是一个Flickr的远程图片搜索代理实例，对了，Flickr的远程图片搜索需要申请API，别忘了去申请一个。 代码部分，类PhotoSearchProxy.as： [js] package{ import flash.events.DataEvent; import flash.events.Event; im... ]]></description>
			<content:encoded><![CDATA[<p>这里是一个Flickr的远程图片搜索代理实例，对了，Flickr的远程图片搜索需要申请API，别忘了去申请一个。<br />
代码部分，类PhotoSearchProxy.as：<br />
[js]<br />
package{<br />
	import flash.events.DataEvent;<br />
	import flash.events.Event;<br />
	import flash.events.EventDispatcher;<br />
	import flash.net.URLLoader;<br />
	import flash.net.URLRequest;</p>
<p>	public class PhotoSearchProxy extends EventDispatcher{<br />
		private static const API_KEY:String="c4643072bfc38caa0257f4c039624cb5";//这是我的Flickr Api_key<br />
		private static const FLICKR_URL:String="http://api.flickr.com/services/rest/";//Flickr的api地址</p>
<p>		public function PhotoSearchProxy(){}<br />
		private function onComplete(_evt:Event):void{<br />
			dispatchEvent(new DataEvent(Event.COMPLETE,false,false,XML(_evt.target.data)));<br />
		}<br />
		public function search(userId:String,tags:String):void{<br />
			var loader:URLLoader=new URLLoader();<br />
			var request:URLRequest=new URLRequest(PhotoSearchProxy.FLICKR_URL+"?method=flickr.photos.search&#038;user_id="+userId+"&#038;tags="+tags+"&#038;api_key="+PhotoSearchProxy.API_KEY);<br />
			loader.addEventListener(Event.COMPLETE,onComplete);<br />
			loader.load(request);<br />
		}<br />
	}<br />
}<br />
[/js]<br />
在loader载入request之后dispatchEvent一个DataEvent。<br />
具体调用部分：<br />
[js]<br />
import PhotoSearchProxy;<br />
var flickr:PhotoSearchProxy=new PhotoSearchProxy();<br />
flickr.addEventListener(Event.COMPLETE,onComplete);<br />
flickr.search("","yellow");<br />
function onComplete(_evt:DataEvent){<br />
	trace(_evt.data);<br />
}<br />
[/js]<br />
实际化PhotoSearchProxy之后，调用search方法，load完之后接收dispatchEvent的DataEvent的data并trace。<br />
记得以前看过的一个AIR的RSS阅读器也是这样做的，写了个EventDispatcher的子类，载入RSS源地址后dispatchEvent。。。</p>
<h4  class="related_post_title">Some Related Posts</h4><ul class="related_post"><li>2009/05/28 -- <a  href="http://nwhy.org/aas3wdp-chapter-8-composite-2.html" title="AAS3WDP-Chapter 8 Composite 组合模式(下)">AAS3WDP-Chapter 8 Composite 组合模式(下)</a> (0)</li><li>2009/05/27 -- <a  href="http://nwhy.org/aas3wdp-chapter-8-composite-1.html" title="AAS3WDP-Chapter 8 Composite 组合模式(上)">AAS3WDP-Chapter 8 Composite 组合模式(上)</a> (0)</li><li>2009/05/19 -- <a  href="http://nwhy.org/aas3wdp-chapter-7-iterator.html" title="AAS3WDP-Chapter 7 Iterator 迭代模式">AAS3WDP-Chapter 7 Iterator 迭代模式</a> (0)</li><li>2009/05/14 -- <a  href="http://nwhy.org/aas3wdp-virtual-proxy.html" title="AAS3WDP-Chapter 6 Virtual Proxy 虚拟代理模式">AAS3WDP-Chapter 6 Virtual Proxy 虚拟代理模式</a> (0)</li><li>2009/05/13 -- <a  href="http://nwhy.org/aas3wdp-chapter-5-factory-%e5%b7%a5%e5%8e%82%e6%a8%a1%e5%bc%8f.html" title="AAS3WDP-Chapter 5 Factory 工厂模式">AAS3WDP-Chapter 5 Factory 工厂模式</a> (0)</li><li>2009/06/24 -- <a  href="http://nwhy.org/flash-ship-on-android-phone.html" title="Flash-Adobe&#8217;s Flash to ship on new Android phone">Flash-Adobe&#8217;s Flash to ship on new Android phone</a> (0)</li><li>2009/06/18 -- <a  href="http://nwhy.org/flash-swfinputs-solving-mozilla-transparent-mode.html" title="Flash-Transparent时在FF和Safari下无法输入中文的解决方案">Flash-Transparent时在FF和Safari下无法输入中文的解决方案</a> (0)</li><li>2009/05/22 -- <a  href="http://nwhy.org/about-flash.html" title="About Flash">About Flash</a> (1)</li><li>2009/05/12 -- <a  href="http://nwhy.org/google-maps-api-for-flash-demo.html" title="Google Maps API for Flash Demo">Google Maps API for Flash Demo</a> (14)</li><li>2009/02/23 -- <a  href="http://nwhy.org/flash-load.html" title="Flash-AS2和AS3的加载">Flash-AS2和AS3的加载</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://nwhy.org/aas3wdp-chapter-6-remote-proxy.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
