Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Mulitple Groups


Level 1

I'm writing an app that will have multiple groups. I want
each group to have properties, like groupType for example.

What's the best way to handle that? With a sharedModel, by
sending an object in a messageItem after node creation, or some
other way that's probably totally obvious?
0 Replies


Level 1
sorry, I meant sharedCollection, not sharedModel.


Level 10

The question sounds interesting. We have an example in
examples folder called MultipleGroups which has a model called
MultipleGroupModel . The model has a collection that keeps track of
all users in a particular group.

For any new property specific to a group, I would publish it
as an Item on the groupName node ( see MultipleGroupModel file) and
in my model I will do a bookkeeping by having a property object for
that property indexed by groupName. Something like this,

I will have

_collectionNode.publish Item(new
MessageItem(groupName,propertyVal, propertyName));

In my model I will have an object lets say called
propertyNameObject["groupName"] = propertyVal

I will populate this object in itemReceive with something
like this,

if ( p_evt.item.itemID == propertyName ) {

propertyNameObject[p_evt.nodeName] = p_evt.item.body ;


In this way , you can have any new property associated with a
particular group.

Of course , prior to doing all this you need to have a shared
model like MultipleGroupModel and create the collectionNode and
groups(nodes) for that model. Refer to the example and the
MultipleGroupModel file for details.

Hope this helps.


Hironmay Basu


Level 1
Thanks for the reply.

I've been using the MultipleGroups example as a model for my

I understand your suggestion. Thanks.

What are your thoughts on using a sharedCollection as a
solution with the groupName as the idField? I was thinking I would
also use one for users. Are there any guidelines for when to use
sharedCollections vs objects in messages?


Level 10

As you have seen, SharedCollection is just another shared
model specifically useful for Lists and DiataGrid as it exposes a
shared ListCollectionView. The Pro's of using it are having methods
for adding, removing , changing the dataCollection and cons are
having ListCollectionView overhead. Normally, if I am just using my
model for specfic purposes I would build it like the
MultipleGroupModel from scratch that extends EventDispatcher and
not use mx classes, but you can also use SharedCollection with
idField as groupName for your purpose I think.


Hironmay Basu