5 Replies Latest reply on Jun 15, 2010 10:02 AM by ska-man

    Problem with ExternalInterface.      addCallback and GoogleChrome

    ska-man

      Hi all

      i am developing a FLEX app that need to interact with FACEBOOK.

      I currently use FACEBOOK JAVASCRIPT API.

       

      I craete the callback function in FLEX and i call the external JS with the EXTERNALLINTERFACE:

       

      flash.external.ExternalInterface.addCallback("gettedMyInfo", gettedMyInfo);

       

      if  (ExternalInterface.available) {
                      ExternalInterface.call("isConnectedFlex");
      }

       

      In the JS code facebook do what he want to do and then i call (previously in the HTML i check the FB connection, init the API and so on):

       

            function isConnectedFlex() {
                FB.getLoginStatus(function(response) {
                if (response.session) {
                      returnSession0K(response.session.uid);
                } else {
                     FB.login(handleSessionResponseFlex);
                }
              });

       

            }

       

      function returnSession0K(uid) {
         getInfoUser(uid);
      }

       

       

      This works fine with firefox and ie but not with GoogleChrome that always return: Uncaught TypeError: Cannot call method 'gettedMyInfo' of undefined

      The ExternalInterface.call("isConnectedFlex"); works fine also in Chrome.

       

      I read the livedocs and i found:

      Error — The container does not support incoming calls.                 Incoming calls are supported only in Internet Explorer  for Windows and browsers                 that use the NPRuntime API such as Mozilla 1.7.5 and  later or Firefox 1.0 and later.

       

      So it seems that Google does not support addCallback method...

       

      Is there a solution or a workaround for using FB JS API with Chrome?

      Or i have to use the Flex FB Api? [i preffer to use JS api because it seems more fast and well designed]

       

       

      Thanks for your time

       

      Marco

        • 1. Re: Problem with ExternalInterface.      addCallback and GoogleChrome
          Dajji

          Your code snippet does not reflect the call to Flex method. How are you getting the reference of your swf? Are you using this.getElementById("mySwf").gettedMyInfo(); in JS to call the Flex method?

          1 person found this helpful
          • 2. Re: Problem with ExternalInterface.      addCallback and GoogleChrome
            ska-man Level 1

            Sorry i post the wrong JS snipet.

            this is the right complete JS CODE:

             

             

             

            //I CALL THIS FROM FLEX
                  function isConnectedFlex() {
                      
                      FB.getLoginStatus(function(response) {
                      if (response.session) {
               
                            returnSession0K(response.session.uid);
                      } else {
                   
                           FB.login(handleSessionResponseFlex);
                      }
                    });

             

                  }

             

            //IF CONNECTED I CALL:

            function returnSession0K(uid) {
                getInfoUser(uid);
            }

             

            //I READ USER INFOS

                function getInfoUser(uid) {
                    // if we have a session, query for the user's profile picture and name
                    FB.api(
                      {
                        method: 'fql.query',
                        query: 'SELECT first_name, last_name,uid,pic_square FROM user WHERE uid=' + uid
                      },
                      function(response) {
                        sendUserInfosToFlex(response);
                      }
                    );

             

                }

             

             

            //I SEND IT BACK TO FLEX:

            function sendUserInfosToFlex(data) {
                thisMovie("flashContent").gettedMyInfo(data)
            }

             

             

            ------------- AS3 CODE -------

            flash.external.ExternalInterface.addCallback("gettedMyInfo", gettedMyInfo);

            if  (ExternalInterface.available) {
                            ExternalInterface.call("isConnectedFlex");

            }

             

            Thanks again

            • 3. Re: Problem with ExternalInterface.      addCallback and GoogleChrome
              Dajji Level 3

              What is thisMovie in following line?

               

              thisMovie("flashContent").gettedMyInfo(data);
              

               

              Try replacing that with following.

               

              getElementById("flashContent").gettedMyInfo(data)
              

              • 4. Re: Problem with ExternalInterface.      addCallback and GoogleChrome
                ska-man Level 1

                This is the function that return the way to call the movie..

                i'm gona try with the getElementId

                 

                function thisMovie(movieName) {
                    if (navigator.appName.indexOf("Microsoft") != -1) {
                        return window[movieName];
                    } else {
                        return document[movieName];
                    }
                }