Page 1 of 1

Converting this Code to work with Extension (ActionScript)

Posted: 28 Mar 2018, 05:40
by GalaxyDoomMaster

Code: Select all

      {
         var sendA:Array = null;
         var i:* = undefined;
         var user:User = null;
         updateUserList();
         if(reacher.gameRoomMode)
         {
            sendA = new Array();
            for(i in userList)
            {
               if(userList[i] is User)
               {
                  user = userList[i];
                  sendA.push({
                     "name":user.getName(),
                     "id":user.getId()
                  });
               }
            }
            reacher.updateCList_Join(sendA,e.params.user.getName());
         }
      }


I am trying to convert this code to be working in my ActionScript Extension. Basically, it sends over to the server the username and updates the userList with the name of the user and stuff. It sends over 'userJoin' to the server. I have tried to use the Docs to help me and some examples but I have not yet been able to completely figure this out.

Any help would be appreciated! :?:

Re: Converting this Code to work with Extension (ActionScript)

Posted: 28 Mar 2018, 14:14
by Lapo
Hi,
the server side Actionscript in SFS PRO is like old AS1 or Javascript, so it doesn't support type definitions, such as:

Code: Select all

var array:Array = []

You just need to get rid of the type definitions and you should be fine

Code: Select all

 var array = []


Cheers

Re: Converting this Code to work with Extension (ActionScript)

Posted: 29 Mar 2018, 12:08
by GalaxyDoomMaster
Yeah that's what I thought. :? but a new challenger appears!

Code: Select all

2018/03/29 02:48:49.059 - [ WARNING ] [id: 10] (JavascriptExtension.logASError): Error in extension [ colonyExRoom.as ]: missing ) after condition (colonyExRoom.as#1600) Internal: 25 -- Line number: 24 in file: colonyExRoom.as


Line '24' being:

Code: Select all

if(userList[i] is User)
.. Since my extension has just a few more lines above. I was unsure of why this issue is happening? :(

Re: Converting this Code to work with Extension (ActionScript)

Posted: 29 Mar 2018, 12:48
by Lapo
The "is" keyword does not exist in AS1 / Javascript.
You will probably need to use "typeof"... If I remember correctly. I haven't been using AS1 in years now :)

Re: Converting this Code to work with Extension (ActionScript)

Posted: 30 Mar 2018, 05:13
by GalaxyDoomMaster
You see, that's actually what I thought. I was looking into it and realized that IS isn't actually really a thing. So I looked into using 'instanceOf' which did not work, same error. I tried 'typeOf' and that did not work. But I tried == and I didn't get any errors...

So maybe that solves it! :shock:

Re: Converting this Code to work with Extension (ActionScript)

Posted: 30 Mar 2018, 08:22
by Lapo
Hi,
instanceof must be all lower case. I don't think "instanceOf" will be recognized. Compilers are picky :)

Re: Converting this Code to work with Extension (ActionScript)

Posted: 01 Apr 2018, 02:14
by GalaxyDoomMaster
Oh! I'm sorry for the confusion, I did try all lowercase, that did not fix the issue either. This is such a weird occasion! Either way, the issue was solved and all that stuffs. Thank you! :D

(I managed to do some stuff to get it to work anyway)