0

有没有人有使用 Adob​​e Air 在 iPad 上实施 Facebook 连接的经验。我对 API (http://code.google.com/p/facebook-actionscript-api/) 有疑问,并不断向我抛出错误。我已经为 web 的 flash 版本使用了相同的代码,它工作正常。

错误:

C:\Documents and Settings\SESA151424\My Documents\Work\projects\Clipsal iSelector\Air\src\com\facebook\graph\core\AbstractFacebook.as, Line 313 1061: Call to a possibly undefined method toString through a reference with static type com.facebook.graph.data:FQLMultiQuery.

代码

import com.facebook.graph.Facebook;
private function init():void{
            Facebook.init(APP_ID, onInit);
            TweenPlugin.activate([TintPlugin, ColorTransformPlugin]);
            this.setUpProjectSection();

        }

        private function socialSignin(e:Event){
            var opts:Object = {scope:"publish_stream, user_photos"};
            //Facebook.login(onLogin, opts);
        }

        private function onLogin(result:Object, fail:Object):void{
            if (result) {
                //closeModalDialoge(new MouseEvent(MouseEvent.CLICK));
                _mainContainer.parent.facebookStatus.text = JSON.encode(result);
                _userInfo = ['result.uid', 'result.accessToken'];

                Facebook.api('/me', onCallApi, null, 'GET');
            }else{
                //_mainContainer.parent.facebookStatus.text = "Not Logged In\n";
            }
        }

        private function onCallApi(result:Object, fail:Object):void{
            //_mainContainer.parent.facebookStatus.text += '/n\n';
            var options:Object = {
                                username    :   _userInfo[0],
                                password    :   _userInfo[1],
                                firstname   :   result.first_name,
                                lastname    :   result.last_name,
                                name        :   result.name,
                                location    :   result.location,
                                gender      :   result.gender,
                                hometown    :   result.hometown
                                }

            _user.socialSignin(options);
            //_mainContainer.parent.facebookStatus.text += JSON.encode(result);
        }
4

1 回答 1

0

解决方案找到包{

import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.media.StageWebView;

import com.facebook.graph.FacebookMobile;
import com.facebook.graph.controls.Distractor;

import demo.controls.GraphicButton;
import demo.events.FacebookDemoEvent;
import demo.models.FriendModel;
import demo.views.FriendDetail;
import demo.views.FriendsList;
import demo.views.UserInfo;

public class FriendListMobile extends MovieClip {

    //Place your application id here.
    protected static const APP_ID:String = 'xxxxxxxx';
    //Place your specified site URL for your app here. This is needed for clearing cookies when logging out.
    protected static const SITE_URL:String = 'xxxxxxxx';
    //Extended permission to access other parts of the user's profile that may be private, or if your application needs to publish content to Facebook on a user's behalf.
    protected var extendedPermissions:Array = ["publish_stream","user_website","user_status","user_about_me"];

    public var userInfo:UserInfo;
    public var loginBtn:GraphicButton;
    public var friendDetail:FriendDetail;
    public var friendList:FriendsList;

    public var distractor:Distractor;
    public var bg:DistractorOverlay;
    public var friendsModel:FriendModel;

    protected var selectedUserInfo:Object = {};

    public function FriendListMobile() {
        // constructor code
        addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
    }

    protected function handleAddedToStage(event:Event):void {
        removeEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.NO_SCALE;
        init();
    }

    protected function init():void {
        configUI();
        addEventListeners();

        FacebookMobile.init(APP_ID, onHandleInit, null);
    }

    protected function configUI():void {
        loginBtn.label = 'Login';
        loginBtn.setSize(440, 60);
        loginBtn.setStyle('font', '_sans');
        loginBtn.setStyle('size', 25);

        friendsModel = new FriendModel();

        distractor = new Distractor();
        friendDetail.visible = false;

        bg = new DistractorOverlay();
        bg.visible = true;
        addChild(bg);

        distractor.x = 120
        distractor.y = 310; 

        bg.addChild(distractor);
    }

    protected function addEventListeners():void {
        loginBtn.addEventListener(MouseEvent.MOUSE_DOWN, handleLoginClick, false, 0, true);
        friendDetail.addEventListener(Event.CLOSE, onCloseDialog, false, 0, true);
        friendsModel.addEventListener(Event.COMPLETE, onFriendsComplete, false, 0, true);
        friendList.addEventListener(FacebookDemoEvent.FRIEND_SELECTED, onFriendSelected, false, 0, true);
    }

    /**
     * Pops up detail view for a selected friend.
     **/
    protected function showFriendDetail():void {
        bg.visible = true;

        friendDetail.visible = true;
        friendDetail.data = selectedUserInfo;

        this.setChildIndex(friendDetail, this.numChildren - 1);
    }

    /**
     * Event Handler Close DetailView
     **/
    protected function onCloseDialog(event:Event):void {
        friendDetail.visible = false;
        bg.visible = false;
    }

    /**
     * Event Handler user selects from the friend list.
     **/
    protected function onFriendSelected(event:FacebookDemoEvent):void {
        selectedUserInfo = event.data;
        showFriendDetail();
    }

    /**
     * Event Handler User clicks Login button.
     **/
    protected function handleLoginClick(event:MouseEvent):void {
        bg.visible = true;

        loginUser();
    }

    /**
     * Event Handler User clicks on Logout button.
     **/
    protected function handleLogOutClick(event:MouseEvent):void {
        FacebookMobile.logout(handleLogout, SITE_URL);

        loginBtn.label = 'Login';
        loginBtn.addEventListener(MouseEvent.MOUSE_DOWN, handleLoginClick, false, 0, true);

        friendList.clear();
        userInfo.clear();

        bg.visible = true;
    }

    /**
     * Event Handler once logged out.
     **/
    protected function handleLogout(response:Object):void {
        bg.visible = false;
    }

    /**
     * Event Handler FacebookMobile initializes application.
     * Application will check if user is return to application, 
     * if not user is prompted to log in.
     **/
    protected function onHandleInit(response:Object, fail:Object):void {
        if (response) {
            updateView(response.uid, response);
        } else {
            loginUser();
        }
    }

    /**
     * Updates UI for views 
     **/
    protected function updateView(id:String, data):void {
        userInfo.id = id;
        userInfo.data = data;

        loginBtn.label = 'Log Out';
        loginBtn.addEventListener(MouseEvent.MOUSE_DOWN, handleLogOutClick);
        loginBtn.removeEventListener(MouseEvent.MOUSE_DOWN, handleLoginClick);

        friendsModel.load();
    }

    /**
     * Preforms a login call to application. Mobile application takes in an instance 
     * StageView class.
     **/
    protected function loginUser():void {
        trace('not log in');
        FacebookMobile.login(handleLogin, stage, extendedPermissions, new StageWebView());
    }

    /**
     * Event Handler once user logs in.
     **/
    protected function handleLogin(response:Object, fail:Object):void {
        bg.visible = false;
        FacebookMobile.api('/me', handleUserInfo);
    }

    /**
     * Event Handler for users information.
     **/
    protected function handleUserInfo(response:Object, fail:Object):void {
        if (response) {
            updateView(response.id, response);
        }
    }

    /**
     * Event Handler FriendModel information has been loaded.
     **/
    protected function onFriendsComplete(event:Event):void {
        bg.visible = false;
        friendList.dataProvider = friendsModel.dataProvider;
    }
}

}

于 2012-05-03T03:10:19.283 回答