Javascript ExternalInterface.addCallback运行不正常
我尝试在我的flash应用程序中建立登录facebook机制。 但是,当我尝试获取令牌访问表单回调页面时,将获取并发送到flash的ExternalInterface.addCallback失败;t跑得很好。 我怎样才能解决它 这是我的代码:Javascript ExternalInterface.addCallback运行不正常,javascript,facebook,flash,token,Javascript,Facebook,Flash,Token,我尝试在我的flash应用程序中建立登录facebook机制。 但是,当我尝试获取令牌访问表单回调页面时,将获取并发送到flash的ExternalInterface.addCallback失败;t跑得很好。 我怎样才能解决它 这是我的代码: var accessToken:String =""; tombol.addEventListener(MouseEvent.CLICK, onClick); function onClick(e:MouseEvent):void{ attemp
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.....
var-accessToken:String=“”;
tombol.addEventListener(MouseEvent.CLICK,onClick);
函数onClick(e:MouseEvent):void{
尝试验证();
tombol.removeEventListener(MouseEvent.CLICK,onClick);
}
函数尝试验证(…权限):无效{
变量范围:String=“”;
如果(permissions.length>0){
scope=“&scope=“+权限.加入(,”);
}
外部接口调用(“window.open”https://graph.facebook.com/oauth/authorize?client_id=245127485627150&type=user_agent&redirect_uri=http://localhost/satu/callback.html“+范围,“FaceBookLoginWindows”,“高度=370,宽度=600”);
teks.text=“成功从服务器fb获取令牌”;
addCallback(“setAccessToken”,setAccessToken);
调用(“函数(){”
+“window.setAccessToken=函数(hashValue){”
+“var satu1=document.getElementById('satu')
+“satu1.setAccessToken(hashValue);”
+ "}"
+ "}");
ExternalInterface.call(“window.alert”、“hashValue”);
teks.text+=“从闪存获取”;
}
函数setAccessToken(a_hashValue:String):void{
teks.text+=“setaccesstoken”;
var hashParams:Array=a_hashValue.substr(1).split(“&”);
var hashKeyAndValue:数组;
for(变量i:int=0;i
flash是否出现错误?在html中,是否设置了allowscriptaccess=always,在flash中设置了System.security.allowDomain(“”;*?根据我的代码,当我运行它时,它会停在ExternalInterface.call(“window.alert”、“hashValue”);teks.text+=“从闪存获取”}>>因为我在teks中的文本中放置了设置文本以查看流程。我得出结论,setAccessToken没有回调,因为teks.text+=“setAccessToken”;没有出现。我应该在页面中始终设置AllowScriptacess=吗?我可以把“system.security.allowDomain”(“”)放在我的应用程序中的什么地方?@DeividiCavarzan:我仍然可以解决这个问题,如何配置system.security.allowDomain?仅供参考,他们都在同一个域中。嗯。。。好啊似乎您声明了tewindow.setAcessToken()
,但从未调用过该函数。。。尝试调用window.setAccessToken()
;在声明之后,看看ehat发生了什么。