I think you can help me out from this little problem.
I am a novice in Facebook developer by choosing ActionScript 3 as my developer platform. I use SWC library from official facebook-actionscript-api that promoted by Adobe.
So I followed their tutorial. So I did following instruction:
Facebook_library_v3.4_flex.swc
to \lib
in Flex project.Provide following code:
import com.facebook.Facebook;
import com.facebook.utils.FacebookSessionUtil;
private var fbook:Facebook;
private var session: FacebookSessionUtil;
protected var api_key : String = "my-facebook-app-api-key";
protected var secret_key : String = "my-facebook-app-secret-key";
public function init() : void {
//fbook = new Facebook();
session=new FacebookSessionUtil(api_key,secret_key,this.loaderInfo);
var fbook : Facebook = session.facebook;
session.validateLogin();
}
After trying to run debug session. I got the error after execute this statement:
session=new FacebookSessionUtil(api_key,secret_key,this.loaderInfo);
I think I did something wrong but I couldn't figure it out. Could you help me by giving your advice or any guideline?
This is exception I got:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.facebook.utils::FacebookSessionUtil()[C:\Users\MikeHunt\Work\FacebookAPI\src\com\facebook\utils\FacebookSessionUtil.as:128]
at CheeseZaa/init()[/Users/teerasej/Documents/Flex Builder 3?/freelance/CheeseZaa/src/CheeseZaa.mxml:24]
at CheeseZaa/___CheeseZaa_Application1_creationComplete()[/Users/teerasej/Documents/Flex Builder 3?/freelance/CheeseZaa/src/CheeseZaa.mxml:4]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9440]
at mx.core::UIComponent/set initialized()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1168]
at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:718]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8744]
at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8684]
I notice that the first line of exception show this:
com.facebook.utils::FacebookSessionUtil()[C:\Users\MikeHunt\Work\FacebookAPI\src\com\facebook\utils\FacebookSessionUtil.as:128]
But I don't sure it involve in exception.
My development platform is:
Every suggestion and guideline would be thank you. I think this would be good for other developer that may found the same problem like me.
loaderInfo is not ready and is currently null.
try:-
public function init():void
{
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true);
}
private function onAddedToStage(event:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
session = new FacebookSessionUtil(api_key, secret_key, this.loaderInfo);
var fbook:Facebook = session.facebook;
session.validateLogin();
}