Mega Code Archive

 
Categories / Flex / Data Model
 

Change Service DataProvider

<!-- Code from Flex 4 Documentation "Using Adobe Flex 4". This user guide is licensed for use under the terms of the Creative Commons Attribution  Non-Commercial 3.0 License.  This License allows users to copy, distribute, and transmit the user guide for noncommercial  purposes only so long as    (1) proper attribution to Adobe is given as the owner of the user guide; and    (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms.  The best way to provide notice is to include the following link.  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ -->     <!-- charts/ChangeSrvDataProvider.mxml --> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"     xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"     creationComplete="srv.send()" height="600">     <fx:Declarations>         <!--             View source of the following page to see the structure of the data             that Flex uses in this example.         -->         <mx:HTTPService id="srv"             url="http://aspexamples.adobe.com/chart_examples/stocks-xml.aspx" />         <!--             To see data in an HTML table, go to             http://aspexamples.adobe.com/chart_examples/stocks.aspx         -->     </fx:Declarations>     <fx:Script>          public function changeDataProvider(event:Event):void {              srv.url = "http://aspexamples.adobe.com/chart_examples/stocks-xml.aspx" +"?" + "tickerSymbol=" + event.currentTarget.selectedItem;              srv.send();          }        </fx:Script>     <s:layout>         <s:VerticalLayout />     </s:layout>     <s:Panel title="Column Chart">         <s:layout>             <s:VerticalLayout />         </s:layout>         <mx:ColumnChart id="myChart" dataProvider="{srv.lastResult.data.result}"             showDataTips="true">             <mx:horizontalAxis>                 <mx:DateTimeAxis dataUnits="days" />             </mx:horizontalAxis>             <mx:series>                 <mx:ColumnSeries yField="close" xField="date"                     displayName="Closing Price of {cb1.selectedItem}" />             </mx:series>         </mx:ColumnChart>         <mx:Legend dataProvider="{myChart}" />     </s:Panel>     <s:ComboBox id="cb1" change="changeDataProvider(event)">         <s:ArrayCollection>             <fx:String>FRED</fx:String>             <fx:String>STRK</fx:String>             <fx:String>FE</fx:String>         </s:ArrayCollection>     </s:ComboBox> </s:Application>