onUserVarsUpdate can't work and can't getVariable

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

m87dd05
Posts: 4
Joined: 12 Aug 2013, 10:06

onUserVarsUpdate can't work and can't getVariable

Postby m87dd05 » 10 Oct 2013, 10:31

the function onUserVarsUpdate is not work and ERROR: line var Hisgender :String=user.getVariable("gender").getStringValue(); can't null.

i don't know why.

Can you tell me what happen ,thank you so much!


Code: Select all


 private function Some(e:SFSEvent):void {


             var SFSUserGenderVars:Array = [];
             SFSUserGenderVars.push(new SFSUserVariable("gender", man));
             trace(SFSUserGenderVars);

             sfs.send(new SetUserVariablesRequest(SFSUserGenderVars));
      }


          private function onUserEnterRoom(e:SFSEvent):void {

      var user:User=e.params.user;

      var Hisgender :String=user.getVariable("gender").getStringValue();      
                if(Hisgender==man){
                          trace("can add man sign");
                          }
      }

      private function onUserVarsUpdate(e:SFSEvent):void {
       var changedVars:Array = e.params.changedVars as Array;
                 var user:User = e.params.user as User;
         trace("do onUserVarsUpdate*****");
       
                  // Check if the user changed his x and y user variables
                  if (changedVars.indexOf("x") != -1 || changedVars.indexOf("y") != -1)
                   {
             
                         trace("do onUserVarsUpdate222222");
              }
m87dd05
Posts: 4
Joined: 12 Aug 2013, 10:06

Re: onUserVarsUpdate can't work and can't getVariable

Postby m87dd05 » 10 Oct 2013, 10:57

i try to trace it and it is null and onUserVariable is not work

so i guess it not send SetUserVariables Request

but i don't know why
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: onUserVarsUpdate can't work and can't getVariable

Postby Lapo » 05 Dec 2013, 09:05

You should read the variable in the USER_VARIABLE_UPDATE event. In the code you have posted you are attempting to read the variable in a function called onUserEnterRoom, which is not the response to a SetUserVariables request.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 49 guests