2

1.6 Mobile Facebook API ( http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=GraphAPI_Mobile_1_6.swc ) を Air for Android アプリケーションに実装しようとしています。私は Web およびデスクトップ API を正常に使用しましたが、モバイル アプリでは、stageReference への追加のパラメーターが必要です。以下を参照してください。

login(callback:Function, stageRef:Stage, extendedPermissions:Array, webView:StageWebView = null)

しかし、Flash CS5 ではなく Flex を使用しているため、this.stage や this などを渡すことはできません。

Flash builder Flex を使用して、その中に何を渡す必要があると思いますか? モバイル アクション スクリプト API の例が見つからないようです。

Mobile API Docs からのログイン情報は次のとおりです。

login   ()  method   
public static function login(callback:Function, stageRef:Stage, extendedPermissions:Array, webView:StageWebView = null):void
Opens a new login window so the current user can log in to Facebook.

Parameters

callback:Function — The method to call when login is successful. The handler must have the signature of callback(success:Object, fail:Object); Success will be a FacebookSession if successful, or null if not.

stageRef:Stage — A reference to the stage

extendedPermissions:Array — (Optional) Array of extended permissions to ask the user for once they are logged in.

webView:StageWebView (default = null) — (Optional) The instance of StageWebView to use for the login window For the most current list of extended permissions, visit http://developers.facebook.com/docs/authentication/permissions
4

1 に答える 1

2

Flexを使用している場合は、FlexFlexGlobals.topLevelApplicationを指しているのでmx:Applications:Applicationそれを呼び出しstageて参照を取得できます。

それ以外の場合、DisplayObjectステージにアタッチされているか、にアタッチされている別のステージにアタッチさDisplayObjectれているstageと、stageプロパティが設定されます(何にもアタッチされていない場合stagenull)。

それ以外は、通常、人々が行うことは、プログラムの開始時に設定される、コードを介してアクセスできる場所に静的なものを保持することです。たとえば、典型的なメインクラスは次のようになります。

package 
{
    import flash.display.Sprite;
    import flash.display.Stage;
    import flash.events.Event;

    public class Main extends Sprite 
    {

        public static var stage:Stage = null;

        public function Main():void 
        {
            // if we have our stage, go directly to _init(), otherwise wait
            if ( this.stage ) this._init();
            else this.addEventListener( Event.ADDED_TO_STAGE, this._init );
        }

        private function _init( e:Event = null ):void 
        {
            // remove the listener
            this.removeEventListener( Event.ADDED_TO_STAGE, this._init );

            // hold the stage
            Main.stage = this.stage;

            // do everything else
            ...
        }

    }

}

その後、コードのどこからでも、を呼び出しMain.stageてにアクセスできますstage

于 2011-04-07T08:02:38.237 に答える