0 Replies Latest reply on Jun 30, 2011 10:51 PM by Edward2009

    question about flex with facebook api

    Edward2009 Level 1

      I want to use flash with facebook,when it visit a url,it will use JSON to decode data,when it contains connection,I hope it can display button which named "show" or "hide"

       

      AS code is follows:

      public function CustomGraphContainerController(a_graphControlContainer:GraphControlContainer)
        {
         super(a_graphControlContainer);
         var loader:URLLoader=new URLLoader();
         var request:URLRequest = new URLRequest();
         var variables:URLVariables = new URLVariables();
         request.url = "http://localhost/api.jsp";
         variables.metadata = 1;
         request.data = variables;
         loader.addEventListener(Event.COMPLETE,onGraphDataLoadComplete);
         loader.load(request);
        }

      private function onGraphDataLoadComplete(a_event:Event):void{
         var loader:URLLoader=a_event.target as URLLoader;
         var graphData:String=loader.data;
         var decodedJSON:Object = JSON.decode(graphData);
         if (decodedJSON.data) {
          var graphList:GraphList = new GraphList();
          var childGraphObject:GraphObject;
          for each(var childObject:Object in decodedJSON.data) {
           childGraphObject = new GraphObject();
           for (var childKey:String in childObject) {
            childGraphObject[childKey] = childObject[childKey];
           }
           graphList.addToList(childGraphObject);
          }
          graphList.paging = decodedJSON.paging;
          this.renderGraphList(graphList);
         }
         else{
          var graphObject:GraphObject=new GraphObject();
          for(var key:String in decodedJSON){
           graphObject[key]=decodedJSON[key];
          }
          this.renderGraphObject(graphObject);
          trace(graphData);
         }
        }

       

      the return codes from url,like follows:

       

      {
      "id": "204603129458_127056137323572",
      "from": {
        "name": "Packt Publishing",
        "category": "Products_other",
        "id": "204603129458"
      },
      "message": "The Amazon SimpleDB Developer Guide has been published!Get your copy now! http://bit.ly/blFQUG",
      "created_time": "2010-06-04T12:39:44+0000",
      "updated_time": "2010-06-04T12:39:44+0000",
      "data": [{
        "name": "Packt Publishing",

        "connection":"https://graph.facebook.com/packtpub/feed",
        "id": "204603129458"
      }],
      "connection": {
        "feed": "https://graph.facebook.com/packtpub/feed",
        "posts": "https://graph.facebook.com/packtpub/posts",
        "tagged": "https://graph.facebook.com/packtpub/tagged",
        "statuses": "https://graph.facebook.com/packtpub/statuses",
        "links": "https://graph.facebook.com/packtpub/links",
        "notes": "https://graph.facebook.com/packtpub/notes",
        "photos": "https://graph.facebook.com/packtpub/photos",
        "albums": "https://graph.facebook.com/packtpub/albums",
        "events": "https://graph.facebook.com/packtpub/events",
        "videos": "https://graph.facebook.com/packtpub/videos"
      },
      "likes": 1
      }

       

      When I run above code,it only display "Pop Out" button,it don't display show or hide button, why?  How to correct above code to display "show" or "hide" button?

       

      Thanks