在 Flash 中,我在构建后首先调用身份验证,如何避免弹出窗口阻止程序。
public function FacebookProxy(appID:String, permissions:Object) {
this.appID = appID;
this.permissions = permissions;
}
public function authenticate():void {
var response:FacebookAuthResponse = Facebook.getAuthResponse();
if(response && response.uid) {
this.success(response);
} else {
this.init();
}
}
protected function init():void {
Security.loadPolicyFile("https://fbcdn-profile-a.akamaihd.net/crossdomain.xml");
Facebook.init(this.appID, this.initHandler);
}
protected function initHandler(response:FacebookAuthResponse, fail:Object):void {
if(response && response.uid){
this.success(response);
} else {
setTimeout(this.login, 200);
}
}
protected function login():void {
Facebook.login(loginHandler, this.permissions);
}
protected function loginHandler(response:FacebookAuthResponse, fail:Object):void {
if(response && response.uid) {
this.success(response);
} else {
//ExternalInterface.call("trace", "code:" + fail.error.code + ", message:" + fail.error.message + ", type:" + fail.error.type);
}
}
protected function success(response:FacebookAuthResponse):void {
}