Hi Varun,
You are getting this error because the object you are attempting to call 'createAuthenticationRequest' on is of type 'GS'; which doesn't have this function. The createAutheticationRequest belongs to the GSRequestBuilder class. You can call this by either a) creating an object of type GSRequestBuilder, or b) invoke it directly on the value returned from 'getRequestBuilder'. i.e.
a)
var gsBuilder:GSRequestBuilder = gs.getRequestBuilder();
gsBuilder.createAuthenticationRequest();
gsBuilder.setUserName.......etc.
b)
gs.getRequestBuilder()
.createAuthenticationRequest()
.setUserName().....etc.
Try out whichever approach seems most intuitive to you and let us know how you get on.
Regards,
Vinnie
Thanks for the response Vinnie,
I tried method "a" but I am still getting errors, here is my new code:
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.messages.*;
var gs:GS = new GS();
gs.setAvailabilityCallback(availabilityCallback)
gs.setUrl("wss://preview.gamesparks.net/ws/W303465GPdkX")
gs.setApiSecret("nMCd72KXdZ02lqSRp3Wx0b22wtazFKnA")
gs.connect();
var gsBuilder:GSRequestBuilder;
function availabilityCallback(isAvailable : Boolean):void
{
trace("connected: "+isAvailable);
connectUser();
}
function connectUser():void
{
gsBuilder = gs.requestBuilder();
gsBuilder.createAuthenticationRequest();
gsBuilder.setUserName("SDK_Tester");
gsBuilder.setPassword("password");
gsBuilder.send(handleAuthenticationResponse);
}
Hi Varun,
Apologies for the delay in getting back to you, we must have somehow missed your reply. What error exactly are you experiencing when attempting to authenticate this way?
Regards,
Vinnie
Varun Dewan
Hello,
I'm new to GameSparks, I'm trying to create a new user while coding in the main time line in as3.
So far I was able to get the swc added, and made a connection to my game with its secret key, see code:
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.messages.*;
var gs:GS = new GS();
gs.setAvailabilityCallback(availabilityCallback) gs.setUrl("wss://preview.gamesparks.net/ws/W303465GPdkX")
gs.setApiSecret("nMCd72KXdZ02lqSRp3Wx0b22wtazFKnA")
gs.connect();
function availabilityCallback(isAvailable : Boolean):void
{
trace("connected: "+isAvailable);
connectUser();
}
function connectUser():void
{
gs.getRequestBuilder();
gs.createAuthenticationRequest(); gs.setUserName("SDK_Tester");
gs.setPassword("password"); gs.send(handleAuthenticationResponse);
}
Everything works till gs.createAuthenticationRequest(); and beyond and the console says "undefined method."
Am I missing some imports? I would like to keep my code in the main timeline.
Any help would be great, thanks in advance.