高傲的活着 发表于 2011-12-22 08:54

Flex4实现搜索功能

<DIV><FONT color=#f00000>这是调用webapis后实现的一个搜索功能,还不错。必须在项目中加一个web API类库。</FONT></DIV>
<DIV><FONT color=#0000f0>下载地址</FONT></DIV>
<DIV><a href="http://code.google.com/p/as3corelib/downloads/list?can=1&amp;q=" target="_blank">http://code.google.com/p/as3corelib/downloads/list?can=1&amp;q=</A></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=#f000f0>源码</FONT></DIV>
<DIV>
<DIV id=codeText class=codeText>
<OL style="PADDING-BOTTOM: 5px; MARGIN: 0px 1px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 5px" class=dp-css>
<LI><SPAN style="COLOR: #000000"><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">?</SPAN>xml <SPAN style="COLOR: #ff0000">version</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"1.0"</SPAN> <SPAN style="COLOR: #ff0000">encoding</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"utf-8"</SPAN><SPAN style="COLOR: #0000cc">?</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000ff">s</SPAN><SPAN style="COLOR: #0000cc">:</SPAN>WindowedApplication xmlns<SPAN style="COLOR: #0000cc">:</SPAN>fx<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"http://ns.adobe.com/mxml/2009"</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlns<SPAN style="COLOR: #0000cc">:</SPAN><SPAN style="COLOR: #0000ff">s</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"library://ns.adobe.com/flex/spark"</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlns<SPAN style="COLOR: #0000cc">:</SPAN>mx<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"library://ns.adobe.com/flex/mx"</SPAN> viewSourceURL<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"srcview/index.html"</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN>fx<SPAN style="COLOR: #0000cc">:</SPAN>Declarations<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">&lt;!-- 将非可视元素(例如服务、值对象)放在此处 --&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>fx<SPAN style="COLOR: #0000cc">:</SPAN>Declarations<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">&lt;</SPAN>fx<SPAN style="COLOR: #0000cc">:</SPAN><SPAN style="COLOR: #0000ff">Script</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">!</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>CDATA<SPAN style="COLOR: #0000cc">[</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #ff0000">import</SPAN> com<SPAN style="COLOR: #0000cc">.</SPAN>adobe<SPAN style="COLOR: #0000cc">.</SPAN>webapis<SPAN style="COLOR: #0000cc">.</SPAN>events<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #ff0000">import</SPAN> com<SPAN style="COLOR: #0000cc">.</SPAN>adobe<SPAN style="COLOR: #0000cc">.</SPAN>webapis<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #ff0000">import</SPAN> com<SPAN style="COLOR: #0000cc">.</SPAN>adobe<SPAN style="COLOR: #0000cc">.</SPAN>serialization<SPAN style="COLOR: #0000cc">.</SPAN>json<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #ff0000">import</SPAN> mx<SPAN style="COLOR: #0000cc">.</SPAN>controls<SPAN style="COLOR: #0000cc">.</SPAN>Alert<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #ff0000">import</SPAN> mx<SPAN style="COLOR: #0000cc">.</SPAN>rpc<SPAN style="COLOR: #0000cc">.</SPAN>events<SPAN style="COLOR: #0000cc">.</SPAN>ResultEvent<SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #ff0000">import</SPAN> mx<SPAN style="COLOR: #0000cc">.</SPAN>rpc<SPAN style="COLOR: #0000cc">.</SPAN>http<SPAN style="COLOR: #0000cc">.</SPAN>HTTPService<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">[</SPAN>Bindable<SPAN style="COLOR: #0000cc">]</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private <SPAN style="COLOR: #0000ff">var</SPAN> dgResults<SPAN style="COLOR: #0000cc">:</SPAN>Array<SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN> source <SPAN style="COLOR: #ff0000">for</SPAN> datagrid<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private function search<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">:</SPAN>void <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">var</SPAN> service<SPAN style="COLOR: #0000cc">:</SPAN>HTTPService <SPAN style="COLOR: #0000cc">=</SPAN> new HTTPService<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service<SPAN style="COLOR: #0000cc">.</SPAN>url <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">'http://ajax.googleapis.com/ajax/services/search/web'</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service<SPAN style="COLOR: #0000cc">.</SPAN>request<SPAN style="COLOR: #0000cc">.</SPAN>v <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">'1.0'</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service<SPAN style="COLOR: #0000cc">.</SPAN>request<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">q</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> searchStr<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">text</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service<SPAN style="COLOR: #0000cc">.</SPAN>resultFormat <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">'text'</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service<SPAN style="COLOR: #0000cc">.</SPAN>addEventListener<SPAN style="COLOR: #0000cc">(</SPAN>ResultEvent<SPAN style="COLOR: #0000cc">.</SPAN>RESULT<SPAN style="COLOR: #0000cc">,</SPAN> onServerResponse<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service<SPAN style="COLOR: #0000cc">.</SPAN>send<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private function onServerResponse<SPAN style="COLOR: #0000cc">(</SPAN>event<SPAN style="COLOR: #0000cc">:</SPAN>ResultEvent<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">:</SPAN>void <SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try <SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">var</SPAN> json<SPAN style="COLOR: #0000cc">:</SPAN><SPAN style="COLOR: #0000ff">Object</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> JSON<SPAN style="COLOR: #0000cc">.</SPAN>decode<SPAN style="COLOR: #0000cc">(</SPAN>event<SPAN style="COLOR: #0000cc">.</SPAN>result as String<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if <SPAN style="COLOR: #0000cc">(</SPAN>json<SPAN style="COLOR: #0000cc">.</SPAN>responseData<SPAN style="COLOR: #0000cc">.</SPAN>results is Array<SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dg<SPAN style="COLOR: #0000cc">.</SPAN>dataProvider <SPAN style="COLOR: #0000cc">=</SPAN> json<SPAN style="COLOR: #0000cc">.</SPAN>responseData<SPAN style="COLOR: #0000cc">.</SPAN>results<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">}</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch <SPAN style="COLOR: #0000cc">(</SPAN>error<SPAN style="COLOR: #0000cc">:</SPAN>Error<SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Alert<SPAN style="COLOR: #0000cc">.</SPAN>show<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"Error on search: "</SPAN> <SPAN style="COLOR: #0000cc">+</SPAN> error<SPAN style="COLOR: #0000cc">.</SPAN>message<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private function goToURL<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">:</SPAN>void<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; navigateToURL<SPAN style="COLOR: #0000cc">(</SPAN>new URLRequest<SPAN style="COLOR: #0000cc">(</SPAN>dg<SPAN style="COLOR: #0000cc">.</SPAN>selectedItem<SPAN style="COLOR: #0000cc">.</SPAN>url<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>fx<SPAN style="COLOR: #0000cc">:</SPAN><SPAN style="COLOR: #0000ff">Script</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN>mx<SPAN style="COLOR: #0000cc">:</SPAN>HBox<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN>mx<SPAN style="COLOR: #0000cc">:</SPAN><SPAN style="COLOR: #ff0000">Text</SPAN> <SPAN style="COLOR: #ff0000">text</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"Search Google:"</SPAN> <SPAN style="COLOR: #ff0000">color</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"#FFFFFF"</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN>mx<SPAN style="COLOR: #0000cc">:</SPAN>TextInput <SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"searchStr"</SPAN> enter<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"search()"</SPAN> <SPAN style="COLOR: #ff0000">width</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"200"</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN>mx<SPAN style="COLOR: #0000cc">:</SPAN><SPAN style="COLOR: #0000ff">Button</SPAN> <SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"btnSearch"</SPAN> click<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"search()"</SPAN> <SPAN style="COLOR: #0000ff">label</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"搜索"</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>mx<SPAN style="COLOR: #0000cc">:</SPAN>HBox<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN>mx<SPAN style="COLOR: #0000cc">:</SPAN>DataGrid <SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"dg"</SPAN> dataProvider<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"{dgResults}"</SPAN> <SPAN style="COLOR: #ff0000">width</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"90%"</SPAN> <SPAN style="COLOR: #ff0000">height</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"113"</SPAN> minColumnWidth<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"200"</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; variableRowHeight<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"false"</SPAN> doubleClickEnabled<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"true"</SPAN> doubleClick<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"goToURL()"</SPAN> x<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"16"</SPAN> y<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"22"</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN>mx<SPAN style="COLOR: #0000cc">:</SPAN>columns<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN>mx<SPAN style="COLOR: #0000cc">:</SPAN>DataGridColumn dataField<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"url"</SPAN> headerText<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"URL"</SPAN> <SPAN style="COLOR: #ff0000">width</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"200"</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN>mx<SPAN style="COLOR: #0000cc">:</SPAN>DataGridColumn dataField<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"titleNoFormatting"</SPAN> headerText<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"Title"</SPAN> wordWrap<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"true"</SPAN> <SPAN style="COLOR: #ff0000">width</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"300"</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>mx<SPAN style="COLOR: #0000cc">:</SPAN>columns<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>mx<SPAN style="COLOR: #0000cc">:</SPAN>DataGrid<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000ff">s</SPAN><SPAN style="COLOR: #0000cc">:</SPAN>WindowedApplication<SPAN style="COLOR: #0000cc">&gt;</SPAN></SPAN></LI></OL></DIV></DIV>
<DIV><FONT color=#f000f0>这是一个air程序,效果如图:</FONT></DIV>
<DIV><a href="http://blog.chinaunix.nethttp://blog.chinaunix.net/attachment/201107/1/25434387_1309487526bn6h.jpg" target="_blank"><IMG border=0 src="http://blog.chinaunix.nethttp://blog.chinaunix.net/attachment/201107/1/25434387_1309487526bn6h.jpg" .load="imgResize(this, 650);" ;></A></DIV>
页: [1]
查看完整版本: Flex4实现搜索功能