Put class in user variable.

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

sorencoder
Posts: 7
Joined: 19 Jan 2019, 15:53

Put class in user variable.

Postby sorencoder » 24 Jan 2019, 19:42

Hi,
I'm trying to put this Game object inside a user variable but it gives error saying "Cannot set variable type for value":

Code: Select all


public class Game implements SerializableSFSType {
    public ArrayList<Card> HomeCards;
    public ArrayList<Card> AwayCards;
}



Code: Select all


public class Card implements SerializableSFSType {
    public int Damage;
    public int Health;

    public Card(int damage, int health) {
        Damage = damage;
        Health = health;
    }
}



What I'm missing?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Put class in user variable.

Postby Lapo » 25 Jan 2019, 08:44

Hi,
User Variables support only a subset of the types in SFSObject. You should see it if you have autocompletion in your IDE, as you won't find a putObject() method directly available on an UserVariable Object.

In any case you can create an SFSObject, add the class to it and then add the SFSObject to the User Variable.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 77 guests