I Have seen alot of sample where the API key is hard coded into, unless you are building a desktop there is no need to do this. Facebook provides the API key, and the session key in the iframe url. Your application should retrieve the keys from the url, this makre your code more portable.

Url Variables:

  • fb_sig_api_key
  • fb_sig_session_key
  • fb_sig_ss

UPDATE – 9/10/10

With the new changes to face book app, make sure that you go into the advanced setting and check canvas session parameters.

    In my experience i have found that using the JavaScript client library for Facebook and the External Interface API in flash is alot more responsive than the Adobe Facebook AS3 library. Sometimes the event fails to fire. The only time you should use the adobe library is when you need to upload fotos, and do so by sharing the session data used by the JavaScript client.

    Example of sharing a session:

    fb= new Facebook();
    var session:WebSession;
    session=new  WebSession(Application.application.parameters.fbsigapikey,
    session.addEventListener(FacebookEvent.CONNECT, function():void{
    var bytes:ByteArray = jpegencoder.encode(lastpumpyourselfbm.bitmapData);
    var call:UploadPhoto = new UploadPhoto(bytes);

    Input Controls

    In this section we will modify the GameEngineView to handle input controls. We do this by calling setFocusable(true); on the constructor of the view. All that is left is to override the onKeyDown and onKeyUp events.

    	public boolean onKeyDown(int keyCode, KeyEvent event) {
    		if(keyCode == android.view.KeyEvent.KEYCODE_DPAD_LEFT )
    				st.setCurrentAnimation("walk_left", true);
    				st.AnimateTo(new Point( st.getXpos()-40, st.getYpos()));
    		if(keyCode == android.view.KeyEvent.KEYCODE_DPAD_RIGHT)
    				st.setCurrentAnimation("walk_right", true);
    				st.AnimateTo(new Point( st.getXpos()+40, st.getYpos()));
    		return super.onKeyDown(keyCode, event);
    	public boolean onKeyUp(int keyCode, KeyEvent event) {
    		if(keyCode == android.view.KeyEvent.KEYCODE_DPAD_LEFT )
    			st.setCurrentAnimation("idle_left", false);
    		if(keyCode == android.view.KeyEvent.KEYCODE_DPAD_RIGHT)
    			st.setCurrentAnimation("idle_right", false);
    		st.MoveTo(new Point( st.getXpos(), st.getYpos()));
    		return super.onKeyUp(keyCode, event);

    In this snippet the “st” object is an Instance of the player object which will be discussed shortly. Note that on key down animate player, on key up we return him to the idle state.


    The player class houses the characteristics that a player consists of. We will use the Sprite Tile as the base object, this will take care of the visual part of our player. We will add function and attributes for animation

    package com.warriormill.warriorengine;
    import android.content.Context;
    import android.graphics.Canvas;
    import android.graphics.Point;
    import com.warriormill.warriorengine.drawable.SpriteTile;
    public class Player extends SpriteTile {
    	public float lifebar=100.0f;
    	private Point move_to = new Point(10,10);
    	public Player(int BitmapResourceId, int XmlAnimationResourceId,
    			Context context) {
    		super(BitmapResourceId, XmlAnimationResourceId, context);
    	public void AnimateTo(Point pt)
    		move_to = pt;
    	public void MoveTo(Point pt)
    		move_to =pt;
    	public void draw(Canvas canvas) {
    	private void updateLocation()
    		if(move_to.y > this.getYpos())
    		else if(move_to.y < this.getYpos())
    		if(move_to.x > this.getXpos())
    		else if(move_to.x < this.getXpos())

    Source Code