| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" title="HTTPService"> |
| <fx:Script> |
| <![CDATA[ |
| import mx.collections.XMLListCollection; |
| import mx.rpc.events.ResultEvent; |
| |
| import spark.skins.mobile.TextAreaSkin; |
| |
| protected function loadRSS():void |
| { |
| if(textInput.text != ""){ |
| rssService.url = textInput.text; |
| rssService.send(); |
| } |
| } |
| |
| protected function rssResult(event:ResultEvent):void |
| { |
| itemsList.dataProvider = new XMLListCollection(new XMLList(event.result.channel.item)); |
| } |
| |
| protected function buttonHandler(event:MouseEvent):void |
| { |
| if(currentState == "DemoState"){ |
| currentState = "InfoState"; |
| }else if(currentState == "InfoState"){ |
| currentState = "DemoState"; |
| } |
| } |
| |
| ]]> |
| </fx:Script> |
| |
| <s:states> |
| <s:State name="DemoState"/> |
| <s:State name="InfoState"/> |
| </s:states> |
| |
| <fx:Declarations> |
| <s:MultiDPIBitmapSource id="aboutIcon" |
| source160dpi="@Embed('assets/icons/160/about.png')" |
| source240dpi="@Embed('assets/icons/240/about.png')" |
| source320dpi="@Embed('assets/icons/320/about.png')" |
| source480dpi="assets/icons/480/about.png"/> |
| <s:MultiDPIBitmapSource id="demoIcon" |
| source160dpi="@Embed('assets/icons/160/dock.png')" |
| source240dpi="@Embed('assets/icons/240/dock.png')" |
| source320dpi="@Embed('assets/icons/320/dock.png')" |
| source480dpi="assets/icons/480/dock.png"/> |
| <s:HTTPService id="rssService" resultFormat="e4x" result="rssResult(event)"/> |
| </fx:Declarations> |
| |
| <s:TextInput id="textInput" text="https://blogs.apache.org/flex/feed/entries/rss" prompt="Type any RSS 2.0 valid URL" skinClass="spark.skins.mobile.TextInputSkin" includeIn="DemoState" enter="loadRSS()" y="10" left="5" right="70" height="40"/> |
| <s:Button label="Load" y="10" includeIn="DemoState" width="60" height="40" right="5" click="loadRSS()"/> |
| |
| <s:List id="itemsList" labelField="title" includeIn="DemoState" width="100%" bottom="0" top="60"/> |
| |
| <s:TextArea includeIn="InfoState" skinClass="spark.skins.mobile.TextAreaSkin" left="10" right="10" top="10" bottom="10" editable="false" text="You use the HTTPService tag to represent an HTTPService object in an MXML file. When you call the HTTPService object's send() method, it makes an HTTP request to the specified URL, and an HTTP response is returned. Optionally, you can pass parameters to the specified URL. When you do not go through the server-based proxy service, you can use only HTTP GET or POST methods. However, when you set the useProxy property to true and you use the server-based proxy service, you can also use the HTTP HEAD, OPTIONS, TRACE, and DELETE methods. |
| 
 
Note: Due to a software limitation, HTTPService does not generate user-friendly error messages when using GET."/> |
| |
| <s:actionContent> |
| <s:Button click="buttonHandler(event)" icon.DemoState="{aboutIcon}" icon.InfoState="{demoIcon}"/> |
| </s:actionContent> |
| </s:View> |