PDA

View Full Version : Kongregate Stats Problem



bcapecci
December 21st, 2009, 10:37 PM
public function loadAPI()
{
var paramObj:Object = LoaderInfo(root.loaderInfo).parameters;
var api_url:String = paramObj.api_path || "http://www.kongregate.com/flash/API_AS3_Local.swf";
var request:URLRequest = new URLRequest ( api_url );
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener ( Event.COMPLETE, apiLoadComplete );
loader.load ( request );
this.addChild ( loader );
}


I get a null reference error on this line:
var paramObj:Object = LoaderInfo(root.loaderInfo).parameters;

Anybody know what I should do. I was just following the tutorial to implement it. I don't quit understand that part of the code so I cannot fix it myself. Do I have to download something for the api to work? Thanks a bunch. Hopefully this can be fixed tonight because I need to add highscores to my game.

TheCanadian
December 21st, 2009, 11:59 PM
The only thing I can think of that would cause an error on that line is root not being accessible which would happen if the class instance hasn't been added to the stage.

bcapecci
December 22nd, 2009, 12:07 AM
Its added to the stage. Well a refrence to it.

In the docs it says:
Note that to access FlashVars in AS3, you must have access to the root object, either from a DisplayObject already in the display list, or a reference saved from an active DisplayObject. The means in which you handle this is your choice.

What I dont understand is how to have access to this root object.