ExternalInterface.addCallback运行良好

时间:2013-08-17 02:09:50

标签: javascript facebook flash token

我尝试在我的Flash应用程序中创建登录facebook机制。 但是当我尝试获取令牌访问表单回调页面时,将获取并发送到闪存的ExternalInterface.addCallback没有运行。 我怎么解决呢?

这是我的代码:

var accessToken:String ="";
tombol.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e:MouseEvent):void{
    attemptToAuthenticate();
    tombol.removeEventListener(MouseEvent.CLICK, onClick);
}

function attemptToAuthenticate(...permissions):void{
  var scope:String = "";
  if (permissions.length > 0){
   scope = "&scope=" + permissions.join(",");
  }
  ExternalInterface.call("window.open","https://graph.facebook.com/oauth/authorize?client_id=245127485627150&type=user_agent&redirect_uri=http://localhost/satu/callback.html"+scope,"facebookLoginWindow","height=370, width=600");    

teks.text = "success get token from server fb";

ExternalInterface.addCallback("setAccessToken", setAccessToken);    

ExternalInterface.call("function() {"
       + "window.setAccessToken = function(hashValue){"
       + "var satu1 = document.getElementById('satu');"
       + "satu1.setAccessToken(hashValue);"
       + "}"
       + "}");

ExternalInterface.call("window.alert", "hashValue");
teks.text += " get from flash"; 
 }

 function setAccessToken(a_hashValue:String):void{
  teks.text += "setaccesstoken";
  var hashParams:Array = a_hashValue.substr(1).split("&");
      var hashKeyAndValue:Array;
      for (var i:int = 0; i < hashParams.length; i++){
      hashKeyAndValue = (hashParams[i] as String).split("=");
  if (hashKeyAndValue[0] == "access_token"){
      this.accessToken = hashKeyAndValue[1];
      break;
    }
  }
  this.request("me","");
  }

 // some code below.....

0 个答案:

没有答案