Converting this Code to work with Extension (ActionScript)

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

GalaxyDoomMaster
Posts: 9
Joined: 20 Mar 2018, 01:14

Converting this Code to work with Extension (ActionScript)

Postby GalaxyDoomMaster » 28 Mar 2018, 05:40

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! :?:
User avatar
Lapo
Site Admin
Posts: 20214
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 28 Mar 2018, 14:14

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
Lapo
--
gotoAndPlay()
...addicted to flash games
GalaxyDoomMaster
Posts: 9
Joined: 20 Mar 2018, 01:14

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

Postby GalaxyDoomMaster » 29 Mar 2018, 12:08

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? :(
User avatar
Lapo
Site Admin
Posts: 20214
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 29 Mar 2018, 12:48

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 :)
Lapo

--

gotoAndPlay()

...addicted to flash games
GalaxyDoomMaster
Posts: 9
Joined: 20 Mar 2018, 01:14

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

Postby GalaxyDoomMaster » 30 Mar 2018, 05:13

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:
User avatar
Lapo
Site Admin
Posts: 20214
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 30 Mar 2018, 08:22

Hi,
instanceof must be all lower case. I don't think "instanceOf" will be recognized. Compilers are picky :)
Lapo

--

gotoAndPlay()

...addicted to flash games
GalaxyDoomMaster
Posts: 9
Joined: 20 Mar 2018, 01:14

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

Postby GalaxyDoomMaster » 01 Apr 2018, 02:14

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)

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 10 guests