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

SOLVED

SharedCollection.AddItem issue

Avatar

Level 2
I've been pulling teeth on this issue. An error is thrown
whenever I try to perform a "_model.AddItem" call (or
SharedCollection.AddItem ) whenever the ConnectSessionContainer
fires the "synchronizationChange" event. The only time
"_model.AddItem" works is after the program loads, and then I use a
click event to then fire off "_model.AddItem" (code not shown).



I'm getting error: "*err.errorID:1009*err.Message:Error
#1009*err.name:TypeError*err.getStackTrace:null"





private function sendMessage(p_evt:SessionEvent):void

{

if (p_evt.type == SessionEvent.ERROR) {

notificationMessage.text = "Error: " + p_evt.error;

return;

}



if (p_evt.type == SessionEvent.SYNCHRONIZATION_CHANGE) {

if (cSession.isSynchronized) {

Alert.show("Connected");

try {

if (_model.connectSession.isSynchronized) {

_model.addItem({FirstName:"John12",LastName:"Austin12"}); }

else {

Alert.show("Model out of synch");

}

} catch (err:Error) {


Alert.show("*err.errorID:"+err.errorID+"*err.Message:"+err.message+"*err.name:"+err.name+"*err.getStackTrace:"+err.getStackTrace());

}

}

}

}



sendMessage is called via the below synchronizationChange
eventr:

<rtc:ConnectSessionContainer roomURL="myroomURL"

id="cSession" authenticator="{auth}" height="187"
width="628" y="106" x="7"
synchronizationChange="sendMessage(event)" > ...

1 Accepted Solution

Avatar

Correct answer by
Level 2
Yes, it worked!!! Awesome.



By the way, Adobe 10 fixes my Flex debugger issue..

View solution in original post

5 Replies

Avatar

Level 10
Hi code_away,



In this case, you might actually have better luck debugging
w/o the try/catch block, and just seeing where it lands in the
source code.



Here's my suspicion : there are actually 2 levels of
synchronization in a room :



1) is at the ConnectSession level - this synchronizes the
list of collectionNodes, as well as all users, files, streams, and
roomSettings.

2) is at the level of each individual collectionNode. The
idea here is that most apps won't want to subscribe to every
possible model in the room right at the outset, so it's expected
that the developer will explicitly subscribe to the ones needed.



So the problem here seems to be that, while the top level of
the room is synched, your models within it aren't ready yet. here's
what I'd suggest :



a) for your synchronizationChange handler for ConnectSession,
have it create your model, ask it to subscribe, and listen to its
synchronizationChange event.

b) in its synchChange event, have it do what sendMessage()
does today.



Technically, you can ask the sharedCollection (or any
sharedModel) to subscribe at any time - you don't have to wait for
the ConnectSession to synch. I just hung it there since you need to
use script to do it somewhere; applicationComplete would work just
as well.



hope this helps

nigel

Avatar

Level 2
Hi Nigel,



I would use my debugger, but currently getting some weird
message: "C:\Windows\System32\Macromed\Flash\NPSWF32.dll ..Flex
Builder cannot locate the required debugger version of Flash
Player. You might need to install the debugger version of Flash
Player 9 or reinstall Flex Builder. "



Anyway, I tried your suggestion, and it didn't work. See
below. Let me know if you have any other ideas. I tried handling
SYNCHRONIZATION_CHANGE and COLLECTION_CHANGE.

---------------------------------------------------------

[Bindable]

private var _model:SharedCollection ;



private function
onSynchronizationChange(p_evt:SessionEvent):void

{

_model = new SharedCollection();

_model.sharedID = "_dataSharedModel";

_model.idField = "FirstName";

_model.connectSession = cSession;

_model.subscribe();


_model.connectSession.addEventListener(SessionEvent.SYNCHRONIZATION_CHANGE,modelSynchronizationChange);



_model.addEventListener(CollectionEvent.COLLECTION_CHANGE,modelSynchronizationChange1);


}

private function
modelSynchronizationChange(p_evt:SessionEvent): void {

add();

}

private function
modelSynchronizationChange1(p_evt:CollectionEvent): void {

add();

}



private function add():void {



_model.addItem({FirstName:"John12",LastName:"Austin12"});

}



AND

<rtc:ConnectSessionContainer roomURL="myURL"

id="cSession" authenticator="{auth}" height="187"
width="628" y="106" x="7"
synchronizationChange="onSynchronizationChange(event)"
creationComplete="onCreationComplete()">

Avatar

Level 2
By the way, I also tried "applicationComplete="add()" to no
avail.

Avatar

Level 10
Hi,



Doesn't seem like that weird a message - you should install
the latest debug player =).
http://www.adobe.com/support/flashplayer/downloads.html#fp10



The bug in your code is that you've got the synchChange
listener set up on _model.connectSession. That's just the
connectSession's synchChange again. try
_model.addEventListener(CollectionNodeEvent.SYNCHRONIZATION_CHANGE,
modelSynchronizationChange).



hope that helps

nigel

Avatar

Correct answer by
Level 2
Yes, it worked!!! Awesome.



By the way, Adobe 10 fixes my Flex debugger issue..