Ethan,

Yup, that was it.  This works (although it's certainly not the only way to 
do it)...

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" 
creationPolicy="all">

        <mx:Script>
                <![CDATA[
                        [Bindable]
                        public var blogResult : Object;

                        public function changeVS() : void{
                                postKeywords.text = "";
                                postTypeVS.selectedIndex = 
(whatPostsCB.selectedItem.data == "popular") 
? 1 : 0 ;
                                refresh();
                                }

                        public function refresh() : void {
                                if (whatPostsCB.selectedItem.data == "popular")
                                        blogAggrWS.getMostPopularPosts.send();
                                else
                                        blogAggrWS.search.send();
                                }
                ]]>
        </mx:Script>

        <mx:WebService id="blogAggrWS"
            wsdl="http://weblogs.macromedia.com/mxna/webservices/mxna2.cfc?wsdl";
            useProxy="false" showBusyCursor="true">

                <mx:operation name="getMostPopularPosts" 
result="blogResult=event.result;">
                    <mx:request>
                        <daysBack>{daysBackCB.value}</daysBack>
                        <limit>{numPostsCB.value}</limit>
                    </mx:request>
                </mx:operation>

                <mx:operation name="search" result="blogResult=event.result;">
                    <mx:request>
                        <offset>0</offset>
                        <limit>50</limit>
                        <searchTerms>{postKeywords.text}</searchTerms>
                        <sortBy>relevance</sortBy>
                        <languageIds>1</languageIds>
                    </mx:request>
                </mx:operation>

                <mx:operation name="getLanguages">
                    <mx:request/>
                </mx:operation>

        </mx:WebService>

        <mx:Panel width="850" height="400" layout="absolute" 
horizontalCenter="0" 
verticalCenter="0" title="Adobe Blogs Post Finder">

                <mx:HBox horizontalCenter="0" top="20" verticalAlign="middle">

                        <mx:Label text="Get:"/>

                        <mx:ComboBox id="whatPostsCB" change="changeVS()">
                                <mx:Object label="Posts By Keyword" 
data="search" />
                                <mx:Object label="Most Popular Posts" 
data="popular" />
                        </mx:ComboBox>

                        <mx:ViewStack id="postTypeVS" width="400">

                                <mx:HBox verticalAlign="middle">
                                        <mx:TextInput id="postKeywords" 
text=""/>
                                        <mx:Button label="Search" 
click="refresh()"/>
                                </mx:HBox>

                                <mx:HBox verticalAlign="middle" width="372">

                                        <mx:Spacer width="10"/>

                                        <mx:Label text="Show:"/>
                                        <mx:ComboBox id="numPostsCB" 
change="refresh()" selectedIndex="0">
                                                <mx:Object label="Top 5 Posts" 
data="5" />
                                                <mx:Object label="Top 10 Posts" 
data="10" />
                                                <mx:Object label="Top 15 Posts" 
data="15" />
                                        </mx:ComboBox>

                                        <mx:Spacer width="10"/>

                                        <mx:Label text="In Last:"/>
                                        <mx:ComboBox id="daysBackCB" 
change="refresh()" selectedIndex="0">
                                                <mx:Object label="30 Days" 
data="30" />
                                                <mx:Object label="60 Days" 
data="60" />
                                                <mx:Object label="90 Days" 
data="90" />
                                        </mx:ComboBox>

                                </mx:HBox>

                        </mx:ViewStack>

                </mx:HBox>

                <mx:DataGrid left="20" right="20" top="62" bottom="20" 
id="keyPostsDG" 
dataProvider="{blogResult}">
                        <mx:columns>
                                <mx:DataGridColumn headerText="Post Title" 
textAlign="left">
                                        <mx:itemRenderer>
                                                <mx:Component>
                                                                                
<mx:LinkButton label="{data.postTitle}"
                                                                                
        click="navigateToURL(new URLRequest(data.postLink))"
                                                                                
        color="blue"/>
                                                                        
</mx:Component>
                                        </mx:itemRenderer>
                                </mx:DataGridColumn>
                                <mx:DataGridColumn headerText="Clicks" 
dataField="clicks" width="50" 
textAlign="right"/>
                                <mx:DataGridColumn headerText="Post Excerpt" 
dataField="postExcerpt" 
wordWrap="true"/>
                        </mx:columns>
                </mx:DataGrid>

        </mx:Panel>

</mx:Application>


Darren








>From: "Darren Houle" <[EMAIL PROTECTED]>
>Reply-To: flexcoders@yahoogroups.com
>To: flexcoders@yahoogroups.com
>Subject: RE: [flexcoders] Variable Type for Web Service Result
>Date: Wed, 23 Aug 2006 22:44:48 -0400
>
>Ethan,
>
>I don't think it's your typing, I think it's your timing.  Looks like 
>you're
>flipping your postTyper() when the combobox is changed, but that's not
>firing a new send() like the original blogger example did.  Try changing
>your code so that changing the combobox triggers the send() and the send
>result="" handler triggers the postTyper().  That way you'll have the
>correct data in lastResult when you change your blogResult variable.  That
>change should then be noticed by the bindings.
>
>Darren
>
>
> >From: Ethan Miller <[EMAIL PROTECTED]>
> >Reply-To: flexcoders@yahoogroups.com
> >To: flexcoders@yahoogroups.com
> >Subject: [flexcoders] Variable Type for Web Service Result
> >Date: Wed, 23 Aug 2006 16:13:19 -0700
> >
> >Greetings -
> >
> >Expanding on the "Connecting to Web Services" tutorial, I added a
> >combo box for switching between methods of the API to the Adobe blog
> >aggregator, ie from getMostPopularPosts to search.
> >
> >As both methods return the same columns, the data grid displaying the
> >result can stay the same, other than needing a different value for
> >data provider, ie:
> >
> >     myWebService.getMostPopularPosts.lastResult
> >vs
> >     myWebService.search.lastResult
> >
> >I was hoping therefore to bind the dataGrid dataProvider value to a
> >variable which I'd set when users change the value of the comboBox
> >(which selects which method to use). However I think I'm typing the
> >variable which stores the value of the service result wrong, as I get
> >null whenever I try and set the value (blogResult), show below:
> >
> ><?xml version="1.0" encoding="utf-8"?>
> ><mx:Application
> >     xmlns:mx="http://www.adobe.com/2006/mxml";
> >     layout="absolute">
> >
> ><mx:Script>
> >     <![CDATA[
> >
> >             [Bindable]
> >             public var blogResult:Object = null;
> >
> >             public function postTyper(event:Event):void{
> >                     if (event.currentTarget.selectedItem.data == "popular"){
> >                             postTypeVS.selectedIndex=1;
> >                             blogResult = 
> > blogAggrWS.getMostPopularPosts.lastResult;
> >                             trace (blogResult);
> >                     }
> >                     else{
> >                             postTypeVS.selectedIndex=0;
> >                             blogResult = blogAggrWS.search.lastResult;
> >                             trace (blogResult);
> >                     }
> >             }
> >     ]]>
> ></mx:Script>
> >
> >     <mx:WebService id="blogAggrWS"
> >         wsdl="http://weblogs.macromedia.com/mxna/webservices/mxna2.cfc?
> >wsdl"
> >         useProxy="false">
> >
> >             <mx:operation name="getMostPopularPosts">
> >                 <mx:request>
> >                     <daysBack>{daysBackCB.value}</daysBack>
> >                     <limit>{numPostsCB.value}</limit>
> >                 </mx:request>
> >             </mx:operation>
> >
> >             <mx:operation name="search">
> >                 <mx:request>
> >                     <offset>0</offset>
> >                     <limit>50</limit>
> >                     <searchTerms>{postKeywords.text}</searchTerms>
> >                     <sortBy>relevance</sortBy>
> >                     <languageIds>1</languageIds>
> >                 </mx:request>
> >             </mx:operation>
> >
> >             <mx:operation name="getLanguages">
> >                 <mx:request/>
> >             </mx:operation>
> >
> >     </mx:WebService>
> >
> >     <mx:Panel
> >             width="850" height="400"
> >             layout="absolute"
> >             horizontalCenter="0" verticalCenter="0"
> >             title="Adobe Blogs Post Finder">
> >
> >             <mx:HBox horizontalCenter="0" top="20" verticalAlign="middle">
> >
> >                     <mx:Label text="Get:"/>
> >
> >                     <mx:ComboBox id="whatPostsCB"
> >                             change="postTyper(event)">
> >                             <mx:Object label="Posts By Keyword" 
> > data="search" />
> >                             <mx:Object label="Most Popular Posts" 
> > data="popular" />
> >                     </mx:ComboBox>
> >
> >                     <mx:ViewStack id="postTypeVS" width="400">
> >
> >                             <mx:HBox verticalAlign="middle">
> >                                     <mx:TextInput id="postKeywords" 
> > text=""/>
> >                                     <mx:Button label="Search" 
> > click="blogAggrWS.search.send()"/>
> >                             </mx:HBox>
> >
> >                             <mx:HBox verticalAlign="middle" width="372"
> >                                     
> > creationComplete="blogAggrWS.getMostPopularPosts.send()">
> >
> >                                     <mx:Spacer width="10"/>
> >
> >                                     <mx:Label text="Show:"/>
> >                                     <mx:ComboBox id="numPostsCB"
> >                                             
> > change="blogAggrWS.getMostPopularPosts.send()">
> >                                             <mx:Object label="Top 5 Posts" 
> > data="5" />
> >                                             <mx:Object label="Top 10 Posts" 
> > data="10" />
> >                                             <mx:Object label="Top 15 Posts" 
> > data="15" />
> >                                     </mx:ComboBox>
> >
> >                                     <mx:Spacer width="10"/>
> >
> >                                     <mx:Label text="In Last:"/>
> >                                     <mx:ComboBox id="daysBackCB"
> >                                             
> > change="blogAggrWS.getMostPopularPosts.send()">
> >                                             <mx:Object label="30 Days" 
> > data="30" />
> >                                             <mx:Object label="60 Days" 
> > data="60" />
> >                                             <mx:Object label="90 Days" 
> > data="90" />
> >                                     </mx:ComboBox>
> >
> >                             </mx:HBox>
> >
> >                     </mx:ViewStack>
> >
> >             </mx:HBox>
> >
> >             <mx:DataGrid left="20" right="20" top="62" bottom="20" 
> > id="keyPostsDG"
> >                     dataProvider="{blogResult}">
> >                     <mx:columns>
> >                             <mx:DataGridColumn headerText="Post Title" 
> > textAlign="left">
> >                                             <mx:itemRenderer>
> >                                             <mx:Component>
> >                                                     <mx:LinkButton 
> > label="{data.postTitle}"
> >                                                     
> > click="navigateToURL(new URLRequest(data.postLink))"
> >                                                     color="blue"/>
> >                                             </mx:Component>
> >                                             </mx:itemRenderer>
> >                             </mx:DataGridColumn>
> >                             <mx:DataGridColumn headerText="Clicks" 
> > dataField="clicks"
> >width="50" textAlign="right"/>
> >                             <mx:DataGridColumn headerText="Post Excerpt"
> >dataField="postExcerpt" wordWrap="true"/>
> >                     </mx:columns>
> >             </mx:DataGrid>
> >
> >     </mx:Panel>
> >
> ></mx:Application>
> >
> >
> >
> >--
> >Flexcoders Mailing List
> >FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> >Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> >Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>
>
>
>--
>Flexcoders Mailing List
>FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
>Yahoo! Groups Links
>
>
>
>
>
>
>




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to