I’m trying to implement the 1.6 Mobile Facebook API (http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=GraphAPI_Mobile_1_6.swc) into an Air for Android application. I’ve succesfully used the Web and Desktop API’s however with the mobile app it’s expecting an extra parameter to a stageReference, see:
login(callback:Function, stageRef:Stage, extendedPermissions:Array, webView:StageWebView = null)
But, using i’m using Flex and not Flash CS5, i can’t just pass in this.stage or this or anything like that.
What exactly would you guys think I need to pass into that using Flash builder Flex? I can’t seem to find any examples for the mobile actionscript API so i’m kinda in the dark, anyone have any ideas?
Here’s the login information from the 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
If you’re using Flex, you have
FlexGlobals.topLevelApplicationwhich will point to yourmx:Applicationors:Applicationso you can callstageon that to get a reference to it.Otherwise, any
DisplayObjectattached to the stage or attached to anotherDisplayObjectattached to thestage, will have it’sstageproperty set (If it’s not attached to anything,stagewill benull).Other than that, normally what people do is keep a static somewhere that they can access through the code, that’s set when the program starts. For example, your typical main class could be something like:
After that, anywhere in your code, you can call
Main.stageto get access to thestage.