Hi,

You must call one function which will update data for different
datagrids. Now you are calling only one function on init(). that will
load data but will store only in one arraycollection.

If you are calling on init(), you should create different
arraycollections for different datagrids. If you want to just change
this code. I did that. I am calling one function on change event of
tabnavigator which will update data on each tab change and update the
datas arraycollection.

modified code is:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute"
        creationComplete="init()"
        borderColor="#020000" backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#BA2A2A, #020000]" width="950"
height="557">
<mx:Script>
     <![CDATA[
         import mx.rpc.events.ResultEvent;
         import mx.collections.ArrayCollection;
         [Bindable]
         public var datas:ArrayCollection;
        public function init():void
         {

         }
         private function changeData():void
         {
          if(tabNav.selectedIndex == 1)
             {
             RSSFeedtech.send();
             }
          if(tabNav.selectedIndex == 2)
             {
             RSSFeedtop.send();
             }
        if(tabNav.selectedIndex == 3)
             {
              RSSFeedworld.send();
             }
        if(tabNav.selectedIndex == 4)
             {
             RSSFeedterror.send();
             }
        if(tabNav.selectedIndex == 5)
             {
             RSSFeedsci.send();
             }
          }
        public function resultHandler(event:ResultEvent):void
         {
             datas = event.result.rss.channel.item;
         }
    ]]>
</mx:Script>
   <mx:HTTPService id="RSSFeedtech" url="http://rss.news.yahoo.com/rss/
tech"
                                        resultFormat="object" result= 
"resultHandler(event)"  />
   <mx:HTTPService id="RSSFeedtop" url="http://rss.news.yahoo.com/rss/
topstories"
                                        resultFormat="object" result= 
"resultHandler(event)"/>
   <mx:HTTPService id="RSSFeedworld" url="http://rss.news.yahoo.com/
rss/world"
                                        resultFormat="object" result= 
"resultHandler(event)"/>
   <mx:HTTPService id="RSSFeedterror" url="http://rss.news.yahoo.com/
rss/terrorism"
                                        resultFormat="object" result= 
"resultHandler(event)"/>
   <mx:HTTPService id="RSSFeedsci" url="http://rss.news.yahoo.com/rss/
science"
                                        resultFormat="object" result= 
"resultHandler(event)"/>
   <mx:TabNavigator id="tabNav" x="26" y="19" width="896" height="527"
change="changeData()">
        <mx:VBox label="Welcome" >
            <mx:Canvas backgroundColor="#9B2B2B" width="895"
height="496">
                        <mx:Panel width="286" height="278" layout="absolute"
x="304.5" y="103"   backgroundColor="#892828">
                        <mx:Label text="Wlcome to the yahoo news reader"  x="10"
y="87" fontFamily="Verdana" fontSize="13" fontWeight="bold"
fontStyle="italic" color="#BDF78E"/>
                        </mx:Panel>
                </mx:Canvas>
        </mx:VBox>
        <mx:VBox id="tech" label="Technology" click="true" >
            <mx:Canvas backgroundColor="#9B2B2B" width="895"
height="496">
                <mx:DataGrid id="technews" dataProvider="{datas}"
width="544" height="260" themeColor="#F65353" borderColor="#060000"
alternatingItemColors="[#FEFEFE, #FADBDB]" y="10" x="175">
                      <mx:columns>
                         <mx:DataGridColumn dataField="title"
headerText="Title" width="300"/>
                         <mx:DataGridColumn dataField="pubDate"
headerText="Publication Date"/>
                      </mx:columns>
                </mx:DataGrid>
                        <mx:Panel x="286" y="278" width="286" height="278"
layout="absolute" title="News Description">
                      <mx:TextArea
htmlText="{technews.selectedItem.description}" x="0" y="0" width="302"
height="160"/>
                </mx:Panel>
            </mx:Canvas>
        </mx:VBox>
        <mx:VBox id="stories" label="TopStories">
            <mx:Canvas backgroundColor="#9B2B2B" width="895"
height="496">
                <mx:DataGrid id="topnews" dataProvider="{datas}"
width="544" height="260" themeColor="#F65353" borderColor="#060000"
alternatingItemColors="[#FEFEFE, #FADBDB]" y="10" x="176">
                  <mx:columns>
                      <mx:DataGridColumn dataField="title"
headerText="Title" width="300"/>
                      <mx:DataGridColumn dataField="pubDate"
headerText="Publication Date"/>
                  </mx:columns>
                </mx:DataGrid>
                <mx:Panel x="286" y="278" width="322" height="200"
layout="absolute" title="News Description">
                     <mx:TextArea
htmlText="{topnews.selectedItem.description}" x="0" y="0" width="302"
height="160"/>
                </mx:Panel>
             </mx:Canvas>
        </mx:VBox>
        <mx:VBox id="world" label="World" >
             <mx:Canvas backgroundColor="#9B2B2B" width="896"
height="493">
                <mx:DataGrid id="worldnews" dataProvider="{datas}"
width="544" height="260" themeColor="#F65353" borderColor="#060000"
alternatingItemColors="[#FEFEFE, #FADBDB]" y="10" x="175">
                  <mx:columns>
                     <mx:DataGridColumn dataField="title"
headerText="Title" width="300"/>
                     <mx:DataGridColumn dataField="pubDate"
headerText="Publication Date"/>
                  </mx:columns>
                </mx:DataGrid>
                <mx:Panel x="286" y="278" width="322" height="200"
layout="absolute" title="News Description">
                    <mx:TextArea
htmlText="{worldnews.selectedItem.description}" x="0" y="0"
width="302" height="160"/>
                </mx:Panel>
             </mx:Canvas>
        </mx:VBox>
        <mx:VBox id="terrorism" label="Terrorism" >
             <mx:Canvas backgroundColor="#9B2B2B" width="895"
height="496">
                <mx:DataGrid id="terrornews" dataProvider="{datas}"
width="544" height="260" themeColor="#F65353" borderColor="#060000"
alternatingItemColors="[#FEFEFE, #FADBDB]" y="10" x="175">
                      <mx:columns>
                         <mx:DataGridColumn dataField="title"
headerText="Title" width="300"/>
                         <mx:DataGridColumn dataField="pubDate"
headerText="Publication Date"/>
                      </mx:columns>
                </mx:DataGrid>
                <mx:Panel x="286" y="278" width="322" height="200"
layout="absolute" title="News Description">
                     <mx:TextArea
htmlText="{terrornews.selectedItem.description}" x="0" y="0"
width="302" height="160"/>
                </mx:Panel>
             </mx:Canvas>
        </mx:VBox>
        <mx:VBox id="sci" label="Science">
            <mx:Canvas backgroundColor="#9B2B2B" width="899"
height="497">
                <mx:DataGrid id="scinews" dataProvider="{datas}"
width="544" height="260" themeColor="#F65353" borderColor="#060000"
alternatingItemColors="[#FEFEFE, #FADBDB]" x="166" y="10">
                          <mx:columns>
                             <mx:DataGridColumn dataField="title"
headerText="Title" width="300"/>
                             <mx:DataGridColumn dataField="pubDate"
headerText="Publication Date"/>
                          </mx:columns>
                </mx:DataGrid>
                <mx:Panel x="286" y="278" width="322" height="200"
layout="absolute" title="News Description">
                    <mx:TextArea
htmlText="{scinews.selectedItem.description}" x="0" y="0" width="302"
height="160"/>
                </mx:Panel>
             </mx:Canvas>
        </mx:VBox>
     </mx:TabNavigator>
</mx:WindowedApplication>

regards,
Sumant

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to