1 Reply Latest reply: Mar 7, 2014 7:02 AM by empardopo RSS

    Api Yahoo

    empardopo

      Hi,

       

      anybody has worked with the AstraWebAPIs.swc lib?

       

      I'm reading the Learning Flex 4 and It uses the next example.

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application
          xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:yahoo="http://www.yahoo.com/astra/2006/mxml"
          defaultButton="{searchButton}"
          currentState="initial">
          
          <fx:Declarations>
              <yahoo:SearchService id="searchService"
                                   applicationId="YahooSearch"
                                   query="{queryTI.text}"/>
          </fx:Declarations>
          
          <fx:Script>
              <![CDATA[
                  private function searchButtonClick():void{
                      if(!(this.currentState == "running")){
                          this.currentState="running";
                      }
                      searchService.send();
                  }
              ]]>
          </fx:Script>
          
          <s:states>
              <s:State name="initial"/>
              <s:State name="running"/>
          </s:states>
          
          <s:VGroup horizontalCenter.initial="0"
                    verticalCenter.initial="0"
                    height.running="100%"
                    width.running="100%"
                    left.running="10"
                    right.running="10"
                    top.running="10"
                    bottom.running="10">
              <s:Label text="Yahoo! Search:" fontWeight="bold"/>
              <s:HGroup>
                  <mx:FormItem label="Query:" fontWeight="bold">
                      <s:TextInput id="queryTI" width="350"/>
                  </mx:FormItem>
                  <mx:FormItem>
                      <s:Button id="searchButton" label="Search"
                                click="searchButtonClick()"/>
                  </mx:FormItem>
              </s:HGroup>
              <s:List id="resultsList" width="100%" height="100%"
                      itemRenderer="learningflex4.renderers.SearchItemRenderer"
                      excludeFrom="initial">
                  <s:dataProvider>
                      <s:ArrayCollection source="{searchService.lastResult}"/>
                  </s:dataProvider>
              </s:List>
          </s:VGroup>
      </s:Application>
      

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                      xmlns:s="library://ns.adobe.com/flex/spark" 
                      xmlns:mx="library://ns.adobe.com/flex/mx" 
                      autoDrawBackground="true" width="100%">
          
          <fx:Script>
              <![CDATA[
                  import flash.net.navigateToURL;
                  import flashx.textLayout.elements.TextFlow;
                  import spark.utils.TextFlowUtil;
                  // merge name and summary and return as TextFlow
                  private function renderText(name:String, summary:String):TextFlow{
                      var textFlow:TextFlow =
                          TextFlowUtil.importFromString(name + summary);
                      return textFlow
                  }
                  private function onClick(event:MouseEvent, url:String):void{
                      var urlRequest:URLRequest = new URLRequest(url);
                      navigateToURL(urlRequest, "_blank");
                  }
              ]]>
          </fx:Script>
          <s:VGroup width="100%" gap="2">
              <s:Label text="From: {data.url}" fontWeight="bold"
                       buttonMode="true" click="onClick(event, data.url)"/>
              <s:TextArea width="100%" heightInLines="1" editable="false"
                          borderVisible="false" verticalScrollPolicy="off"
                          textFlow="{renderText(data.name, data.summary)}"/>
          </s:VGroup>
          
      </s:ItemRenderer>
      

       

      The program hasn't errors but I don't appears anything in my list component.

       

      Any idea?

       

      Thanks in advance!